コード例 #1
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Size preferredSize = Size.Empty;

            // Ensure the control has the correct parent
            UpdateParent(context.Control);

            // If there is a date time picker associated then ask for its requested size
            if (LastDateTimePicker != null)
            {
                if (ActualVisible(LastDateTimePicker))
                {
                    preferredSize = LastDateTimePicker.GetPreferredSize(context.DisplayRectangle.Size);

                    // Add two pixels, one for the left and right edges that will be padded
                    preferredSize.Width += 2;
                }
            }
            else
            {
                preferredSize.Width = NULL_CONTROL_WIDTH;
            }

            if (_currentSize == GroupItemSize.Large)
            {
                preferredSize.Height = _ribbon.CalculatedValues.GroupTripleHeight;
            }
            else
            {
                preferredSize.Height = _ribbon.CalculatedValues.GroupLineHeight;
            }

            return(preferredSize);
        }
コード例 #2
0
        internal override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            // Only interested in key processing if this control definition
            // is enabled and itself and all parents are also visible
            if (Enabled && ChainVisible)
            {
                // Do we have a shortcut definition for ourself?
                if (ShortcutKeys != Keys.None)
                {
                    // Does it match the incoming key combination?
                    if (ShortcutKeys == keyData)
                    {
                        // Can the date time picker take the focus
                        if ((LastDateTimePicker != null) && (LastDateTimePicker.CanFocus))
                        {
                            LastDateTimePicker.Focus();
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // We take on all the available display area
            ClientRectangle = context.DisplayRectangle;

            // Are we allowed to change the layout of controls?
            if (!context.ViewManager.DoNotLayoutControls)
            {
                // If we have an actual control, position it with a pixel padding all around
                LastDateTimePicker?.SetBounds(ClientLocation.X + 1,
                                              ClientLocation.Y + 1,
                                              ClientWidth - 2,
                                              ClientHeight - 2);
            }

            // Let child elements layout in given space
            base.Layout(context);
        }