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:
authorDominique Louis <savagesoftware@gmail.com>2018-02-14 19:30:31 +0300
committerDominique Louis <savagesoftware@gmail.com>2018-05-16 12:19:20 +0300
commitead73805bd3b147aa96f305ded0fdf35dcc66177 (patch)
tree79973d271c2e3da9ba9f11d6fc4d6b162c1803d1 /Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs
parent1af9327e5d13cd8f4ca1190961e1375274a6f84a (diff)
[Mac] Initial CustomExpression Implementation.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs b/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs
new file mode 100644
index 0000000..17be2bc
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Reflection;
+using AppKit;
+using CoreGraphics;
+using Foundation;
+using ObjCRuntime;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class CustomExpressionView : BasePopOverViewModelControl
+ {
+ Type vmType;
+ const string CustomExpressionPropertyString = "CustomExpression";
+ PropertyInfo customExpressionPropertyInfo;
+
+ public CustomExpressionView (PropertyViewModel viewModel) : base (viewModel, Properties.Resources.CustomExpression, "custom-expression-32")
+ {
+ Frame = new CGRect (CGPoint.Empty, new CGSize (250, 60));
+
+ var customExpressionField = new NSTextField {
+ StringValue = string.Empty,
+ TranslatesAutoresizingMaskIntoConstraints = false,
+ };
+
+ vmType = viewModel.GetType ();
+ customExpressionPropertyInfo = vmType.GetProperty (CustomExpressionPropertyString);
+ var value = customExpressionPropertyInfo.GetValue (viewModel);
+ if (value != null)
+ customExpressionField.StringValue = (string)value;
+
+ customExpressionField.Activated += (sender, e) => {
+ customExpressionPropertyInfo.SetValue (viewModel, customExpressionField.StringValue);
+ };
+
+ AddSubview (customExpressionField);
+
+ this.DoConstraints (new[] {
+ customExpressionField.ConstraintTo (this, (s, c) => s.Top == c.Top + 30),
+ customExpressionField.ConstraintTo (this, (s, c) => s.Left == c.Left + 30),
+ customExpressionField.ConstraintTo (this, (s, c) => s.Width == c.Width - 37),
+ customExpressionField.ConstraintTo (this, (s, c) => s.Height == 24),
+ });
+ }
+ }
+}