protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (!this.isLeftButtonDown || !this.IsSelected) { return; } Point position = e.MouseDevice.GetPosition((IInputElement)null); if (position == this.previousAbsoluteMousePosition) { return; } this.previousAbsoluteMousePosition = position; if (!this.haveMoved) { this.haveMoved = true; ValueEditorUtils.ExecuteCommand((ICommand)this.GetValue(TimelineSlider.SlideBeginCommandProperty), (IInputElement)this, (object)null); this.autoScrollTimer = TimelineView.CreateAutoScrollTimer(); this.autoScrollTimer.Tick += new EventHandler(this.AutoScrollTimer_Tick); this.autoScrollTimer.Start(); } this.Value = this.ComputeValueFromPosition(e.MouseDevice.GetPosition(this.GetReferenceElement())); ValueEditorUtils.ExecuteCommand((ICommand)this.GetValue(TimelineSlider.SlideCommandProperty), (IInputElement)this, (object)null); this.BringIntoView(this.viewRect); }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); Point position = e.MouseDevice.GetPosition((IInputElement)this); if (this.controlPoint1Editor.HitTest(position.X, position.Y)) { this.activePointEditor = this.controlPoint1Editor; } if (this.controlPoint2Editor.HitTest(position.X, position.Y)) { this.activePointEditor = this.controlPoint2Editor; } if (this.activePointEditor == null) { return; } if (!this.CaptureMouse()) { this.activePointEditor = (ControlPointEditor)null; } else { ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, null); } }
// <summary> // Basic ctor // </summary> // <param name="property">Property to display</param> // <param name="valueDialogTemplate">Template to use</param> public PropertyValueDialogControl(PropertyEntry property, DataTemplate valueDialogTemplate) { Fx.Assert(property != null, "property parameter is null"); Fx.Assert(valueDialogTemplate != null, "valueDialogTemplate parameter is null"); ModelPropertyEntry modelPropertyValue = property as ModelPropertyEntry; if (modelPropertyValue != null) { _rootTransaction = modelPropertyValue.FirstModelProperty.Value.BeginEdit(); } InitializeComponent(); // Make sure we use PI-specific resources within this control this.Resources.MergedDictionaries.Add(PropertyInspectorResources.GetResources()); // Hook into an opening of nested dialogs. PropertyInspector class takes care of this for us. // However, we are using Blend's collection editor which doesn't do the same thing, so // we need to reproduce that behavior manually. PropertyValueDialogHost.AttachOpenDialogHandlers(this); // Hook into the standard set of Commands _defaultCommandHandler = new PropertyValueEditorCommandHandler(this); _OKButton.Click += new RoutedEventHandler(OnOkButtonClicked); _cancelButton.Click += new RoutedEventHandler(OnCancelButtonClicked); _contentControl.Content = property.PropertyValue; _contentControl.ContentTemplate = valueDialogTemplate; //Handle the commit and cancel keys within the property inspector, that is hosted in the collection editor ValueEditorUtils.SetHandlesCommitKeys(this, true); }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnMouseLeftButtonUp(e); if (!this.isLeftButtonDown) { return; } ICommand command = (ICommand)null; this.isLeftButtonDown = false; e.MouseDevice.Capture((IInputElement)null); if (this.IsSelected && this.haveMoved && this.autoScrollTimer != null) { this.autoScrollTimer.Stop(); this.autoScrollTimer.Tick -= new EventHandler(this.AutoScrollTimer_Tick); this.autoScrollTimer = (DispatcherTimer)null; command = this.SlideEndCommand; } else if (!this.haveMoved) { if (this.selectOnMouseUp) { command = this.SelectCommand; } else if (this.toggleOnMouseUp) { command = this.ToggleSelectCommand; } } ValueEditorUtils.ExecuteCommand(command, (IInputElement)this, (object)null); }
private void CommitEditing() { if (!this.isCapturing) { return; } ValueEditorUtils.ExecuteCommand(this.EndEditCommand, (IInputElement)this, (object)null); this.FinishEditing(); }
protected override void CancelEditing() { if (!this.isCapturing) { return; } ValueEditorUtils.ExecuteCommand(this.CancelEditCommand, (IInputElement)this, (object)null); this.FinishEditing(); }
private void CoreUpdateColor() { Color pixelColor = ColorEyedropperBase.GetPixelColor(this.currentPoint.x, this.currentPoint.y); if (this.Color != pixelColor) { this.Color = pixelColor; ValueEditorUtils.ExecuteCommand(this.ContinueEditCommand, this, null); } }
private void FinishEditing() { InputManager.Current.PostNotifyInput -= new NotifyInputEventHandler(this.Current_PostNotifyInput); this.Cursor = (Cursor)null; this.isCapturing = false; this.ReleaseMouseCapture(); this.CloseFeedbackWindow(); this.ShowColorEditorTrack(true); ValueEditorUtils.ExecuteCommand(this.FinishEditingCommand, (IInputElement)this, (object)null); }
private void FinishEditing(bool commit) { this.isButtonDown = false; InputManager.Current.PostNotifyInput -= new NotifyInputEventHandler(this.Current_PostNotifyInput); ValueEditorUtils.ExecuteCommand(commit ? this.EndEditCommand : this.CancelEditCommand, (IInputElement)this, (object)null); if (!this.IsMouseCaptured) { return; } this.ReleaseMouseCapture(); }
internal EditResourceDialog(DesignerContext designerContext) { this.designerContext = designerContext; this.Title = StringTable.EditResourceDialogTitle; this.transactionHelper = new PropertyEditingHelper((UIElement)this); this.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.FinishEditing, new ExecutedRoutedEventHandler(this.OnPropertyContainerCommandsFinishEditing))); PropertyInspectorHelper.SetOwningPropertyInspectorModel((DependencyObject)this, (IPropertyInspector)this); PropertyInspectorHelper.SetOwningPropertyInspectorElement((DependencyObject)this, (UIElement)this); ValueEditorUtils.SetHandlesCommitKeys((DependencyObject)this, true); this.InitializeComponent(); }
private void FinishEditing() { this.isButtonDown = false; this.isEditing = false; this.isDragging = false; this.aboutToCommit = false; this.ShowColorEditorTrack(true); this.CloseFeedbackWindow(); this.ReleaseMouseCapture(); ValueEditorUtils.ExecuteCommand(this.FinishEditingCommand, (IInputElement)this, (object)null); }
protected override void CancelEditing() { if (this.aboutToCommit || !this.isEditing) { return; } this.isEditing = false; this.ClearFeedback(); ValueEditorUtils.ExecuteCommand(this.CancelEditCommand, (IInputElement)this, (object)null); this.FinishEditing(); }
internal Dialog(Window parent) { base.WindowStartupLocation = (parent.WindowState != WindowState.Maximized ? WindowStartupLocation.CenterOwner : WindowStartupLocation.CenterScreen); base.ShowInTaskbar = false; if (parent != null) { base.Owner = parent; } base.SnapsToDevicePixels = true; TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); ValueEditorUtils.SetHandlesCommitKeys(this, false); }
private bool Update(Point pointerPosition, MultiSlider.SequencePosition sequencePosition) { if (sequencePosition == MultiSlider.SequencePosition.First) { if (pointerPosition.X < -2.0 || (pointerPosition.X > this.RenderSize.Width + 2.0 || pointerPosition.Y < -2.0) || pointerPosition.Y > this.RenderSize.Height + 2.0) { return(false); } } else if (pointerPosition.Y > this.RenderSize.Height + 16.0) { if (!this.haveRemovedThumb && MultiSlider.DragOff.CanExecute((object)null, (IInputElement)this) && this.Items.Count > this.MinimumItemCount) { MultiSlider.DragOff.Execute((object)null, (IInputElement)this); this.haveRemovedThumb = true; } if (this.haveRemovedThumb) { return(true); } } double minimum = this.Minimum; double maximum = this.Maximum; double num1 = pointerPosition.X / this.ActualWidth; double num2 = Math.Round(Math.Min(maximum, Math.Max(minimum, minimum + num1 * (maximum - minimum))), 3); if (sequencePosition == MultiSlider.SequencePosition.First) { ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null); if (MultiSlider.Click.CanExecute((object)num2, (IInputElement)this)) { MultiSlider.Click.Execute((object)num2, (IInputElement)this); } } else if (this.haveRemovedThumb) { if (MultiSlider.DragOn.CanExecute((object)null, (IInputElement)this)) { MultiSlider.DragOn.Execute((object)null, (IInputElement)this); } this.haveRemovedThumb = false; } if (sequencePosition == MultiSlider.SequencePosition.Middle) { MultiSliderThumb multiSliderThumb = this.ItemContainerGenerator.ContainerFromItem(this.SelectedItem) as MultiSliderThumb; if (multiSliderThumb != null && multiSliderThumb.SliderValue != num2) { multiSliderThumb.SliderValue = num2; ValueEditorUtils.ExecuteCommand(this.ContinueEditCommand, (IInputElement)this, (object)null); } } return(true); }
private void AutoScrollTimer_Tick(object sender, EventArgs e) { double valueFromPosition = this.ComputeValueFromPosition(InputManager.Current.PrimaryMouseDevice.GetPosition(this.GetReferenceElement())); if (this.Value == valueFromPosition) { return; } this.Value = valueFromPosition; ValueEditorUtils.ExecuteCommand((ICommand)this.GetValue(TimelineSlider.SlideCommandProperty), (IInputElement)this, (object)null); this.BringIntoView(this.viewRect); }
public PropertyInspector() { this.DataContext = this; HookIntoCommands(); this.InitializeComponent(); //Handle the commit and cancel keys within the property inspector ValueEditorUtils.SetHandlesCommitKeys(this, true); _propertyToolBar.CurrentViewManagerChanged += new EventHandler(OnCurrentViewManagerChanged); }
private void BeginEditing() { this.isEditing = this.CaptureMouse(); if (!this.isEditing) { return; } ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null); Mouse.OverrideCursor = ValueEditorCursors.EyedropperCursor; this.ShowColorEditorTrack(false); InputManager.Current.PostNotifyInput += new NotifyInputEventHandler(this.Current_PostNotifyInput); this.OpenFeedbackWindow(); }
public override void ShowDialog(Microsoft.Windows.Design.PropertyEditing.PropertyValue propertyValue, IInputElement commandSource) { this.activeDialog = (Dialog) new DialogValueEditorHost(propertyValue, this.template); ValueEditorUtils.SetHandlesCommitKeys((DependencyObject)this.activeDialog, true); Type genericCollectionType = CollectionAdapterDescription.GetGenericCollectionType(propertyValue.ParentProperty.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.ParentProperty.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.FinishEditing, new ExecutedRoutedEventHandler(this.OnPropertyValueFinishEditingCommand))); PropertyValueEditorCommands.BeginTransaction.Execute((object)new PropertyTransactionParameters() { TransactionDescription = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1] { (object)propertyValue.ParentProperty.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.CommitTransaction.Execute((object)null, commandSource); } else { PropertyValueEditorCommands.AbortTransaction.Execute((object)null, commandSource); } }
protected override void OnMouseMove(MouseEventArgs e) { if (this.isButtonDown && !this.isDragging) { this.GetPosition(); if ((double)Math.Abs(this.startPoint.x - this.endPoint.x) > SystemParameters.MinimumHorizontalDragDistance || (double)Math.Abs(this.startPoint.y - this.endPoint.y) > SystemParameters.MinimumVerticalDragDistance) { this.isDragging = true; this.CancelUpdateColor(); ValueEditorUtils.ExecuteCommand(this.CancelEditCommand, (IInputElement)this, (object)null); ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null); } } base.OnMouseMove(e); }
private void Thumb_OnPointerButtonDown(object sender, MouseButtonEventArgs args) { this.lastMousePosition = args.MouseDevice.GetPosition((IInputElement)this); MultiSliderThumb thumb = sender as MultiSliderThumb; if (args.ChangedButton != MouseButton.Left || thumb == null) { return; } this.Focus(); this.haveRemovedThumb = false; this.SelectedIndex = this.ElementIndex(thumb); ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null); InputManager.Current.PostNotifyInput += new NotifyInputEventHandler(this.Current_PostNotifyInput); this.isButtonDown = true; args.MouseDevice.Capture((IInputElement)this); args.Handled = true; }
private void CompleteGradient() { this.isButtonDown = false; this.aboutToCommit = true; this.GetPosition(); this.ClearFeedback(); Mouse.OverrideCursor = Cursors.Wait; Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Loaded, (Delegate)(o => { if (this.isDragging) { this.UpdateGradient(this.startPoint, this.endPoint); } ValueEditorUtils.ExecuteCommand(this.EndEditCommand, (IInputElement)this, (object)null); this.FinishEditing(); Mouse.OverrideCursor = (Cursor)null; return((object)null); }), (object)null); }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (!this.isLeftButtonDown) { ValueEditorUtils.UpdateBinding((FrameworkElement)this, TimelineSlider.ValueProperty, UpdateBindingType.Target); e.MouseDevice.Capture((IInputElement)this); this.isLeftButtonDown = true; this.originalMousePosition = e.MouseDevice.GetPosition(this.GetReferenceElement()); this.originalValue = this.Value; this.haveMoved = false; this.previousAbsoluteMousePosition = e.MouseDevice.GetPosition((IInputElement)null); this.viewRect = new Rect(e.MouseDevice.GetPosition((IInputElement)this).X - 3.0, 0.0, 6.0, this.ActualHeight); this.toggleOnMouseUp = false; this.selectOnMouseUp = false; ICommand command = (ICommand)null; if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { command = this.ExtendSelectCommand; } else if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None) { if (!this.IsSelected) { command = this.ExtendSelectCommand; } else { this.toggleOnMouseUp = true; } } else if (this.IsSelected) { this.selectOnMouseUp = true; } else { command = this.SelectCommand; } ValueEditorUtils.ExecuteCommand(command, (IInputElement)this, (object)null); } e.Handled = true; }
private void ColorModel_CancelEdit() { ValueEditorUtils.ExecuteCommand(this.CancelEditCommand, (IInputElement)this, (object)null); }
private void ColorModel_EndEdit() { ValueEditorUtils.ExecuteCommand(this.EndEditCommand, (IInputElement)this, (object)null); this.colorEditorModel.SetLastColorModel(); }
void Finish() { ValueEditorUtils.ExecuteCommand(PropertyValueEditorCommands.FinishEditing, this, null); }
private bool Execute(ICommand command) { return(ValueEditorUtils.ExecuteCommand(command, (IInputElement)this, (object)null)); }
protected override void OnLostMouseCapture(MouseEventArgs e) { base.OnLostMouseCapture(e); this.activePointEditor = (ControlPointEditor)null; ValueEditorUtils.ExecuteCommand(this.CommitEditCommand, (IInputElement)this, null); }