Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2018-07-06 00:12:49 +0300
committerEric Maupin <ermaup@microsoft.com>2018-07-19 00:20:56 +0300
commit70748f154c503d8551d2af3ee7df1fe3b3869a3b (patch)
tree3021f57ef636d52c94b355787467e0c3d52df496 /Xamarin.PropertyEditing.Windows
parent0b971c5ca151bebe05ef81496556e63a55fcee43 (diff)
[Win] Create ValueCOnverter window
Also move whole type selector to control
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r--Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml32
-rw-r--r--Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml.cs47
-rw-r--r--Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml27
-rw-r--r--Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml.cs49
-rw-r--r--Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml37
-rw-r--r--Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml.cs2
-rw-r--r--Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj14
7 files changed, 171 insertions, 37 deletions
diff --git a/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml b/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml
new file mode 100644
index 0000000..5bd97aa
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml
@@ -0,0 +1,32 @@
+<local:WindowEx x:Class="Xamarin.PropertyEditing.Windows.CreateValueConverterWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:Xamarin.PropertyEditing.Windows"
+ xmlns:prop="clr-namespace:Xamarin.PropertyEditing.Properties;assembly=Xamarin.PropertyEditing"
+ mc:Ignorable="d" Title="{x:Static prop:Resources.AddValueConverterTitle}" x:ClassModifier="internal"
+ Background="{DynamicResource DialogBackgroundBrush}" Foreground="{DynamicResource DialogForegroundBrush}"
+ d:DesignHeight="450" d:DesignWidth="400" ShowMaximize="False" ShowIcon="False" ShowMinimize="False">
+ <Window.Resources>
+ <ResourceDictionary Source="Themes/DialogResources.xaml" />
+ </Window.Resources>
+ <Grid Margin="12">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <TextBlock Text="{x:Static prop:Resources.ValueConverterName}" Grid.Row="0" />
+ <local:TextBoxEx x:Name="converterName" Text="{Binding ConverterName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Margin="0,4,0,0" />
+
+ <local:TypeSelectorControl x:Name="typeSelector" Grid.Row="2" SelectedItem="{Binding SelectedType,Mode=OneWayToSource}" SelectedItemChanged="OnSelectedItemChanged" ItemActivated="OnItemActivated" />
+
+ <StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right">
+ <Button Name="ok" MinHeight="23" MinWidth="75" IsEnabled="False" Content="{x:Static prop:Resources.OK}" IsDefault="True" Click="OnOkClicked" />
+ <Button MinHeight="23" MinWidth="75" Margin="4,0,0,0" Content="{x:Static prop:Resources.Cancel}" IsCancel="True" />
+ </StackPanel>
+ </Grid>
+</local:WindowEx>
diff --git a/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml.cs b/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml.cs
new file mode 100644
index 0000000..172b64a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/CreateValueConverterWindow.xaml.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Windows
+{
+ internal partial class CreateValueConverterWindow
+ : WindowEx
+ {
+ internal CreateValueConverterWindow (IEnumerable<ResourceDictionary> mergedResources, TargetPlatform platform, object target, AsyncValue<IReadOnlyDictionary<IAssemblyInfo, ILookup<string, ITypeInfo>>> assignableTypes)
+ {
+ DataContext = new AddValueConverterViewModel (platform, target, assignableTypes);
+ InitializeComponent ();
+ Resources.MergedDictionaries.AddItems (mergedResources);
+ }
+
+ internal static Tuple<string, ITypeInfo> RequestConverter (FrameworkElement owner, TargetPlatform platform, object target, AsyncValue<IReadOnlyDictionary<IAssemblyInfo, ILookup<string, ITypeInfo>>> assignableTypes)
+ {
+ Window hostWindow = Window.GetWindow (owner);
+ var w = new CreateValueConverterWindow (owner.Resources.MergedDictionaries, platform, target, assignableTypes) {
+ Owner = hostWindow,
+ };
+
+ if (!w.ShowDialog () ?? false)
+ return null;
+
+ return new Tuple<string, ITypeInfo> (w.converterName.Text, w.typeSelector.SelectedItem as ITypeInfo);
+ }
+
+ private void OnSelectedItemChanged (object sender, RoutedPropertyChangedEventArgs<object> e)
+ {
+ this.ok.IsEnabled = (e.NewValue as ITypeInfo) != null;
+ }
+
+ private void OnItemActivated (object sender, System.EventArgs e)
+ {
+ DialogResult = true;
+ }
+
+ private void OnOkClicked (object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml b/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml
new file mode 100644
index 0000000..f415b39
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml
@@ -0,0 +1,27 @@
+<UserControl x:Class="Xamarin.PropertyEditing.Windows.TypeSelectorControl"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:Xamarin.PropertyEditing.Windows"
+ xmlns:prop="clr-namespace:Xamarin.PropertyEditing.Properties;assembly=Xamarin.PropertyEditing"
+ mc:Ignorable="d"
+ d:DesignHeight="450" d:DesignWidth="800">
+ <UserControl.Resources>
+ <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
+ </UserControl.Resources>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <local:TextBoxEx Margin="0,4,0,0" Style="{DynamicResource SearchTextBox}" MinHeight="20" Text="{Binding FilterText,UpdateSourceTrigger=PropertyChanged}" ShowClearButton="True" Hint="{x:Static prop:Resources.SearchObjectsTitle}" />
+
+ <ProgressBar Grid.Row="1" IsIndeterminate="True" Height="10" Visibility="{Binding IsLoading,Converter={StaticResource BoolToVisibilityConverter}}" />
+ <local:TreeViewEx x:Name="tree" Grid.Row="1" Margin="0,4,0,0" Style="{DynamicResource TypeTreeView}" ItemsSource="{Binding Types}" />
+
+ <CheckBox Grid.Row="2" HorizontalAlignment="Left" Margin="0,4,0,0" IsChecked="{Binding ShowAllAssemblies}" Foreground="{DynamicResource PanelGroupForegroundBrush}" Content="{x:Static prop:Resources.ShowAllAssemblies}" />
+ </Grid>
+</UserControl>
diff --git a/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml.cs b/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml.cs
new file mode 100644
index 0000000..9ec8279
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/TypeSelectorControl.xaml.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace Xamarin.PropertyEditing.Windows
+{
+ public partial class TypeSelectorControl
+ : UserControl
+ {
+ public TypeSelectorControl ()
+ {
+ InitializeComponent ();
+ }
+
+ public event RoutedPropertyChangedEventHandler<object> SelectedItemChanged
+ {
+ add { this.tree.SelectedItemChanged += value; }
+ remove { this.tree.SelectedItemChanged -= value; }
+ }
+
+ public event EventHandler ItemActivated
+ {
+ add { this.tree.ItemActivated += value; }
+ remove { this.tree.ItemActivated -= value; }
+ }
+
+ public override void OnApplyTemplate ()
+ {
+ base.OnApplyTemplate ();
+
+ this.tree.SelectedItemChanged += OnSelectedItemChanged;
+ }
+
+ public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register (
+ "SelectedItem", typeof(object), typeof(TypeSelectorControl), new PropertyMetadata (default(object)));
+
+ public object SelectedItem
+ {
+ get { return (object) GetValue (SelectedItemProperty); }
+ set { SetValue (SelectedItemProperty, value); }
+ }
+
+ private void OnSelectedItemChanged (object sender, RoutedPropertyChangedEventArgs<object> e)
+ {
+ SetCurrentValue (SelectedItemProperty, e.NewValue);
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml b/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml
index 867df42..4f5607e 100644
--- a/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml
+++ b/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml
@@ -14,46 +14,11 @@
</Window.Resources>
<Grid Margin="12">
<Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
- <local:TextBoxEx Margin="0,4,0,0" Style="{DynamicResource SearchTextBox}" MinHeight="20" Text="{Binding FilterText,UpdateSourceTrigger=PropertyChanged}" ShowClearButton="True" Hint="{x:Static prop:Resources.SearchObjectsTitle}" />
-
- <ProgressBar Grid.Row="1" IsIndeterminate="True" Height="10" Visibility="{Binding IsLoading,Converter={StaticResource BoolToVisibilityConverter}}" />
- <local:TreeViewEx x:Name="tree" Grid.Row="1" Margin="0,4,0,0" Style="{DynamicResource SelectionTreeView}" ItemsSource="{Binding Types}" Foreground="{DynamicResource PanelGroupForegroundBrush}" Background="{DynamicResource ListBackgroundBrush}" BorderBrush="{DynamicResource ListBackgroundBrush}" SelectedItemChanged="OnSelectedItemChanged" ItemActivated="OnItemActivated">
- <local:TreeViewEx.ItemTemplate>
- <HierarchicalDataTemplate ItemsSource="{Binding Value,Mode=OneTime}">
- <HierarchicalDataTemplate.ItemTemplate>
- <HierarchicalDataTemplate ItemsSource="{Binding Value,Mode=OneTime}">
- <HierarchicalDataTemplate.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <!-- Icon -->
- <TextBlock Margin="8,0,0,0" Text="{Binding Name,Mode=OneTime}" />
- </StackPanel>
-
- </DataTemplate>
- </HierarchicalDataTemplate.ItemTemplate>
-
- <StackPanel Orientation="Horizontal">
- <!-- Icon -->
- <TextBlock Text="{Binding Key}" Margin="8,0,0,0" />
- </StackPanel>
- </HierarchicalDataTemplate>
- </HierarchicalDataTemplate.ItemTemplate>
-
- <StackPanel Orientation="Horizontal">
- <!-- Icon -->
- <TextBlock Margin="8,0,0,0" Text="{Binding Key,Mode=OneTime}" />
- </StackPanel>
- </HierarchicalDataTemplate>
- </local:TreeViewEx.ItemTemplate>
- </local:TreeViewEx>
-
- <CheckBox Grid.Row="2" HorizontalAlignment="Left" Margin="0,4,0,0" IsChecked="{Binding ShowAllAssemblies}" Foreground="{DynamicResource PanelGroupForegroundBrush}" Content="{x:Static prop:Resources.ShowAllAssemblies}" />
+ <local:TypeSelectorControl x:Name="typeSelector" Grid.Row="0" SelectedItemChanged="OnSelectedItemChanged" ItemActivated="OnItemActivated" />
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="ok" MinHeight="23" MinWidth="75" IsEnabled="False" Content="{x:Static prop:Resources.OK}" IsDefault="True" Click="OnOkClicked" />
diff --git a/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml.cs b/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml.cs
index de96e47..30c622e 100644
--- a/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml.cs
+++ b/Xamarin.PropertyEditing.Windows/TypeSelectorWindow.xaml.cs
@@ -26,7 +26,7 @@ namespace Xamarin.PropertyEditing.Windows
if (!w.ShowDialog () ?? false)
return null;
- return w.tree.SelectedItem as ITypeInfo;
+ return w.typeSelector.SelectedItem as ITypeInfo;
}
private void OnSelectedItemChanged (object sender, RoutedPropertyChangedEventArgs<object> e)
diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
index 1a0a2b4..1de4f88 100644
--- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
+++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
@@ -85,6 +85,9 @@
<DependentUpon>CreateResourceWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DoubleToAngleConverter.cs" />
+ <Compile Include="CreateValueConverterWindow.xaml.cs">
+ <DependentUpon>CreateValueConverterWindow.xaml</DependentUpon>
+ </Compile>
<Compile Include="EntryPopup.cs" />
<Compile Include="CurrentColorEditorControl.cs" />
<Compile Include="DoubleToPercentageConverter.cs" />
@@ -128,6 +131,9 @@
<Compile Include="StringEditorControl.cs" />
<Compile Include="Themes\WinThemeManager.cs" />
<Compile Include="TreeViewItemEx.cs" />
+ <Compile Include="TypeSelectorControl.xaml.cs">
+ <DependentUpon>TypeSelectorControl.xaml</DependentUpon>
+ </Compile>
<Compile Include="TypeSelectorWindow.xaml.cs">
<DependentUpon>TypeSelectorWindow.xaml</DependentUpon>
</Compile>
@@ -143,6 +149,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="CreateValueConverterWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="ResourceSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -167,6 +177,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="TypeSelectorControl.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="TypeSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>