Esempio n. 1
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)
 {
     ExecuteCommand();
     IsSelected = true;
     PopupService.RaiseDismissPopupEvent(sender, DismissPopupMode.Always);
     e.Handled = true;
 }
Esempio n. 2
0
        // Window's messages hook up
        private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
#pragma warning disable 618
            var message = (WM)msg;

            // We must terminate the keytip's adorner chain if:
            if (message == WM.NCACTIVATE || // mouse clicks in non client area
                (message == WM.ACTIVATE && wParam == IntPtr.Zero) || // the window is deactivated
                (message >= WM.NCLBUTTONDOWN && message <= WM.NCXBUTTONDBLCLK) || // mouse click (non client area)
                (message >= WM.LBUTTONDOWN && message <= WM.MBUTTONDBLCLK))    // mouse click
            {
                if (this.activeAdornerChain?.IsAdornerChainAlive == true)
                {
                    this.Terminate();
                }
            }

            // Fix for #632.
            // Yes this looks awkward, calling the PopupService here, but the alternative would be to let the PopupService know about windows.
            if (message == WM.ACTIVATE &&
                wParam == IntPtr.Zero)    // the window is deactivated
            {
                PopupService.RaiseDismissPopupEvent(this.ribbon, DismissPopupMode.Always, DismissPopupReason.ApplicationLostFocus);
                PopupService.RaiseDismissPopupEvent(Mouse.Captured, DismissPopupMode.Always, DismissPopupReason.ApplicationLostFocus);
                PopupService.RaiseDismissPopupEvent(Keyboard.FocusedElement, DismissPopupMode.Always, DismissPopupReason.ApplicationLostFocus);
            }
#pragma warning restore 618

            return(IntPtr.Zero);
        }
Esempio n. 3
0
        private void OnListBoxSelectedChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.isSelectionChanging)
            {
                return;
            }

            this.isSelectionChanging = true;

            if (e.AddedItems != null &&
                e.AddedItems.Count > 0)
            {
                // Remove selection from others
                this.noColorButton.IsChecked   = false;
                this.automaticButton.IsChecked = false;

                foreach (var listBox in this.listBoxes)
                {
                    if (ReferenceEquals(listBox, sender) == false)
                    {
                        listBox.SelectedItem = null;
                    }
                }

                this.SelectedColor = (Color)e.AddedItems[0];
                PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
            }

            this.isSelectionChanging = false;
        }
Esempio n. 4
0
        private void OnPopupDismiss(object sender, DismissPopupEventArgs e)
        {
            var backstage = LogicalTreeHelper.GetParent(this);

            if (backstage != null)
            {
                PopupService.RaiseDismissPopupEvent(backstage, DismissPopupMode.Always);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Called when a <see cref="T:System.Windows.Controls.Button"/> is clicked.
 /// </summary>
 protected override void OnClick()
 {
     // Close popup on click
     if (IsDefinitive)
     {
         PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
     }
     base.OnClick();
 }
Esempio n. 6
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.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
            }

            base.OnClick();
        }
Esempio n. 7
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)
        {
            // Close popup on click
            if (this.IsDefinitive)
            {
                PopupService.RaiseDismissPopupEvent(sender, DismissPopupMode.Always);
            }

            this.ExecuteCommand();
            this.IsSelected = true;
            e.Handled       = true;
        }
Esempio n. 8
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 (((State == RibbonGroupBoxState.Collapsed) || (State == RibbonGroupBoxState.QuickAccess)) && (popup != null))
     {
         e.Handled = true;
         if (!IsDropDownOpen)
         {
             IsDropDownOpen = true;
         }
         else
         {
             PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.MouseNotOver);
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Called when a <see cref="T:System.Windows.Controls.Button"/> is clicked.
        /// </summary>
        protected override void OnClick()
        {
            // Close popup on click
            //if ((IsDefinitive)&&(!HasItems)) PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);

            /*if (HasItems && IsSplited)
             * {
             *  Border buttonBorder = GetTemplateChild("PART_ButtonBorder") as Border;
             *  if ((buttonBorder != null) && (buttonBorder.IsMouseOver))
             *  {
             *      if (IsDefinitive) PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
             *  }
             * }
             * else */
            if ((IsDefinitive) && (!HasItems || IsSplited))
            {
                PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
            }
            base.OnClick();
        }
Esempio n. 10
0
        /// <inheritdoc />
        protected override void OnClick()
        {
            // Close popup on click
            if (this.IsDefinitive)
            {
                PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
            }

            // fix for #481
            // We can't overwrite OnToggle because it's "internal protected"...
            if (string.IsNullOrEmpty(this.GroupName) == false)
            {
                // Only forward click if button is not checked to prevent wrong bound values
                if (this.IsChecked == false)
                {
                    base.OnClick();
                }
            }
            else
            {
                base.OnClick();
            }
        }
Esempio n. 11
0
 private void OnListBoxSelectedChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.isSelectionChanging)
     {
         return;
     }
     this.isSelectionChanging = true;
     if (e.AddedItems != null && e.AddedItems.Count > 0)
     {
         // Remove selection from others
         this.noColorButton.IsChecked   = false;
         this.automaticButton.IsChecked = false;
         for (int i = 0; i < this.listBoxes.Count; i++)
         {
             if (this.listBoxes[i] != sender)
             {
                 this.listBoxes[i].SelectedItem = null;
             }
         }
         this.SelectedColor = (Color)e.AddedItems[0];
         PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.Always);
     }
     this.isSelectionChanging = false;
 }
Esempio n. 12
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(System.Windows.Input.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.RaiseDismissPopupEvent(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;
                }));
            }
        }
Esempio n. 13
0
 private void ClosePopups()
 {
     PopupService.RaiseDismissPopupEvent(Keyboard.FocusedElement, DismissPopupMode.Always);
 }
Esempio n. 14
0
 private void ClosePopups()
 {
     PopupService.RaiseDismissPopupEvent(Keyboard.FocusedElement, DismissPopupMode.Always, DismissPopupReason.ShowingKeyTips);
 }