From 8ff08a5cbbf49ec1395df17e47cbf1df7d184d50 Mon Sep 17 00:00:00 2001 From: Eric Maupin Date: Thu, 23 Aug 2018 16:41:22 -0400 Subject: [Core/Win] Add type icon support Closes #118 --- .../PropertyEditorPanel.cs | 26 ++++++++++++++++++++++ .../Themes/PropertyEditorPanelStyle.xaml | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'Xamarin.PropertyEditing.Windows') diff --git a/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs index 813f644..ee7fb84 100644 --- a/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs +++ b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs @@ -3,10 +3,12 @@ using System.Collections; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; +using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Data; +using System.Windows.Media.Imaging; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Windows @@ -82,6 +84,7 @@ namespace Xamarin.PropertyEditing.Windows base.OnApplyTemplate (); this.root = (FrameworkElement) GetTemplateChild ("root"); + this.typeIcon = (Image) GetTemplateChild ("typeIcon"); this.items = (ItemsControl) GetTemplateChild ("propertyItems"); this.propertiesPane = (FrameworkElement) GetTemplateChild ("propertiesPane"); this.eventsPane = (FrameworkElement) GetTemplateChild ("eventsPane"); @@ -99,6 +102,7 @@ namespace Xamarin.PropertyEditing.Windows private ItemsControl items; private ChoiceControl paneSelector; private FrameworkElement propertiesPane, eventsPane; + private Image typeIcon; private void OnPaneChanged (object sender, EventArgs e) { @@ -142,6 +146,28 @@ namespace Xamarin.PropertyEditing.Windows if (ArrangeMode == PropertyArrangeMode.Name) OnArrangeModeChanged (ArrangeMode); + + UpdateIcon (); + } + + private async void UpdateIcon () + { + if (this.typeIcon == null) + return; + + Stream icon = await this.vm.GetIconAsync (); + if (icon == null) { + this.typeIcon.Source = null; + this.typeIcon.Visibility = Visibility.Collapsed; + } else { + var source = new BitmapImage(); + source.BeginInit(); + source.StreamSource = icon; + source.EndInit(); + + this.typeIcon.Source = source; + this.typeIcon.Visibility = Visibility.Visible; + } } private void OnTargetPlatformChanged () diff --git a/Xamarin.PropertyEditing.Windows/Themes/PropertyEditorPanelStyle.xaml b/Xamarin.PropertyEditing.Windows/Themes/PropertyEditorPanelStyle.xaml index 3fe3c53..29f7db0 100644 --- a/Xamarin.PropertyEditing.Windows/Themes/PropertyEditorPanelStyle.xaml +++ b/Xamarin.PropertyEditing.Windows/Themes/PropertyEditorPanelStyle.xaml @@ -112,8 +112,8 @@ - - + + -- cgit v1.2.3