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:
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 ();
+ }
+ }
}
}