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-05-12 01:57:24 +0300
committerEric Maupin <ermaup@microsoft.com>2018-05-15 22:14:34 +0300
commitaeb3043e1e697a94703f4e523775855cecfef2e4 (patch)
tree202dee60c067f2b6cb78422675d2b8c51d428433 /Xamarin.PropertyEditing.Windows
parent16296387c97379de890db98ebc88d98350a0da3c (diff)
[Core/Win] Create resource core/window
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r--Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml81
-rw-r--r--Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml.cs54
-rw-r--r--Xamarin.PropertyEditing.Windows/PropertyButton.cs24
-rw-r--r--Xamarin.PropertyEditing.Windows/ResourceSelectorWindow.xaml.cs2
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/Resources.xaml22
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml6
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml4
-rw-r--r--Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj7
8 files changed, 188 insertions, 12 deletions
diff --git a/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml b/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml
new file mode 100644
index 0000000..d12a118
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml
@@ -0,0 +1,81 @@
+<local:WindowEx x:Class="Xamarin.PropertyEditing.Windows.CreateResourceWindow"
+ 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" x:ClassModifier="internal"
+ Background="{DynamicResource DialogBackgroundBrush}" Foreground="{DynamicResource DialogForegroundBrush}"
+ Height="270" Width="500" ResizeMode="NoResize" ShowMaximize="False" ShowIcon="False" ShowMinimize="False"
+ WindowStartupLocation="CenterOwner">
+ <local:WindowEx.Title>
+ <Binding StringFormat="{x:Static prop:Resources.CreateResourceTitle}" Path="Property.TypeName" Mode="OneTime" />
+ </local:WindowEx.Title>
+ <local:WindowEx.Resources>
+ <Style TargetType="RadioButton">
+ <Setter Property="Margin" Value="24,4,0,0" />
+ <Setter Property="Foreground" Value="{DynamicResource DialogForegroundBrush}" />
+ <Setter Property="FocusVisualStyle" Value="{DynamicResource GenericVisualFocusStyle}" />
+ <Setter Property="VerticalAlignment" Value="Center" />
+ <Style.Triggers>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Foreground" Value="#FFA2A4A5" />
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </local:WindowEx.Resources>
+ <Grid Margin="12">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <GroupBox Grid.Row="0" Header="{x:Static prop:Resources.ResourceNameLabel}" Margin="0,4,0,0" BorderThickness="0">
+ <StackPanel>
+ <RadioButton HorizontalContentAlignment="Stretch" IsChecked="{Binding IsKeyed,Mode=TwoWay}">
+ <local:TextBoxEx x:Name="resourceKey" Text="{Binding ResourceKey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource ValidationTextBox}" />
+ </RadioButton>
+ <RadioButton IsEnabled="{Binding CanApplyToAll,Mode=OneTime}" IsChecked="{Binding IsAppliedToAll,Mode=TwoWay}">Apply to all</RadioButton>
+ </StackPanel>
+ </GroupBox>
+
+ <GroupBox Grid.Row="1" Header="{x:Static prop:Resources.DefineIn}" Margin="0,4,0,0" BorderThickness="0">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="27" />
+ <RowDefinition Height="27" />
+ <RowDefinition Height="27" />
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+
+ <RadioButton Grid.Column="0" Grid.Row="0" Content="{x:Static prop:Resources.Application}" IsChecked="{Binding DefineInApplication,Mode=TwoWay}" />
+ <RadioButton Grid.Column="0" Grid.Row="1" Content="{x:Static prop:Resources.ThisDocument}" IsEnabled="{Binding HasDocumentSources}" IsChecked="{Binding DefineInDocument,Mode=TwoWay}" />
+ <RadioButton Grid.Column="0" Grid.Row="2" Content="{x:Static prop:Resources.ResourceDictionary}" IsEnabled="{Binding HasApplicationSources}" IsChecked="{Binding DefineInApplicationSource,Mode=TwoWay}" />
+
+ <ComboBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Width="160" Margin="25,4,25,0" IsEnabled="{Binding DefineInDocument}" ItemsSource="{Binding DocumentSources}" SelectedItem="{Binding SelectedDocumentSource,Mode=TwoWay}" DisplayMemberPath="Name" />
+ <ComboBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Width="160" Margin="25,4,25,0" IsEnabled="{Binding DefineInApplicationSource}" ItemsSource="{Binding ApplicationSources}" SelectedItem="{Binding SelectedApplicationSource,Mode=TwoWay}" DisplayMemberPath="Name" />
+ </Grid>
+ </GroupBox>
+
+ <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,4,0,0">
+ <Button Name="ok" MinHeight="23" MinWidth="75" Content="{x:Static prop:Resources.OK}" IsDefault="True" Command="{Binding CreateResourceCommand,Mode=OneTime}" Click="OnOkClicked" />
+ <Button MinHeight="23" MinWidth="75" Margin="4,0,0,0" Content="{x:Static prop:Resources.Cancel}" IsCancel="True" Click="OnCancelClicked" />
+ </StackPanel>
+
+ <Border Background="{DynamicResource DialogBackgroundBrush}" Grid.Row="0" Grid.RowSpan="2">
+ <Border.Visibility>
+ <Binding Path="HasFatalError">
+ <Binding.Converter>
+ <BooleanToVisibilityConverter />
+ </Binding.Converter>
+ </Binding>
+ </Border.Visibility>
+ <TextBlock Text="{Binding FatalError}" HorizontalAlignment="Center" VerticalAlignment="Center" />
+ </Border>
+ </Grid>
+</local:WindowEx>
diff --git a/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml.cs b/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml.cs
new file mode 100644
index 0000000..0f6aa6a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/CreateResourceWindow.xaml.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Windows;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Windows
+{
+ internal partial class CreateResourceWindow
+ : WindowEx
+ {
+ public CreateResourceWindow (IEnumerable<ResourceDictionary> merged, IResourceProvider provider, IEnumerable<object> targets, IPropertyInfo property)
+ {
+ Resources.MergedDictionaries.AddItems (merged);
+ DataContext = new CreateResourceViewModel (provider, targets, property);
+ InitializeComponent ();
+ SetupResourceKey ();
+ }
+
+ private async void SetupResourceKey()
+ {
+ await ((CreateResourceViewModel) DataContext).LoadingTask;
+ this.resourceKey.SelectAll();
+ this.resourceKey.Focus ();
+ }
+
+ private void OnOkClicked (object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ }
+
+ private void OnCancelClicked (object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ }
+
+ internal static Tuple<ResourceSource, string> CreateResource (FrameworkElement owner, IResourceProvider provider, IEnumerable<object> targets, IPropertyInfo property)
+ {
+ Window ownerWindow = Window.GetWindow (owner);
+ var window = new CreateResourceWindow (owner.Resources.MergedDictionaries, provider, targets, property) {
+ Owner = ownerWindow
+ };
+ window.Resources.MergedDictionaries.AddItems (owner.Resources.MergedDictionaries);
+ bool? result = window.ShowDialog();
+
+ var vm = (CreateResourceViewModel)window.DataContext;
+ if (result.HasValue && result.Value) {
+ return new Tuple<ResourceSource, string> (vm.SelectedResourceSource, vm.ResourceKey);
+ } else {
+ return new Tuple<ResourceSource, string> (null, null);
+ }
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Windows/PropertyButton.cs b/Xamarin.PropertyEditing.Windows/PropertyButton.cs
index c32cbf7..f69bc2c 100644
--- a/Xamarin.PropertyEditing.Windows/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Windows/PropertyButton.cs
@@ -99,12 +99,16 @@ namespace Xamarin.PropertyEditing.Windows
private void OnDataContextChanged (object sender, DependencyPropertyChangedEventArgs e)
{
- if (e.OldValue is PropertyViewModel pvm)
+ if (e.OldValue is PropertyViewModel pvm) {
pvm.ResourceRequested -= OnResourceRequested;
+ pvm.CreateResourceRequested -= OnCreateResourceRequested;
+ }
this.vm = e.NewValue as PropertyViewModel;
- if (this.vm != null)
+ if (this.vm != null) {
this.vm.ResourceRequested += OnResourceRequested;
+ this.vm.CreateResourceRequested += OnCreateResourceRequested;
+ }
}
private void OnValueSourceChanged (ValueSource source)
@@ -140,9 +144,19 @@ namespace Xamarin.PropertyEditing.Windows
private void OnResourceRequested (object sender, ResourceRequestedEventArgs e)
{
- var panel = this.FindParent<PropertyEditorPanel> ();
- var vm = ((PropertyViewModel)DataContext);
- e.Resource = ResourceSelectorWindow.RequestResource (panel, vm.ResourceProvider, vm.Editors.Select (ed => ed.Target), vm.Property, e.Resource);
+ var panel = this.FindPropertiesHost();
+ var pvm = (PropertyViewModel) DataContext;
+ e.Resource = ResourceSelectorWindow.RequestResource (panel, pvm.ResourceProvider, pvm.Editors.Select (ed => ed.Target), pvm.Property, e.Resource);
+ }
+
+ private void OnCreateResourceRequested (object sender, CreateResourceRequestedEventArgs e)
+ {
+ var panel = this.FindPropertiesHost();
+ var pvm = (PropertyViewModel) DataContext;
+
+ var result = CreateResourceWindow.CreateResource (panel, pvm.ResourceProvider, pvm.Editors.Select (oe => oe.Target), pvm.Property);
+ e.Source = result.Item1;
+ e.Name = result.Item2;
}
private void OnCustomExpression (object sender, RoutedEventArgs e)
diff --git a/Xamarin.PropertyEditing.Windows/ResourceSelectorWindow.xaml.cs b/Xamarin.PropertyEditing.Windows/ResourceSelectorWindow.xaml.cs
index f26e188..7744761 100644
--- a/Xamarin.PropertyEditing.Windows/ResourceSelectorWindow.xaml.cs
+++ b/Xamarin.PropertyEditing.Windows/ResourceSelectorWindow.xaml.cs
@@ -18,7 +18,7 @@ namespace Xamarin.PropertyEditing.Windows
InitializeComponent ();
}
- internal static Resource RequestResource (PropertyEditorPanel owner, IResourceProvider provider, IEnumerable<object> targets, IPropertyInfo property, Resource currentValue)
+ internal static Resource RequestResource (FrameworkElement owner, IResourceProvider provider, IEnumerable<object> targets, IPropertyInfo property, Resource currentValue)
{
Window hostWindow = Window.GetWindow (owner);
diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
index 4497fe9..5f40012 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
@@ -411,11 +411,8 @@
<MenuItem Header="{x:Static prop:Resources.ConvertToLocalValue}" Icon="{StaticResource LiteralMarker}" Command="{Binding ConvertToLocalValueCommand,Mode=OneTime}" />
<Separator Visibility="{Binding SupportsResources,Mode=OneTime,Converter={StaticResource BoolToVisibilityConverter}}" />
<MenuItem Header="{x:Static prop:Resources.ResourceEllipsis}" Command="{Binding RequestResourceCommand,Mode=OneTime}" Icon="{StaticResource ResourceMarker}" Visibility="{Binding SupportsResources,Mode=OneTime,Converter={StaticResource BoolToVisibilityConverter}}" />
- <!--<MenuItem Header="{x:Static prop:Resources.LocalResource}" />
- <MenuItem Header="{x:Static prop:Resources.SystemResource}" />
- <MenuItem Header="{x:Static prop:Resources.EditResourceEllipse}" />
- <MenuItem Header="{x:Static prop:Resources.ConvertToNewResourceEllipse}" />
- <Separator />
+ <MenuItem Header="{x:Static prop:Resources.ConvertToNewResourceEllipsis}" Command="{Binding RequestCreateResourceCommand}" Icon="{StaticResource ResourceMarker}" Visibility="{Binding CanCreateResources,Converter={StaticResource BoolToVisibilityConverter}}" />
+ <!--<Separator />
<MenuItem Header="{x:Static prop:Resources.CreateDataBindingEllipse}" />
<MenuItem Header="{x:Static prop:Resources.TemplateBinding}" />!-->
<Separator Visibility="{Binding SupportsValueSourceNavigation,Mode=OneTime,Converter={StaticResource BoolToVisibilityConverter}}" />
@@ -1935,6 +1932,21 @@
</Style.Triggers>
</Style>
+ <Style x:Key="ValidationTextBox" TargetType="local:TextBoxEx" BasedOn="{StaticResource {x:Type local:TextBoxEx}}">
+ <Setter Property="Validation.ErrorTemplate">
+ <Setter.Value>
+ <ControlTemplate>
+ <DockPanel>
+ <AdornedElementPlaceholder Name="adorned" DockPanel.Dock="Top" />
+ <Border DockPanel.Dock="Bottom" Background="{DynamicResource ToolTipBackgroundBrush}" BorderThickness="1" BorderBrush="{DynamicResource ToolTipBorderBrush}">
+ <ContentPresenter Margin="7,4,7,4" TextElement.Foreground="{DynamicResource ToolTipForegroundBrush}" Content="{Binding ElementName=adorned,Path=AdornedElement.(Validation.Errors)/ErrorContent}" />
+ </Border>
+ </DockPanel>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
<local:NumericTemplateSelector x:Key="NumericTemplateSelector">
<local:NumericTemplateSelector.FloatingTemplate>
<DataTemplate DataType="vm:FloatingPropertyViewModel">
diff --git a/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml b/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
index 5c54e51..e59794c 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
@@ -76,6 +76,10 @@
<SolidColorBrush x:Key="PopupForegroundBrush">#FFF1F1F1</SolidColorBrush>
<SolidColorBrush x:Key="PopupBorderBrush">#FF333337</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipForegroundBrush">#FF000000</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipBorderBrush">#FF000000</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipBackgroundBrush">#FFFFFFFF</SolidColorBrush>
+
<SolidColorBrush x:Key="ThicknessIconBackgroundBrush">#292929</SolidColorBrush>
<SolidColorBrush x:Key="ThicknessIconBorderBrush">#292929</SolidColorBrush>
@@ -110,7 +114,7 @@
<SolidColorBrush x:Key="ComboBoxButtonPressedSeparatorBrush">#FF007ACC</SolidColorBrush>
<SolidColorBrush x:Key="ComboBoxPopupBackgroundBrush">#FF1B1B1C</SolidColorBrush>
<SolidColorBrush x:Key="ComboBoxPopupBorderBrush">#FF333337</SolidColorBrush>
-
+
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Fill" Color="Transparent"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Stroke" Color="#F1F1F1"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Fill" Color="#F1F1F1"/>
diff --git a/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml b/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
index 09811c7..88368aa 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
@@ -77,6 +77,10 @@
<SolidColorBrush x:Key="PopupForegroundBrush">#FF1E1E1E</SolidColorBrush>
<SolidColorBrush x:Key="PopupBorderBrush">#FFCCCEDB</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipForegroundBrush">#FF000000</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipBorderBrush">#FF000000</SolidColorBrush>
+ <SolidColorBrush x:Key="ToolTipBackgroundBrush">#FFFFFFFF</SolidColorBrush>
+
<SolidColorBrush x:Key="ThicknessIconBackgroundBrush">#EEEEF2</SolidColorBrush>
<SolidColorBrush x:Key="ThicknessIconBorderBrush">#EEEEF2</SolidColorBrush>
diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
index 659634c..cb1a9f9 100644
--- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
+++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
@@ -80,6 +80,9 @@
<Compile Include="ColorEditorControlBase.cs" />
<Compile Include="ColorHelper.cs" />
<Compile Include="CommonColorToColorConverter.cs" />
+ <Compile Include="CreateResourceWindow.xaml.cs">
+ <DependentUpon>CreateResourceWindow.xaml</DependentUpon>
+ </Compile>
<Compile Include="EntryPopup.cs" />
<Compile Include="CurrentColorEditorControl.cs" />
<Compile Include="DoubleToPercentageConverter.cs" />
@@ -134,6 +137,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="CreateResourceWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="ResourceSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>