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:
-rw-r--r--Xamarin.PropertyEditing.Tests/SolidBrushPropertyViewModelTests.cs4
-rw-r--r--Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs6
-rw-r--r--Xamarin.PropertyEditing.Windows/BrushEditorControl.cs57
-rw-r--r--Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs2
-rw-r--r--Xamarin.PropertyEditing.Windows/SolidBrushEditorControl.cs6
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/Resources.xaml28
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml2
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml2
-rw-r--r--Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj1
-rw-r--r--Xamarin.PropertyEditing/BrushPropertyInfo.cs (renamed from Xamarin.PropertyEditing/SolidBrushPropertyInfo.cs)6
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonBrush.cs8
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonGradientBrush.cs7
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonImageBrush.cs2
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonLinearGradientBrush.cs2
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonRadialGradientBrush.cs2
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonSolidBrush.cs2
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonTileBrush.cs7
-rw-r--r--Xamarin.PropertyEditing/Properties/Resources.Designer.cs18
-rw-r--r--Xamarin.PropertyEditing/Properties/Resources.resx8
-rw-r--r--Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs84
-rw-r--r--Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs2
-rw-r--r--Xamarin.PropertyEditing/ViewModels/SolidBrushPropertyViewModel.cs93
-rw-r--r--Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj3
23 files changed, 226 insertions, 126 deletions
diff --git a/Xamarin.PropertyEditing.Tests/SolidBrushPropertyViewModelTests.cs b/Xamarin.PropertyEditing.Tests/SolidBrushPropertyViewModelTests.cs
index ebd4a19..f209c84 100644
--- a/Xamarin.PropertyEditing.Tests/SolidBrushPropertyViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/SolidBrushPropertyViewModelTests.cs
@@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Tests
{
protected override CommonBrush GetRandomTestValue (Random rand)
{
- var color = rand.NextColor();
+ CommonColor color = rand.NextColor();
var colorSpace = rand.NextString ();
var opacity = rand.NextDouble ();
@@ -31,7 +31,7 @@ namespace Xamarin.PropertyEditing.Tests
mockProperty.As<IColorSpaced>().SetupGet (pi => pi.ColorSpaces).Returns (SampleColorSpaces);
var mockEditor = new Mock<IObjectEditor> ();
- var vm = new SolidBrushPropertyViewModel(mockProperty.Object, new[] { mockEditor.Object });
+ var vm = new BrushPropertyViewModel(mockProperty.Object, new[] { mockEditor.Object });
Assert.That (vm.ColorSpaces, new CollectionEquivalentConstraint (SampleColorSpaces));
}
}
diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs b/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs
index 4341af8..b9303ea 100644
--- a/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs
+++ b/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs
@@ -8,10 +8,10 @@ namespace Xamarin.PropertyEditing.Windows.Standalone
public MockedSampleControlButton () : base (new MockSampleControl ())
{
// TODO: Move the declaration of this property to MockSampleControl once SolidBrush is supported on both platforms.
- var brushPropertyInfo = new SolidBrushPropertyInfo ("SolidBrush", "Windows Only", true,
+ var brushPropertyInfo = new BrushPropertyInfo ("SolidBrush", "Windows Only", true,
new[] { "RGB", "sRGB" });
- MockedControl.AddProperty<CommonSolidBrush> (brushPropertyInfo);
- MockedControl.SetValue(brushPropertyInfo,
+ MockedControl.AddProperty<CommonBrush> (brushPropertyInfo);
+ MockedControl.SetValue<CommonBrush>(brushPropertyInfo,
new CommonSolidBrush(20, 120, 220, 240, "sRGB"));
}
}
diff --git a/Xamarin.PropertyEditing.Windows/BrushEditorControl.cs b/Xamarin.PropertyEditing.Windows/BrushEditorControl.cs
new file mode 100644
index 0000000..1a0399e
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/BrushEditorControl.cs
@@ -0,0 +1,57 @@
+using System.Windows.Controls;
+using Xamarin.PropertyEditing.Drawing;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Windows
+{
+ public class BrushEditorControl : PropertyEditorControl
+ {
+ public BrushEditorControl()
+ {
+ DefaultStyleKey = typeof (BrushEditorControl);
+ }
+
+ BrushPropertyViewModel ViewModel => DataContext as BrushPropertyViewModel;
+
+ TabControl tabs;
+ TabItem noBrushTab;
+ TabItem solidColorTab;
+
+ public override void OnApplyTemplate ()
+ {
+ base.OnApplyTemplate ();
+
+ tabs = GetTemplateChild ("brushTabs") as TabControl;
+ noBrushTab = GetTemplateChild ("noBrushTab") as TabItem;
+ solidColorTab = GetTemplateChild ("solidColorTab") as TabItem;
+
+ if (ViewModel.Value == null) {
+ tabs.SelectedItem = noBrushTab;
+ }
+ else if (ViewModel.Value is CommonSolidBrush solidBrush) {
+ tabs.SelectedItem = solidColorTab;
+ }
+
+ tabs.SelectionChanged += (s, e) => {
+ if (ViewModel == null) return;
+ if (tabs.Items[tabs.SelectedIndex] is TabItem tab) {
+ StorePreviousBrush ();
+ if (tab == noBrushTab) {
+ ViewModel.Value = null;
+ }
+ else if (tab == solidColorTab) {
+ ViewModel.Value = ViewModel.PreviousSolidBrush ?? new CommonSolidBrush (new CommonColor (0, 0, 0));
+ }
+ }
+ };
+ }
+
+ void StorePreviousBrush()
+ {
+ if (ViewModel == null) return;
+ if (ViewModel.Value is CommonSolidBrush solidBrush) {
+ ViewModel.PreviousSolidBrush = solidBrush;
+ }
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs b/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
index a8ba861..e9b8209 100644
--- a/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
+++ b/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
@@ -106,7 +106,7 @@ namespace Xamarin.PropertyEditing.Windows
{ typeof(PropertyViewModel<Thickness>), typeof(ThicknessEditorControl) },
{ typeof(PropertyViewModel<CommonThickness>), typeof(ThicknessEditorControl) },
{ typeof(PredefinedValuesViewModel<>), typeof(EnumEditorControl) },
- { typeof(SolidBrushPropertyViewModel), typeof(SolidBrushEditorControl) }
+ { typeof(BrushPropertyViewModel), typeof(BrushEditorControl) },
};
}
}
diff --git a/Xamarin.PropertyEditing.Windows/SolidBrushEditorControl.cs b/Xamarin.PropertyEditing.Windows/SolidBrushEditorControl.cs
index 4ca3403..9190c47 100644
--- a/Xamarin.PropertyEditing.Windows/SolidBrushEditorControl.cs
+++ b/Xamarin.PropertyEditing.Windows/SolidBrushEditorControl.cs
@@ -15,12 +15,14 @@ namespace Xamarin.PropertyEditing.Windows
ComboBox colorSpacePicker;
- SolidBrushPropertyViewModel ViewModel => DataContext as SolidBrushPropertyViewModel;
+ BrushPropertyViewModel ViewModel => DataContext as BrushPropertyViewModel;
public override void OnApplyTemplate ()
{
base.OnApplyTemplate ();
+ if (ViewModel == null) return;
+
colorSpacePicker = (ComboBox)GetTemplateChild ("colorSpacePicker");
if (ViewModel.ColorSpaces == null || ViewModel.ColorSpaces.Count == 0) {
colorSpacePicker.Visibility = Visibility.Collapsed;
@@ -30,7 +32,7 @@ namespace Xamarin.PropertyEditing.Windows
// Handle color space changes
colorSpacePicker.SelectionChanged += (s, e) => {
if (ViewModel != null && ViewModel.Value != null) {
- ViewModel.Value = new CommonSolidBrush (ViewModel.Value.Color, (string)e.AddedItems[0]);
+ ViewModel.Value = new CommonSolidBrush (ViewModel.Color, (string)e.AddedItems[0]);
}
};
}
diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
index 558c2a2..b1d2e7c 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
@@ -326,6 +326,34 @@
</Setter>
</Style>
+ <Style TargetType="local:BrushEditorControl">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <TabControl x:Name="brushTabs" MinHeight="20">
+ <TabItem Name="noBrushTab" ToolTip="{x:Static prop:Resources.NoBrush}" AutomationProperties.HelpText="{x:Static prop:Resources.NoBrush}" MinWidth="40" MinHeight="25">
+ <TabItem.Header>
+ <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="30" Height="20" Margin="4,4,0,0">
+ <Polygon Points="0,0 24,0 0,14" Fill="{DynamicResource VectorGlyphBrush}" StrokeThickness="0"/>
+ <Polygon Points="25,1 25,15 1,15" Fill="{DynamicResource VectorGlyphBrush}" StrokeThickness="0"/>
+ </Canvas>
+ </TabItem.Header>
+ </TabItem>
+ <TabItem Name="solidColorTab" ToolTip="{x:Static prop:Resources.SolidBrush}" AutomationProperties.HelpText="{x:Static prop:Resources.SolidBrush}" MinWidth="40" MinHeight="25">
+ <TabItem.Header>
+ <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="30" Height="20" Margin="4,4,0,0">
+ <Rectangle Canvas.Left="0" Canvas.Top="0" Width="25" Height="15" Stroke="{DynamicResource VectorGlyphBrush}" StrokeThickness="1"/>
+ <Rectangle Canvas.Left="2" Canvas.Top="2" Width="21" Height="11" Fill="{DynamicResource VectorGlyphBrush}" StrokeThickness="0"/>
+ </Canvas>
+ </TabItem.Header>
+ <local:SolidBrushEditorControl x:Name="solidBrushEditor"/>
+ </TabItem>
+ </TabControl>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
<Style TargetType="local:SolidBrushEditorControl">
<Setter Property="Template">
<Setter.Value>
diff --git a/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml b/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
index 4621d54..da5fd75 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/VS.Dark.xaml
@@ -59,6 +59,8 @@
<SolidColorBrush x:Key="BrushBoxCheckerBoardLight">#FFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="BrushBoxCheckerBoardDark">#D3D3D3</SolidColorBrush>
+ <SolidColorBrush x:Key="VectorGlyphBrush">#C5C5C5</SolidColorBrush>
+
<SolidColorBrush x:Key="CategoryExpanderBorderBrush" Color="#333333" />
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Fill" Color="Transparent"/>
diff --git a/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml b/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
index f72d690..ba85c23 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/VS.Light.xaml
@@ -70,6 +70,8 @@
<SolidColorBrush x:Key="BrushBoxCheckerBoardLight">#FFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="BrushBoxCheckerBoardDark">#D3D3D3</SolidColorBrush>
+ <SolidColorBrush x:Key="VectorGlyphBrush">#424242</SolidColorBrush>
+
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Fill" Color="#FF595959"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Stroke" Color="#FF262626"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Stroke" Color="#FF27C7F7"/>
diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
index c966464..ec779cf 100644
--- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
+++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
@@ -52,6 +52,7 @@
</Compile>
<Compile Include="BoolEditorControl.cs" />
<Compile Include="BrushBoxControl.cs" />
+ <Compile Include="BrushEditorControl.cs" />
<Compile Include="DoubleToDegreesConverter.cs" />
<Compile Include="DoubleToPercentageConverter.cs" />
<Compile Include="ByteToPercentageConverter.cs" />
diff --git a/Xamarin.PropertyEditing/SolidBrushPropertyInfo.cs b/Xamarin.PropertyEditing/BrushPropertyInfo.cs
index 99c2a4d..4257cb0 100644
--- a/Xamarin.PropertyEditing/SolidBrushPropertyInfo.cs
+++ b/Xamarin.PropertyEditing/BrushPropertyInfo.cs
@@ -4,9 +4,9 @@ using Xamarin.PropertyEditing.Drawing;
namespace Xamarin.PropertyEditing
{
- public class SolidBrushPropertyInfo : IPropertyInfo, IColorSpaced
+ public class BrushPropertyInfo : IPropertyInfo, IColorSpaced
{
- public SolidBrushPropertyInfo (string name, string category, bool canWrite,
+ public BrushPropertyInfo (string name, string category, bool canWrite,
IReadOnlyList<string> colorSpaces, ValueSources valueSources = ValueSources.Local,
IReadOnlyList<PropertyVariation> variations = null,
IReadOnlyList<IAvailabilityConstraint> availabilityConstraints = null)
@@ -24,7 +24,7 @@ namespace Xamarin.PropertyEditing
public string Name { get; }
- public Type Type => typeof(CommonSolidBrush);
+ public Type Type => typeof(CommonBrush);
public string Category { get; }
diff --git a/Xamarin.PropertyEditing/Drawing/CommonBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonBrush.cs
index b2d504b..c7ce63e 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonBrush.cs
@@ -6,7 +6,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// Base class for brush descriptions.
/// </summary>
[Serializable]
- public abstract class CommonBrush : IEquatable<CommonBrush>
+ public abstract class CommonBrush
{
// TODO: add transforms
@@ -27,14 +27,12 @@ namespace Xamarin.PropertyEditing.Drawing
return Equals (brush);
}
- public bool Equals (CommonBrush other)
+ protected bool Equals (CommonBrush other)
{
return other != null &&
Opacity == other.Opacity;
}
-
- public static bool operator == (CommonBrush left, CommonBrush right) => Equals (left, right);
- public static bool operator != (CommonBrush left, CommonBrush right) => !Equals (left, right);
+ // Note: not overriding equality operators on the base class on purpose because that won't be properly overridden on derived classes.
public override int GetHashCode ()
{
diff --git a/Xamarin.PropertyEditing/Drawing/CommonGradientBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonGradientBrush.cs
index 1677ee4..f10aee4 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonGradientBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonGradientBrush.cs
@@ -8,7 +8,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// An abstract description of a gradient brush, composed of gradient stops.
/// </summary>
[Serializable]
- public abstract class CommonGradientBrush : CommonBrush, IEquatable<CommonGradientBrush>
+ public abstract class CommonGradientBrush : CommonBrush
{
protected CommonGradientBrush (
IEnumerable<CommonGradientStop> stops,
@@ -54,7 +54,7 @@ namespace Xamarin.PropertyEditing.Drawing
return Equals (brush);
}
- public bool Equals (CommonGradientBrush other)
+ protected bool Equals (CommonGradientBrush other)
{
if (other == null) return false;
if (GradientStops.Count != other.GradientStops.Count) return false;
@@ -67,9 +67,6 @@ namespace Xamarin.PropertyEditing.Drawing
SpreadMethod == other.SpreadMethod;
}
- public static bool operator == (CommonGradientBrush left, CommonGradientBrush right) => Equals (left, right);
- public static bool operator != (CommonGradientBrush left, CommonGradientBrush right) => !Equals (left, right);
-
public override int GetHashCode ()
{
var hashCode = base.GetHashCode ();
diff --git a/Xamarin.PropertyEditing/Drawing/CommonImageBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonImageBrush.cs
index 9ddd8c7..dd0132b 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonImageBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonImageBrush.cs
@@ -6,7 +6,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// Paints an area with an image.
/// </summary>
[Serializable]
- public class CommonImageBrush : CommonTileBrush, IEquatable<CommonImageBrush>
+ public sealed class CommonImageBrush : CommonTileBrush, IEquatable<CommonImageBrush>
{
public CommonImageBrush(
string imageSource,
diff --git a/Xamarin.PropertyEditing/Drawing/CommonLinearGradientBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonLinearGradientBrush.cs
index 6ca792c..5746341 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonLinearGradientBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonLinearGradientBrush.cs
@@ -7,7 +7,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// A linear gradient.
/// </summary>
[Serializable]
- public class CommonLinearGradientBrush : CommonGradientBrush, IEquatable<CommonLinearGradientBrush>
+ public sealed class CommonLinearGradientBrush : CommonGradientBrush, IEquatable<CommonLinearGradientBrush>
{
public CommonLinearGradientBrush (
CommonPoint startPoint, CommonPoint endPoint,
diff --git a/Xamarin.PropertyEditing/Drawing/CommonRadialGradientBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonRadialGradientBrush.cs
index 174929b..f52f21b 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonRadialGradientBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonRadialGradientBrush.cs
@@ -8,7 +8,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// A focal point defines the beginning of the gradient, and a circle defines the end point of the gradient.
/// </summary>
[Serializable]
- public class CommonRadialGradientBrush : CommonGradientBrush, IEquatable<CommonRadialGradientBrush>
+ public sealed class CommonRadialGradientBrush : CommonGradientBrush, IEquatable<CommonRadialGradientBrush>
{
public CommonRadialGradientBrush(
CommonPoint center,
diff --git a/Xamarin.PropertyEditing/Drawing/CommonSolidBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonSolidBrush.cs
index a2b3ef9..e4686ec 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonSolidBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonSolidBrush.cs
@@ -6,7 +6,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// Paints an area with a solid color.
/// </summary>
[Serializable]
- public class CommonSolidBrush : CommonBrush, IEquatable<CommonSolidBrush>
+ public sealed class CommonSolidBrush : CommonBrush, IEquatable<CommonSolidBrush>
{
public CommonSolidBrush(CommonColor color, string colorSpace = null, double opacity = 1.0)
: base(opacity)
diff --git a/Xamarin.PropertyEditing/Drawing/CommonTileBrush.cs b/Xamarin.PropertyEditing/Drawing/CommonTileBrush.cs
index e9a8a7e..a79b455 100644
--- a/Xamarin.PropertyEditing/Drawing/CommonTileBrush.cs
+++ b/Xamarin.PropertyEditing/Drawing/CommonTileBrush.cs
@@ -6,7 +6,7 @@ namespace Xamarin.PropertyEditing.Drawing
/// Describes a way to paint a region by using one or more tiles.
/// </summary>
[Serializable]
- public abstract class CommonTileBrush : CommonBrush, IEquatable<CommonTileBrush>
+ public abstract class CommonTileBrush : CommonBrush
{
public CommonTileBrush(
CommonAlignmentX alignmentX,
@@ -73,7 +73,7 @@ namespace Xamarin.PropertyEditing.Drawing
return Equals (brush);
}
- public bool Equals (CommonTileBrush other)
+ protected bool Equals (CommonTileBrush other)
{
return other != null &&
base.Equals (other) &&
@@ -87,9 +87,6 @@ namespace Xamarin.PropertyEditing.Drawing
ViewPortUnits == other.ViewPortUnits;
}
- public static bool operator == (CommonTileBrush left, CommonTileBrush right) => Equals (left, right);
- public static bool operator != (CommonTileBrush left, CommonTileBrush right) => !Equals (left, right);
-
public override int GetHashCode ()
{
var hashCode = base.GetHashCode ();
diff --git a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
index 7afa4ee..68d179f 100644
--- a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
+++ b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
@@ -367,6 +367,15 @@ namespace Xamarin.PropertyEditing.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to No brush.
+ /// </summary>
+ public static string NoBrush {
+ get {
+ return ResourceManager.GetString("NoBrush", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to &lt;No Name&gt;.
/// </summary>
public static string NoName {
@@ -448,6 +457,15 @@ namespace Xamarin.PropertyEditing.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Solid color brush.
+ /// </summary>
+ public static string SolidBrush {
+ get {
+ return ResourceManager.GetString("SolidBrush", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Type.
/// </summary>
public static string Type {
diff --git a/Xamarin.PropertyEditing/Properties/Resources.resx b/Xamarin.PropertyEditing/Properties/Resources.resx
index 509c8b8..eb63036 100644
--- a/Xamarin.PropertyEditing/Properties/Resources.resx
+++ b/Xamarin.PropertyEditing/Properties/Resources.resx
@@ -296,4 +296,12 @@
<value>Y</value>
<comment>Yellow initial used as yellow textbox label</comment>
</data>
+ <data name="NoBrush" xml:space="preserve">
+ <value>No brush</value>
+ <comment>No brush tab help text</comment>
+ </data>
+ <data name="SolidBrush" xml:space="preserve">
+ <value>Solid color brush</value>
+ <comment>Solid color brush help text</comment>
+ </data>
</root> \ No newline at end of file
diff --git a/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs
index 9c43c9d..c9c8b52 100644
--- a/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs
+++ b/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs
@@ -8,6 +8,90 @@ namespace Xamarin.PropertyEditing.ViewModels
public BrushPropertyViewModel(IPropertyInfo property, IEnumerable<IObjectEditor> editors)
: base(property, editors)
{
+ if (property is IColorSpaced colorSpacedPropertyInfo) {
+ ColorSpaces = colorSpacedPropertyInfo.ColorSpaces;
+ }
+ }
+
+ public IReadOnlyList<string> ColorSpaces { get; }
+
+ public CommonSolidBrush PreviousSolidBrush { get; set; }
+
+ string ColorSpace => Value is CommonSolidBrush solidBrush ? solidBrush.ColorSpace : null;
+
+ CommonColor? hueColor;
+ public CommonColor HueColor {
+ get => (hueColor ?? (hueColor = LastColor.HueColor)).Value;
+ set {
+ if (!hueColor.Equals (value)) {
+ var saturation = Color.Saturation;
+ var brightness = Color.Brightness;
+ Color = CommonColor.FromHSB (value.Hue, saturation, brightness, Color.A);
+ OnPropertyChanged (nameof (Color));
+ hueColor = value;
+ OnPropertyChanged ();
+ Value = new CommonSolidBrush (Color, ColorSpace, Value.Opacity);
+ }
+ }
+ }
+
+ CommonColor? shade;
+ public CommonColor Shade {
+ get => (shade.HasValue ? shade : (shade = LastColor)).Value;
+ set {
+ if (!shade.Equals (value)) {
+ shade = value;
+ OnPropertyChanged ();
+ Value = new CommonSolidBrush (value, ColorSpace, Value.Opacity);
+ }
+ }
+ }
+
+ public CommonColor Color {
+ get => Value is CommonSolidBrush solidBrush ? solidBrush.Color : new CommonColor(0, 0, 0);
+ set {
+ if (!Color.Equals (value)) {
+ CommonColor oldHue = HueColor;
+ CommonColor newHue = value.HueColor;
+ Value = new CommonSolidBrush (value, ColorSpace, Value.Opacity);
+ OnPropertyChanged ();
+ if (!newHue.Equals (oldHue)) {
+ hueColor = newHue;
+ OnPropertyChanged (nameof (HueColor));
+ }
+ if (!value.Equals (shade)) {
+ shade = value;
+ OnPropertyChanged (nameof (Shade));
+ }
+ if (!initialColor.HasValue) {
+ initialColor = value;
+ }
+ }
+ }
+ }
+
+ CommonColor? initialColor;
+ public CommonColor InitialColor => initialColor ?? (initialColor = Color).Value;
+
+ CommonColor? lastColor;
+ public CommonColor LastColor => lastColor ?? (lastColor = Color).Value;
+
+ public void CommitLastColor ()
+ {
+ lastColor = Color;
+ shade = Color;
+ hueColor = Color.HueColor;
+ OnPropertyChanged (nameof (LastColor));
+ OnPropertyChanged (nameof (Shade));
+ OnPropertyChanged (nameof (HueColor));
+ Value = new CommonSolidBrush (Color, ColorSpace, Value.Opacity);
+ }
+
+ public void CommitShade ()
+ {
+ lastColor = Shade;
+ OnPropertyChanged (nameof (LastColor));
+ Value = new CommonSolidBrush (Shade, ColorSpace, Value.Opacity);
}
}
}
diff --git a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
index 9a6a630..7b647ec 100644
--- a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
+++ b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
@@ -424,7 +424,7 @@ namespace Xamarin.PropertyEditing.ViewModels
{ typeof(double), (p,e) => new FloatingPropertyViewModel (p, e) },
{ typeof(int), (p,e) => new IntegerPropertyViewModel (p, e) },
{ typeof(long), (p,e) => new IntegerPropertyViewModel (p, e) },
- { typeof(CommonSolidBrush), (p, e) => new SolidBrushPropertyViewModel(p, e) },
+ { typeof(CommonSolidBrush), (p, e) => new BrushPropertyViewModel(p, e) },
{ typeof(CommonBrush), (p, e) => new BrushPropertyViewModel(p, e) },
{ typeof(CommonPoint), (p,e) => new PointPropertyViewModel (p, e) },
{ typeof(CommonSize), (p,e) => new SizePropertyViewModel (p, e) },
diff --git a/Xamarin.PropertyEditing/ViewModels/SolidBrushPropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/SolidBrushPropertyViewModel.cs
deleted file mode 100644
index a3226e7..0000000
--- a/Xamarin.PropertyEditing/ViewModels/SolidBrushPropertyViewModel.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System.Collections.Generic;
-using Xamarin.PropertyEditing.Drawing;
-
-namespace Xamarin.PropertyEditing.ViewModels
-{
- internal class SolidBrushPropertyViewModel : PropertyViewModel<CommonSolidBrush>, IColorSpaced
- {
- public SolidBrushPropertyViewModel(IPropertyInfo property, IEnumerable<IObjectEditor> editors)
- : base(property, editors)
- {
- if (property is IColorSpaced solidBrushPropertyInfo) {
- ColorSpaces = solidBrushPropertyInfo.ColorSpaces;
- }
- }
-
- public IReadOnlyList<string> ColorSpaces { get; }
-
- CommonColor? hueColor;
- public CommonColor HueColor {
- get => (hueColor ?? (hueColor = LastColor.HueColor)).Value;
- set {
- if (!hueColor.Equals(value)) {
- var saturation = Color.Saturation;
- var brightness = Color.Brightness;
- Color = CommonColor.FromHSB (value.Hue, saturation, brightness, Color.A);
- OnPropertyChanged (nameof (Color));
- hueColor = value;
- OnPropertyChanged ();
- Value = new CommonSolidBrush(Color, Value.ColorSpace, Value.Opacity);
- }
- }
- }
-
- CommonColor? shade;
- public CommonColor Shade {
- get => (shade.HasValue ? shade : (shade = LastColor)).Value;
- set {
- if (!shade.Equals(value)) {
- shade = value;
- OnPropertyChanged ();
- Value = new CommonSolidBrush (value, Value.ColorSpace, Value.Opacity);
- }
- }
- }
-
- public CommonColor Color {
- get => Value.Color;
- set {
- if (!Value.Color.Equals(value)) {
- CommonColor oldHue = HueColor;
- CommonColor newHue = value.HueColor;
- Value = new CommonSolidBrush (value, Value.ColorSpace, Value.Opacity);
- OnPropertyChanged ();
- if (!newHue.Equals(oldHue)) {
- hueColor = newHue;
- OnPropertyChanged (nameof (HueColor));
- }
- if (!value.Equals(shade)) {
- shade = value;
- OnPropertyChanged (nameof (Shade));
- }
- if (!initialColor.HasValue) {
- initialColor = value;
- }
- }
- }
- }
-
- CommonColor? initialColor;
- public CommonColor InitialColor => initialColor ?? (initialColor = Color).Value;
-
- CommonColor? lastColor;
- public CommonColor LastColor => lastColor ?? (lastColor = Color).Value;
-
- public void CommitLastColor()
- {
- lastColor = Color;
- shade = Color;
- hueColor = Color.HueColor;
- OnPropertyChanged (nameof (LastColor));
- OnPropertyChanged (nameof (Shade));
- OnPropertyChanged (nameof (HueColor));
- Value = new CommonSolidBrush (Color, Value.ColorSpace, Value.Opacity);
- }
-
- public void CommitShade ()
- {
- lastColor = Shade;
- OnPropertyChanged (nameof (LastColor));
- Value = new CommonSolidBrush (Shade, Value.ColorSpace, Value.Opacity);
- }
- }
-}
diff --git a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
index ecea907..d5b7b50 100644
--- a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
+++ b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
@@ -42,6 +42,7 @@
<ItemGroup>
<Compile Include="AsyncWorkQueue.cs" />
<Compile Include="BidirectionalDictionary.cs" />
+ <Compile Include="BrushPropertyInfo.cs" />
<Compile Include="Drawing\CommonAlignment.cs" />
<Compile Include="Drawing\CommonBrush.cs" />
<Compile Include="Drawing\CommonBrushMappingMode.cs" />
@@ -89,7 +90,6 @@
<Compile Include="Reflection\ReflectionEventInfo.cs" />
<Compile Include="Reflection\ReflectionObjectEditor.cs" />
<Compile Include="Reflection\ReflectionPropertyInfo.cs" />
- <Compile Include="SolidBrushPropertyInfo.cs" />
<Compile Include="ValueInfo.cs" />
<Compile Include="ValueSource.cs" />
<Compile Include="ViewModels\ArrangeModeViewModel.cs" />
@@ -108,7 +108,6 @@
<Compile Include="ViewModels\PropertyViewModel.cs" />
<Compile Include="ViewModels\RelayCommand.cs" />
<Compile Include="ViewModels\SizePropertyViewModel.cs" />
- <Compile Include="ViewModels\SolidBrushPropertyViewModel.cs" />
<Compile Include="ViewModels\StringPropertyViewModel.cs" />
<Compile Include="PropertyArrangeMode.cs" />
<Compile Include="IGroupingList.cs" />