protected virtual void ToggleCalendar(object sender, ExecutedRoutedEventArgs e) { calDatePopup.IsOpen = true; //Mouse.Capture(mdpDate, CaptureMode.None); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(calDatePopup, new MouseButtonEventHandler(mdpDate_PreviewMouseDownOutsideCapturedElement)); System.Diagnostics.Debug.WriteLine("ToggleCalendarAction"); }
private void OpenOrClose() { if (!_isBound) { return; } if (IsOpen) { if (!StaysOpen) { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnLostMouseCapture); Mouse.Capture(this, CaptureMode.SubTree); } } switch (Placement) { case DrawerPlacement.Left: case DrawerPlacement.Right: if (double.IsPositiveInfinity(MaxWidth)) { return; } AnimationUtil.BeginDoubleAnimation(this, WidthProperty, double.IsNaN(Width) ? 0 : Width, IsOpen ? (MaxWidth - ShadowHelper.GetBlurRadius(this)) : MinWidth, IsLoaded ? AnimationDuration : TimeSpan.Zero, null, AnimationEase); break; default: if (double.IsPositiveInfinity(MaxHeight)) { throw new Exception("Drawer.MaxHeight must have a ensured value."); } AnimationUtil.BeginDoubleAnimation(this, HeightProperty, double.IsNaN(Height) ? 0 : Height, IsOpen ? (MaxHeight - ShadowHelper.GetBlurRadius(this)) : MinHeight, IsLoaded ? AnimationDuration : TimeSpan.Zero, null, AnimationEase);; break; } }
public DropDownButton() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); //case 166525 : Do no inherit an implicit style of Button this.InheritanceBehavior = InheritanceBehavior.SkipToThemeNow; }
/// <summary> /// Walk the visual tree to find the ItemsControl and /// hook into some of its events. This is done to make /// sure that editing is cancelled whenever /// /// 1> The parent control is scrolling its content /// 1.1> The MouseWheel is used /// 2> A user clicks outside the adorner control /// 3> The parent control changes its size /// /// </summary> private void HookItemsControlEvents() { if (_PART_MeasureTextBlock == null) { return; } _TextBox = new TextBox(); _Adorner = new EditBoxAdorner(_PART_MeasureTextBlock, _TextBox, this); AdornerLayer layer = AdornerLayer.GetAdornerLayer(_PART_MeasureTextBlock); if (layer == null) // This layer does not always seem to be available? { return; } layer.Add(_Adorner); // try to get the text box focused when layout finishes. _TextBox.LayoutUpdated += new EventHandler(this.OnTextBoxLayoutUpdated); CaptureMouse(); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideElement); _TextBox.PreviewTextInput += OnPreviewTextInput; _TextBox.KeyDown += new KeyEventHandler(this.OnTextBoxKeyDown); _TextBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OnTextBoxLostKeyboardFocus); _TextBox.LostFocus += new RoutedEventHandler(this.OnLostFocus); _ParentItemsControl = this.GetDpObjectFromVisualTree(this, typeof(ItemsControl)) as ItemsControl; Debug.Assert(_ParentItemsControl != null, "DEBUG ISSUE: No FolderTreeView found."); if (_ParentItemsControl != null) { // Handle events on parent control and determine whether to switch to Normal mode or stay in editing mode _ParentItemsControl.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(this.OnScrollViewerChanged)); _ParentItemsControl.AddHandler(ScrollViewer.MouseWheelEvent, new RoutedEventHandler((s, e) => this.OnSwitchToNormalMode()), true); _ParentItemsControl.MouseDown += new MouseButtonEventHandler((s, e) => this.OnSwitchToNormalMode()); _ParentItemsControl.SizeChanged += new SizeChangedEventHandler((s, e) => this.OnSwitchToNormalMode()); // Restrict text box to visible area of scrollviewer this.ParentScrollViewer = this.GetDpObjectFromVisualTree(_ParentItemsControl, typeof(ScrollViewer)) as ScrollViewer; if (this.ParentScrollViewer == null) { this.ParentScrollViewer = FindVisualChild <ScrollViewer>(_ParentItemsControl); } Debug.Assert(this.ParentScrollViewer != null, "DEBUG ISSUE: No ScrollViewer found."); if (this.ParentScrollViewer != null) { _TextBox.MaxWidth = this.ParentScrollViewer.ViewportWidth; } } }
public ColorPickerDropDown() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OutsideControl_Click); Keyboard.AddKeyDownHandler(this, OutsideControl_KeyDown); AddHandler(ColorPickerDropDown.MouseLeaveEvent, new RoutedEventHandler(DropDown_MouseLeave)); }
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnPreviewMouseLeftButtonDown(e); sb_PopDetail.Begin(); Mouse.Capture(this); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, new MouseButtonEventHandler(MouseDownOutSide)); }
public DropDownButton() { Keyboard.AddKeyDownHandler(this, this.OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, this.OnMouseDownOutsideCapturedElement); this.mVisibilityTimer = new Timer(); this.mVisibilityTimer.Elapsed += this.OnVisibilityTimerElapsed; this.mVisibilityTimer.AutoReset = false; }
public AboutWindow() { InitializeComponent(); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, (s, e) => { this.Close(); }); CenterWindowOnScreen(); }
public ColorPickerDialog() { InitializeComponent(); this.DataContext = this; Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, (s, e) => { this.CloseDialog(); }); CenterWindowOnScreen(); }
} // proc LoadInternAsync /// <summary>Control is created.</summary> protected virtual void OnControlCreated() { CallMemberDirect(nameof(OnControlCreated), Array.Empty <object>(), rawGet: true, ignoreNilFunction: true); Mouse.AddPreviewMouseDownHandler(Control, Control_MouseDownHandler); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(Control, Control_MouseDownHandler); Keyboard.AddPreviewGotKeyboardFocusHandler(Control, Control_GotKeyboardFocusHandler); Keyboard.AddPreviewLostKeyboardFocusHandler(Control, Control_LostKeyboardFocusHandler); Keyboard.AddPreviewKeyUpHandler(Control, Control_KeyUpHandler); } // proc OnControlCreated
private void GetMouseCapture(FrameworkElement el) { if (el != null && Mouse.Captured != el) { el.IsMouseCaptureWithinChanged -= _IsMouseCapturedChanged; Mouse.Capture(el, CaptureMode.SubTree); Mouse.RemovePreviewMouseDownOutsideCapturedElementHandler(el, PreviewMouseDownOutsideCapturedElement); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(el, PreviewMouseDownOutsideCapturedElement); el.IsMouseCaptureWithinChanged += _IsMouseCapturedChanged; } }
public MenuControl() { MainLevel = new MainMenuControlSubElement(); MainLevel.Glyph = new DXImageGrayscaleExtension() { Image = new DXImageGrayscaleConverter().ConvertFrom("Home_16x16.png") as DXImageInfo }.ProvideValue(null) as ImageSource; Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseOutside); levels.Push(MainLevel); IsRootLevel = true; }
public ColorPicker() { #if VS2008 this.RecentColors = new ObservableCollection <ColorItem>(); #else this.SetCurrentValue(ColorPicker.RecentColorsProperty, new ObservableCollection <ColorItem>()); #endif Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public OverflowButton() { InitializeComponent(); // Set the data context for binding ContainerGrid.DataContext = this; // Add a preview mouse down outside captured element handler Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OutsideCapturedElementHandler); Loaded += (s, e) => ParentScrollViewer = this.FindParent <ScrollViewer>(); }
public DropDown() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, CapturedMouse_Click); Mouse.AddPreviewMouseMoveHandler(this, CapturedMouse_Move); Keyboard.AddKeyDownHandler(this, CapturedKeyboard_KeyDown); AddHandler(DropDown.MouseLeaveEvent, new RoutedEventHandler(PopUp_MouseLeave)); InitializeDelegateDictionary(); }
public CalculatorUpDown() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public ColorPickerDropDown() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OutsideControlClick); }
void PopupOpened(object sender, EventArgs e) { Mouse.Capture(this, CaptureMode.SubTree); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OutsideCapturedElementHandler); }
public DateTimePicker() { AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(OnKeyDown), true); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public DateTimePicker() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public CheckComboBox() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); _displayMemberPathValuesChangeHelper = new ValueChangeHelper(this.OnDisplayMemberPathValuesChanged); }
public MultiLineTextEditor() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
//----------------------------------------------------------------------- public MultilineTextEditor() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public ColorPicker() { RecentColors = new ObservableCollection <ColorItem>(); Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public SplitButton() { // maybe later //Keyboard.AddKeyDownHandler(this, this.OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, this.OutsideCapturedElementHandler); }
protected TimePickerBase() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, this.OutsideCapturedElementHandler); }
public DropDownButton() { Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public CheckComboBox() { Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public TimePicker() { DateTimeFormatInfo = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture); Keyboard.AddKeyDownHandler(this, OnKeyDown); Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }
public PopupSelector() { Member = "Item.Name"; VerticalAlignment = VerticalAlignment.Center; Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); }