diff options
15 files changed, 198 insertions, 16 deletions
diff --git a/Xamarin.PropertyEditing.Windows.Standalone/App.xaml b/Xamarin.PropertyEditing.Windows.Standalone/App.xaml index 58ad820..511de2d 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/App.xaml +++ b/Xamarin.PropertyEditing.Windows.Standalone/App.xaml @@ -4,6 +4,10 @@ xmlns:local="clr-namespace:Xamarin.PropertyEditing.Windows.Standalone" StartupUri="MainWindow.xaml"> <Application.Resources> - + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="pack://application:,,,/Xamarin.PropertyEditing.Windows;component/Resources.xaml" /> + </ResourceDictionary.MergedDictionaries> + </ResourceDictionary> </Application.Resources> </Application> diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml index f8ac6cb..b3e5ff7 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml +++ b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml @@ -4,9 +4,23 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Xamarin.PropertyEditing.Windows.Standalone" + xmlns:xamarinprops="clr-namespace:Xamarin.PropertyEditing.Windows;assembly=Xamarin.PropertyEditing.Windows" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> - <Grid> - - </Grid> -</Window> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + + <Grid.RowDefinitions> + <RowDefinition /> + <RowDefinition /> + </Grid.RowDefinitions> + + <Button Grid.Row="0" Grid.Column="0">Select me</Button> + <Button Grid.Row="1" Grid.Column="0">Select me 2</Button> + + <xamarinprops:PropertyEditorPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" /> + </Grid> +</Window>
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Windows.Standalone/Xamarin.PropertyEditing.Windows.Standalone.csproj b/Xamarin.PropertyEditing.Windows.Standalone/Xamarin.PropertyEditing.Windows.Standalone.csproj index 66886e5..121a0d5 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/Xamarin.PropertyEditing.Windows.Standalone.csproj +++ b/Xamarin.PropertyEditing.Windows.Standalone/Xamarin.PropertyEditing.Windows.Standalone.csproj @@ -93,5 +93,15 @@ <ItemGroup> <None Include="App.config" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Xamarin.PropertyEditing.Windows\Xamarin.PropertyEditing.Windows.csproj"> + <Project>{60af04be-1b6b-411b-bcba-c95eafbd7ac0}</Project> + <Name>Xamarin.PropertyEditing.Windows</Name> + </ProjectReference> + <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj"> + <Project>{a0b6fe73-d046-4e1c-ba9d-f20683889c5a}</Project> + <Name>Xamarin.PropertyEditing</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Windows/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Windows/PropertyEditorControl.cs new file mode 100644 index 0000000..616e4c4 --- /dev/null +++ b/Xamarin.PropertyEditing.Windows/PropertyEditorControl.cs @@ -0,0 +1,18 @@ +using System.Windows; +using System.Windows.Controls; + +namespace Xamarin.PropertyEditing.Windows +{ + public abstract class PropertyEditorControl + : Control + { + public static readonly DependencyProperty LabelProperty = DependencyProperty.Register ( + "Label", typeof(object), typeof(PropertyEditorControl), new PropertyMetadata (default(object))); + + public object Label + { + get { return (object) GetValue (LabelProperty); } + set { SetValue (LabelProperty, value); } + } + } +}
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs new file mode 100644 index 0000000..e985912 --- /dev/null +++ b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs @@ -0,0 +1,13 @@ +using System.Windows.Controls; + +namespace Xamarin.PropertyEditing.Windows +{ + public class PropertyEditorPanel + : ItemsControl + { + public PropertyEditorPanel () + { + DefaultStyleKey = typeof(PropertyEditorPanel); + } + } +}
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Windows/Resources.xaml b/Xamarin.PropertyEditing.Windows/Resources.xaml new file mode 100644 index 0000000..bba0ef9 --- /dev/null +++ b/Xamarin.PropertyEditing.Windows/Resources.xaml @@ -0,0 +1,25 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:local="clr-namespace:Xamarin.PropertyEditing.Windows"> + + <Style TargetType="local:StringEditorControl"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="local:StringEditorControl"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition SharedSizeGroup="Label" /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + + <Label Target="{Binding ElementName=TextBox,Mode=OneTime}" Content="{TemplateBinding Label}" /> + <TextBox Name="TextBox" Grid.Column="1" /> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="local:PropertyEditorPanel"> + <Setter Property="Grid.IsSharedSizeScope" Value="True" /> + </Style> +</ResourceDictionary>
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Windows/StringEditorControl.cs b/Xamarin.PropertyEditing.Windows/StringEditorControl.cs new file mode 100644 index 0000000..81f66f0 --- /dev/null +++ b/Xamarin.PropertyEditing.Windows/StringEditorControl.cs @@ -0,0 +1,7 @@ +namespace Xamarin.PropertyEditing.Windows +{ + public class StringEditorControl + : PropertyEditorControl + { + } +} diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj index 0863ca2..4dda26f 100644 --- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj +++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj @@ -30,20 +30,33 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Windows.Presentation" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Xml" /> + <Reference Include="WindowsBase" /> </ItemGroup> <ItemGroup> <Compile Include="..\Xamarin.PropertyEditing\Properties\GlobalAssemblyInfo.cs"> <Link>Properties\GlobalAssemblyInfo.cs</Link> </Compile> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="PropertyEditorControl.cs" /> + <Compile Include="PropertyEditorPanel.cs" /> + <Compile Include="StringEditorControl.cs" /> + </ItemGroup> + <ItemGroup> + <Page Include="Resources.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Xamarin.PropertyEditing/IObjectEditor.cs b/Xamarin.PropertyEditing/IObjectEditor.cs index 01e1b3e..48bcea4 100644 --- a/Xamarin.PropertyEditing/IObjectEditor.cs +++ b/Xamarin.PropertyEditing/IObjectEditor.cs @@ -7,9 +7,7 @@ namespace Xamarin.PropertyEditing public class EditorPropertyChangedEventArgs : EventArgs { - /// <remarks> - /// A <c>null</c> <paramref name="property"/> is meant as a full refresh, like empty property names for INPC - /// </remarks> + /// <param name="property">The property that was updated, or <c>null</c> if a full refresh is required.</param> public EditorPropertyChangedEventArgs (IPropertyInfo property) { Property = property; diff --git a/Xamarin.PropertyEditing/IResourceProvider.cs b/Xamarin.PropertyEditing/IResourceProvider.cs new file mode 100644 index 0000000..0b9a791 --- /dev/null +++ b/Xamarin.PropertyEditing/IResourceProvider.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Xamarin.PropertyEditing +{ + public class Resource + { + public Resource (string name) + { + if (name == null) + throw new ArgumentNullException (nameof (name)); + + Name = name; + } + + public string Name + { + get; + } + } + + public interface IResourceProvider + { + /// <summary> + /// Gets the + /// </summary> + /// <param name="property"></param> + /// <returns></returns> + Task<IReadOnlyList<Resource>> GetResourcesAsync (IPropertyInfo property); + } +}
\ No newline at end of file diff --git a/Xamarin.PropertyEditing/Properties/AssemblyInfo.cs b/Xamarin.PropertyEditing/Properties/AssemblyInfo.cs index 4220956..9367daf 100644 --- a/Xamarin.PropertyEditing/Properties/AssemblyInfo.cs +++ b/Xamarin.PropertyEditing/Properties/AssemblyInfo.cs @@ -6,5 +6,6 @@ using System.Runtime.InteropServices; [assembly: ComVisible (false)] [assembly: Guid ("a0b6fe73-d046-4e1c-ba9d-f20683889c5a")] +[assembly: InternalsVisibleTo ("Xamarin.PropertyEditing.Tests")] [assembly: InternalsVisibleTo ("Xamarin.PropertyEditing.Windows")] [assembly: InternalsVisibleTo ("Xamarin.PropertyEditing.Mac")]
\ No newline at end of file diff --git a/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs b/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs index 9acde30..2206753 100644 --- a/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Threading.Tasks; namespace Xamarin.PropertyEditing.ViewModels { - public class ObjectViewModel + internal class ObjectViewModel : PropertiesViewModel { private object value; @@ -14,7 +11,6 @@ namespace Xamarin.PropertyEditing.ViewModels public ObjectViewModel (IEditorProvider provider) : base (provider) { - } public object Value @@ -23,7 +19,7 @@ namespace Xamarin.PropertyEditing.ViewModels set { this.value = value; - RaisePropertyChanged (); + OnPropertyChanged (); OnPropertiesChanged (); } } diff --git a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs index f5a731b..964c859 100644 --- a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs @@ -106,7 +106,7 @@ namespace Xamarin.PropertyEditing.ViewModels private void OnEditorsChanged (object sender, NotifyCollectionChangedEventArgs e) { - // properties will suppor multi-selection of designer items by self-handling having multiple + // properties will support multi-selection of designer items by self-handling having multiple // property editors. } } diff --git a/Xamarin.PropertyEditing/ViewModels/RelayCommand.cs b/Xamarin.PropertyEditing/ViewModels/RelayCommand.cs new file mode 100644 index 0000000..9d446f9 --- /dev/null +++ b/Xamarin.PropertyEditing/ViewModels/RelayCommand.cs @@ -0,0 +1,49 @@ +using System; +using System.Windows.Input; + +namespace Xamarin.PropertyEditing.ViewModels +{ + internal class RelayCommand<T> + : ICommand + { + public RelayCommand (Action<T> execute) + { + if (execute == null) + throw new ArgumentNullException (nameof (execute)); + + this.execute = execute; + } + + public RelayCommand (Action<T> execute, Func<T, bool> canExecute) + : this (execute) + { + if (canExecute == null) + throw new ArgumentNullException (nameof (canExecute)); + + this.canExecute = canExecute; + } + + public event EventHandler CanExecuteChanged; + + public bool CanExecute (object parameter) + { + if (this.canExecute == null) + return true; + + return this.canExecute ((T) parameter); + } + + public void Execute (object parameter) + { + this.execute ((T) parameter); + } + + public void ChangeCanExecute () + { + CanExecuteChanged?.Invoke (this, EventArgs.Empty); + } + + private readonly Func<T, bool> canExecute; + private readonly Action<T> execute; + } +}
\ No newline at end of file diff --git a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj index 9ba1022..91bdaf1 100644 --- a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj +++ b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj @@ -45,6 +45,7 @@ <Compile Include="IEditorProvider.cs" /> <Compile Include="IObjectEditor.cs" /> <Compile Include="IPropertyInfo.cs" /> + <Compile Include="IResourceProvider.cs" /> <Compile Include="ISelfConstrainedPropertyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\GlobalAssemblyInfo.cs" /> @@ -57,6 +58,7 @@ <Compile Include="ViewModels\PanelViewModel.cs" /> <Compile Include="ViewModels\PropertiesViewModel.cs" /> <Compile Include="ViewModels\PropertyViewModel.cs" /> + <Compile Include="ViewModels\RelayCommand.cs" /> <Compile Include="ViewModels\ViewModelBase.cs" /> </ItemGroup> <ItemGroup /> |