-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added two Image derived controls to improve binding
- SvgBitmap is added as a base class - SvgIcon is an extension of the SvgBitmap for monochrome SVG files - Resolves the issue #189
- Loading branch information
Showing
11 changed files
with
1,343 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Reflection; | ||
using System.ComponentModel; | ||
|
||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace WpfTestResourceSvg | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
public partial class MainWindow : Window, INotifyPropertyChanged | ||
{ | ||
public class KnownColor | ||
{ | ||
public Color Color { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
private Brush _fillBrush; | ||
|
||
private IList<KnownColor> _knownColors; | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
|
||
_fillBrush = Brushes.Green; | ||
_knownColors = typeof(Colors).GetProperties(BindingFlags.Public | BindingFlags.Static) | ||
.Select(i => new KnownColor() | ||
{ | ||
Color = (Color)i.GetValue(null, null), | ||
Name = i.Name | ||
}).ToList(); | ||
|
||
this.DataContext = this; | ||
} | ||
|
||
public Brush FillBrush | ||
{ | ||
get { | ||
return _fillBrush; | ||
} | ||
} | ||
|
||
public IList<KnownColor> KnownColors | ||
{ | ||
get { | ||
return _knownColors; | ||
} | ||
} | ||
|
||
private void OnColorChanged(object sender, SelectionChangedEventArgs e) | ||
{ | ||
if (cboColors.SelectedIndex < 0) | ||
{ | ||
return; | ||
} | ||
|
||
_fillBrush = new SolidColorBrush(_knownColors[cboColors.SelectedIndex].Color); | ||
this.NotifyPropertyChanged("FillBrush"); | ||
} | ||
|
||
private void NotifyPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |
Oops, something went wrong.