Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2019-07-04 01:34:48 +0300
committerGitHub <noreply@github.com>2019-07-04 01:34:48 +0300
commitf77ce63e6566dfeaa9ca3a70a619870a251be78f (patch)
tree6697c0c6f7cd291577c8198d7c7a1b31ffb96c02 /Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
parent98584081ea54226fe486977032f8e2dd93f62fca (diff)
parenta2c5c82cc22edaea46b0eeadeb982a9ac5fe75f7 (diff)
Merge pull request #561 from xamarin/dominique-BindingDialog
[Mac] Initial Binding Editor Dialog.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs31
1 files changed, 30 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
index 5768136..90ca577 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using AppKit;
using CoreGraphics;
using Xamarin.PropertyEditing.ViewModels;
@@ -19,12 +20,16 @@ namespace Xamarin.PropertyEditing.Mac
set {
if (this.viewModel != null) {
this.viewModel.PropertyChanged -= OnPropertyChanged;
+ if (this.viewModel.SupportsBindings)
+ this.viewModel.CreateBindingRequested -= OnBindingRequested;
}
this.viewModel = value;
if (this.viewModel != null) {
this.viewModel.PropertyChanged += OnPropertyChanged;
+ if (this.viewModel.SupportsBindings)
+ this.viewModel.CreateBindingRequested += OnBindingRequested;
ValueSourceChanged (this.viewModel.ValueSource);
}
@@ -113,10 +118,22 @@ namespace Xamarin.PropertyEditing.Mac
this.popUpContextMenu.AddItem (mi2);
}
+ if (this.viewModel.SupportsBindings) {
+ this.popUpContextMenu.AddItem (NSMenuItem.SeparatorItem);
+
+ this.popUpContextMenu.AddItem (new CommandMenuItem (Properties.Resources.CreateDataBindingMenuItem, this.viewModel.RequestCreateBindingCommand) {
+ AttributedTitle = new Foundation.NSAttributedString (
+ Properties.Resources.CreateDataBindingMenuItem,
+ new CoreText.CTStringAttributes {
+ Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
+ })
+ });
+ }
+
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) {
+ this.popUpContextMenu.AddItem (new CommandMenuItem (Properties.Resources.Reset, this.viewModel.ClearValueCommand) {
AttributedTitle = new Foundation.NSAttributedString (
Properties.Resources.Reset,
new CoreText.CTStringAttributes {
@@ -242,5 +259,17 @@ namespace Xamarin.PropertyEditing.Mac
resourceSelectorPopOver.Show (requestResourceView.Frame, (NSView)this, NSRectEdge.MinYEdge);
}
+
+ private void OnBindingRequested (object sender, CreateBindingRequestedEventArgs e)
+ {
+ var bindingEditorWindow = new BindingEditorWindow (this.hostResources, this.viewModel) {
+ Appearance = EffectiveAppearance,
+ };
+
+ var result = (NSModalResponse)(int)NSApplication.SharedApplication.RunModalForWindow (bindingEditorWindow);
+ if (result == NSModalResponse.OK) {
+ e.BindingObject = bindingEditorWindow.ViewModel.SelectedObjects.Single ();
+ }
+ }
}
}