Skip to content

Commit

Permalink
Added two Image derived controls to improve binding
Browse files Browse the repository at this point in the history
- 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
paulushub committed Jul 19, 2022
1 parent ac5c26c commit 894077b
Show file tree
Hide file tree
Showing 11 changed files with 1,343 additions and 153 deletions.
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ The library can be downloaded from the following sources
* **NuGet (Full Package - WPF/GDI++)**, [Version 1.8.0 - SharpVectors.Reloaded](https://www.nuget.org/packages/SharpVectors.Reloaded/).
* **GitHub Releases Page**, [Version 1.8.0](https://github.com/ElinamLLC/SharpVectors/releases).

> * The **SharpVectors.Reloaded** package is the same as the **SharpVectors**, which is the recommended package if you need the full package.
> * The **SharpVectors.Reloaded** name was used for the Nuget package at the time the **SharpVectors** package name was not available.
> * The **SharpVectors.Reloaded** package name will be retired in Version 2.0.
> * The **SharpVectors.Wpf** is the recommended package, for `WPF` only application.
> * As outlined in the [roadmap](https://github.com/ElinamLLC/SharpVectors/issues/147), other packages such as the **SharpVectors.Gdi** for the `GDI+`, will be available as the renderers mature.
## Documentation
An introduction and a tutorial with sample are available. See the [Documentation](https://elinamllc.github.io/SharpVectors) section for more information.

Expand Down
181 changes: 177 additions & 4 deletions Samples/WpfTestResourceSvg/MainWindow.xaml

Large diffs are not rendered by default.

65 changes: 56 additions & 9 deletions Samples/WpfTestResourceSvg/MainWindow.xaml.cs
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));
}
}
}
Loading

0 comments on commit 894077b

Please sign in to comment.