RaiseDismissPopupEventAsync() public static method

Raises DismissPopup event (Async)
public static RaiseDismissPopupEventAsync ( object sender, DismissPopupMode mode ) : void
sender object
mode DismissPopupMode
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Called when a <see cref="T:System.Windows.Controls.Button"/> is clicked.
        /// </summary>
        protected override void OnClick()
        {
            // Close popup on click
            if (this.IsDefinitive &&
                (!this.HasItems || this.IsSplited))
            {
                PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.Always);
            }

            var revertIsChecked = false;

            // Rewriting everthing contained in base.OnClick causes a lot of trouble.
            // In case IsCheckable is true and GroupName is not empty we revert the value for IsChecked back to true to prevent unchecking all items in the group
            if (this.IsCheckable &&
                string.IsNullOrEmpty(this.GroupName) == false)
            {
                // If checked revert the IsChecked value back to true after forwarding the click to base
                if (this.IsChecked)
                {
                    revertIsChecked = true;
                }
            }

            base.OnClick();

            if (revertIsChecked)
            {
                this.RunInDispatcherAsync(() => this.SetCurrentValue(IsCheckedProperty, BooleanBoxes.TrueBox), DispatcherPriority.Background);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles click event
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">The event data</param>
        protected virtual void OnClick(object sender, RoutedEventArgs e)
        {
            PopupService.RaiseDismissPopupEventAsync(sender, DismissPopupMode.Always);

            this.ExecuteCommand();
            this.IsSelected = true;
            e.Handled       = true;
        }
Ejemplo n.º 3
0
        private void OnPopupDismiss(object sender, DismissPopupEventArgs e)
        {
            var backstage = LogicalTreeHelper.GetParent(this);

            if (backstage != null)
            {
                PopupService.RaiseDismissPopupEventAsync(backstage, DismissPopupMode.Always);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when a <see cref="T:System.Windows.Controls.Button"/> is clicked.
        /// </summary>
        protected override void OnClick()
        {
            // Close popup on click
            if (this.IsDefinitive)
            {
                PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.Always);
            }

            base.OnClick();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown�routed
        /// event reaches an element in its route that is derived from this class.
        /// Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
        /// The event data reports that the left mouse button was pressed.</param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if ((this.State == RibbonGroupBoxState.Collapsed || this.State == RibbonGroupBoxState.QuickAccess) &&
                popup != null)
            {
                e.Handled = true;

                if (!this.IsDropDownOpen)
                {
                    this.IsDropDownOpen = true;
                }
                else
                {
                    PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.MouseNotOver);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown routed event
        /// reaches an element in its route that is derived from this class. Implement this method to add
        /// class handling for this event.
        /// </summary>
        /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
        /// The event data reports that the left mouse button was pressed.</param>
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (!buttonBorder.IsMouseOver)
            {
                return;
            }

            if (!IsDropDownOpen)
            {
                if (isFirstTime)
                {
                    DropDownPopup.Opacity = 0;
                }

                if (!isFirstTime)
                {
                    IsDropDownOpen = true;
                }
            }
            else
            {
                PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.MouseNotOver);
                IsDropDownOpen = false;
            }

            e.Handled = true;

            if (isFirstTime)
            {
                isFirstTime = false;
                //IsDropDownOpen = false;
                Dispatcher.Invoke(DispatcherPriority.Send, (ThreadStart)(() =>
                {
                    IsDropDownOpen = true;
                    DropDownPopup.Opacity = 1;
                }));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown
        /// event reaches an element in its route that is derived from this class.
        /// Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
        /// The event data reports that the left mouse button was pressed.</param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (ReferenceEquals(e.Source, this) == false ||
                this.DropDownPopup == null)
            {
                return;
            }

            if (this.State == RibbonGroupBoxState.Collapsed ||
                this.State == RibbonGroupBoxState.QuickAccess)
            {
                e.Handled = true;

                if (!this.IsDropDownOpen)
                {
                    this.IsDropDownOpen = true;
                }
                else
                {
                    PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.MouseNotOver);
                }
            }
        }
Ejemplo n.º 8
0
 private void OnListBoxSelectedChanged(object sender, SelectionChangedEventArgs e)
 {
     if (isSelectionChanged)
     {
         return;
     }
     isSelectionChanged = true;
     if (e.AddedItems != null && e.AddedItems.Count > 0)
     {
         // Remove selection from others
         noColorButton.IsChecked   = false;
         automaticButton.IsChecked = false;
         for (int i = 0; i < listBoxes.Count; i++)
         {
             if (listBoxes[i] != sender)
             {
                 listBoxes[i].SelectedItem = null;
             }
         }
         SelectedColor = (Color)e.AddedItems[0];
         PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.Always);
     }
     isSelectionChanged = false;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown routed event
        /// reaches an element in its route that is derived from this class. Implement this method to add
        /// class handling for this event.
        /// </summary>
        /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
        /// The event data reports that the left mouse button was pressed.</param>
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (!buttonBorder.IsMouseOver)
            {
                return;
            }

            if (!IsDropDownOpen)
            {
                if (isFirstTime)
                {
                    DropDownPopup.Opacity = 0;
                }

                if (menuPanel != null)
                {
                    if (scrollViewer != null /* && ResizeMode != ContextMenuResizeMode.None*/)
                    {
                        scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                    }

                    menuPanel.Width   = double.NaN;
                    menuPanel.Height  = double.NaN;// Math.Min(menuPanel.MinHeight, MaxDropDownHeight);
                    menuPanel.Loaded += OnMenuPanelLoaded;
                }

                if (!isFirstTime)
                {
                    IsDropDownOpen = true;
                }
            }
            else
            {
                PopupService.RaiseDismissPopupEventAsync(this, DismissPopupMode.MouseNotOver);
                IsDropDownOpen = false;
            }

            e.Handled = true;

            if (isFirstTime)
            {
                isFirstTime = false;
                //IsDropDownOpen = false;
                Dispatcher.Invoke(DispatcherPriority.Send, (ThreadStart)(() =>
                {
                    if (menuPanel != null)
                    {
                        if (scrollViewer != null /* && ResizeMode != ContextMenuResizeMode.None*/)
                        {
                            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                        }
                        menuPanel.Width = double.NaN;
                        menuPanel.Height = double.NaN;
                        menuPanel.Loaded += OnMenuPanelLoaded;
                    }
                    IsDropDownOpen = true;
                    OnMenuPanelLoaded(null, null);
                    DropDownPopup.Opacity = 1;
                }));
            }
        }