コード例 #1
0
        /// <summary>
        /// Gets the appropriate reduced <see cref="RibbonGroupBoxState"/> depending on StateDefinition />
        /// </summary>
        public RibbonGroupBoxState ReduceState(RibbonGroupBoxState ribbonGroupBoxState)
        {
            var currentStates = this.GetStates();
            var index         = Array.IndexOf(currentStates, ribbonGroupBoxState);

            if (index >= 0)
            {
                if (index < currentStates.Length - 1)
                {
                    return(currentStates[index + 1]);
                }
                else
                {
                    return(currentStates[currentStates.Length - 1]);
                }
            }
            else
            {
                // If not found current state, find the closest state that exists in the state list
                while (++ribbonGroupBoxState <= RibbonGroupBoxState.Collapsed)
                {
                    index = Array.IndexOf(currentStates, ribbonGroupBoxState);
                    if (index >= 0)
                    {
                        return(currentStates[index]);
                    }
                }

                return(currentStates[currentStates.Length - 1]);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the appropriate enlarged <see cref="RibbonGroupBoxState"/> depending on StateDefinition />
        /// </summary>
        public RibbonGroupBoxState EnlargeState(RibbonGroupBoxState ribbonGroupBoxState)
        {
            var currentStates = this.GetStates();
            var index         = Array.IndexOf(currentStates, ribbonGroupBoxState);

            if (index >= 0)
            {
                if (index > 0)
                {
                    return(this.States[index - 1]);
                }
                else
                {
                    return(this.States[0]);
                }
            }
            else
            {
                //  If not found current state, find the closest state that exists in the state list
                while (--ribbonGroupBoxState >= RibbonGroupBoxState.Large)
                {
                    index = Array.IndexOf(currentStates, ribbonGroupBoxState);
                    if (index >= 0)
                    {
                        return(this.States[index]);
                    }
                }

                return(this.States[0]);
            }
        }
コード例 #3
0
        /// <summary>
        /// On state property changed
        /// </summary>
        /// <param name="d">Object</param>
        /// <param name="e">The event data</param>
        static void StatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RibbonGroupBox ribbonGroupBox = (RibbonGroupBox)d;
            RibbonGroupBoxState ribbonGroupBoxState = (RibbonGroupBoxState)e.NewValue;

            SetChildSizes(ribbonGroupBoxState, ribbonGroupBox);
        }
コード例 #4
0
 // Set child sizes
 private static void SetChildSizes(RibbonGroupBoxState ribbonGroupBoxState, RibbonGroupBox ribbonGroupBox)
 {
     for (int i = 0; i < ribbonGroupBox.Items.Count; i++)
     {
         SetAppropriateSizeRecursive((UIElement)ribbonGroupBox.Items[i], ribbonGroupBoxState);
         //RibbonControl.SetAppropriateSize((UIElement)ribbonGroupBox.Items[i], ribbonGroupBoxState);
     }
 }
コード例 #5
0
        /// <summary>
        /// Sets appropriate size of the control according to the
        /// given group box state and control's size definition
        /// </summary>
        /// <param name="element">UI Element</param>
        /// <param name="state">Group box state</param>
        public static void SetAppropriateSize(DependencyObject element, RibbonGroupBoxState state)
        {
            var index = (int)state;

            if (state == RibbonGroupBoxState.Collapsed)
            {
                index = 0;
            }

            SetRibbonSize(element, GetThreeRibbonSizeDefinition(element)[index]);
        }
コード例 #6
0
        // Set child sizes
        private static void SetChildSizes(RibbonGroupBoxState ribbonGroupBoxState, ItemsControl ribbonGroupBox)
        {
            if (ribbonGroupBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
            {
                return;
            }

            foreach (var item in ribbonGroupBox.Items)
            {
                RibbonAttachedProperties.SetAppropriateSize(ribbonGroupBox.ItemContainerGenerator.ContainerFromItem(item), ribbonGroupBoxState);
            }
        }
コード例 #7
0
        static void SetAppropriateSizeRecursive(UIElement root, RibbonGroupBoxState ribbonGroupBoxState)
        {
            if (root == null) return;
            if (root is RibbonControl)
            {
                RibbonControl.SetAppropriateSize(root, ribbonGroupBoxState);
                return;
            }

            int childrenCount = VisualTreeHelper.GetChildrenCount(root);
            for (int i = 0; i < childrenCount; i++)
            {
                SetAppropriateSizeRecursive(VisualTreeHelper.GetChild(root, i) as UIElement, ribbonGroupBoxState);
            }
        }
コード例 #8
0
ファイル: RibbonControl.cs プロジェクト: ckimpel/FSE-2011-PDE
        /// <summary>
        /// Sets appropriate size of the control according to the
        /// given group box state and control's size definition
        /// </summary>
        /// <param name="element">UI Element</param>
        /// <param name="state">Group box state</param>
        public static void SetAppropriateSize(UIElement element, RibbonGroupBoxState state)
        {
            int index = (int)state;

            if (state == RibbonGroupBoxState.Collapsed)
            {
                index = 0;
            }
            RibbonControl control = (element as RibbonControl);

            if (control != null)
            {
                control.Size = GetThreeSizeDefinition(element)[index];
            }
        }
コード例 #9
0
        /// <summary>
        /// Gets the appropriate <see cref="RibbonControlSize"/> from <see cref="Large"/>, <see cref="Middle"/> or <see cref="Small"/> depending on <paramref name="ribbonGroupBoxState"/>
        /// </summary>
        public RibbonControlSize GetSize(RibbonGroupBoxState ribbonGroupBoxState)
        {
            switch (ribbonGroupBoxState)
            {
            case RibbonGroupBoxState.Large:
                return(this.Large);

            case RibbonGroupBoxState.Middle:
                return(this.Middle);

            case RibbonGroupBoxState.Small:
                return(this.Small);

            case RibbonGroupBoxState.Collapsed:
            case RibbonGroupBoxState.QuickAccess:
                return(this.Large);

            default:
                return(RibbonControlSize.Large);
            }
        }
コード例 #10
0
 /// <summary>
 /// Sets appropriate size of the control according to the
 /// given group box state and control's size definition
 /// </summary>
 /// <param name="element">UI Element</param>
 /// <param name="state">Group box state</param>
 public static void SetAppropriateSize(DependencyObject element, RibbonGroupBoxState state)
 {
     SetSize(element, GetSizeDefinition(element).GetSize(state));
 }
コード例 #11
0
 /// <summary>
 /// Sets appropriate size of the control according to the 
 /// given group box state and control's size definition
 /// </summary>
 /// <param name="element">UI Element</param>
 /// <param name="state">Group box state</param>
 public static void SetAppropriateSize(DependencyObject element, RibbonGroupBoxState state)
 {
     SetSize(element, GetSizeDefinition(element).GetSize(state));
 }
コード例 #12
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;
     }
 }
コード例 #13
0
        /// <summary>
        /// Gets the appropriate <see cref="RibbonControlSize"/> from <see cref="Large"/>, <see cref="Middle"/> or <see cref="Small"/> depending on <paramref name="ribbonGroupBoxState"/>
        /// </summary>
        public RibbonControlSize GetSize(RibbonGroupBoxState ribbonGroupBoxState)
        {
            switch (ribbonGroupBoxState)
            {
                case RibbonGroupBoxState.Large:
                    return this.Large;

                case RibbonGroupBoxState.Middle:
                    return this.Middle;

                case RibbonGroupBoxState.Small:
                    return this.Small;

                case RibbonGroupBoxState.Collapsed:
                case RibbonGroupBoxState.QuickAccess:
                    return this.Large;

                default:
                    return RibbonControlSize.Large;
            }
        }
コード例 #14
0
 /// <summary>
 /// Sets appropriate size of the control according to the 
 /// given group box state and control's size definition
 /// </summary>
 /// <param name="element">UI Element</param>
 /// <param name="state">Group box state</param>
 public static void SetAppropriateSize(UIElement element, RibbonGroupBoxState state)
 {
     int index = (int)state;
     if (state == RibbonGroupBoxState.Collapsed) index = 0;
     IRibbonControl control = (element as IRibbonControl);
     if (control != null) control.Size = GetThreeSizeDefinition(element)[index];
 }
コード例 #15
0
        /// <summary>
        /// Sets appropriate size of the control according to the 
        /// given group box state and control's size definition
        /// </summary>
        /// <param name="element">UI Element</param>
        /// <param name="state">Group box state</param>
        public static void SetAppropriateSize(DependencyObject element, RibbonGroupBoxState state)
        {
            var index = (int)state;
            if (state == RibbonGroupBoxState.Collapsed)
            {
                index = 0;
            }

            SetRibbonSize(element, GetThreeRibbonSizeDefinition(element)[index]);
        }
コード例 #16
0
        /// <summary>
        /// Sets appropriate size of the control according to the
        /// given group box state and control's size definition
        /// </summary>
        /// <param name="element">UI Element</param>
        /// <param name="state">Group box state</param>
        /// <param name="isSimplified">Group box isSimplified state</param>
        public static void SetAppropriateSize(DependencyObject element, RibbonGroupBoxState state, bool isSimplified)
        {
            var sizeDefinition = isSimplified ? GetSimplifiedSizeDefinition(element) : GetSizeDefinition(element);

            SetSize(element, sizeDefinition.GetSize(state));
        }
コード例 #17
0
        // Set child sizes
        private static void SetChildSizes(RibbonGroupBoxState ribbonGroupBoxState, ItemsControl ribbonGroupBox)
        {
            if (ribbonGroupBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
            {
                return;
            }

            foreach (var item in ribbonGroupBox.Items)
            {
                RibbonAttachedProperties.SetAppropriateSize(ribbonGroupBox.ItemContainerGenerator.ContainerFromItem(item), ribbonGroupBoxState);
            }
        }