public void AddCommandBindings(UIElement host, SupportedPropertyCommands supportedCommands) { host.SetValue(ExpressionPropertyValueEditorCommands.ExpressionPropertyValueEditorCommandsProperty, (object)new ExpressionPropertyValueEditorCommands() { BeginTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnBeginTransaction(obj))), CommitTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnCommitTransaction(obj))), AbortTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnAbortTransaction(obj))) }); if ((supportedCommands & SupportedPropertyCommands.Transactions) == SupportedPropertyCommands.Transactions) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_BeginTransaction(), new ExecutedRoutedEventHandler(this.OnBeginTransaction))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_CommitTransaction(), new ExecutedRoutedEventHandler(this.OnCommitTransaction))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_AbortTransaction(), new ExecutedRoutedEventHandler(this.OnAbortTransaction))); } if ((supportedCommands & SupportedPropertyCommands.DialogEditor) == SupportedPropertyCommands.DialogEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyContainer.get_OpenDialogWindow(), new ExecutedRoutedEventHandler(this.OnOpenDialogWindow), new CanExecuteRoutedEventHandler(this.OnCanOpenDialogWindow))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowDialogEditor(), new ExecutedRoutedEventHandler(this.OnShowDialogEditor))); } if ((supportedCommands & SupportedPropertyCommands.PinnedEditor) == SupportedPropertyCommands.PinnedEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowExtendedPinnedEditor(), new ExecutedRoutedEventHandler(this.OnShowExtendedPinnedEditor))); } if ((supportedCommands & SupportedPropertyCommands.PopupEditor) == SupportedPropertyCommands.PopupEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowExtendedPopupEditor(), new ExecutedRoutedEventHandler(this.OnShowExtendedPopupEditor))); } host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowInlineEditor(), new ExecutedRoutedEventHandler(this.OnShowInlineEditor))); host.SetValue(PropertyEditingHelper.SupportedPropertyCommandsProperty, (object)supportedCommands); }
public virtual void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { this.activeDialog = (Dialog) new DialogValueEditorHost(propertyValue, this.template); ValueEditorUtils.SetHandlesCommitKeys((DependencyObject)this.activeDialog, true); Type genericCollectionType = CollectionAdapterDescription.GetGenericCollectionType(propertyValue.get_ParentProperty().get_PropertyType()); string str = ""; if (genericCollectionType != (Type)null) { str = genericCollectionType.Name + " "; } this.activeDialog.Title = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.CollectionEditorDialogTitle, new object[2] { (object)str, (object)propertyValue.get_ParentProperty().get_PropertyName() }); this.activeDialog.ResizeMode = ResizeMode.CanResize; this.activeDialog.Width = 600.0; this.activeDialog.Height = 600.0; this.activeDialog.SizeToContent = SizeToContent.Manual; this.activeDialog.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_FinishEditing(), new ExecutedRoutedEventHandler(this.OnPropertyValueFinishEditingCommand))); PropertyValueEditorCommands.get_BeginTransaction().Execute((object)new PropertyTransactionParameters() { TransactionDescription = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1] { (object)propertyValue.get_ParentProperty().get_PropertyName() }), TransactionType = SceneEditTransactionType.Normal }, commandSource); bool?nullable = new bool?(); try { nullable = this.activeDialog.ShowDialog(); } catch { this.messageDisplayService.ShowError(StringTable.CollectionEditorErrorMessage); this.activeDialog.Close(); } if (nullable.HasValue && nullable.Value) { PropertyValueEditorCommands.get_CommitTransaction().Execute(null, commandSource); } else { PropertyValueEditorCommands.get_AbortTransaction().Execute(null, commandSource); } }
private void ReverseGradientStopsHandler() { PropertyValueEditorCommands.get_BeginTransaction().Execute((object)null, (IInputElement)this.BrushEditor); if (!this.BasisProperty.IsValueLocal) { this.BasisProperty.DoSetLocalValue(); } Dictionary <double, List <GradientStopEditor> > dictionary = new Dictionary <double, List <GradientStopEditor> >(); foreach (GradientStopEditor gradientStopEditor in (IEnumerable)this.GradientStops) { if (!dictionary.ContainsKey(gradientStopEditor.Offset)) { dictionary.Add(gradientStopEditor.Offset, new List <GradientStopEditor>()); } dictionary[gradientStopEditor.Offset].Add(gradientStopEditor); } SceneNodeObjectSet sceneNodeObjectSet = this.BasisProperty.SceneNodeObjectSet; foreach (KeyValuePair <double, List <GradientStopEditor> > keyValuePair in dictionary) { double key = keyValuePair.Key; List <GradientStopEditor> list = keyValuePair.Value; bool flag = list.Count > 1; bool isMixed = false; for (int index = 0; index < list.Count; ++index) { list[index].Offset = RoundingHelper.RoundScale(1.0 - key); if (flag && index < list.Count / 2) { GradientStopEditor gradientStopEditor1 = list[index]; GradientStopEditor gradientStopEditor2 = list[list.Count - 1 - index]; DocumentNode valueAsDocumentNode1 = gradientStopEditor1.ColorProperty.GetLocalValueAsDocumentNode(false, out isMixed); DocumentNode valueAsDocumentNode2 = gradientStopEditor2.ColorProperty.GetLocalValueAsDocumentNode(false, out isMixed); gradientStopEditor1.ColorProperty.SetValue((object)valueAsDocumentNode2); gradientStopEditor2.ColorProperty.SetValue((object)valueAsDocumentNode1); } } } PropertyValueEditorCommands.get_CommitTransaction().Execute((object)null, (IInputElement)this.BrushEditor); this.RebuildModel(-1); }