示例#1
0
        /// <summary>
        /// Initialize a new instance of the KeyTipControl class.
        /// </summary>
        /// <param name="ribbon">Reference to owning control instance.</param>
        /// <param name="keyTips">List of key tips.</param>
        /// <param name="showDisabled">True to show disabled entries, otherwise enabled.</param>
        public KeyTipControl(KryptonRibbon ribbon, 
                             KeyTipInfoList keyTips,
                             bool showDisabled)
        {
            _ribbon = ribbon;
            _showDisabled = showDisabled;

            // Update form properties so we do not have a border and do not show
            // in the task bar. We draw the background in Magenta and set that as
            // the transparency key so it is a show through window.
            StartPosition = FormStartPosition.Manual;
            FormBorderStyle = FormBorderStyle.None;
            ShowInTaskbar = false;
            TransparencyKey = Color.Magenta;

            // Disabled key tips are show semi-transparent
            if (_showDisabled)
                Opacity = 0.5f;

            // Define the initial set of key tips
            SetKeyTips(keyTips);
        }
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <param name="keyTipList">List to add new entries into.</param>
        /// <param name="lineHint">Provide hint to item about its location.</param>
        public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint)
        {
            // Only provide a key tip if we are visible and the target control can accept focus
            if (Visible && LastMaskedTextBox.CanFocus)
            {
                // Get the screen location of the button
                Rectangle viewRect = _ribbon.KeyTipToScreen(this);

                // Determine the screen position of the key tip
                Point screenPt = Point.Empty;

                // Determine the screen position of the key tip dependant on item location/size
                switch (_currentSize)
                {
                    case GroupItemSize.Large:
                        screenPt = new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom);
                        break;
                    case GroupItemSize.Medium:
                    case GroupItemSize.Small:
                        screenPt = _ribbon.CalculatedValues.KeyTipRectToPoint(viewRect, lineHint);
                        break;
                }

                keyTipList.Add(new KeyTipInfo(_ribbonMaskedTextBox.Enabled,
                                              _ribbonMaskedTextBox.KeyTip,
                                              screenPt,
                                              ClientRectangle,
                                              _controller));
            }
        }
示例#3
0
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <param name="keyTipList">List to add new entries into.</param>
        public void GetGroupKeyTips(KeyTipInfoList keyTipList)
        {
            if (Collapsed)
            {
                // Get the screen location of the collapsed view
                Rectangle viewRect = _ribbon.KeyTipToScreen(_layoutCollapsedMain);

                // The keytip should be centered at the bottom of the view
                Point screenPt = new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom + 4);

                keyTipList.Add(new KeyTipInfo(true, _ribbonGroup.KeyTipGroup, screenPt,
                                              _layoutCollapsedMain.ClientRectangle, _collapsedController));
            }
            else
            {
                // Do we add a key tip for the dialog box launcher button
                if (_ribbonGroup.DialogBoxLauncher)
                {
                    // Get the screen location of the dialog button view
                    Rectangle viewRect = _ribbon.KeyTipToScreen(_viewNormalDialog);

                    // The keytip should be centered at the bottom of the view
                    Point screenPt = new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom + 4);

                    keyTipList.Add(new KeyTipInfo(true, _ribbonGroup.KeyTipDialogLauncher, screenPt,
                                                  _viewNormalDialog.ClientRectangle, _viewNormalDialog.DialogButtonController));
                }

                // Populate with key tips for the content of the group
                _layoutNormalContent.GetGroupKeyTips(keyTipList);
            }
        }
        /// <summary>
        /// Generate a key tip info for each visible tab.
        /// </summary>
        /// <param name="ownerForm">KryptonForm instance that owns this view.</param>
        /// <returns>Array of KeyTipInfo instances.</returns>
        public KeyTipInfo[] GetQATKeyTips(KryptonForm ownerForm)
        {
            // Create all the list of all possible QAT key tip strings
            Stack <string> keyTipsPool = new Stack <string>();

            // Then use the alphanumeric 0A - 0Z
            for (int i = 25; i >= 0; i--)
            {
                keyTipsPool.Push("0" + (char)(65 + i));
            }

            // Then use the number 09 - 01
            for (int i = 1; i <= 9; i++)
            {
                keyTipsPool.Push("0" + i.ToString());
            }

            // Start with the number 1 - 9
            for (int i = 9; i >= 1; i--)
            {
                keyTipsPool.Push(i.ToString());
            }

            // If integrated into the caption area then get the caption area height
            Padding borders = Padding.Empty;

            if ((ownerForm != null) && !ownerForm.ApplyComposition)
            {
                borders = ownerForm.RealWindowBorders;
            }

            KeyTipInfoList keyTipList = new KeyTipInfoList();

            foreach (ViewBase child in this)
            {
                // If visible and we have another key tip available on stack
                if (child.Visible && (keyTipsPool.Count > 0) &&
                    (child is ViewDrawRibbonQATButton))
                {
                    // Cast to correct type
                    ViewDrawRibbonQATButton viewQAT = (ViewDrawRibbonQATButton)child;

                    // Get the screen location of the view tab
                    Rectangle viewRect = ParentControl.RectangleToScreen(viewQAT.ClientRectangle);

                    // The keytip should be centered on the bottom center of the view
                    Point screenPt = new Point((viewRect.Left + (viewRect.Width / 2)) - borders.Left,
                                               viewRect.Bottom - 2 - borders.Top);

                    // Create new key tip that invokes the qat controller
                    keyTipList.Add(new KeyTipInfo(viewQAT.Enabled, keyTipsPool.Pop(), screenPt,
                                                  viewQAT.ClientRectangle, viewQAT.KeyTipTarget));
                }
            }

            // If we have the extra button and it is in overflow appearance
            if ((_extraButton != null) && _extraButton.Overflow)
            {
                // Get the screen location of the extra button
                Rectangle viewRect = ParentControl.RectangleToScreen(_extraButton.ClientRectangle);

                // The keytip should be centered on the bottom center of the view
                Point screenPt = new Point((viewRect.Left + (viewRect.Width / 2)) - borders.Left,
                                           viewRect.Bottom - 2 - borders.Top);

                // Create fixed key tip of '00' that invokes the extra button contoller
                keyTipList.Add(new KeyTipInfo(true, "00", screenPt, _extraButton.ClientRectangle, _extraButton.KeyTipTarget));
            }

            return(keyTipList.ToArray());
        }
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList)
 {
     // Separator never has key tips
 }
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <returns>Array of KeyTipInfo; otherwise null.</returns>
        public KeyTipInfo[] GetGroupKeyTips()
        {
            ViewLayoutRibbonGroups groups = _viewFiller as ViewLayoutRibbonGroups;

            // If we contain a groups layout
            if (groups != null)
            {
                KeyTipInfoList keyTips = new KeyTipInfoList();

                // Grab the list of key tips for all groups
                keyTips.AddRange(groups.GetGroupKeyTips());

                // Remove all those that do not intercept the view rectangle
                for (int i = 0; i < keyTips.Count; i++)
                    if (!_viewClipRect.Contains(keyTips[i].ClientRect))
                        keyTips[i].Visible = false;

                return keyTips.ToArray();
            }
            else
                return new KeyTipInfo[] { };
        }
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 /// <param name="lineHint">Provide hint to item about its location.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint)
 {
     // A label never has a key tip
 }
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList)
 {
     // Separator never has key tips
 }
示例#9
0
        /// <summary>
        /// Define the set of key tips to display.
        /// </summary>
        /// <param name="keyTips">List of key tips.</param>
        public void SetKeyTips(KeyTipInfoList keyTips)
        {
            // Create a new list of key tip views
            _viewList = new List<ViewDrawRibbonKeyTip>();

            Rectangle enclosingRect = Rectangle.Empty;

            // Create a view per key tip definition
            foreach (KeyTipInfo keyTip in keyTips)
            {
                // Create the initial rect as enclosing just the single point
                if (enclosingRect.IsEmpty)
                    enclosingRect = new Rectangle(keyTip.ScreenPt, new Size(1, 1));
                else
                {
                    // Enlarge the rect to enclose the new point
                    if (keyTip.ScreenPt.X < enclosingRect.Left)
                    {
                        int diff = enclosingRect.Left - keyTip.ScreenPt.X;
                        enclosingRect.Width += diff;
                        enclosingRect.X -= diff;
                    }

                    if (keyTip.ScreenPt.X > enclosingRect.Right)
                        enclosingRect.Width += (keyTip.ScreenPt.X - enclosingRect.Right);

                    if (keyTip.ScreenPt.Y < enclosingRect.Top)
                    {
                        int diff = enclosingRect.Top - keyTip.ScreenPt.Y;
                        enclosingRect.Height += diff;
                        enclosingRect.Y -= diff;
                    }

                    if (keyTip.ScreenPt.Y > enclosingRect.Bottom)
                        enclosingRect.Height += (keyTip.ScreenPt.Y - enclosingRect.Bottom);
                }

                _viewList.Add(new ViewDrawRibbonKeyTip(keyTip,
                                                       _ribbon.StateCommon.RibbonKeyTip.Back,
                                                       _ribbon.StateCommon.RibbonKeyTip.Border,
                                                       _ribbon.StateCommon.RibbonKeyTip.Content));
            }

            // Inflate the enclosing rect to account for maximum expected key tip
            enclosingRect.Inflate(50, 50);

            // Remove any prefix characters
            _prefix = string.Empty;

            // Our position covers the enclosing rect
            SetBounds(enclosingRect.X,
                      enclosingRect.Y,
                      enclosingRect.Width,
                      enclosingRect.Height);

            StartTimer();
        }
示例#10
0
        /// <summary>
        /// Define the set of key tips to display.
        /// </summary>
        /// <param name="keyTips">List of key tips.</param>
        public void SetKeyTips(KeyTipInfoList keyTips)
        {
            // Create a new list of key tip views
            _viewList = new List <ViewDrawRibbonKeyTip>();

            Rectangle enclosingRect = Rectangle.Empty;

            // Create a view per key tip definition
            foreach (KeyTipInfo keyTip in keyTips)
            {
                // Create the initial rect as enclosing just the single point
                if (enclosingRect.IsEmpty)
                {
                    enclosingRect = new Rectangle(keyTip.ScreenPt, new Size(1, 1));
                }
                else
                {
                    // Enlarge the rect to enclose the new point
                    if (keyTip.ScreenPt.X < enclosingRect.Left)
                    {
                        int diff = enclosingRect.Left - keyTip.ScreenPt.X;
                        enclosingRect.Width += diff;
                        enclosingRect.X     -= diff;
                    }

                    if (keyTip.ScreenPt.X > enclosingRect.Right)
                    {
                        enclosingRect.Width += (keyTip.ScreenPt.X - enclosingRect.Right);
                    }

                    if (keyTip.ScreenPt.Y < enclosingRect.Top)
                    {
                        int diff = enclosingRect.Top - keyTip.ScreenPt.Y;
                        enclosingRect.Height += diff;
                        enclosingRect.Y      -= diff;
                    }

                    if (keyTip.ScreenPt.Y > enclosingRect.Bottom)
                    {
                        enclosingRect.Height += (keyTip.ScreenPt.Y - enclosingRect.Bottom);
                    }
                }

                _viewList.Add(new ViewDrawRibbonKeyTip(keyTip,
                                                       _ribbon.StateCommon.RibbonKeyTip.Back,
                                                       _ribbon.StateCommon.RibbonKeyTip.Border,
                                                       _ribbon.StateCommon.RibbonKeyTip.Content));
            }

            // Inflate the enclosing rect to account for maximum expected key tip
            enclosingRect.Inflate(DpiHelper.Default.ScaleValue(50), DpiHelper.Default.ScaleValue(50));

            // Remove any prefix characters
            _prefix = string.Empty;

            // Our position covers the enclosing rect
            SetBounds(enclosingRect.X,
                      enclosingRect.Y,
                      enclosingRect.Width,
                      enclosingRect.Height);

            StartTimer();
        }
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <param name="keyTipList">List to add new entries into.</param>
        /// <param name="lineHint">Provide hint to item about its location.</param>
        public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint)
        {
            // Only provide a key tip if we are visible
            if (Visible)
            {
                // Get the screen location of the button
                Rectangle viewRect = _ribbon.KeyTipToScreen(this[0]);

                // Determine the screen position of the key tip dependant on item location
                Point screenPt = _ribbon.CalculatedValues.KeyTipRectToPoint(viewRect, lineHint);

                keyTipList.Add(new KeyTipInfo(_ribbonButton.Enabled, _ribbonButton.KeyTip, screenPt,
                                              this[0].ClientRectangle, _viewMediumSmall.Controller));
            }
        }
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList)
 {
     if (_ribbonGallery.Visible)
     {
         if (_viewLarge.Visible)
         {
             // Get the screen location of the button
             Rectangle viewRect = _ribbon.KeyTipToScreen(_viewLarge);
             keyTipList.Add(new KeyTipInfo(_ribbonGallery.Enabled,
                                           _ribbonGallery.KeyTip,
                                           new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom),
                                           ClientRectangle,
                                           _viewLarge.Controller));
         }
         else if (LastGallery.CanFocus)
         {
             // Get the screen location of the button
             Rectangle viewRect = _ribbon.KeyTipToScreen(this);
             keyTipList.Add(new KeyTipInfo(_ribbonGallery.Enabled,
                                           _ribbonGallery.KeyTip,
                                           new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom),
                                           ClientRectangle,
                                           _controller));
         }
     }
 }
        /// <summary>
        /// Perform actual selection of the item.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        public void KeyTipSelect(KryptonRibbon ribbon)
        {
            OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));

            // We should have a visual popup for showing the collapsed group
            if (VisualPopupManager.Singleton.IsTracking &&
                (VisualPopupManager.Singleton.CurrentPopup is VisualPopupGroup))
            {
                // Cast to correct type
                VisualPopupGroup popupGroup = (VisualPopupGroup)VisualPopupManager.Singleton.CurrentPopup;

                // Grab the list of key tips from the popup group
                _ribbon.KeyTipMode = KeyTipMode.PopupGroup;
                KeyTipInfoList keyTipList = new KeyTipInfoList();
                popupGroup.ViewGroup.GetGroupKeyTips(keyTipList);

                // Update key tips with those appropriate for this tab
                _ribbon.SetKeyTips(keyTipList, KeyTipMode.PopupGroup);
            }
        }
        /// <summary>
        /// Generate a key tip info for each visible tab.
        /// </summary>
        /// <returns>Array of KeyTipInfo instances.</returns>
        public KeyTipInfo[] GetQATKeyTips()
        {
            KeyTipInfoList keyTipList = new KeyTipInfoList();

            // Add all the entries for the contents
            keyTipList.AddRange(_borderContents.GetQATKeyTips(OwnerForm));

            // If we have the extra button and it is in overflow appearance
            if (_extraButton.Overflow)
            {
                // If integrated into the caption area then get the caption area height
                Padding borders = Padding.Empty;
                if ((OwnerForm != null) && !OwnerForm.ApplyComposition)
                    borders = OwnerForm.RealWindowBorders;

                // Get the screen location of the extra button
                Rectangle viewRect = _borderContents.ParentControl.RectangleToScreen(_extraButton.ClientRectangle);

                // The keytip should be centered on the bottom center of the view
                Point screenPt = new Point(viewRect.Left + (viewRect.Width / 2) - borders.Left,
                                           viewRect.Bottom - 2 - borders.Top);

                // Create fixed key tip of '00' that invokes the extra button contoller
                keyTipList.Add(new KeyTipInfo(true, "00", screenPt,
                                              _extraButton.ClientRectangle,
                                              _extraButton.KeyTipTarget));
            }

            return keyTipList.ToArray();
        }
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 /// <param name="lineHint">Provide hint to item about its location.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint)
 {
     // A label never has a key tip
 }
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <param name="keyTipList">List to add new entries into.</param>
        /// <param name="lineHint">Provide hint to item about its location.</param>
        public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint)
        {
            // Only provide a key tip if we are visible
            if (Visible)
            {
                // Get the screen location of the button
                Rectangle viewRect = _ribbon.KeyTipToScreen(this[0]);

                Point screenPt = Point.Empty;
                GroupButtonController controller = null;

                // Determine the screen position of the key tip dependant on item location/size
                switch (_currentSize)
                {
                    case GroupItemSize.Large:
                        screenPt = new Point(viewRect.Left + (viewRect.Width / 2), viewRect.Bottom);
                        controller = _viewLarge.Controller;
                        break;
                    case GroupItemSize.Medium:
                    case GroupItemSize.Small:
                        screenPt = _ribbon.CalculatedValues.KeyTipRectToPoint(viewRect, lineHint);
                        controller = _viewMediumSmall.Controller;
                        break;
                }

                keyTipList.Add(new KeyTipInfo(_ribbonColorButton.Enabled, _ribbonColorButton.KeyTip,
                                              screenPt, this[0].ClientRectangle, controller));
            }
        }
        /// <summary>
        /// Perform actual selection of the item.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        public void KeyTipSelect(KryptonRibbon ribbon)
        {
            // Change to a fixed pressed appearance
            SetFixed();
            UpdateTargetState();

            // Generate a click event
            OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));

            // We should have a visual popup for showing the qat overflow group
            if (VisualPopupManager.Singleton.IsTracking &&
                (VisualPopupManager.Singleton.CurrentPopup is VisualPopupQATOverflow))
            {
                // Cast to correct type
                VisualPopupQATOverflow popupOverflow = (VisualPopupQATOverflow)VisualPopupManager.Singleton.CurrentPopup;

                // Grab the list of key tips from the popup group
                Ribbon.KeyTipMode = KeyTipMode.PopupQATOverflow;
                KeyTipInfoList keyTipList = new KeyTipInfoList();
                keyTipList.AddRange(popupOverflow.ViewQATContents.GetQATKeyTips(null));

                // Update key tips with those appropriate for this tab
                Ribbon.SetKeyTips(keyTipList, KeyTipMode.PopupQATOverflow);
            }
        }