コード例 #1
0
ファイル: GalleryItem.cs プロジェクト: ckimpel/FSE-2011-PDE
 /// <summary>
 /// Handles click event
 /// </summary>
 /// <param name="e">The event data</param>
 protected virtual void OnClick(RoutedEventArgs e)
 {
     ExecuteCommand();
     IsSelected = true;
     RibbonPopup.CloseAll();
     e.Handled = true;
 }
コード例 #2
0
 private void OnMenuClosed(object sender, EventArgs e)
 {
     Scale = savedScale;
     if (quickAccessPopup != popup)
     {
         UIElement element = quickAccessPopup.Child;
         quickAccessPopup.Child = null;
         if (element != null)
         {
             Decorator parent = VisualTreeHelper.GetParent(element) as Decorator;
             if (parent != null) parent.Child = null;
         }
         popup.Child = element;
     }
     Width = double.NaN;
     Height = double.NaN;
     this.State = savedState;
     quickAccessPopup.PlacementTarget = popupPlacementTarget;
     UpdateLayout();
     ((ToggleButton)((Popup)sender).Tag).IsChecked = false;
     quickAccessPopup.Closed -= OnMenuClosed;
     quickAccessPopup = null;
     IsSnapped = false;
     IsOpen = false;
 }
コード例 #3
0
        // Creates ribbon popup and removes original
        // System.Windows.Controls.ContextMenu popup
        void HookupParentPopup()
        {
            popup = new RibbonPopup();
            popup.AllowsTransparency = true;
            //menuBar;

            /*
             * for (int i = 0; i < Items.Count;i++ )
             * {
             *  MenuBar.Items.Add(items[i]);
             * }*/

            Binding binding = new Binding("ResizeMode");

            binding.Mode   = BindingMode.TwoWay;
            binding.Source = this;
            MenuBar.SetBinding(ContextMenuBar.ResizeModeProperty, binding);
            MenuBar.ParentContextMenu = this;
            MenuBar.FlowDirection     = FlowDirection;

            // Preventing ribbon popup closing
            popup.Child = MenuBar;
            popup.HorizontalAlignment = HorizontalAlignment.Left;
            popup.VerticalAlignment   = VerticalAlignment.Top;
            popup.Opened += OnPopupFirstClose;

            popup.Opened += ((sender, args) => RaiseEvent(new RoutedEventArgs(OpenedEvent, this)));
            popup.Closed += ((sender, args) => RaiseEvent(new RoutedEventArgs(ClosedEvent, this)));

            // Set ribbon popup bindings
            CreatePopupRoot(this.popup, this);
        }
コード例 #4
0
 /// <summary>
 /// Invoked when an unhandled System.Windows.Input.Mouse.PreviewMouseWheel 
 /// attached 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.MouseWheelEventArgs that contains the event data.</param>
 protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
 {
     if (RibbonPopup.GetActivePopup() != null)
     {
         return;
     }
     ProcessMouseWheel(e);
     e.Handled = true;
 }
コード例 #5
0
ファイル: RibbonPopup.cs プロジェクト: ckimpel/FSE-2011-PDE
 private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (!(bool)e.NewValue)
     {
         RibbonPopup popup = d as RibbonPopup;
         if (openedPopups.Contains(popup))
         {
             openedPopups.Remove(popup);
         }
     }
 }
コード例 #6
0
 void RestoreFocuses()
 {
     if (backUpFocusedElement != null)
     {
         if (RibbonPopup.GetActivePopup() == null)
         {
             backUpFocusedElement.Focus();
         }
     }
     ribbon.Focusable = false;
 }
コード例 #7
0
ファイル: Gallery.cs プロジェクト: ckimpel/FSE-2011-PDE
        void OnFilterMenuItemClick(object sender, RoutedEventArgs e)
        {
            MenuItem senderItem = (MenuItem)sender;
            MenuItem item       = GetFilterMenuItem(SelectedFilter);

            item.IsChecked       = false;
            senderItem.IsChecked = true;
            SelectedFilter       = senderItem.Tag as GalleryGroupFilter;
            e.Handled            = true;
            RibbonPopup.CollapseCurrent();
        }
コード例 #8
0
ファイル: MenuItem.cs プロジェクト: ckimpel/FSE-2011-PDE
 /// <summary>
 /// Handles before click
 /// </summary>
 /// <param name="args"></param>
 protected override void OnBeforeClick(RoutedEventArgs args)
 {
     base.OnBeforeClick(args);
     if (IsCheckable)
     {
         IsChecked = !IsChecked;
     }
     if (HasItems)
     {
         IsOpen = true;
     }
     else
     {
         RibbonPopup.CloseAll();
     }
 }
コード例 #9
0
ファイル: MenuItem.cs プロジェクト: ckimpel/FSE-2011-PDE
        RibbonPopup FindParentPopup()
        {
            UIElement element = this.Parent as UIElement;

            while (element != null)
            {
                RibbonPopup ribbonPopup = element as RibbonPopup;
                if (ribbonPopup != null)
                {
                    return(ribbonPopup);
                }
                UIElement parent = (UIElement)VisualTreeHelper.GetParent(element);
                if (parent != null)
                {
                    element = parent;
                }
                else
                {
                    element = (UIElement)LogicalTreeHelper.GetParent(element);
                }
            }
            return(null);
        }
コード例 #10
0
        // Set popup bindings
        static void CreatePopupRoot(RibbonPopup popup, UIElement child)
        {
            Binding binding = new Binding("PlacementTarget");

            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.PlacementTargetProperty, binding);
            binding        = new Binding("VerticalOffset");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.VerticalOffsetProperty, binding);
            binding        = new Binding("HorizontalOffset");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.HorizontalOffsetProperty, binding);
            binding        = new Binding("PlacementRectangle");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.PlacementRectangleProperty, binding);
            binding        = new Binding("Placement");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.PlacementProperty, binding);
            binding        = new Binding("StaysOpen");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.StaysOpenProperty, binding);
            binding        = new Binding("CustomPopupPlacementCallback");
            binding.Mode   = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(Popup.CustomPopupPlacementCallbackProperty, binding);
            binding        = new Binding("IsOpen");
            binding.Mode   = BindingMode.TwoWay;
            binding.Source = child;
            popup.SetBinding(Popup.IsOpenProperty, binding);
        }
コード例 #11
0
 // Set popup bindings
 static void CreatePopupRoot(RibbonPopup popup, UIElement child)
 {
     Binding binding = new Binding("PlacementTarget");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.PlacementTargetProperty, binding);
     binding = new Binding("VerticalOffset");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.VerticalOffsetProperty, binding);
     binding = new Binding("HorizontalOffset");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.HorizontalOffsetProperty, binding);
     binding = new Binding("PlacementRectangle");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.PlacementRectangleProperty, binding);
     binding = new Binding("Placement");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.PlacementProperty, binding);
     binding = new Binding("StaysOpen");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.StaysOpenProperty, binding);
     binding = new Binding("CustomPopupPlacementCallback");
     binding.Mode = BindingMode.OneWay;
     binding.Source = child;
     popup.SetBinding(Popup.CustomPopupPlacementCallbackProperty, binding);
     binding = new Binding("IsOpen");
     binding.Mode = BindingMode.TwoWay;
     binding.Source = child;
     popup.SetBinding(Popup.IsOpenProperty, binding);
 }
コード例 #12
0
        // Creates ribbon popup and removes original 
        // System.Windows.Controls.ContextMenu popup
        void HookupParentPopup()
        {            
            popup = new RibbonPopup();
            popup.AllowsTransparency = true;
            //menuBar;            
            /*
            for (int i = 0; i < Items.Count;i++ )
            {
                MenuBar.Items.Add(items[i]);                
            }*/

            Binding binding = new Binding("ResizeMode");
            binding.Mode = BindingMode.TwoWay;
            binding.Source = this;
            MenuBar.SetBinding(ContextMenuBar.ResizeModeProperty, binding);
            MenuBar.ParentContextMenu = this;
            MenuBar.FlowDirection = FlowDirection;

            // Preventing ribbon popup closing
            popup.Child = MenuBar;
            popup.HorizontalAlignment = HorizontalAlignment.Left;
            popup.VerticalAlignment = VerticalAlignment.Top;
            popup.Opened += OnPopupFirstClose;

            popup.Opened += ((sender, args) => RaiseEvent(new RoutedEventArgs(OpenedEvent, this)));
            popup.Closed += ((sender, args) => RaiseEvent(new RoutedEventArgs(ClosedEvent, this)));
        
            // Set ribbon popup bindings
            CreatePopupRoot(this.popup, this);            
        }
コード例 #13
0
 void OnQuickAccessClick(object sender, MouseButtonEventArgs e)
 {
     ToggleButton button = (ToggleButton)sender;
     if ((!IsOpen) && (!IsSnapped))
     {
         if (popup == null)
         {
             // Trying to load control
             RibbonTabItem item = Parent as RibbonTabItem;
             if (item != null)
             {
                 RibbonTabControl tabControl = item.Parent as RibbonTabControl;
                 if (tabControl != null)
                 {
                     RibbonTabItem selectedItem = tabControl.SelectedItem as RibbonTabItem;
                     tabControl.SelectedItem = item;
                     tabControl.UpdateLayout();
                     tabControl.SelectedItem = selectedItem;
                 }
             }
         }
         IsSnapped = true;
         savedState = this.State;
         this.State = RibbonGroupBoxState.Collapsed;
         if (!IsVisible)
         {
             UIElement element = popup.Child;
             popup.Child = null;
             if (element != null)
             {
                 Decorator parent = VisualTreeHelper.GetParent(element) as Decorator;
                 if (parent != null) parent.Child = null;
             }
             quickAccessPopup = new RibbonPopup();
             quickAccessPopup.AllowsTransparency = popup.AllowsTransparency;
             quickAccessPopup.Child = element;
         }
         else quickAccessPopup = popup as RibbonPopup;
         quickAccessPopup.Closed += OnMenuClosed;
         popupPlacementTarget = popup.PlacementTarget;
         quickAccessPopup.PlacementTarget = button;
         quickAccessPopup.Tag = button;
         if (IsVisible)
         {
             Width = ActualWidth;
             Height = ActualHeight;
         }
         savedScale = Scale;
         Scale = -100;
         quickAccessPopup.IsOpen = true;
         RaiseEvent(new RoutedEventArgs(RibbonControl.ClickEvent, this));
         /*
         if (quickAccessPopup.Child != null)
         {
             Decorator parent = VisualTreeHelper.GetParent(quickAccessPopup.Child) as Decorator;
             if (parent != null) parent.UpdateLayout();
         }
         */
         if (quickAccessPopup.Child != null) quickAccessPopup.Child.InvalidateMeasure();
         button.IsChecked = true;
         e.Handled = true;
     }
 }