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.Mac/Controls/BasePointEditorControl.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs229
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs135
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs120
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs80
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs49
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs104
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs22
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs78
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs4
-rw-r--r--Xamarin.PropertyEditing.Mac/Resources/stepper-down.pngbin0 -> 359 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/Resources/stepper-down@2x.pngbin0 -> 705 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/Resources/stepper-up.pngbin0 -> 357 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/Resources/stepper-up@2x.pngbin0 -> 640 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj521
-rw-r--r--Xamarin.PropertyEditing.Tests/ConstrainedPropertyViewModelTests.cs5
-rw-r--r--Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs2
-rw-r--r--Xamarin.PropertyEditing.Tests/MockControls/MockWpfControl.cs1
-rw-r--r--Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs2
-rw-r--r--Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs3
-rw-r--r--Xamarin.PropertyEditing.Tests/PropertiesViewModelTests.cs2
-rw-r--r--Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs2
-rw-r--r--Xamarin.PropertyEditing.Tests/RatioViewModelTests.cs194
-rw-r--r--Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj1
-rw-r--r--Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs2
-rw-r--r--Xamarin.PropertyEditing.Windows/RatioEditorControl.cs44
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/Resources.xaml34
-rw-r--r--Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj1
-rw-r--r--Xamarin.PropertyEditing/Controls/FieldValidation.cs178
-rw-r--r--Xamarin.PropertyEditing/Drawing/CommonRatio.cs105
-rw-r--r--Xamarin.PropertyEditing/Properties/Resources.Designer.cs926
-rw-r--r--Xamarin.PropertyEditing/Properties/Resources.resx3
-rw-r--r--Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs1
-rw-r--r--Xamarin.PropertyEditing/ViewModels/RatioViewModel.cs153
-rw-r--r--Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj3
37 files changed, 1682 insertions, 1328 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs
index b438f2c..287a92f 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs
@@ -15,7 +15,7 @@ namespace Xamarin.PropertyEditing.Mac
internal NumericSpinEditor<T> YEditor { get; set; }
public override NSView FirstKeyView => XEditor;
- public override NSView LastKeyView => YEditor;
+ public override NSView LastKeyView => YEditor.DecrementButton;
public BasePointEditorControl ()
{
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs
index 5cdd872..1c57694 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs
@@ -21,7 +21,7 @@ namespace Xamarin.PropertyEditing.Mac
protected NumericSpinEditor<T> HeightEditor { get; set; }
public override NSView FirstKeyView => XEditor;
- public override NSView LastKeyView => HeightEditor;
+ public override NSView LastKeyView => HeightEditor.DecrementButton;
public BaseRectangleEditorControl ()
{
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs
index edb17f5..1aabaa0 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs
@@ -2,6 +2,8 @@
using AppKit;
using CoreGraphics;
using Foundation;
+using Xamarin.PropertyEditing.Drawing;
+using Xamarin.PropertyEditing.Themes;
namespace Xamarin.PropertyEditing.Mac
{
@@ -12,8 +14,21 @@ namespace Xamarin.PropertyEditing.Mac
internal class NumericSpinEditor : NSView, INSAccessibilityGroup
{
NumericTextField numericEditor;
- NSStepper stepper;
- bool editing;
+ public NumericTextField NumericEditor {
+ get { return numericEditor; }
+ }
+
+ UpSpinnerButton incrementButton;
+ public UpSpinnerButton IncrementButton {
+ get { return incrementButton; }
+ }
+
+ DownSpinnerButton decrementButton;
+ public DownSpinnerButton DecrementButton {
+ get { return decrementButton; }
+ }
+
+ protected bool editing;
public event EventHandler ValueChanged;
public event EventHandler EditingEnded;
@@ -31,28 +46,16 @@ namespace Xamarin.PropertyEditing.Mac
set { ((NSTextFieldCell)numericEditor.Cell).PlaceholderString = value; }
}
- NSStepper Stepper {
- get { return stepper; }
- }
-
- public NSTextField TextField {
- get { return numericEditor; }
- }
-
public override CGSize IntrinsicContentSize {
get {
- var baseSize = stepper.IntrinsicContentSize;
- return new CGSize (baseSize.Width + 40, baseSize.Height);
+ var baseSize = numericEditor.IntrinsicContentSize;
+ return new CGSize (baseSize.Width + 20, baseSize.Height);
}
}
public NSColor BackgroundColor {
- get {
- return numericEditor.BackgroundColor;
- }
- set {
- numericEditor.BackgroundColor = value;
- }
+ get { return numericEditor.BackgroundColor; }
+ set { numericEditor.BackgroundColor = value; }
}
public override nfloat BaselineOffsetFromBottom {
@@ -66,7 +69,7 @@ namespace Xamarin.PropertyEditing.Mac
public double Value {
- get { return stepper.DoubleValue; }
+ get { return numericEditor.DoubleValue; }
set { SetValue (value); }
}
@@ -76,47 +79,38 @@ namespace Xamarin.PropertyEditing.Mac
set { SetValue (value); }
}
- public bool Wrap {
- get { return stepper.ValueWraps; }
- set { stepper.ValueWraps = value; }
- }
-
public double MinimumValue {
- get { return stepper.MinValue; }
+ get { return formatter.Minimum.DoubleValue; }
set {
- stepper.MinValue = value;
formatter.Minimum = new NSNumber (value);
}
}
public double MaximumValue {
- get { return stepper.MaxValue; }
+ get { return formatter.Maximum.DoubleValue; }
set {
- stepper.MaxValue = value;
formatter.Maximum = new NSNumber (value);
}
}
+ double incrementValue = 1.0f;
public double IncrementValue {
- get { return stepper.Increment; }
- set { stepper.Increment = value; }
+ get { return incrementValue; }
+ set { incrementValue = value; }
}
public bool Enabled {
- get {
- return numericEditor.Enabled;
- }
+ get { return numericEditor.Enabled; }
set {
numericEditor.Enabled = value;
- stepper.Enabled = value;
+ incrementButton.Enabled = value;
+ decrementButton.Enabled = value;
}
}
NSNumberFormatter formatter;
public NSNumberFormatter Formatter {
- get {
- return formatter;
- }
+ get { return formatter; }
set {
formatter = value;
numericEditor.Formatter = formatter;
@@ -124,32 +118,31 @@ namespace Xamarin.PropertyEditing.Mac
}
public bool IsIndeterminate {
- get {
- return !string.IsNullOrEmpty (numericEditor.StringValue);
- }
+ get { return !string.IsNullOrEmpty (numericEditor.StringValue); }
set {
if (value)
numericEditor.StringValue = string.Empty;
- else
- numericEditor.DoubleValue = stepper.DoubleValue;
}
}
public bool Editable {
- get {
- return numericEditor.Editable;
- }
+ get { return numericEditor.Editable; }
set {
numericEditor.Editable = value;
- stepper.Enabled = value;
+ incrementButton.Enabled = value;
+ decrementButton.Enabled = value;
}
}
public NSNumberFormatterStyle NumberStyle {
get { return formatter.NumberStyle; }
- set {
- formatter.NumberStyle = value;
- }
+ set { formatter.NumberStyle = value; }
+ }
+
+ public bool AllowRatios
+ {
+ get { return numericEditor.AllowRatios; }
+ set { numericEditor.AllowRatios = value; }
}
protected virtual void OnConfigureNumericTextField ()
@@ -157,6 +150,12 @@ namespace Xamarin.PropertyEditing.Mac
numericEditor.Formatter = formatter;
}
+ public bool AllowNegativeValues
+ {
+ get { return numericEditor.AllowNegativeValues; }
+ set { numericEditor.AllowNegativeValues = value; }
+ }
+
public virtual void Reset ()
{
}
@@ -166,99 +165,110 @@ namespace Xamarin.PropertyEditing.Mac
TranslatesAutoresizingMaskIntoConstraints = false;
var controlSize = NSControlSize.Small;
- stepper = new NSStepper {
- TranslatesAutoresizingMaskIntoConstraints = false,
- ValueWraps = false,
- ControlSize = controlSize,
- };
+ incrementButton = new UpSpinnerButton ();
+
+ decrementButton = new DownSpinnerButton ();
formatter = new NSNumberFormatter {
FormatterBehavior = NSNumberFormatterBehavior.Version_10_4,
Locale = NSLocale.CurrentLocale,
MaximumFractionDigits = 15,
+ Maximum = double.MaxValue,
+ Minimum = double.MinValue,
NumberStyle = NSNumberFormatterStyle.Decimal,
UsesGroupingSeparator = false,
};
numericEditor = new NumericTextField {
Alignment = NSTextAlignment.Right,
- Formatter = formatter,
TranslatesAutoresizingMaskIntoConstraints = false,
Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
ControlSize = controlSize,
};
- stepper.Activated += (s, e) => {
- OnStepperActivated (s, e);
- };
+ incrementButton.OnMouseLeftDown += (sender, e) => { IncrementNumericValue (); };
+ decrementButton.OnMouseLeftDown += (sender, e) => { DecrementNumericValue (); };
- numericEditor.KeyArrowUp += (sender, e) => { IncrementNumericValue (); };
- numericEditor.KeyArrowDown += (sender, e) => { DecrementNumericValue (); };
+ numericEditor.KeyArrowUp += (sender, e) => { IncrementNumericValue (e); };
+ numericEditor.KeyArrowDown += (sender, e) => { DecrementNumericValue (e); };
numericEditor.ValidatedEditingEnded += (s, e) => {
OnEditingEnded (s, e);
};
- AddSubview (stepper);
AddSubview (numericEditor);
+ AddSubview (incrementButton);
+ AddSubview (decrementButton);
this.DoConstraints (new[] {
numericEditor.ConstraintTo (this, (n, c) => n.Width == c.Width - 16),
- numericEditor.ConstraintTo (this, (n, c) => n.Height == 19),
- stepper.ConstraintTo (numericEditor, (s, n) => s.Left == n.Right + 4),
- stepper.ConstraintTo (numericEditor, (s, n) => s.Top == n.Top),
+ numericEditor.ConstraintTo (this, (n, c) => n.Height == PropertyEditorControl.DefaultControlHeight - 3),
+ incrementButton.ConstraintTo (numericEditor, (s, n) => s.Left == n.Right + 5),
+ incrementButton.ConstraintTo (numericEditor, (s, n) => s.Top == n.Top + 1),
+ incrementButton.ConstraintTo (numericEditor, (s, n) => s.Width == 9),
+ incrementButton.ConstraintTo (numericEditor, (s, n) => s.Height == 9),
+ decrementButton.ConstraintTo (numericEditor, (s, n) => s.Left == n.Right + 5),
+ decrementButton.ConstraintTo (numericEditor, (s, n) => s.Top == n.Top + 10),
+ decrementButton.ConstraintTo (numericEditor, (s, n) => s.Width == 9),
+ decrementButton.ConstraintTo (numericEditor, (s, n) => s.Height == 9),
});
+
+ PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
+
+ UpdateTheme ();
}
- protected virtual void SetStepperActivated ()
+ protected override void Dispose (bool disposing)
{
- SetValue (stepper.DoubleValue);
+ if (disposing) {
+ PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
+ }
}
- protected void OnStepperActivated (object sender, EventArgs e)
+ void ThemeManager_ThemeChanged (object sender, EventArgs e)
{
- if (!editing) {
- editing = true;
- SetStepperActivated ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- editing = false;
- }
+ UpdateTheme ();
}
- protected void OnValueChanged (object sender, EventArgs e)
+ protected void UpdateTheme ()
{
- if (!editing) {
- editing = true;
- SetValue (numericEditor.StringValue);
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- editing = false;
+ this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance;
+
+ // Skin the inc/dec buttons until we support theming files
+ switch (PropertyEditorPanel.ThemeManager.Theme) {
+ case PropertyEditorTheme.Dark:
+ incrementButton.Image = NSImage.ImageNamed ("stepper-up"); // TODO path to proper image
+ decrementButton.Image = NSImage.ImageNamed ("stepper-down"); // TODO path to proper image
+ break;
+
+ case PropertyEditorTheme.Light:
+ incrementButton.Image = NSImage.ImageNamed ("stepper-up"); // TODO path to proper image
+ decrementButton.Image = NSImage.ImageNamed ("stepper-down"); // TODO path to proper image
+ break;
+
+ case PropertyEditorTheme.None:
+ incrementButton.Image = NSImage.ImageNamed ("stepper-up"); // TODO path to proper image
+ decrementButton.Image = NSImage.ImageNamed ("stepper-down"); // TODO path to proper image
+ break;
}
+
}
- protected void OnEditingEnded (object sender, EventArgs e)
+ virtual protected void OnEditingEnded (object sender, EventArgs e)
{
if (!editing) {
editing = true;
SetValue (numericEditor.StringValue);
- if (EditingEnded != null)
- EditingEnded (this, EventArgs.Empty);
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
+ EditingEnded?.Invoke (this, EventArgs.Empty);
editing = false;
}
}
void SetValue (string value)
{
- //Regulates maximun and minium out of range
- if (!string.IsNullOrEmpty (value)) {
- stepper.DoubleValue = CoerceValue (FieldValidation.FixInitialValue (value, Value.ToEditorString ()).ToEditorDouble ());
- numericEditor.StringValue = FieldValidation.RoundDoubleValue (stepper.DoubleValue.ToEditorString (), NumericMode == ValidationType.Decimal ? FieldValidation.DefaultXcodeMaxRoundDigits : 0);
- } else {
- stepper.StringValue = value;
+ if (numericEditor.StringValue != value) {
numericEditor.StringValue = value;
+ NotifyingValueChanged (EventArgs.Empty);
}
}
@@ -267,21 +277,40 @@ namespace Xamarin.PropertyEditing.Mac
SetValue (value.ToString ());
}
- protected double CoerceValue (double val)
+ protected void NotifyingValueChanged (EventArgs eventArgs)
+ {
+ ValueChanged?.Invoke (this, eventArgs);
+ }
+
+ public void IncrementNumericValue (bool shiftPressed = false)
+ {
+ if (!editing) {
+ editing = true;
+ SetIncrementOrDecrementValue (shiftPressed ? 10 * incrementValue : incrementValue);
+ editing = false;
+ }
+ }
+
+ public void DecrementNumericValue (bool shiftPressed = false)
{
- return FieldValidation.CoerceValue (val, MinimumValue, MaximumValue);
+ if (!editing) {
+ editing = true;
+ SetIncrementOrDecrementValue (-(shiftPressed ? 10 * incrementValue : incrementValue));
+ editing = false;
+ }
}
- public void IncrementNumericValue ()
+ virtual protected void SetIncrementOrDecrementValue (double incDevValue)
{
- SetValue (stepper.DoubleValue + IncrementValue);
- OnStepperActivated (stepper, EventArgs.Empty);
+ // Constrain our value to our Min/Max before we set it
+ var newValue = Clamp (numericEditor.DoubleValue + incDevValue);
+
+ SetValue (newValue);
}
- public void DecrementNumericValue ()
+ public double Clamp (double value)
{
- SetValue (stepper.DoubleValue - IncrementValue);
- OnStepperActivated (stepper, EventArgs.Empty);
+ return (double)Decimal.Round ((decimal)(value < MinimumValue ? MinimumValue : value > MaximumValue ? MaximumValue : value), Digits);
}
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs
index bd3a045..f324c9b 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs
@@ -25,8 +25,8 @@ namespace Xamarin.PropertyEditing.Mac
get; set;
}
- public event EventHandler KeyArrowUp;
- public event EventHandler KeyArrowDown;
+ public event EventHandler<bool> KeyArrowUp;
+ public event EventHandler<bool> KeyArrowDown;
public event EventHandler ValidatedEditingEnded;
public NumericTextField ()
@@ -34,15 +34,15 @@ namespace Xamarin.PropertyEditing.Mac
AllowNegativeValues = true;
var keyUpDownDelegate = new KeyUpDownDelegate ();
- keyUpDownDelegate.KeyArrowUp += (sender, e) => { OnKeyArrowUp (); };
- keyUpDownDelegate.KeyArrowDown += (sender, e) => { OnKeyArrowDown (); };
+ keyUpDownDelegate.KeyArrowUp += (sender, e) => { OnKeyArrowUp (e); };
+ keyUpDownDelegate.KeyArrowDown += (sender, e) => { OnKeyArrowDown (e); };
Delegate = keyUpDownDelegate;
}
- public override bool ShouldBeginEditing (NSText fieldEditor)
+ public override bool ShouldBeginEditing (NSText textObject)
{
- CachedCurrentEditor = fieldEditor;
- cachedValueString = fieldEditor.Value;
+ CachedCurrentEditor = textObject;
+ cachedValueString = textObject.Value;
if (AllowRatios)
CachedCurrentEditor.Delegate = new RatioValidateDelegate (this);
@@ -52,27 +52,19 @@ namespace Xamarin.PropertyEditing.Mac
return true;
}
- protected virtual void OnKeyArrowUp ()
+ protected virtual void OnKeyArrowUp (bool shiftPressed)
{
- var handler = KeyArrowUp;
- if (handler != null) {
- handler (this, EventArgs.Empty);
- }
+ KeyArrowUp?.Invoke (this, shiftPressed);
}
- protected virtual void OnKeyArrowDown ()
+ protected virtual void OnKeyArrowDown (bool shiftPressed)
{
- var handler = KeyArrowDown;
- if (handler != null) {
- handler (this, EventArgs.Empty);
- }
+ KeyArrowDown?.Invoke (this, shiftPressed);
}
- public virtual void RaiseValidatedEditingEnded ()
+ public virtual void NotifyValidatedEditingEnded ()
{
- var handler = ValidatedEditingEnded;
- if (handler != null)
- handler (this, EventArgs.Empty);
+ ValidatedEditingEnded?.Invoke (this, EventArgs.Empty);
}
public virtual void ResetInvalidInput ()
@@ -80,12 +72,66 @@ namespace Xamarin.PropertyEditing.Mac
this.StringValue = cachedValueString;
}
+ public static bool CheckIfNumber (string finalString, ValidationType mode, bool allowNegativeValues)
+ {
+ return mode == ValidationType.Decimal ?
+ ValidateDecimal (finalString, allowNegativeValues) :
+ ValidateInteger (finalString, allowNegativeValues);
+ }
+
+ public static bool ValidateDecimal (string finalString, bool allowNegativeValues)
+ {
+ double value;
+ //Checks parsing to number
+ if (!double.TryParse (finalString, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.CurrentUICulture, out value))
+ return false;
+ //Checks if needs to be possitive value
+ if (!allowNegativeValues && value < 0)
+ return false;
+ //Checks a common validation
+ return ViewModels.RatioViewModel.IsValidInput (finalString);
+ }
+
+ public static bool ValidateInteger (string finalString, bool allowNegativeValues)
+ {
+ int value;
+ //Checks parsing to number
+ if (!int.TryParse (finalString, out value))
+ return false;
+ //Checks if needs to be possitive value
+ if (!allowNegativeValues && value < 0)
+ return false;
+ //Checks a common validation
+ return ViewModels.RatioViewModel.IsValidInput (finalString);
+ }
+
+ public static bool CheckIfRatio (string finalString, ValidationType mode, bool allowNegativeValues)
+ {
+ var parts = finalString.Split (ViewModels.RatioViewModel.SplitSeparators, StringSplitOptions.RemoveEmptyEntries);
+ if (parts.Length == 2) {
+ bool parsed = true;
+
+ if (!CheckIfNumber (parts[0], mode, allowNegativeValues))
+ parsed = false;
+
+ if (!String.IsNullOrEmpty (parts[1]) && !CheckIfNumber (parts[1], mode, allowNegativeValues))
+ parsed = false;
+
+ if (parsed)
+ return true;
+ } else if (parts.Length == 1) { // We have a potential whole number, let's make sure
+ if (CheckIfNumber (parts[0], mode, allowNegativeValues)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
class KeyUpDownDelegate : NSTextFieldDelegate
{
- public event EventHandler KeyArrowUp;
- public event EventHandler KeyArrowDown;
+ public event EventHandler<bool> KeyArrowUp;
+ public event EventHandler<bool> KeyArrowDown;
public override bool DoCommandBySelector (NSControl control, NSTextView textView, Selector commandSelector)
{
@@ -96,27 +142,27 @@ namespace Xamarin.PropertyEditing.Mac
case "moveDown:":
OnKeyArrowDown ();
break;
+ case "moveUpAndModifySelection:":
+ OnKeyArrowUp (true);
+ break;
+ case "moveDownAndModifySelection:":
+ OnKeyArrowDown (true);
+ break;
default:
return false;
}
- return false;
+ return true;
}
- protected virtual void OnKeyArrowUp ()
+ protected virtual void OnKeyArrowUp (bool shiftPressed = false)
{
- var handler = KeyArrowUp;
- if (handler != null) {
- handler (this, EventArgs.Empty);
- }
+ KeyArrowUp?.Invoke (this, shiftPressed);
}
- protected virtual void OnKeyArrowDown ()
+ protected virtual void OnKeyArrowDown (bool shiftPressed = false)
{
- var handler = KeyArrowDown;
- if (handler != null) {
- handler (this, EventArgs.Empty);
- }
+ KeyArrowDown?.Invoke (this, shiftPressed);
}
}
@@ -138,17 +184,22 @@ namespace Xamarin.PropertyEditing.Mac
public override bool TextShouldEndEditing (NSText textObject)
{
- if (!ValidateFinalString (TextField.StringValue)) {
+ bool shouldEndEditing = false;
+ if (!ValidateFinalString (textObject.Value)) {
TextField.ResetInvalidInput ();
AppKitFramework.NSBeep ();
- return false;
+ TextField.ShouldEndEditing (textObject);
+ } else {
+ shouldEndEditing = TextField.ShouldEndEditing (textObject);
}
- return TextField.ShouldEndEditing (textObject);
+
+ return shouldEndEditing;
}
public override void TextDidEndEditing (NSNotification notification)
{
- TextField.RaiseValidatedEditingEnded ();
+ TextField.NotifyValidatedEditingEnded ();
+ TextField.DidEndEditing (notification);
}
protected abstract bool ValidateFinalString (string value);
@@ -165,8 +216,8 @@ namespace Xamarin.PropertyEditing.Mac
protected override bool ValidateFinalString (string value)
{
return TextField.NumericMode == ValidationType.Decimal ?
- FieldValidation.ValidateDecimal (value, TextField.AllowNegativeValues) :
- FieldValidation.ValidateInteger (value, TextField.AllowNegativeValues);
+ NumericTextField.ValidateDecimal (value, TextField.AllowNegativeValues) :
+ NumericTextField.ValidateInteger (value, TextField.AllowNegativeValues);
}
}
@@ -180,7 +231,9 @@ namespace Xamarin.PropertyEditing.Mac
protected override bool ValidateFinalString (string value)
{
- return FieldValidation.ValidateRatio (value, ValidationType.Decimal, TextField.AllowNegativeValues);
+ if (NumericTextField.CheckIfRatio (value, ValidationType.Decimal, false) || NumericTextField.CheckIfNumber (value, ValidationType.Decimal, false))
+ return true;
+ return false;
}
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
index a300e18..77a2cb3 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
@@ -2,11 +2,12 @@
using AppKit;
using CoreGraphics;
using Xamarin.PropertyEditing.Mac.Resources;
+using Xamarin.PropertyEditing.Themes;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
- public class PropertyButton : NSImageView
+ public class PropertyButton : UnfocusableButton
{
NSMenu popUpContextMenu;
@@ -35,106 +36,101 @@ namespace Xamarin.PropertyEditing.Mac
AccessibilityHelp = LocalizationResources.AccessibilityPropertiesButtonDescription;
Enabled = true;
Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10");
- ImageScaling = NSImageScale.AxesIndependently;
+ ImageScaling = NSImageScale.None;
ToolTip = Properties.Resources.Default;
TranslatesAutoresizingMaskIntoConstraints = false;
+
+ OnMouseEntered += (sender, e) => {
+ ToggleFocusImage (true);
+ };
+
+ OnMouseExited += (sender, e) => {
+ ToggleFocusImage ();
+ };
+
+ OnMouseLeftDown += (sender, e) => {
+ PopUpContextMenu ();
+ };
}
- public override void MouseDown (NSEvent theEvent)
+ private void PopUpContextMenu ()
{
- if (theEvent.Type == NSEventType.LeftMouseDown) {
- if (this.popUpContextMenu == null) {
- this.popUpContextMenu = new NSMenu ();
-
- if (this.viewModel.TargetPlatform.SupportsCustomExpressions) {
- var mi = new NSMenuItem (Properties.Resources.CustomExpressionEllipsis) {
- AttributedTitle = new Foundation.NSAttributedString (
- Properties.Resources.CustomExpressionEllipsis,
- new CoreText.CTStringAttributes () {
- Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
- })
- };
-
- mi.Activated += OnCustomExpression;
-
- this.popUpContextMenu.AddItem (mi);
- this.popUpContextMenu.AddItem (NSMenuItem.SeparatorItem);
- }
-
- // TODO If we add more menu items consider making the Label/Command a dictionary that we can iterate over to populate everything.
- this.popUpContextMenu.AddItem (new CommandMenuItem (Properties.Resources.Reset, viewModel.ClearValueCommand) {
+ if (this.popUpContextMenu == null) {
+ this.popUpContextMenu = new NSMenu ();
+
+ if (this.viewModel.TargetPlatform.SupportsCustomExpressions) {
+ var mi = new NSMenuItem (Properties.Resources.CustomExpressionEllipsis) {
AttributedTitle = new Foundation.NSAttributedString (
- Properties.Resources.Reset,
- new CoreText.CTStringAttributes () {
- Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
- })
- });
- }
+ Properties.Resources.CustomExpressionEllipsis,
+ new CoreText.CTStringAttributes () {
+ Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
+ })
+ };
- var menuOrigin = this.Superview.ConvertPointToView (new CGPoint (Frame.Location.X - 1, Frame.Location.Y + Frame.Size.Height + 4), null);
+ mi.Activated += OnCustomExpression;
- var popupMenuEvent = NSEvent.MouseEvent (NSEventType.LeftMouseDown, menuOrigin, (NSEventModifierMask)0x100, 0, this.Window.WindowNumber, this.Window.GraphicsContext, 0, 1, 1);
+ this.popUpContextMenu.AddItem (mi);
+ this.popUpContextMenu.AddItem (NSMenuItem.SeparatorItem);
+ }
- NSMenu.PopUpContextMenu (popUpContextMenu, popupMenuEvent, this);
+ // TODO If we add more menu items consider making the Label/Command a dictionary that we can iterate over to populate everything.
+ this.popUpContextMenu.AddItem (new CommandMenuItem (Properties.Resources.Reset, viewModel.ClearValueCommand) {
+ AttributedTitle = new Foundation.NSAttributedString (
+ Properties.Resources.Reset,
+ new CoreText.CTStringAttributes () {
+ Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
+ })
+ });
}
- }
- public override void MouseEntered (NSEvent theEvent)
- {
- ChangeActiveImage (viewModel.ValueSource, true);
- }
+ var menuOrigin = this.Superview.ConvertPointToView (new CGPoint (Frame.Location.X - 1, Frame.Location.Y + Frame.Size.Height + 4), null);
- public override void MouseExited (NSEvent theEvent)
- {
- ChangeActiveImage (viewModel.ValueSource);
+ var popupMenuEvent = NSEvent.MouseEvent (NSEventType.LeftMouseDown, menuOrigin, (NSEventModifierMask)0x100, 0, this.Window.WindowNumber, this.Window.GraphicsContext, 0, 1, 1);
+
+ NSMenu.PopUpContextMenu (popUpContextMenu, popupMenuEvent, this);
}
- public override void UpdateTrackingAreas ()
+ protected override void UpdateTheme ()
{
- base.UpdateTrackingAreas ();
-
- foreach (var item in TrackingAreas ()) {
- RemoveTrackingArea (item);
- }
-
- var options = NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveAlways;
+ base.UpdateTheme ();
- var trackingArea = new NSTrackingArea (this.Bounds, options, this, null);
-
- AddTrackingArea (trackingArea);
+ ToggleFocusImage ();
}
- private void ChangeActiveImage (ValueSource valueSource, bool activeImage = false)
+ private void ToggleFocusImage (bool focused = false)
{
- switch (valueSource) {
+ if (viewModel != null) {
+
+ switch (viewModel.ValueSource) {
case ValueSource.Binding:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-10");
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-10");
break;
case ValueSource.Default:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10");
- return;
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10");
+ break;
case ValueSource.Local:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-10");
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-10");
break;
case ValueSource.Inherited:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10");
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10");
break;
case ValueSource.Resource:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10");
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10");
break;
case ValueSource.Unset:
- Image = activeImage ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10");
+ Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10");
break;
default:
// To Handle ValueSource.DefaultStyle, ValueSource.Style etc.
Image = null;
break;
+ }
}
}
@@ -171,7 +167,7 @@ namespace Xamarin.PropertyEditing.Mac
break;
}
- ChangeActiveImage (valueSource, false);
+ UpdateTheme ();
}
private void OnPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs
new file mode 100644
index 0000000..507eee3
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs
@@ -0,0 +1,80 @@
+using System;
+using AppKit;
+using Foundation;
+using Xamarin.PropertyEditing.Drawing;
+using Xamarin.PropertyEditing.Mac;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class RatioEditor<T> : NumericSpinEditor<T>
+ {
+ private bool fullSelection;
+
+ public RatioEditor ()
+ {
+ AllowNegativeValues = false;
+ AllowRatios = true;
+ BackgroundColor = NSColor.Clear;
+ StringValue = string.Empty;
+ TranslatesAutoresizingMaskIntoConstraints = false;
+ }
+
+ protected override void OnEditingEnded (object sender, EventArgs e)
+ {
+ if (!editing) {
+ editing = true;
+ NotifyingValueChanged (new RatioEventArgs (0, 0, 0));
+ editing = false;
+ }
+ }
+
+ protected override void SetIncrementOrDecrementValue (double incDevValue)
+ {
+ nint caretLocation = 0;
+ nint selectionLength = 0;
+
+ GetEditorCaretLocationAndLength (out caretLocation, out selectionLength);
+
+ // Fire A Value change, so things are updated
+ NotifyingValueChanged (new RatioEventArgs ((int)caretLocation, (int)selectionLength, incDevValue));
+
+ // Resposition our caret so it doesn't jump around.
+ SetEditorCaretLocationAndLength (caretLocation, selectionLength);
+ }
+
+ private void SetEditorCaretLocationAndLength (nint caretLocation, nint selectionLength)
+ {
+ if (NumericEditor.CurrentEditor != null) {
+ if (fullSelection && (selectionLength != NumericEditor.StringValue.Length)) {
+ selectionLength = NumericEditor.StringValue.Length;
+ }
+ NumericEditor.CurrentEditor.SelectedRange = new NSRange (caretLocation, selectionLength);
+ }
+ }
+
+ private void GetEditorCaretLocationAndLength (out nint caretLocation, out nint selectionLength)
+ {
+ caretLocation = 0;
+ selectionLength = 0;
+ if (NumericEditor.CurrentEditor != null) {
+ caretLocation = NumericEditor.CurrentEditor.SelectedRange.Location;
+ selectionLength = NumericEditor.CurrentEditor.SelectedRange.Length;
+ fullSelection = NumericEditor.StringValue.Length == selectionLength;
+ }
+ }
+
+ public class RatioEventArgs : EventArgs
+ {
+ public RatioEventArgs (int caretPosition, int selectionLength, double incrementValue)
+ {
+ CaretPosition = caretPosition;
+ SelectionLength = selectionLength;
+ IncrementValue = incrementValue;
+ }
+
+ public int CaretPosition { get; }
+ public int SelectionLength { get; }
+ public double IncrementValue { get; }
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs
new file mode 100644
index 0000000..0ba72dc
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs
@@ -0,0 +1,49 @@
+using System;
+using AppKit;
+using ObjCRuntime;
+using Xamarin.PropertyEditing.Themes;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ public class UpSpinnerButton : UnfocusableButton
+ {
+ public UpSpinnerButton ()
+ {
+ OnMouseEntered += (sender, e) => {
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up-focus-blue");
+ };
+
+ OnMouseExited += (sender, e) => {
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up");
+ };
+ }
+
+ protected override void UpdateTheme ()
+ {
+ base.UpdateTheme ();
+
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up");
+ }
+ }
+
+ public class DownSpinnerButton : UnfocusableButton
+ {
+ public DownSpinnerButton ()
+ {
+ OnMouseEntered += (sender, e) => {
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down-focus-blue");
+ };
+
+ OnMouseExited += (sender, e) => {
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down");
+ };
+ }
+
+ protected override void UpdateTheme ()
+ {
+ base.UpdateTheme ();
+
+ Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down");
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs
new file mode 100644
index 0000000..3a18805
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs
@@ -0,0 +1,104 @@
+using System;
+using AppKit;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ public abstract class UnfocusableButton : NSImageView
+ {
+ public event EventHandler OnMouseEntered;
+ public event EventHandler OnMouseExited;
+ public event EventHandler OnMouseLeftDown;
+ public event EventHandler OnMouseRightDown;
+
+ public UnfocusableButton ()
+ {
+ Enabled = true;
+ ImageScaling = NSImageScale.AxesIndependently;
+ TranslatesAutoresizingMaskIntoConstraints = false;
+
+ PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
+
+ UpdateTheme ();
+ }
+
+ #region Overridden Methods
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing) {
+ PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
+ }
+ }
+
+ public override void MouseDown (NSEvent theEvent)
+ {
+ switch (theEvent.Type) {
+ case NSEventType.LeftMouseDown:
+ NotifyMouseLeftDown ();
+ break;
+
+ case NSEventType.RightMouseDown:
+ NotifyMouseRightDown ();
+ break;
+ }
+ }
+
+ public override void MouseEntered (NSEvent theEvent)
+ {
+ NotifyMouseEntered ();
+ }
+
+ public override void MouseExited (NSEvent theEvent)
+ {
+ NotifyMouseExited ();
+ }
+
+ public override void UpdateTrackingAreas ()
+ {
+ base.UpdateTrackingAreas ();
+
+ foreach (var item in TrackingAreas ()) {
+ RemoveTrackingArea (item);
+ }
+
+ var options = NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveAlways;
+
+ var trackingArea = new NSTrackingArea (this.Bounds, options, this, null);
+
+ AddTrackingArea (trackingArea);
+ }
+ #endregion
+
+
+ #region Local Methods
+ private void NotifyMouseEntered ()
+ {
+ OnMouseEntered?.Invoke (this, EventArgs.Empty);
+ }
+
+ private void NotifyMouseExited ()
+ {
+ OnMouseExited?.Invoke (this, EventArgs.Empty);
+ }
+
+ private void NotifyMouseLeftDown ()
+ {
+ OnMouseLeftDown?.Invoke (this, EventArgs.Empty);
+ }
+
+ private void NotifyMouseRightDown ()
+ {
+ OnMouseRightDown?.Invoke (this, EventArgs.Empty);
+ }
+
+ void ThemeManager_ThemeChanged (object sender, EventArgs e)
+ {
+ UpdateTheme ();
+ }
+
+ protected virtual void UpdateTheme ()
+ {
+ this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance;
+ }
+ #endregion
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
index 916957a..b0ab2b9 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
@@ -57,7 +57,7 @@ namespace Xamarin.PropertyEditing.Mac
}
public override NSView FirstKeyView => NumericEditor;
- public override NSView LastKeyView => NumericEditor;
+ public override NSView LastKeyView => NumericEditor.DecrementButton;
protected NSNumberFormatterStyle NumberStyle {
get {
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
index 04c7c48..d4cc0d6 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
@@ -54,7 +54,7 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- public void UpdateKeyViews (bool backward = true, bool forward = true)
+ public void UpdateKeyViews ()
{
if (TableRow < 0)
return;
@@ -62,15 +62,17 @@ namespace Xamarin.PropertyEditing.Mac
PropertyEditorControl ctrl = null;
//FIXME: don't hardcode column
- if (backward && TableRow > 0 && (ctrl = TableView.GetView (1, TableRow - 1, false) as PropertyEditorControl) != null) {
- ctrl.LastKeyView.NextKeyView = FirstKeyView;
- ctrl.UpdateKeyViews (forward: false);
- }
-
- //FIXME: don't hardcode column
- if (forward && TableRow < TableView.RowCount - 1 && (ctrl = TableView.GetView (1, TableRow + 1, false) as PropertyEditorControl) != null) {
- LastKeyView.NextKeyView = ctrl.FirstKeyView;
- ctrl.UpdateKeyViews (backward: false);
+ var tr = TableRow;
+ if (tr > 0) {
+ do {
+ tr--;
+ ctrl = TableView.GetView (1, tr, false) as PropertyEditorControl;
+ } while (tr > 0 && ctrl == null);
+
+ if (ctrl != null) {
+ ctrl.LastKeyView.NextKeyView = FirstKeyView;
+ ctrl.UpdateKeyViews ();
+ }
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs
new file mode 100644
index 0000000..a859652
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using AppKit;
+using Xamarin.PropertyEditing.Mac.Resources;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class RatioEditorControl<T> : PropertyEditorControl<RatioViewModel>
+ {
+ RatioEditor<T> ratioEditor;
+
+ public RatioEditorControl ()
+ {
+ base.TranslatesAutoresizingMaskIntoConstraints = false;
+
+ ratioEditor = new RatioEditor<T> {
+ AllowNegativeValues = false,
+ AllowRatios = true,
+ BackgroundColor = NSColor.Clear,
+ StringValue = string.Empty,
+ TranslatesAutoresizingMaskIntoConstraints = false,
+ };
+
+ // update the value on keypress
+ ratioEditor.ValueChanged += (sender, e) => {
+ if (e is RatioEditor<T>.RatioEventArgs ratioEventArgs) {
+ ViewModel.ValueChanged (ratioEditor.StringValue, ratioEventArgs.CaretPosition, ratioEventArgs.SelectionLength, ratioEventArgs.IncrementValue);
+ }
+ };
+ AddSubview (ratioEditor);
+
+ this.DoConstraints (new[] {
+ ratioEditor.ConstraintTo (this, (re, c) => re.Top == c.Top - 2),
+ ratioEditor.ConstraintTo (this, (re, c) => re.Left == c.Left + 4),
+ ratioEditor.ConstraintTo (this, (re, c) => re.Width == c.Width - 33),
+ ratioEditor.ConstraintTo (this, (re, c) => re.Height == DefaultControlHeight),
+ });
+
+ UpdateTheme ();
+ }
+
+ public override NSView FirstKeyView => ratioEditor.NumericEditor;
+ public override NSView LastKeyView => ratioEditor.DecrementButton;
+
+ protected override void HandleErrorsChanged (object sender, DataErrorsChangedEventArgs e)
+ {
+ UpdateErrorsDisplayed (ViewModel.GetErrors (ViewModel.Property.Name));
+ }
+
+ protected override void SetEnabled ()
+ {
+ ratioEditor.Editable = ViewModel.Property.CanWrite;
+ }
+
+ protected override void UpdateAccessibilityValues ()
+ {
+ ratioEditor.AccessibilityEnabled = ratioEditor.Enabled;
+ ratioEditor.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityNumeric, ViewModel.Property.Name);
+ }
+
+ protected override void UpdateErrorsDisplayed (IEnumerable errors)
+ {
+ if (ViewModel.HasErrors) {
+ SetErrors (errors);
+ } else {
+ SetErrors (null);
+ SetEnabled ();
+ }
+ }
+
+ protected override void UpdateValue ()
+ {
+ ratioEditor.StringValue = ViewModel.ValueString;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
index db257b7..511b8fd 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
@@ -247,6 +247,8 @@ namespace Xamarin.PropertyEditing.Mac
{typeof (PropertyViewModel<Point>), typeof (SystemPointEditorControl)},
{typeof (PropertyViewModel<Size>), typeof (SystemSizeEditorControl)},
{typeof (PropertyViewModel<Rectangle>), typeof (SystemRectangleEditorControl)},
- {typeof (BrushPropertyViewModel), typeof (BrushEditorControl) }};
+ {typeof (BrushPropertyViewModel), typeof (BrushEditorControl)},
+ {typeof (RatioViewModel), typeof (RatioEditorControl<CommonRatio>)},
+ };
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Resources/stepper-down.png b/Xamarin.PropertyEditing.Mac/Resources/stepper-down.png
new file mode 100644
index 0000000..45c0fc6
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Resources/stepper-down.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/Resources/stepper-down@2x.png b/Xamarin.PropertyEditing.Mac/Resources/stepper-down@2x.png
new file mode 100644
index 0000000..c76f383
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Resources/stepper-down@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/Resources/stepper-up.png b/Xamarin.PropertyEditing.Mac/Resources/stepper-up.png
new file mode 100644
index 0000000..496d2f8
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Resources/stepper-up.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/Resources/stepper-up@2x.png b/Xamarin.PropertyEditing.Mac/Resources/stepper-up@2x.png
new file mode 100644
index 0000000..32792d0
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Resources/stepper-up@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
index c2f7a98..ba046cb 100644
--- a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
+++ b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
@@ -1,253 +1,268 @@
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{E8F4F0EB-C2B1-4116-8459-E076E0E0E485}</ProjectGuid>
- <ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <OutputType>Library</OutputType>
- <RootNamespace>Xamarin.PropertyEditing.Mac</RootNamespace>
- <AssemblyName>Xamarin.PropertyEditing.Mac</AssemblyName>
- <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
- <MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
- <TargetFrameworkProfile />
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <EnableCodeSigning>false</EnableCodeSigning>
- <CreatePackage>false</CreatePackage>
- <EnablePackageSigning>false</EnablePackageSigning>
- <IncludeMonoRuntime>false</IncludeMonoRuntime>
- <UseSGen>false</UseSGen>
- <HttpClientHandler></HttpClientHandler>
- <LinkMode></LinkMode>
- <XamMacArch></XamMacArch>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <Optimize>true</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <DefineConstants></DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <EnableCodeSigning>false</EnableCodeSigning>
- <CreatePackage>false</CreatePackage>
- <EnablePackageSigning>false</EnablePackageSigning>
- <IncludeMonoRuntime>false</IncludeMonoRuntime>
- <UseSGen>false</UseSGen>
- <HttpClientHandler></HttpClientHandler>
- <LinkMode></LinkMode>
- <XamMacArch></XamMacArch>
- </PropertyGroup>
- <!-- Build with strong naming if built as part of some Xamarin VSIX, normally referencing this project as a git submodule under external\Xamarin.PropertyEditing -->
- <PropertyGroup Condition="Exists('../../../xamarin.snk')">
- <AssemblyOriginatorKeyFile>../../../xamarin.snk</AssemblyOriginatorKeyFile>
- <SignAssembly>true</SignAssembly>
- <DefineConstants>$(DefineConstants);STRONG_NAMED</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="Xamarin.Mac" />
- <Reference Include="System.Drawing" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="PropertyEditorPanel.cs" />
- <Compile Include="PropertyEditorPanel.designer.cs">
- <DependentUpon>PropertyEditorPanel.cs</DependentUpon>
- </Compile>
- <Compile Include="Controls\StringEditorControl.cs" />
- <Compile Include="Controls\PropertyEditorControl.cs" />
- <Compile Include="PropertyTableDelegate.cs" />
- <Compile Include="PropertyTableDataSource.cs" />
- <Compile Include="Controls\NumericEditorControl.cs" />
- <Compile Include="Controls\BooleanEditorControl.cs" />
- <Compile Include="Controls\ConstraintExtensions.cs" />
- <Compile Include="Controls\BaseRectangleEditorControl.cs" />
- <Compile Include="Controls\CGRectEditorControl.cs" />
- <Compile Include="Controls\CGPointEditorControl.cs" />
- <Compile Include="NSObjectFacade.cs" />
- <Compile Include="Controls\PredefinedValuesEditor.cs" />
- <Compile Include="Controls\BasePointEditorControl.cs" />
- <Compile Include="Controls\CGSizeEditorControl.cs" />
- <Compile Include="Controls\PointEditorControl.cs" />
- <Compile Include="Controls\RectangleEditorControl.cs" />
- <Compile Include="Controls\SizeEditorControl.cs" />
- <Compile Include="Controls\Custom\NumericSpinEditor.cs" />
- <Compile Include="Controls\Custom\NumericTextField.cs" />
- <Compile Include="Resources\LocalizationResources.Designer.cs">
- <DependentUpon>LocalizationResources.resx</DependentUpon>
- </Compile>
- <Compile Include="Controls\Custom\UnfocusableTextField.cs" />
- <Compile Include="Controls\CombinablePropertyEditor.cs" />
- <Compile Include="Controls\Custom\PropertyButton.cs" />
- <Compile Include="Controls\Custom\CommandMenuItem.cs" />
- <Compile Include="Controls\Custom\BasePopOverControl.cs" />
- <Compile Include="Controls\Custom\BasePopOverViewModelControl.cs" />
- <Compile Include="Controls\CustomExpressionView.cs" />
- <Compile Include="Controls\Custom\AutoClosePopOver.cs" />
- <Compile Include="Controls\BrushEditorControl.cs" />
- <Compile Include="Controls\Custom\SolidColorBrushEditor.cs" />
- <Compile Include="Controls\Custom\BrushTabViewController.cs" />
- <Compile Include="Controls\Custom\NotifyingTabViewController.cs" />
- <Compile Include="Controls\Custom\NotifyingViewController.cs" />
- <Compile Include="Controls\Custom\SolidColorBrushEditorViewController.cs" />
- <Compile Include="Controls\Custom\DrawingExtensions.cs" />
- <Compile Include="Controls\Custom\ResourceBrushViewController.cs" />
- <Compile Include="Controls\Custom\CommonBrushView.cs" />
- <Compile Include="Controls\Custom\ColorComponentEditor.cs" />
- <Compile Include="Controls\Custom\ColorComponentTabViewController.cs" />
- <Compile Include="Controls\Custom\ColorComponentViewController.cs" />
- <Compile Include="Controls\Custom\NotifyingViewAdaptor.cs" />
- <Compile Include="Controls\Custom\MaterialBrushEditorViewController.cs" />
- <Compile Include="Controls\Custom\MaterialView.cs" />
- <Compile Include="Controls\Custom\MaterialColorLayer.cs" />
- <Compile Include="Controls\Custom\EmptyBrushEditorViewController.cs" />
- <Compile Include="Controls\Custom\ChannelEditorType.cs" />
- <Compile Include="Controls\Custom\ChannelEditor.cs" />
- <Compile Include="Controls\Custom\CommonBrushLayer.cs" />
- <Compile Include="Controls\Custom\CommonGradientBrushLayer.cs" />
- <Compile Include="Controls\Custom\HueLayer.cs" />
- <Compile Include="Controls\Custom\ShadeLayer.cs" />
- <Compile Include="Controls\Custom\HistoryLayer.cs" />
- <Compile Include="Controls\Custom\ColorEditorView.cs" />
- <Compile Include="Controls\Custom\ColorEditorLayer.cs" />
- <Compile Include="Controls\Custom\ComponentSpinEditor.cs" />
- <Compile Include="Controls\Custom\UnderlinedTabViewController.cs" />
- <Compile Include="Controls\Custom\UnderlinedTextField.cs" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Themes\MacThemeManager.cs" />
- <Compile Include="Controls\BaseEditorControl.cs" />
- <Compile Include="Controls\ErrorMessageView.cs" />
- </ItemGroup>
- <ItemGroup />
- <ItemGroup>
- <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
- <Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
- <Name>Xamarin.PropertyEditing</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="Resources\LocalizationResources.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>LocalizationResources.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <BundleResource Include="Resources\action-browse-16.png" />
- <BundleResource Include="Resources\action-browse-16%402x.png" />
- <BundleResource Include="Resources\action-browse-16~dark.png" />
- <BundleResource Include="Resources\action-browse-16~dark%402x.png" />
- <BundleResource Include="Resources\action-edit-16.png" />
- <BundleResource Include="Resources\action-edit-16%402x.png" />
- <BundleResource Include="Resources\action-edit-16~dark.png" />
- <BundleResource Include="Resources\action-edit-16~dark%402x.png" />
- <BundleResource Include="Resources\action-palette-16.png" />
- <BundleResource Include="Resources\action-palette-16%402x.png" />
- <BundleResource Include="Resources\action-palette-16~dark.png" />
- <BundleResource Include="Resources\action-palette-16~dark%402x.png" />
- <BundleResource Include="Resources\action-reveal-16.png" />
- <BundleResource Include="Resources\action-reveal-16%402x.png" />
- <BundleResource Include="Resources\action-reveal-16~dark.png" />
- <BundleResource Include="Resources\action-reveal-16~dark%402x.png" />
- <BundleResource Include="Resources\action-typography-16.png" />
- <BundleResource Include="Resources\action-typography-16%402x 13-35-55-102.png" />
- <BundleResource Include="Resources\action-typography-16~dark.png" />
- <BundleResource Include="Resources\action-typography-16~dark%402x 13-35-55-083.png" />
- <BundleResource Include="Resources\action-warning-16.png" />
- <BundleResource Include="Resources\action-warning-16%402x.png" />
- <BundleResource Include="Resources\action-warning-16~dark.png" />
- <BundleResource Include="Resources\action-warning-16~dark%402x.png" />
- <BundleResource Include="Resources\property-button-bound-mac-10.png" />
- <BundleResource Include="Resources\property-button-bound-mac-10%402x.png" />
- <BundleResource Include="Resources\property-button-bound-mac-10~dark.png" />
- <BundleResource Include="Resources\property-button-bound-mac-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-default-mac-10.png" />
- <BundleResource Include="Resources\property-button-default-mac-10%402x.png" />
- <BundleResource Include="Resources\property-button-default-mac-10~dark.png" />
- <BundleResource Include="Resources\property-button-default-mac-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-10.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-10%402x.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-10~dark.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-local-mac-10.png" />
- <BundleResource Include="Resources\property-button-local-mac-10%402x.png" />
- <BundleResource Include="Resources\property-button-local-mac-10~dark.png" />
- <BundleResource Include="Resources\property-button-local-mac-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-bound-mac-active-10.png" />
- <BundleResource Include="Resources\property-button-bound-mac-active-10%402x.png" />
- <BundleResource Include="Resources\property-button-bound-mac-active-10~dark.png" />
- <BundleResource Include="Resources\property-button-bound-mac-active-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-default-mac-active-10.png" />
- <BundleResource Include="Resources\property-button-default-mac-active-10%402x.png" />
- <BundleResource Include="Resources\property-button-default-mac-active-10~dark.png" />
- <BundleResource Include="Resources\property-button-default-mac-active-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-active-10.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-active-10%402x.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-active-10~dark.png" />
- <BundleResource Include="Resources\property-button-inherited-mac-active-10~dark%402x.png" />
- <BundleResource Include="Resources\property-button-local-mac-active-10.png" />
- <BundleResource Include="Resources\property-button-local-mac-active-10%402x.png" />
- <BundleResource Include="Resources\property-button-local-mac-active-10~dark.png" />
- <BundleResource Include="Resources\property-button-local-mac-active-10~dark%402x.png" />
- <BundleResource Include="Resources\custom-expression-32.png" />
- <BundleResource Include="Resources\custom-expression-32%402x.png" />
- <BundleResource Include="Resources\custom-expression-32~dark.png" />
- <BundleResource Include="Resources\custom-expression-32~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-gradient-16.png" />
- <BundleResource Include="Resources\property-brush-gradient-16%402x.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~dark.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~dark~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~sel.png" />
- <BundleResource Include="Resources\property-brush-gradient-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-image-16.png" />
- <BundleResource Include="Resources\property-brush-image-16%402x.png" />
- <BundleResource Include="Resources\property-brush-image-16~dark.png" />
- <BundleResource Include="Resources\property-brush-image-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-image-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-image-16~dark~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-image-16~sel.png" />
- <BundleResource Include="Resources\property-brush-image-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-none-16.png" />
- <BundleResource Include="Resources\property-brush-none-16%402x.png" />
- <BundleResource Include="Resources\property-brush-none-16~dark.png" />
- <BundleResource Include="Resources\property-brush-none-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-none-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-none-16~dark~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-none-16~sel.png" />
- <BundleResource Include="Resources\property-brush-none-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-resources-16.png" />
- <BundleResource Include="Resources\property-brush-resources-16%402x.png" />
- <BundleResource Include="Resources\property-brush-resources-16~dark.png" />
- <BundleResource Include="Resources\property-brush-resources-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-resources-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-resources-16~dark~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-resources-16~sel.png" />
- <BundleResource Include="Resources\property-brush-resources-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-solid-16.png" />
- <BundleResource Include="Resources\property-brush-solid-16%402x.png" />
- <BundleResource Include="Resources\property-brush-solid-16~dark.png" />
- <BundleResource Include="Resources\property-brush-solid-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-solid-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-solid-16~dark~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-solid-16~sel.png" />
- <BundleResource Include="Resources\property-brush-solid-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-palette-16.png" />
- <BundleResource Include="Resources\property-brush-palette-16%402x.png" />
- <BundleResource Include="Resources\property-brush-palette-16~dark.png" />
- <BundleResource Include="Resources\property-brush-palette-16~dark%402x.png" />
- <BundleResource Include="Resources\property-brush-palette-16~sel.png" />
- <BundleResource Include="Resources\property-brush-palette-16~sel%402x.png" />
- <BundleResource Include="Resources\property-brush-palette-16~dark~sel.png" />
- <BundleResource Include="Resources\property-brush-palette-16~dark~sel%402x.png" />
- </ItemGroup>
- <Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{E8F4F0EB-C2B1-4116-8459-E076E0E0E485}</ProjectGuid>
+ <ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Xamarin.PropertyEditing.Mac</RootNamespace>
+ <AssemblyName>Xamarin.PropertyEditing.Mac</AssemblyName>
+ <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+ <MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <EnableCodeSigning>false</EnableCodeSigning>
+ <CreatePackage>false</CreatePackage>
+ <EnablePackageSigning>false</EnablePackageSigning>
+ <IncludeMonoRuntime>false</IncludeMonoRuntime>
+ <UseSGen>false</UseSGen>
+ <HttpClientHandler></HttpClientHandler>
+ <LinkMode></LinkMode>
+ <XamMacArch></XamMacArch>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <DefineConstants></DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <EnableCodeSigning>false</EnableCodeSigning>
+ <CreatePackage>false</CreatePackage>
+ <EnablePackageSigning>false</EnablePackageSigning>
+ <IncludeMonoRuntime>false</IncludeMonoRuntime>
+ <UseSGen>false</UseSGen>
+ <HttpClientHandler></HttpClientHandler>
+ <LinkMode></LinkMode>
+ <XamMacArch></XamMacArch>
+ </PropertyGroup>
+ <!-- Build with strong naming if built as part of some Xamarin VSIX, normally referencing this project as a git submodule under external\Xamarin.PropertyEditing -->
+ <PropertyGroup Condition="Exists('../../../xamarin.snk')">
+ <AssemblyOriginatorKeyFile>../../../xamarin.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly>true</SignAssembly>
+ <DefineConstants>$(DefineConstants);STRONG_NAMED</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="Xamarin.Mac" />
+ <Reference Include="System.Drawing" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="PropertyEditorPanel.cs" />
+ <Compile Include="PropertyEditorPanel.designer.cs">
+ <DependentUpon>PropertyEditorPanel.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Controls\StringEditorControl.cs" />
+ <Compile Include="Controls\PropertyEditorControl.cs" />
+ <Compile Include="PropertyTableDelegate.cs" />
+ <Compile Include="PropertyTableDataSource.cs" />
+ <Compile Include="Controls\NumericEditorControl.cs" />
+ <Compile Include="Controls\BooleanEditorControl.cs" />
+ <Compile Include="Controls\ConstraintExtensions.cs" />
+ <Compile Include="Controls\BaseRectangleEditorControl.cs" />
+ <Compile Include="Controls\CGRectEditorControl.cs" />
+ <Compile Include="Controls\CGPointEditorControl.cs" />
+ <Compile Include="NSObjectFacade.cs" />
+ <Compile Include="Controls\PredefinedValuesEditor.cs" />
+ <Compile Include="Controls\BasePointEditorControl.cs" />
+ <Compile Include="Controls\CGSizeEditorControl.cs" />
+ <Compile Include="Controls\PointEditorControl.cs" />
+ <Compile Include="Controls\RectangleEditorControl.cs" />
+ <Compile Include="Controls\SizeEditorControl.cs" />
+ <Compile Include="Controls\Custom\NumericSpinEditor.cs" />
+ <Compile Include="Controls\Custom\NumericTextField.cs" />
+ <Compile Include="Resources\LocalizationResources.Designer.cs">
+ <DependentUpon>LocalizationResources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Controls\Custom\UnfocusableTextField.cs" />
+ <Compile Include="Controls\CombinablePropertyEditor.cs" />
+ <Compile Include="Controls\Custom\PropertyButton.cs" />
+ <Compile Include="Controls\Custom\CommandMenuItem.cs" />
+ <Compile Include="Controls\Custom\BasePopOverControl.cs" />
+ <Compile Include="Controls\Custom\BasePopOverViewModelControl.cs" />
+ <Compile Include="Controls\CustomExpressionView.cs" />
+ <Compile Include="Controls\Custom\AutoClosePopOver.cs" />
+ <Compile Include="Controls\RatioEditorControl.cs" />
+ <Compile Include="Controls\Custom\RatioEditor.cs" />
+ <Compile Include="Controls\BrushEditorControl.cs" />
+ <Compile Include="Controls\Custom\BrushTabViewController.cs" />
+ <Compile Include="Controls\Custom\CommonBrushLayer.cs" />
+ <Compile Include="Controls\Custom\UnderlinedTabViewController.cs" />
+ <Compile Include="Controls\Custom\NotifyingTabViewController.cs" />
+ <Compile Include="Controls\Custom\NotifyingViewAdaptor.cs" />
+ <Compile Include="Controls\Custom\CommonGradientBrushLayer.cs" />
+ <Compile Include="Controls\Custom\DrawingExtensions.cs" />
+ <Compile Include="Controls\Custom\SolidColorBrushEditorViewController.cs" />
+ <Compile Include="Controls\Custom\EmptyBrushEditorViewController.cs" />
+ <Compile Include="Controls\Custom\MaterialBrushEditorViewController.cs" />
+ <Compile Include="Controls\Custom\ResourceBrushViewController.cs" />
+ <Compile Include="Controls\Custom\NotifyingViewController.cs" />
+ <Compile Include="Controls\Custom\ChannelEditor.cs" />
+ <Compile Include="Controls\Custom\ComponentSpinEditor.cs" />
+ <Compile Include="Controls\Custom\MaterialView.cs" />
+ <Compile Include="Controls\Custom\MaterialColorLayer.cs" />
+ <Compile Include="Controls\Custom\ColorEditorView.cs" />
+ <Compile Include="Controls\Custom\SolidColorBrushEditor.cs" />
+ <Compile Include="Controls\Custom\ColorEditorLayer.cs" />
+ <Compile Include="Controls\Custom\ColorComponentTabViewController.cs" />
+ <Compile Include="Controls\Custom\HistoryLayer.cs" />
+ <Compile Include="Controls\Custom\HueLayer.cs" />
+ <Compile Include="Controls\Custom\ShadeLayer.cs" />
+ <Compile Include="Controls\Custom\ChannelEditorType.cs" />
+ <Compile Include="Controls\Custom\ColorComponentViewController.cs" />
+ <Compile Include="Controls\Custom\ColorComponentEditor.cs" />
+ <Compile Include="Controls\Custom\UnderlinedTextField.cs" />
+ <Compile Include="Controls\Custom\CommonBrushView.cs" />
+ <Compile Include="Controls\Custom\UnfocusableButton.cs" />
+ <Compile Include="Controls\Custom\SpinnerButton.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Controls\" />
+ <Folder Include="Controls\Custom\" />
+ <Folder Include="Resources\" />
+ <Compile Include="Themes\MacThemeManager.cs" />
+ <Compile Include="Controls\BaseEditorControl.cs" />
+ <Compile Include="Controls\ErrorMessageView.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Controls\" />
+ <Folder Include="Themes\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
+ <Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
+ <Name>Xamarin.PropertyEditing</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources\LocalizationResources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>LocalizationResources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <BundleResource Include="Resources\action-browse-16.png" />
+ <BundleResource Include="Resources\action-browse-16%402x.png" />
+ <BundleResource Include="Resources\action-browse-16~dark.png" />
+ <BundleResource Include="Resources\action-browse-16~dark%402x.png" />
+ <BundleResource Include="Resources\action-edit-16.png" />
+ <BundleResource Include="Resources\action-edit-16%402x.png" />
+ <BundleResource Include="Resources\action-edit-16~dark.png" />
+ <BundleResource Include="Resources\action-edit-16~dark%402x.png" />
+ <BundleResource Include="Resources\action-palette-16.png" />
+ <BundleResource Include="Resources\action-palette-16%402x.png" />
+ <BundleResource Include="Resources\action-palette-16~dark.png" />
+ <BundleResource Include="Resources\action-palette-16~dark%402x.png" />
+ <BundleResource Include="Resources\action-reveal-16.png" />
+ <BundleResource Include="Resources\action-reveal-16%402x.png" />
+ <BundleResource Include="Resources\action-reveal-16~dark.png" />
+ <BundleResource Include="Resources\action-reveal-16~dark%402x.png" />
+ <BundleResource Include="Resources\action-typography-16.png" />
+ <BundleResource Include="Resources\action-typography-16%402x 13-35-55-102.png" />
+ <BundleResource Include="Resources\action-typography-16~dark.png" />
+ <BundleResource Include="Resources\action-typography-16~dark%402x 13-35-55-083.png" />
+ <BundleResource Include="Resources\action-warning-16.png" />
+ <BundleResource Include="Resources\action-warning-16%402x.png" />
+ <BundleResource Include="Resources\action-warning-16~dark.png" />
+ <BundleResource Include="Resources\action-warning-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-10.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-10%402x.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-10~dark.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-default-mac-10.png" />
+ <BundleResource Include="Resources\property-button-default-mac-10%402x.png" />
+ <BundleResource Include="Resources\property-button-default-mac-10~dark.png" />
+ <BundleResource Include="Resources\property-button-default-mac-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-10.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-10%402x.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-10~dark.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-local-mac-10.png" />
+ <BundleResource Include="Resources\property-button-local-mac-10%402x.png" />
+ <BundleResource Include="Resources\property-button-local-mac-10~dark.png" />
+ <BundleResource Include="Resources\property-button-local-mac-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-active-10.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-active-10%402x.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-active-10~dark.png" />
+ <BundleResource Include="Resources\property-button-bound-mac-active-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-default-mac-active-10.png" />
+ <BundleResource Include="Resources\property-button-default-mac-active-10%402x.png" />
+ <BundleResource Include="Resources\property-button-default-mac-active-10~dark.png" />
+ <BundleResource Include="Resources\property-button-default-mac-active-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-active-10.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-active-10%402x.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-active-10~dark.png" />
+ <BundleResource Include="Resources\property-button-inherited-mac-active-10~dark%402x.png" />
+ <BundleResource Include="Resources\property-button-local-mac-active-10.png" />
+ <BundleResource Include="Resources\property-button-local-mac-active-10%402x.png" />
+ <BundleResource Include="Resources\property-button-local-mac-active-10~dark.png" />
+ <BundleResource Include="Resources\property-button-local-mac-active-10~dark%402x.png" />
+ <BundleResource Include="Resources\custom-expression-32.png" />
+ <BundleResource Include="Resources\custom-expression-32%402x.png" />
+ <BundleResource Include="Resources\custom-expression-32~dark.png" />
+ <BundleResource Include="Resources\custom-expression-32~dark%402x.png" />
+ <BundleResource Include="Resources\stepper-down.png" />
+ <BundleResource Include="Resources\stepper-down%402x.png" />
+ <BundleResource Include="Resources\stepper-up.png" />
+ <BundleResource Include="Resources\stepper-up%402x.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-gradient-16~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-image-16.png" />
+ <BundleResource Include="Resources\property-brush-image-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-image-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-image-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-image-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-image-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-image-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-image-16~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-none-16.png" />
+ <BundleResource Include="Resources\property-brush-none-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-none-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-none-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-none-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-none-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-none-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-none-16~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-palette-16.png" />
+ <BundleResource Include="Resources\property-brush-palette-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-palette-16~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-resources-16.png" />
+ <BundleResource Include="Resources\property-brush-resources-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-resources-16~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-solid-16.png" />
+ <BundleResource Include="Resources\property-brush-solid-16%402x.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~dark.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~dark%402x.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~dark~sel.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~dark~sel%402x.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~sel.png" />
+ <BundleResource Include="Resources\property-brush-solid-16~sel%402x.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
+</Project>
diff --git a/Xamarin.PropertyEditing.Tests/ConstrainedPropertyViewModelTests.cs b/Xamarin.PropertyEditing.Tests/ConstrainedPropertyViewModelTests.cs
index c14e390..654683a 100644
--- a/Xamarin.PropertyEditing.Tests/ConstrainedPropertyViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/ConstrainedPropertyViewModelTests.cs
@@ -108,10 +108,5 @@ namespace Xamarin.PropertyEditing.Tests
protected abstract T GetConstrainedRandomValueAboveBounds (Random rand, out T max, out T min);
protected abstract T GetConstrainedRandomValueBelowBounds (Random rand, out T max, out T min);
-
- protected TViewModel GetViewModel (IPropertyInfo property, IObjectEditor editor)
- {
- return GetViewModel (property, new[] { editor });
- }
}
}
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
index 32d8d6f..faafc83 100644
--- a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
+++ b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
@@ -22,6 +22,7 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
AddProperty<CommonPoint> ("Point", ReadWrite);
AddProperty<CommonSize> ("Size", ReadWrite);
AddProperty<CommonRectangle> ("Rectangle", ReadWrite);
+ AddProperty<CommonRatio> ("Ratio", ReadWrite);
// AddProperty<CommonThickness> ("Thickness", ReadWrite); // Lacking support on the mac at this point in time.
AddProperty<object> ("Object", ReadWrite);
AddProperty<IList> ("Collection", ReadWrite);
@@ -36,6 +37,7 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
AddReadOnlyProperty<CommonPoint> ("ReadOnlyPoint", ReadOnly);
AddReadOnlyProperty<CommonSize> ("ReadOnlySize", ReadOnly);
AddReadOnlyProperty<CommonRectangle> ("ReadOnlyRectangle", ReadOnly);
+ AddReadOnlyProperty<CommonRatio> ("ReadOnlyRatio", ReadOnly);
// AddReadOnlyProperty<CommonThickness> ("ReadOnlyThickness", ReadOnly);
AddProperty<NotImplemented> ("Uncategorized", None);
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockWpfControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockWpfControl.cs
index e9f9680..c9eb3fb 100644
--- a/Xamarin.PropertyEditing.Tests/MockControls/MockWpfControl.cs
+++ b/Xamarin.PropertyEditing.Tests/MockControls/MockWpfControl.cs
@@ -105,6 +105,7 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
AddProperty<VerticalAlignment> ("VerticalContentAlignment", Layout);
AddProperty<Visibility> ("Visibility");
AddProperty<double> ("Width");
+ AddProperty<CommonRatio> ("Ratio");
#endregion
#region Events
AddEvents (
diff --git a/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs b/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
index 6bb2968..c0ab5b7 100644
--- a/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
+++ b/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
@@ -56,7 +56,7 @@ namespace Xamarin.PropertyEditing.Tests
var grouping = lookup[key];
((INotifyCollectionChanged) grouping).CollectionChanged += (sender, args) => {
if (args.Action == NotifyCollectionChangedAction.Remove) {
- if (args.OldItems[0] == value)
+ if ((string)args.OldItems[0] == value)
itemRemoved = true;
}
};
diff --git a/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs b/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
index a00ccd8..7b51e8f 100644
--- a/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
@@ -18,8 +18,9 @@ namespace Xamarin.PropertyEditing.Tests
: PropertiesViewModelTests<PanelViewModel>
{
[SetUp]
- public void Setup ()
+ public override void Setup ()
{
+ base.Setup ();
SynchronizationContext.SetSynchronizationContext (this.context = new TestContext ());
}
diff --git a/Xamarin.PropertyEditing.Tests/PropertiesViewModelTests.cs b/Xamarin.PropertyEditing.Tests/PropertiesViewModelTests.cs
index 8bd7ae2..a7e98a9 100644
--- a/Xamarin.PropertyEditing.Tests/PropertiesViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/PropertiesViewModelTests.cs
@@ -37,7 +37,7 @@ namespace Xamarin.PropertyEditing.Tests
private Exception unhandled;
[SetUp]
- public void Setup ()
+ public virtual void Setup ()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
}
diff --git a/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs b/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs
index 8232d80..f206158 100644
--- a/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs
@@ -429,7 +429,7 @@ namespace Xamarin.PropertyEditing.Tests
resourcesMock.Setup (rp => rp.GetResourcesAsync (editor.Target, mockProperty.Object, It.IsAny<CancellationToken> ())).ReturnsAsync (new[] { resource });
editor.ValueEvaluator = (info, val, source) => {
- if (source == resource)
+ if ((Resource)source == resource)
return value;
return default(TValue);
diff --git a/Xamarin.PropertyEditing.Tests/RatioViewModelTests.cs b/Xamarin.PropertyEditing.Tests/RatioViewModelTests.cs
new file mode 100644
index 0000000..9aeedd0
--- /dev/null
+++ b/Xamarin.PropertyEditing.Tests/RatioViewModelTests.cs
@@ -0,0 +1,194 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Xamarin.PropertyEditing.Drawing;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Tests
+{
+ internal class RatioViewModelTests
+ : PropertyViewModelTests<CommonRatio, RatioViewModel>
+ {
+ [Test]
+ public void Numerator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+ Assume.That (vm.Value, Is.EqualTo (new CommonRatio ()));
+
+ bool xChanged = false, valueChanged = false;
+ vm.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == nameof(RatioViewModel.Numerator))
+ xChanged = true;
+ if (args.PropertyName == nameof(RatioViewModel.Value))
+ valueChanged = true;
+ };
+
+ vm.Numerator = 5;
+ Assert.That (vm.Value.Numerator, Is.EqualTo (5));
+ Assert.That (xChanged, Is.True);
+ Assert.That (valueChanged, Is.True);
+ }
+
+ [Test]
+ public void Denominator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+ Assume.That (vm.Value, Is.EqualTo (new CommonRatio ()));
+
+ bool xChanged = false, valueChanged = false;
+ vm.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == nameof (RatioViewModel.Denominator))
+ xChanged = true;
+ if (args.PropertyName == nameof (RatioViewModel.Value))
+ valueChanged = true;
+ };
+
+ vm.Denominator = 5;
+ Assert.That (vm.Value.Denominator, Is.EqualTo (5));
+ Assert.That (xChanged, Is.True);
+ Assert.That (valueChanged, Is.True);
+ }
+
+ [Test]
+ public void RatioSeparator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+ Assume.That (vm.Value, Is.EqualTo (new CommonRatio ()));
+
+ bool xChanged = false, valueChanged = false;
+ vm.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == nameof (RatioViewModel.RatioSeparator))
+ xChanged = true;
+ if (args.PropertyName == nameof (RatioViewModel.Value))
+ valueChanged = true;
+ };
+
+ vm.RatioSeparator = '/';
+ Assert.That (vm.Value.RatioSeparator, Is.EqualTo ('/'));
+ Assert.That (xChanged, Is.True);
+ Assert.That (valueChanged, Is.True);
+ }
+
+ [Test]
+ public void ValueChangesNumeratorDenominatorRatioSeparator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+ Assume.That (vm.Numerator, Is.EqualTo (0));
+ Assume.That (vm.Denominator, Is.EqualTo (0));
+
+ bool nChanged = false, dChanged = false, sChanged = false, valueChanged = false;
+ vm.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == nameof(RatioViewModel.Numerator))
+ nChanged = true;
+ if (args.PropertyName == nameof(RatioViewModel.Denominator))
+ dChanged = true;
+ if (args.PropertyName == nameof (RatioViewModel.RatioSeparator))
+ sChanged = true;
+ if (args.PropertyName == nameof(SizePropertyViewModel.Value))
+ valueChanged = true;
+ };
+
+ vm.Value = new CommonRatio (5, 10, ':');
+
+ Assert.That (vm.Numerator, Is.EqualTo (5));
+ Assert.That (vm.Denominator, Is.EqualTo (10));
+ Assert.That (nChanged, Is.True);
+ Assert.That (dChanged, Is.True);
+ Assert.That (sChanged, Is.True);
+ Assert.That (valueChanged, Is.True);
+ }
+
+ [Test]
+ public void RatioWithoutDenominator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+
+ vm.ValueString = "21";
+
+ Assert.That (vm.Numerator, Is.EqualTo (21));
+ Assert.That (vm.Denominator, Is.EqualTo (1));
+ Assert.That (vm.RatioSeparator, Is.EqualTo (':'));
+ }
+
+ [Test]
+ public void RatioWithNumeratorDenominatorAndColonSeparator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+
+ vm.ValueString = "21:2";
+
+ Assert.That (vm.Numerator, Is.EqualTo (21));
+ Assert.That (vm.Denominator, Is.EqualTo (2));
+ Assert.That (vm.RatioSeparator, Is.EqualTo (':'));
+ }
+
+ [Test]
+ public void RatioWithNumeratorDenominatorAndSlashSeparator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+
+ vm.ValueString = "21/2";
+
+ Assert.That (vm.Numerator, Is.EqualTo (21));
+ Assert.That (vm.Denominator, Is.EqualTo (2));
+ Assert.That (vm.RatioSeparator, Is.EqualTo ('/'));
+ }
+
+ [Test]
+ public void RatioWithWrongSeparator ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+ bool eChanged = false;
+ vm.ErrorsChanged += (sender, args) => {
+ eChanged = true;
+ };
+
+ vm.ValueString = "21@2";
+
+ // Was Error raised?
+ Assert.That (eChanged, Is.True);
+ }
+
+ [Test]
+ public void RatioWithSpaces ()
+ {
+ var property = GetPropertyMock ();
+ var editor = GetBasicEditor (property.Object);
+ var vm = GetViewModel (property.Object, new[] { editor });
+
+ vm.ValueString = " 21: 2 ";
+
+ Assert.That (vm.ValueString, Is.EqualTo ("21:2"));
+ }
+
+ protected override CommonRatio GetRandomTestValue (Random rand)
+ {
+ var randomDenominator = rand.Next ();
+ // Can't be less than 1
+ if (randomDenominator < 1)
+ randomDenominator = 1;
+ return new CommonRatio (rand.Next (), randomDenominator, '/');
+ }
+
+ protected override RatioViewModel GetViewModel (TargetPlatform platform, IPropertyInfo property, IEnumerable<IObjectEditor> editors)
+ {
+ return new RatioViewModel (platform, property, editors);
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj b/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj
index ba02175..c5419cd 100644
--- a/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj
+++ b/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj
@@ -119,6 +119,7 @@
<Compile Include="ValueInfoTests.cs" />
<Compile Include="MockControls\MockNSControl.cs" />
<Compile Include="MockControls\MockNSButton.cs" />
+ <Compile Include="RatioViewModelTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Manual\BrushEditor.md" />
diff --git a/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs b/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
index 9cddbe8..45994e4 100644
--- a/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
+++ b/Xamarin.PropertyEditing.Windows/EditorPropertySelector.cs
@@ -109,7 +109,7 @@ namespace Xamarin.PropertyEditing.Windows
{ typeof(PropertyGroupViewModel), typeof(GroupEditorControl) },
{ typeof(ObjectPropertyViewModel), typeof(ObjectEditorControl) },
{ typeof(CollectionPropertyViewModel), typeof(CollectionEditor) },
-
+ { typeof(RatioViewModel), typeof(RatioEditorControl) },
};
}
}
diff --git a/Xamarin.PropertyEditing.Windows/RatioEditorControl.cs b/Xamarin.PropertyEditing.Windows/RatioEditorControl.cs
new file mode 100644
index 0000000..89cb8d1
--- /dev/null
+++ b/Xamarin.PropertyEditing.Windows/RatioEditorControl.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Windows
+{
+ class RatioEditorControl : PropertyEditorControl
+ {
+ private RatioViewModel ViewModel => DataContext as RatioViewModel;
+ TextBoxEx ratioTextBox;
+
+ protected override void OnPreviewKeyDown (KeyEventArgs e)
+ {
+ ratioTextBox = e.Source as TextBoxEx;
+ var incValue = e.KeyboardDevice.IsKeyDown (Key.LeftShift) || e.KeyboardDevice.IsKeyDown (Key.RightShift) ? 10 : 1;
+ switch (e.Key) {
+ case Key.Up:
+ // Increment Value
+ ValueChanged (ratioTextBox.Text, ratioTextBox.CaretIndex, ratioTextBox.SelectionLength, incValue);
+ e.Handled = true;
+ break;
+ case Key.Down:
+ // Decrement Value
+ ValueChanged (ratioTextBox.Text, ratioTextBox.CaretIndex, ratioTextBox.SelectionLength, -incValue);
+ e.Handled = true;
+ break;
+ }
+
+ base.OnPreviewKeyDown (e);
+ }
+
+ void ValueChanged (string inputedText, int caretPosition, int selectionLength, double incrementValue)
+ {
+ ViewModel.ValueChanged (inputedText, caretPosition, selectionLength, incrementValue);
+ ratioTextBox.CaretIndex = caretPosition;
+ ratioTextBox.SelectionLength = selectionLength;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
index c068a9d..0772b60 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
@@ -317,21 +317,31 @@
</Style>
<Style TargetType="local:SizeEditorControl">
- <Setter Property="Template">
+ <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SizeEditorControl">
<Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Label Grid.Column="0" Name="WidthLabel" Target="{Binding ElementName=WidthTextBox,Mode=OneTime}" Content="Width" />
- <local:DoubleUpDownControl x:Name="WidthTextBox" Grid.Column="1" Value="{Binding Width}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" AutomationProperties.LabeledBy="{Binding ElementName=WidthLabel,Mode=OneTime}"/>
- <Label Name="HeightLabel" Grid.Column="2" Target="{Binding ElementName=HeightTextBox,Mode=OneTime}" Content="Height" />
- <local:DoubleUpDownControl x:Name="HeightTextBox" Grid.Column="3" Value="{Binding Height}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" AutomationProperties.LabeledBy="{Binding ElementName=HeightLabel,Mode=OneTime}"/>
- </Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+ <Label Grid.Column="0" Name="WidthLabel" Target="{Binding ElementName=WidthTextBox,Mode=OneTime}" Content="Width" />
+ <local:DoubleUpDownControl x:Name="WidthTextBox" Grid.Column="1" Value="{Binding Width}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" AutomationProperties.LabeledBy="{Binding ElementName=WidthLabel,Mode=OneTime}" />
+ <Label Name="HeightLabel" Grid.Column="2" Target="{Binding ElementName=HeightTextBox,Mode=OneTime}" Content="Height" />
+ <local:DoubleUpDownControl x:Name="HeightTextBox" Grid.Column="3" Value="{Binding Height}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" AutomationProperties.LabeledBy="{Binding ElementName=HeightLabel,Mode=OneTime}" />
+ </Grid>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="local:RatioEditorControl">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="local:RatioEditorControl">
+ <local:TextBoxEx x:Name="RatioTextBox" AutomationProperties.Name="{Binding Property.Name,Mode=OneTime}" Text="{Binding ValueString}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" VerticalContentAlignment="Center" />
</ControlTemplate>
</Setter.Value>
</Setter>
diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
index 6fdaea3..29b4c67 100644
--- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
+++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
@@ -130,6 +130,7 @@
<Compile Include="PropertyMenuItemContainerStyleSelector.cs" />
<Compile Include="PropertyPresenter.cs" />
<Compile Include="ShadeEditorControl.cs" />
+ <Compile Include="RatioEditorControl.cs" />
<Compile Include="SizeEditorControl.cs" />
<Compile Include="HueEditorControl.cs" />
<Compile Include="SolidBrushEditorControl.cs" />
diff --git a/Xamarin.PropertyEditing/Controls/FieldValidation.cs b/Xamarin.PropertyEditing/Controls/FieldValidation.cs
deleted file mode 100644
index f229fc9..0000000
--- a/Xamarin.PropertyEditing/Controls/FieldValidation.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using System;
-using System.Linq;
-
-namespace Xamarin.PropertyEditing
-{
- public class FieldValidation
- {
- public const string DefaultInitialValue = "1";
- public const double DefaultIntengerIncrementValue = 1;
- public const double DefaultDecimalIncrementValue = 0.5d;
-
- public const int DefaultXcodeMaxRoundDigits = 6;
- public static char[] Separators = { '/', ':' };
-
- public static void SetSpinButtonValue (string newValue, int roundDigits, out string finalStringValue, out double finalDecimalValue)
- {
- if (CheckIfRatio (newValue)) {
- finalStringValue = FieldValidation.RoundRatioValue (newValue, roundDigits);
- finalDecimalValue = newValue.Split (FieldValidation.GetSeparator (newValue))[0].ToEditorDouble ();
- }
- else {
- finalStringValue = FieldValidation.RoundDoubleValue (newValue, roundDigits);
- finalDecimalValue = newValue.ToEditorDouble ();
- }
- }
-
- public static double CoerceValue (double actualValue, double minimumValue, double maximumValue, bool isWrap)
- {
- return (isWrap && actualValue == minimumValue) ? maximumValue : CoerceValue (actualValue, minimumValue, maximumValue);
- }
- public static double CoerceValue (double actualValue, double minimumValue, double maximumValue)
- {
- return Math.Min (maximumValue, Math.Max (actualValue, minimumValue));
- }
-
- public static string FixInitialValue (string value, string defaultValue = DefaultInitialValue)
- {
- double parsedValue;
- if (!value.ToEditorDoubleIfPossible (out parsedValue))
- value = defaultValue;
- return string.IsNullOrEmpty (value) ? defaultValue : value;
- }
-
- public static string GetInitialOrDefaultValue (string value, double minimumValue, double maximumValue)
- {
- return string.IsNullOrEmpty (value) ?
- FixZeroDoubleValue (Math.Min (Math.Max (minimumValue, 0), maximumValue).ToEditorString ()) :
- value;
- }
-
- public static void SetSpinButtonValue (double newValue, string actualStringValue, int roundDigits, out string finalStringValue, out double finalDecimalValue)
- {
- //We round the new value
- newValue = Math.Round (newValue, roundDigits);
- //Get the current data to increment
- double originalValue;
- //values 0 are writed like 0.0 we need to fix it
- if (CheckIfRatio (actualStringValue)) {
- originalValue = actualStringValue.Split (FieldValidation.GetSeparator (actualStringValue))[0].ToEditorDouble ();
- finalStringValue = string.Concat (FieldValidation.FixZeroDoubleValue (newValue.ToEditorString ()), actualStringValue.Substring (originalValue.ToEditorString ().Length));
- }
- else {
- finalStringValue = FieldValidation.FixZeroDoubleValue (newValue.ToEditorString ());
- }
- finalDecimalValue = newValue;
- }
-
- public static bool IsNumberLast (string value)
- {
- return value.Length > 0 && Char.IsNumber (value.LastOrDefault ());
- }
-
- public static string FixZeroDoubleValue (string value)
- {
- return value == "0.0" ? "0" : value;
- }
-
- public static string RoundDoubleValue (string value, int decimals)
- {
- return FixZeroDoubleValue (Math.Round (value.ToEditorDouble (), decimals).ToEditorString ());
- }
-
- public static string RoundRatioValue (string value, int decimals)
- {
- var separator = FieldValidation.GetSeparator (value);
- var values = value.Split (separator);
- return string.Concat (RoundDoubleValue (values[0], decimals), separator, RoundDoubleValue (values[1], decimals));
- }
-
- public static bool IsRatio (string value)
- {
- if (IsNumberLast (value) && CheckIfRatio (value, ValidationType.Decimal, false)) {
- var values = value.Split (FieldValidation.GetSeparator (value));
- return !values[0].ToEditorDouble ().Equals (0) && !values[1].ToEditorDouble ().Equals (0);
- }
- return CheckIfNumber (value, ValidationType.Decimal, false);
- }
-
- public static bool ValidateDecimal (string finalString, bool allowNegativeValues)
- {
- double value;
- //Checks parsing to number
- if (!double.TryParse (finalString, out value))
- return false;
- //Checks if needs to be possitive value
- if (!allowNegativeValues && value < 0)
- return false;
- //Checks a common validation
- return CommonValidate (finalString);
- }
-
- public static bool ValidateInteger (string finalString, bool allowNegativeValues)
- {
- int value;
- //Checks parsing to number
- if (!int.TryParse (finalString, out value))
- return false;
- //Checks if needs to be possitive value
- if (!allowNegativeValues && value < 0)
- return false;
- //Checks a common validation
- return CommonValidate (finalString);
- }
-
- static bool CommonValidate (string finalString)
- {
- return finalString != "-" && !string.IsNullOrEmpty (finalString);
- }
-
- public static bool ValidateRatio (string finalString, ValidationType mode, bool allowNegativeValues)
- {
- if (CheckIfRatio (finalString, mode, allowNegativeValues) || CheckIfNumber (finalString, mode, allowNegativeValues))
- return true;
- return false;
- }
-
- public static char GetSeparator (string finalString)
- {
- foreach (var separator in Separators) {
- if (finalString.Contains (separator))
- return separator;
- }
- return default (char);
- }
-
- public static bool CheckIfRatio (string value)
- {
- return CheckIfRatio (value, ValidationType.Decimal, false);
- }
-
- public static bool CheckIfRatio (string finalString, ValidationType mode, bool allowNegativeValues)
- {
- foreach (var separator in Separators) {
- var parts = finalString.Split (new[] { separator });
- if (parts.Length == 2) {
- bool parsed = true;
-
- if (!CheckIfNumber (parts[0], mode, allowNegativeValues))
- parsed = false;
-
- if (!String.IsNullOrEmpty (parts[1]) && !CheckIfNumber (parts[1], mode, allowNegativeValues))
- parsed = false;
-
- if (parsed)
- return true;
- }
- }
- return false;
- }
-
- public static bool CheckIfNumber (string finalString, ValidationType mode, bool allowNegativeValues)
- {
- return mode == ValidationType.Decimal ?
- ValidateDecimal (finalString, allowNegativeValues) :
- ValidateInteger (finalString, allowNegativeValues);
- }
- }
-}
diff --git a/Xamarin.PropertyEditing/Drawing/CommonRatio.cs b/Xamarin.PropertyEditing/Drawing/CommonRatio.cs
new file mode 100644
index 0000000..b847a77
--- /dev/null
+++ b/Xamarin.PropertyEditing/Drawing/CommonRatio.cs
@@ -0,0 +1,105 @@
+using System;
+
+namespace Xamarin.PropertyEditing.Drawing
+{
+ /// <summary>
+ /// Struct to hold Ratio values
+ /// </summary>
+ [Serializable]
+ public struct CommonRatio : IEquatable<CommonRatio>
+ {
+ /// <param name="numerator">The ratio numerator value.</param>
+ /// <param name="denominator">The ratio denominator value.</param>
+ /// <param name="ratioSeparator">The ratio separator character, '/' or ':'.</param>
+ public CommonRatio (double numerator = 1.0f, double denominator = 1.0f, char ratioSeparator = ':')
+ {
+ this.numerator = numerator;
+ this.denominator = denominator;
+ this.ratioSeparator = ratioSeparator;
+ }
+
+ // Normal values like 1, 200, 400 would be stored as:
+ // Numerator = 100, Denominator = 1
+ //
+ // Ratio values such as 1:3 or 5/6 would be stored as
+ // Numerator = 1, Denominator = 3 etc.
+ public double numerator;
+ public double Numerator {
+ get {
+ if (this.numerator <= 0.0f) {
+ this.numerator = 1; // Default
+ }
+ return this.numerator;
+ }
+ set { this.numerator = value; }
+ }
+
+ public double denominator;
+ public double Denominator {
+ get {
+ if (this.denominator <= 0.0f) {
+ this.denominator = 1; // Default
+ }
+ return this.denominator;
+ }
+ set { this.denominator = value; }
+ }
+
+ public double Value => Numerator / Denominator;
+
+ // This can be either '/' or ':'
+ char ratioSeparator;
+ public char RatioSeparator {
+ get {
+ if (this.ratioSeparator == '\0') {
+ this.ratioSeparator = ':'; // Default
+ }
+ return this.ratioSeparator;
+ }
+ set {
+ this.ratioSeparator = value;
+ }
+ }
+
+ public bool IsRatio => !Denominator.Equals (1.0f);
+
+ public string StringValue => string.Format ("{0}{1}{2}", Numerator, RatioSeparator, Denominator);
+
+ public static bool operator == (CommonRatio left, CommonRatio right)
+ {
+ return Equals (left, right);
+ }
+
+ public static bool operator != (CommonRatio left, CommonRatio right)
+ {
+ return !Equals (left, right);
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null)
+ return false;
+ if (!(obj is CommonRatio))
+ return false;
+ return Equals ((CommonRatio)obj);
+ }
+
+ public bool Equals (CommonRatio other)
+ {
+ return Numerator.Equals (other.Numerator)
+ && Denominator.Equals (other.Denominator)
+ && RatioSeparator.Equals (other.RatioSeparator);
+ }
+
+ public override int GetHashCode ()
+ {
+ var hashCode = 3571; //TODO May need better primes
+ unchecked {
+ hashCode = hashCode * -7919 + Numerator.GetHashCode ();
+ hashCode = hashCode * -7919 + Denominator.GetHashCode ();
+ hashCode = hashCode * -7919 + RatioSeparator.GetHashCode ();
+ }
+ return hashCode;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
index a6d0394..3d1d708 100644
--- a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
+++ b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs
@@ -10,48 +10,35 @@
namespace Xamarin.PropertyEditing.Properties {
using System;
+ using System.Reflection;
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
- private static global::System.Resources.ResourceManager resourceMan;
+ private static System.Resources.ResourceManager resourceMan;
- private static global::System.Globalization.CultureInfo resourceCulture;
+ private static System.Globalization.CultureInfo resourceCulture;
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager {
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Resources.ResourceManager ResourceManager {
get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xamarin.PropertyEditing.Properties.Resources", typeof(Resources).Assembly);
+ if (object.Equals(null, resourceMan)) {
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Xamarin.PropertyEditing.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture {
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -60,1146 +47,771 @@ namespace Xamarin.PropertyEditing.Properties {
}
}
- /// <summary>
- /// Looks up a localized string similar to Add value converter….
- /// </summary>
- public static string AddValueConverterEllipsis {
+ public static string Alpha {
get {
- return ResourceManager.GetString("AddValueConverterEllipsis", resourceCulture);
+ return ResourceManager.GetString("Alpha", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Add Value Converter.
- /// </summary>
- public static string AddValueConverterTitle {
+ public static string AlphaInitial {
get {
- return ResourceManager.GetString("AddValueConverterTitle", resourceCulture);
+ return ResourceManager.GetString("AlphaInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Alpha.
- /// </summary>
- public static string Alpha {
+ public static string Black {
get {
- return ResourceManager.GetString("Alpha", resourceCulture);
+ return ResourceManager.GetString("Black", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to A.
- /// </summary>
- public static string AlphaInitial {
+ public static string BlackInitial {
get {
- return ResourceManager.GetString("AlphaInitial", resourceCulture);
+ return ResourceManager.GetString("BlackInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Application.
- /// </summary>
- public static string Application {
+ public static string Blue {
get {
- return ResourceManager.GetString("Application", resourceCulture);
+ return ResourceManager.GetString("Blue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Apply to all.
- /// </summary>
- public static string ApplyToAll {
+ public static string BlueInitial {
get {
- return ResourceManager.GetString("ApplyToAll", resourceCulture);
+ return ResourceManager.GetString("BlueInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Binding.
- /// </summary>
- public static string Binding {
+ public static string Brightness {
get {
- return ResourceManager.GetString("Binding", resourceCulture);
+ return ResourceManager.GetString("Brightness", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Binding type.
- /// </summary>
- public static string BindingType {
+ public static string BrightnessInitial {
get {
- return ResourceManager.GetString("BindingType", resourceCulture);
+ return ResourceManager.GetString("BrightnessInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Black.
- /// </summary>
- public static string Black {
+ public static string CMYK {
get {
- return ResourceManager.GetString("Black", resourceCulture);
+ return ResourceManager.GetString("CMYK", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to K.
- /// </summary>
- public static string BlackInitial {
+ public static string ColorSpace {
get {
- return ResourceManager.GetString("BlackInitial", resourceCulture);
+ return ResourceManager.GetString("ColorSpace", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Blue.
- /// </summary>
- public static string Blue {
+ public static string CurrentColor {
get {
- return ResourceManager.GetString("Blue", resourceCulture);
+ return ResourceManager.GetString("CurrentColor", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to B.
- /// </summary>
- public static string BlueInitial {
+ public static string Cyan {
get {
- return ResourceManager.GetString("BlueInitial", resourceCulture);
+ return ResourceManager.GetString("Cyan", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Brightness.
- /// </summary>
- public static string Brightness {
+ public static string CyanInitial {
get {
- return ResourceManager.GetString("Brightness", resourceCulture);
+ return ResourceManager.GetString("CyanInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to B.
- /// </summary>
- public static string BrightnessInitial {
+ public static string CyanMagentaYellowBlack {
get {
- return ResourceManager.GetString("BrightnessInitial", resourceCulture);
+ return ResourceManager.GetString("CyanMagentaYellowBlack", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Cancel.
- /// </summary>
- public static string Cancel {
+ public static string ConvertToLocalValue {
get {
- return ResourceManager.GetString("Cancel", resourceCulture);
+ return ResourceManager.GetString("ConvertToLocalValue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to CMYK.
- /// </summary>
- public static string CMYK {
+ public static string CustomExpressionEllipsis {
get {
- return ResourceManager.GetString("CMYK", resourceCulture);
+ return ResourceManager.GetString("CustomExpressionEllipsis", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Collection Editor: {0}.
- /// </summary>
- public static string CollectionEditorTitle {
+ public static string EventHandlersSelectedElement {
get {
- return ResourceManager.GetString("CollectionEditorTitle", resourceCulture);
+ return ResourceManager.GetString("EventHandlersSelectedElement", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to (Collection).
- /// </summary>
- public static string CollectionValue {
+ public static string Events {
get {
- return ResourceManager.GetString("CollectionValue", resourceCulture);
+ return ResourceManager.GetString("Events", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Editor.
- /// </summary>
- public static string ColorEditorTabLabel {
+ public static string Green {
get {
- return ResourceManager.GetString("ColorEditorTabLabel", resourceCulture);
+ return ResourceManager.GetString("Green", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Color space.
- /// </summary>
- public static string ColorSpace {
+ public static string GreenInitial {
get {
- return ResourceManager.GetString("ColorSpace", resourceCulture);
+ return ResourceManager.GetString("GreenInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Convert to Local Value.
- /// </summary>
- public static string ConvertToLocalValue {
+ public static string HexValue {
get {
- return ResourceManager.GetString("ConvertToLocalValue", resourceCulture);
+ return ResourceManager.GetString("HexValue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Convert to new resource….
- /// </summary>
- public static string ConvertToNewResourceEllipsis {
+ public static string HLS {
get {
- return ResourceManager.GetString("ConvertToNewResourceEllipsis", resourceCulture);
+ return ResourceManager.GetString("HLS", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Create New Binding….
- /// </summary>
- public static string CreateDataBindingMenuItem {
+ public static string HSB {
get {
- return ResourceManager.GetString("CreateDataBindingMenuItem", resourceCulture);
+ return ResourceManager.GetString("HSB", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Create Data Binding for {0}.
- /// </summary>
- public static string CreateDataBindingTitle {
+ public static string Hue {
get {
- return ResourceManager.GetString("CreateDataBindingTitle", resourceCulture);
+ return ResourceManager.GetString("Hue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Create {0} Resource.
- /// </summary>
- public static string CreateResourceTitle {
+ public static string HueInitial {
get {
- return ResourceManager.GetString("CreateResourceTitle", resourceCulture);
+ return ResourceManager.GetString("HueInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Current color.
- /// </summary>
- public static string CurrentColor {
+ public static string HueLightnessSaturation {
get {
- return ResourceManager.GetString("CurrentColor", resourceCulture);
+ return ResourceManager.GetString("HueLightnessSaturation", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Custom.
- /// </summary>
- public static string Custom {
+ public static string HueSaturationBrightness {
get {
- return ResourceManager.GetString("Custom", resourceCulture);
+ return ResourceManager.GetString("HueSaturationBrightness", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Custom expression.
- /// </summary>
- public static string CustomExpression {
+ public static string InitialColor {
get {
- return ResourceManager.GetString("CustomExpression", resourceCulture);
+ return ResourceManager.GetString("InitialColor", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Custom Expression….
- /// </summary>
- public static string CustomExpressionEllipsis {
+ public static string LastColor {
get {
- return ResourceManager.GetString("CustomExpressionEllipsis", resourceCulture);
+ return ResourceManager.GetString("LastColor", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Cyan.
- /// </summary>
- public static string Cyan {
+ public static string Lightness {
get {
- return ResourceManager.GetString("Cyan", resourceCulture);
+ return ResourceManager.GetString("Lightness", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to C.
- /// </summary>
- public static string CyanInitial {
+ public static string LightnessInitial {
get {
- return ResourceManager.GetString("CyanInitial", resourceCulture);
+ return ResourceManager.GetString("LightnessInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Cyan / Magenta / Yellow / Black.
- /// </summary>
- public static string CyanMagentaYellowBlack {
+ public static string Magenta {
get {
- return ResourceManager.GetString("CyanMagentaYellowBlack", resourceCulture);
+ return ResourceManager.GetString("Magenta", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Default.
- /// </summary>
- public static string Default {
+ public static string MagentaInitial {
get {
- return ResourceManager.GetString("Default", resourceCulture);
+ return ResourceManager.GetString("MagentaInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Define in.
- /// </summary>
- public static string DefineIn {
+ public static string MultipleObjectsSelected {
get {
- return ResourceManager.GetString("DefineIn", resourceCulture);
+ return ResourceManager.GetString("MultipleObjectsSelected", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to ….
- /// </summary>
- public static string Ellipsis {
+ public static string MultipleTypesSelected {
get {
- return ResourceManager.GetString("Ellipsis", resourceCulture);
+ return ResourceManager.GetString("MultipleTypesSelected", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Event handlers for the selected element.
- /// </summary>
- public static string EventHandlersSelectedElement {
+ public static string Name {
get {
- return ResourceManager.GetString("EventHandlersSelectedElement", resourceCulture);
+ return ResourceManager.GetString("Name", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Events.
- /// </summary>
- public static string Events {
+ public static string NoName {
get {
- return ResourceManager.GetString("Events", resourceCulture);
+ return ResourceManager.GetString("NoName", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Something went wrong.
- /// </summary>
- public static string GenericErrorMessage {
+ public static string Properties {
get {
- return ResourceManager.GetString("GenericErrorMessage", resourceCulture);
+ return ResourceManager.GetString("Properties", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Go to Source.
- /// </summary>
- public static string GoToSource {
+ public static string PropertiesSelectedElement {
get {
- return ResourceManager.GetString("GoToSource", resourceCulture);
+ return ResourceManager.GetString("PropertiesSelectedElement", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Green.
- /// </summary>
- public static string Green {
+ public static string Red {
get {
- return ResourceManager.GetString("Green", resourceCulture);
+ return ResourceManager.GetString("Red", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to G.
- /// </summary>
- public static string GreenInitial {
+ public static string RedGreenBlue {
get {
- return ResourceManager.GetString("GreenInitial", resourceCulture);
+ return ResourceManager.GetString("RedGreenBlue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Hex value.
- /// </summary>
- public static string HexValue {
+ public static string RedInitial {
get {
- return ResourceManager.GetString("HexValue", resourceCulture);
+ return ResourceManager.GetString("RedInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to HLS.
- /// </summary>
- public static string HLS {
+ public static string RGB {
get {
- return ResourceManager.GetString("HLS", resourceCulture);
+ return ResourceManager.GetString("RGB", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to HSB.
- /// </summary>
- public static string HSB {
+ public static string Saturation {
get {
- return ResourceManager.GetString("HSB", resourceCulture);
+ return ResourceManager.GetString("Saturation", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Hue.
- /// </summary>
- public static string Hue {
+ public static string SaturationInitial {
get {
- return ResourceManager.GetString("Hue", resourceCulture);
+ return ResourceManager.GetString("SaturationInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to H.
- /// </summary>
- public static string HueInitial {
+ public static string Reset {
get {
- return ResourceManager.GetString("HueInitial", resourceCulture);
+ return ResourceManager.GetString("Reset", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Hue / Lightness / Saturation.
- /// </summary>
- public static string HueLightnessSaturation {
+ public static string Type {
get {
- return ResourceManager.GetString("HueLightnessSaturation", resourceCulture);
+ return ResourceManager.GetString("Type", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Hue / Saturation / Brightness.
- /// </summary>
- public static string HueSaturationBrightness {
+ public static string ViewPropertiesOrEvents {
get {
- return ResourceManager.GetString("HueSaturationBrightness", resourceCulture);
+ return ResourceManager.GetString("ViewPropertiesOrEvents", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Inherited.
- /// </summary>
- public static string Inherited {
+ public static string Yellow {
get {
- return ResourceManager.GetString("Inherited", resourceCulture);
+ return ResourceManager.GetString("Yellow", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Initial color.
- /// </summary>
- public static string InitialColor {
+ public static string YellowInitial {
get {
- return ResourceManager.GetString("InitialColor", resourceCulture);
+ return ResourceManager.GetString("YellowInitial", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to {0} is an Invalid Value.
- /// </summary>
- public static string InvalidValue {
+ public static string NoBrush {
get {
- return ResourceManager.GetString("InvalidValue", resourceCulture);
+ return ResourceManager.GetString("NoBrush", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Items.
- /// </summary>
- public static string Items {
+ public static string SolidBrush {
get {
- return ResourceManager.GetString("Items", resourceCulture);
+ return ResourceManager.GetString("SolidBrush", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Last color.
- /// </summary>
- public static string LastColor {
+ public static string ResourceBrush {
get {
- return ResourceManager.GetString("LastColor", resourceCulture);
+ return ResourceManager.GetString("ResourceBrush", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Lightness.
- /// </summary>
- public static string Lightness {
+ public static string Opacity {
get {
- return ResourceManager.GetString("Lightness", resourceCulture);
+ return ResourceManager.GetString("Opacity", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to L.
- /// </summary>
- public static string LightnessInitial {
+ public static string ShowAdvancedProperties {
get {
- return ResourceManager.GetString("LightnessInitial", resourceCulture);
+ return ResourceManager.GetString("ShowAdvancedProperties", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Local.
- /// </summary>
- public static string Local {
+ public static string Cancel {
get {
- return ResourceManager.GetString("Local", resourceCulture);
+ return ResourceManager.GetString("Cancel", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Magenta.
- /// </summary>
- public static string Magenta {
+ public static string OK {
get {
- return ResourceManager.GetString("Magenta", resourceCulture);
+ return ResourceManager.GetString("OK", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to M.
- /// </summary>
- public static string MagentaInitial {
+ public static string ShowAllAssemblies {
get {
- return ResourceManager.GetString("MagentaInitial", resourceCulture);
+ return ResourceManager.GetString("ShowAllAssemblies", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Amber.
- /// </summary>
- public static string MaterialColorAmber {
+ public static string SearchProperties {
get {
- return ResourceManager.GetString("MaterialColorAmber", resourceCulture);
+ return ResourceManager.GetString("SearchProperties", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Black and White.
- /// </summary>
- public static string MaterialColorBlackAndWhite {
+ public static string New {
get {
- return ResourceManager.GetString("MaterialColorBlackAndWhite", resourceCulture);
+ return ResourceManager.GetString("New", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Blue.
- /// </summary>
- public static string MaterialColorBlue {
+ public static string SearchObjectsTitle {
get {
- return ResourceManager.GetString("MaterialColorBlue", resourceCulture);
+ return ResourceManager.GetString("SearchObjectsTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Blue Grey.
- /// </summary>
- public static string MaterialColorBlueGrey {
+ public static string SelectObjectTitle {
get {
- return ResourceManager.GetString("MaterialColorBlueGrey", resourceCulture);
+ return ResourceManager.GetString("SelectObjectTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Brown.
- /// </summary>
- public static string MaterialColorBrown {
+ public static string CustomExpression {
get {
- return ResourceManager.GetString("MaterialColorBrown", resourceCulture);
+ return ResourceManager.GetString("CustomExpression", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Cyan.
- /// </summary>
- public static string MaterialColorCyan {
+ public static string ColorEditorTabLabel {
get {
- return ResourceManager.GetString("MaterialColorCyan", resourceCulture);
+ return ResourceManager.GetString("ColorEditorTabLabel", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Deep Orange.
- /// </summary>
- public static string MaterialColorDeepOrange {
+ public static string SearchResourcesTitle {
get {
- return ResourceManager.GetString("MaterialColorDeepOrange", resourceCulture);
+ return ResourceManager.GetString("SearchResourcesTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Deep Purple.
- /// </summary>
- public static string MaterialColorDeepPurple {
+ public static string SelectResourceTitle {
get {
- return ResourceManager.GetString("MaterialColorDeepPurple", resourceCulture);
+ return ResourceManager.GetString("SelectResourceTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Green.
- /// </summary>
- public static string MaterialColorGreen {
+ public static string ShowSystemResources {
get {
- return ResourceManager.GetString("MaterialColorGreen", resourceCulture);
+ return ResourceManager.GetString("ShowSystemResources", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Grey.
- /// </summary>
- public static string MaterialColorGrey {
+ public static string ResourceEllipsis {
get {
- return ResourceManager.GetString("MaterialColorGrey", resourceCulture);
+ return ResourceManager.GetString("ResourceEllipsis", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Indigo.
- /// </summary>
- public static string MaterialColorIndigo {
+ public static string Default {
get {
- return ResourceManager.GetString("MaterialColorIndigo", resourceCulture);
+ return ResourceManager.GetString("Default", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Light Blue.
- /// </summary>
- public static string MaterialColorLightBlue {
+ public static string Inherited {
get {
- return ResourceManager.GetString("MaterialColorLightBlue", resourceCulture);
+ return ResourceManager.GetString("Inherited", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Light Green.
- /// </summary>
- public static string MaterialColorLightGreen {
+ public static string InvalidValue {
get {
- return ResourceManager.GetString("MaterialColorLightGreen", resourceCulture);
+ return ResourceManager.GetString("InvalidValue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Lime.
- /// </summary>
- public static string MaterialColorLime {
+ public static string Local {
get {
- return ResourceManager.GetString("MaterialColorLime", resourceCulture);
+ return ResourceManager.GetString("Local", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Orange.
- /// </summary>
- public static string MaterialColorOrange {
+ public static string Unset {
get {
- return ResourceManager.GetString("MaterialColorOrange", resourceCulture);
+ return ResourceManager.GetString("Unset", resourceCulture);
+ }
+ }
+
+ public static string MaterialColorRed {
+ get {
+ return ResourceManager.GetString("MaterialColorRed", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Pink.
- /// </summary>
public static string MaterialColorPink {
get {
return ResourceManager.GetString("MaterialColorPink", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Purple.
- /// </summary>
public static string MaterialColorPurple {
get {
return ResourceManager.GetString("MaterialColorPurple", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Red.
- /// </summary>
- public static string MaterialColorRed {
+ public static string MaterialColorDeepPurple {
get {
- return ResourceManager.GetString("MaterialColorRed", resourceCulture);
+ return ResourceManager.GetString("MaterialColorDeepPurple", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Teal.
- /// </summary>
- public static string MaterialColorTeal {
+ public static string MaterialColorIndigo {
get {
- return ResourceManager.GetString("MaterialColorTeal", resourceCulture);
+ return ResourceManager.GetString("MaterialColorIndigo", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Yellow.
- /// </summary>
- public static string MaterialColorYellow {
+ public static string MaterialColorBlue {
get {
- return ResourceManager.GetString("MaterialColorYellow", resourceCulture);
+ return ResourceManager.GetString("MaterialColorBlue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Material Design Colors.
- /// </summary>
- public static string MaterialDesignColorBrush {
+ public static string MaterialColorLightBlue {
get {
- return ResourceManager.GetString("MaterialDesignColorBrush", resourceCulture);
+ return ResourceManager.GetString("MaterialColorLightBlue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Move item down.
- /// </summary>
- public static string MoveItemDown {
+ public static string MaterialColorCyan {
get {
- return ResourceManager.GetString("MoveItemDown", resourceCulture);
+ return ResourceManager.GetString("MaterialColorCyan", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Move item up.
- /// </summary>
- public static string MoveItemUp {
+ public static string MaterialColorTeal {
get {
- return ResourceManager.GetString("MoveItemUp", resourceCulture);
+ return ResourceManager.GetString("MaterialColorTeal", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to {0} objects selected.
- /// </summary>
- public static string MultipleObjectsSelected {
+ public static string MaterialColorGreen {
get {
- return ResourceManager.GetString("MultipleObjectsSelected", resourceCulture);
+ return ResourceManager.GetString("MaterialColorGreen", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to {0} types selected.
- /// </summary>
- public static string MultipleTypesSelected {
+ public static string MaterialColorLightGreen {
get {
- return ResourceManager.GetString("MultipleTypesSelected", resourceCulture);
+ return ResourceManager.GetString("MaterialColorLightGreen", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Name.
- /// </summary>
- public static string Name {
+ public static string MaterialColorLime {
get {
- return ResourceManager.GetString("Name", resourceCulture);
+ return ResourceManager.GetString("MaterialColorLime", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to New.
- /// </summary>
- public static string New {
+ public static string MaterialColorYellow {
get {
- return ResourceManager.GetString("New", resourceCulture);
+ return ResourceManager.GetString("MaterialColorYellow", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to No brush.
- /// </summary>
- public static string NoBrush {
+ public static string MaterialColorAmber {
get {
- return ResourceManager.GetString("NoBrush", resourceCulture);
+ return ResourceManager.GetString("MaterialColorAmber", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to &lt;No Name&gt;.
- /// </summary>
- public static string NoName {
+ public static string MaterialColorOrange {
get {
- return ResourceManager.GetString("NoName", resourceCulture);
+ return ResourceManager.GetString("MaterialColorOrange", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to No preview available.
- /// </summary>
- public static string NoPreviewAvailable {
+ public static string MaterialColorDeepOrange {
get {
- return ResourceManager.GetString("NoPreviewAvailable", resourceCulture);
+ return ResourceManager.GetString("MaterialColorDeepOrange", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to No value converter.
- /// </summary>
- public static string NoValueConverter {
+ public static string MaterialColorBrown {
get {
- return ResourceManager.GetString("NoValueConverter", resourceCulture);
+ return ResourceManager.GetString("MaterialColorBrown", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to OK.
- /// </summary>
- public static string OK {
+ public static string MaterialColorGrey {
get {
- return ResourceManager.GetString("OK", resourceCulture);
+ return ResourceManager.GetString("MaterialColorGrey", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Opacity.
- /// </summary>
- public static string Opacity {
+ public static string MaterialColorBlueGrey {
get {
- return ResourceManager.GetString("Opacity", resourceCulture);
+ return ResourceManager.GetString("MaterialColorBlueGrey", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to &lt;Other type…&gt;.
- /// </summary>
- public static string OtherTypeAction {
+ public static string MaterialDesignColorBrush {
get {
- return ResourceManager.GetString("OtherTypeAction", resourceCulture);
+ return ResourceManager.GetString("MaterialDesignColorBrush", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Path.
- /// </summary>
- public static string Path {
+ public static string MaterialColorBlackAndWhite {
get {
- return ResourceManager.GetString("Path", resourceCulture);
+ return ResourceManager.GetString("MaterialColorBlackAndWhite", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Properties.
- /// </summary>
- public static string Properties {
+ public static string White {
get {
- return ResourceManager.GetString("Properties", resourceCulture);
+ return ResourceManager.GetString("White", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Properties for the selected element.
- /// </summary>
- public static string PropertiesSelectedElement {
+ public static string NoPreviewAvailable {
get {
- return ResourceManager.GetString("PropertiesSelectedElement", resourceCulture);
+ return ResourceManager.GetString("NoPreviewAvailable", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Red.
- /// </summary>
- public static string Red {
+ public static string Resource {
get {
- return ResourceManager.GetString("Red", resourceCulture);
+ return ResourceManager.GetString("Resource", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Red / Green/ Blue.
- /// </summary>
- public static string RedGreenBlue {
+ public static string ResourceWithName {
get {
- return ResourceManager.GetString("RedGreenBlue", resourceCulture);
+ return ResourceManager.GetString("ResourceWithName", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to R.
- /// </summary>
- public static string RedInitial {
+ public static string Binding {
get {
- return ResourceManager.GetString("RedInitial", resourceCulture);
+ return ResourceManager.GetString("Binding", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Remove item.
- /// </summary>
- public static string RemoveItem {
+ public static string GoToSource {
get {
- return ResourceManager.GetString("RemoveItem", resourceCulture);
+ return ResourceManager.GetString("GoToSource", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Reset.
- /// </summary>
- public static string Reset {
+ public static string CollectionValue {
get {
- return ResourceManager.GetString("Reset", resourceCulture);
+ return ResourceManager.GetString("CollectionValue", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Resource.
- /// </summary>
- public static string Resource {
+ public static string Ellipsis {
get {
- return ResourceManager.GetString("Resource", resourceCulture);
+ return ResourceManager.GetString("Ellipsis", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Brush from resource.
- /// </summary>
- public static string ResourceBrush {
+ public static string OtherTypeAction {
get {
- return ResourceManager.GetString("ResourceBrush", resourceCulture);
+ return ResourceManager.GetString("OtherTypeAction", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Resource dictionary.
- /// </summary>
- public static string ResourceDictionary {
+ public static string Items {
get {
- return ResourceManager.GetString("ResourceDictionary", resourceCulture);
+ return ResourceManager.GetString("Items", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Resource….
- /// </summary>
- public static string ResourceEllipsis {
+ public static string CollectionEditorTitle {
get {
- return ResourceManager.GetString("ResourceEllipsis", resourceCulture);
+ return ResourceManager.GetString("CollectionEditorTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Name.
- /// </summary>
- public static string ResourceNameLabel {
+ public static string MoveItemDown {
get {
- return ResourceManager.GetString("ResourceNameLabel", resourceCulture);
+ return ResourceManager.GetString("MoveItemDown", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Resources.
- /// </summary>
- public static string ResourcePlural {
+ public static string MoveItemUp {
get {
- return ResourceManager.GetString("ResourcePlural", resourceCulture);
+ return ResourceManager.GetString("MoveItemUp", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Resource ({0}).
- /// </summary>
- public static string ResourceWithName {
+ public static string RemoveItem {
get {
- return ResourceManager.GetString("ResourceWithName", resourceCulture);
+ return ResourceManager.GetString("RemoveItem", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to RGB.
- /// </summary>
- public static string RGB {
+ public static string GenericErrorMessage {
get {
- return ResourceManager.GetString("RGB", resourceCulture);
+ return ResourceManager.GetString("GenericErrorMessage", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Saturation.
- /// </summary>
- public static string Saturation {
+ public static string DefineIn {
get {
- return ResourceManager.GetString("Saturation", resourceCulture);
+ return ResourceManager.GetString("DefineIn", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to S.
- /// </summary>
- public static string SaturationInitial {
+ public static string Application {
get {
- return ResourceManager.GetString("SaturationInitial", resourceCulture);
+ return ResourceManager.GetString("Application", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Search Objects.
- /// </summary>
- public static string SearchObjectsTitle {
+ public static string ApplyToAll {
get {
- return ResourceManager.GetString("SearchObjectsTitle", resourceCulture);
+ return ResourceManager.GetString("ApplyToAll", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Search properties.
- /// </summary>
- public static string SearchProperties {
+ public static string ThisDocument {
get {
- return ResourceManager.GetString("SearchProperties", resourceCulture);
+ return ResourceManager.GetString("ThisDocument", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Search Resources.
- /// </summary>
- public static string SearchResourcesTitle {
+ public static string ConvertToNewResourceEllipsis {
get {
- return ResourceManager.GetString("SearchResourcesTitle", resourceCulture);
+ return ResourceManager.GetString("ConvertToNewResourceEllipsis", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Select Object.
- /// </summary>
- public static string SelectObjectTitle {
+ public static string CreateResourceTitle {
get {
- return ResourceManager.GetString("SelectObjectTitle", resourceCulture);
+ return ResourceManager.GetString("CreateResourceTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Select Resource.
- /// </summary>
- public static string SelectResourceTitle {
+ public static string ResourceNameLabel {
get {
- return ResourceManager.GetString("SelectResourceTitle", resourceCulture);
+ return ResourceManager.GetString("ResourceNameLabel", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Show advanced properties.
- /// </summary>
- public static string ShowAdvancedProperties {
+ public static string ResourceDictionary {
get {
- return ResourceManager.GetString("ShowAdvancedProperties", resourceCulture);
+ return ResourceManager.GetString("ResourceDictionary", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to _Show all assemblies.
- /// </summary>
- public static string ShowAllAssemblies {
+ public static string CreateDataBindingMenuItem {
get {
- return ResourceManager.GetString("ShowAllAssemblies", resourceCulture);
+ return ResourceManager.GetString("CreateDataBindingMenuItem", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to _Show system resources.
- /// </summary>
- public static string ShowSystemResources {
+ public static string AddValueConverterEllipsis {
get {
- return ResourceManager.GetString("ShowSystemResources", resourceCulture);
+ return ResourceManager.GetString("AddValueConverterEllipsis", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Solid color brush.
- /// </summary>
- public static string SolidBrush {
+ public static string AddValueConverterTitle {
get {
- return ResourceManager.GetString("SolidBrush", resourceCulture);
+ return ResourceManager.GetString("AddValueConverterTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to This document.
- /// </summary>
- public static string ThisDocument {
+ public static string NoValueConverter {
get {
- return ResourceManager.GetString("ThisDocument", resourceCulture);
+ return ResourceManager.GetString("NoValueConverter", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Type.
- /// </summary>
- public static string Type {
+ public static string ValueConverterName {
get {
- return ResourceManager.GetString("Type", resourceCulture);
+ return ResourceManager.GetString("ValueConverterName", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Unset.
- /// </summary>
- public static string Unset {
+ public static string CreateDataBindingTitle {
get {
- return ResourceManager.GetString("Unset", resourceCulture);
+ return ResourceManager.GetString("CreateDataBindingTitle", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Value converter name.
- /// </summary>
- public static string ValueConverterName {
+ public static string BindingType {
get {
- return ResourceManager.GetString("ValueConverterName", resourceCulture);
+ return ResourceManager.GetString("BindingType", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to View properties or events.
- /// </summary>
- public static string ViewPropertiesOrEvents {
+ public static string Path {
get {
- return ResourceManager.GetString("ViewPropertiesOrEvents", resourceCulture);
+ return ResourceManager.GetString("Path", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to White.
- /// </summary>
- public static string White {
+ public static string ResourcePlural {
get {
- return ResourceManager.GetString("White", resourceCulture);
+ return ResourceManager.GetString("ResourcePlural", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Yellow.
- /// </summary>
- public static string Yellow {
+ public static string Custom {
get {
- return ResourceManager.GetString("Yellow", resourceCulture);
+ return ResourceManager.GetString("Custom", resourceCulture);
}
}
- /// <summary>
- /// Looks up a localized string similar to Y.
- /// </summary>
- public static string YellowInitial {
+ public static string InvalidRatio {
get {
- return ResourceManager.GetString("YellowInitial", resourceCulture);
+ return ResourceManager.GetString("InvalidRatio", resourceCulture);
}
}
}
diff --git a/Xamarin.PropertyEditing/Properties/Resources.resx b/Xamarin.PropertyEditing/Properties/Resources.resx
index f9798a8..ebaf050 100644
--- a/Xamarin.PropertyEditing/Properties/Resources.resx
+++ b/Xamarin.PropertyEditing/Properties/Resources.resx
@@ -545,4 +545,7 @@
<data name="Custom" xml:space="preserve">
<value>Custom</value>
</data>
+ <data name="InvalidRatio" xml:space="preserve">
+ <value>Invalid Ratio</value>
+ </data>
</root> \ No newline at end of file
diff --git a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
index 6338908..ba97690 100644
--- a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
+++ b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs
@@ -498,6 +498,7 @@ namespace Xamarin.PropertyEditing.ViewModels
{ typeof(BindingSource), (tp,p,e) => new PropertyViewModel<BindingSource> (tp, p, e) },
{ typeof(Resource), (tp,p,e) => new PropertyViewModel<Resource> (tp, p, e) },
{ typeof(object), (tp,p,e) => new ObjectPropertyViewModel (tp, p, e) },
+ { typeof(CommonRatio), (tp, p, e) => new RatioViewModel (tp, p, e) },
};
}
}
diff --git a/Xamarin.PropertyEditing/ViewModels/RatioViewModel.cs b/Xamarin.PropertyEditing/ViewModels/RatioViewModel.cs
new file mode 100644
index 0000000..9c16d20
--- /dev/null
+++ b/Xamarin.PropertyEditing/ViewModels/RatioViewModel.cs
@@ -0,0 +1,153 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using Xamarin.PropertyEditing.Drawing;
+
+namespace Xamarin.PropertyEditing.ViewModels
+{
+ internal class RatioViewModel
+ : PropertyViewModel<CommonRatio>
+ {
+ public double Numerator
+ {
+ get { return Value.Numerator; }
+ set {
+ if (Value.Numerator.Equals (value))
+ return;
+
+ Value = new CommonRatio (value, Value.Denominator, Value.RatioSeparator);
+ }
+ }
+
+ public double Denominator
+ {
+ get { return Value.Denominator; }
+
+ set {
+ if (Value.Denominator.Equals (value))
+ return;
+
+ Value = new CommonRatio (Value.Numerator, value, Value.RatioSeparator);
+ }
+ }
+
+ public char RatioSeparator {
+ get { return Value.RatioSeparator; }
+
+ set {
+ if (Value.RatioSeparator.Equals (value))
+ return;
+
+ Value = new CommonRatio (Value.Numerator, Value.Denominator, value);
+ }
+ }
+
+ internal void ValueChanged (string stringValue, int caretPosition, int selectionLength, double incrementValue)
+ {
+ var separator = GetSeparator (stringValue);
+ SetRatioFromString (stringValue);
+
+ var newNumerator = Value.Numerator + incrementValue;
+ if (newNumerator < 1)
+ newNumerator = 1;
+
+ var newDenominator = Value.Denominator + incrementValue;
+ if (newDenominator < 1)
+ newDenominator = 1;
+
+ // Full selection, increment both
+ if (selectionLength == stringValue.Length) {
+ // Increment both values.
+ Value = new CommonRatio (newNumerator, newDenominator, separator);
+ } else {
+ // Only Increment numerator
+ Value = new CommonRatio (newNumerator, Value.Denominator, separator);
+ }
+ }
+
+ public string ValueString
+ {
+ get { return Value.StringValue; }
+ set {
+ if (Value.StringValue.Equals (value))
+ return;
+
+ SetRatioFromString (value);
+ }
+ }
+
+ public static char[] Separators = { ':', '/' };
+ public static char[] SplitSeparators = { ':', '/', ' ' };
+
+ public RatioViewModel (TargetPlatform platform, IPropertyInfo property, IEnumerable<IObjectEditor> editors)
+ : base (platform, property, editors)
+ {
+ }
+
+ protected override void OnValueChanged ()
+ {
+ base.OnValueChanged ();
+ OnPropertyChanged (nameof (Numerator));
+ OnPropertyChanged (nameof (Denominator));
+ OnPropertyChanged (nameof (RatioSeparator));
+ OnPropertyChanged (nameof (ValueString));
+ }
+
+ private void SetRatioFromString (string value)
+ {
+ bool parsed = true;
+ var parts = value.Split (SplitSeparators, StringSplitOptions.RemoveEmptyEntries);
+ double numerator = 0f;
+ if (parts.Length == 2) { // We have a potential ratio, let's make sure
+ if (!IsDouble (parts[0], out numerator))
+ parsed = false;
+ double denominator = 0f;
+ if (!String.IsNullOrEmpty (parts[1]) && !IsDouble (parts[1], out denominator))
+ parsed = false;
+
+ if (parsed) {
+ Value = new CommonRatio (numerator, denominator, GetSeparator (value));
+ }
+ } else if (parts.Length == 1) { // We have a potential whole number, let's make sure
+ if (!IsDouble (parts[0], out numerator)) {
+ parsed = false;
+ }
+ if (parsed) {
+ Value = new CommonRatio (numerator, 1, GetSeparator (value));
+ }
+ }
+
+ if (!parsed) {
+ SetError (string.Format (Properties.Resources.InvalidRatio, value));
+ }
+ }
+
+ private char GetSeparator (string finalString)
+ {
+ var index = finalString.IndexOfAny (Separators);
+ if (index != -1)
+ return finalString[index];
+ else
+ return ':';
+ }
+
+ private bool IsDouble (string stringValue, out double value)
+ {
+ //Checks parsing to number
+ if (!double.TryParse (stringValue, out value))
+ return false;
+
+ //Checks if needs to be positive value
+ if (value < 0)
+ return false;
+
+ //Checks a common validation
+ return IsValidInput (stringValue);
+ }
+
+ public static bool IsValidInput (string finalString)
+ {
+ return finalString != "-" && !string.IsNullOrEmpty (finalString);
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
index 0887558..af46062 100644
--- a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
+++ b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
@@ -156,12 +156,13 @@
<Compile Include="IMutableLookup.cs" />
<Compile Include="OrderedDictionary.cs" />
<Compile Include="Controls\ValidationType.cs" />
- <Compile Include="Controls\FieldValidation.cs" />
<Compile Include="Controls\StringConversionExtensions.cs" />
<Compile Include="ViewModels\RectanglePropertyViewModel.cs" />
<Compile Include="ViewModels\ThicknessPropertyViewModel.cs" />
<Compile Include="ViewModels\ObjectTreeElement.cs" />
<Compile Include="ViewModels\TypeSelectorViewModel.cs" />
+ <Compile Include="ViewModels\RatioViewModel.cs" />
+ <Compile Include="Drawing\CommonRatio.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Themes\BaseThemeManager.cs" />