/// <summary>
        /// Initialize a new instance of the PaletteRibbonTabContentInheritOverride class.
        /// </summary>
        /// <param name="primaryBack">First choice inheritence background.</param>
        /// <param name="primaryText">First choice inheritence text.</param>
        /// <param name="primaryContent">First choice inheritence content.</param>
        /// <param name="backupBack">Backup inheritence background.</param>
        /// <param name="backupText">Backup inheritence text.</param>
        /// <param name="backupContent">Backup inheritence content.</param>
        /// <param name="state">Palette state to override.</param>
        public PaletteRibbonTabContentInheritOverride(IPaletteRibbonBack primaryBack,
                                                      IPaletteRibbonText primaryText,
                                                      IPaletteContent primaryContent,
                                                      IPaletteRibbonBack backupBack,
                                                      IPaletteRibbonText backupText,
                                                      IPaletteContent backupContent,
                                                      PaletteState state)
        {
            Debug.Assert(primaryBack != null);
            Debug.Assert(primaryText != null);
            Debug.Assert(primaryContent != null);
            Debug.Assert(backupBack != null);
            Debug.Assert(backupText != null);
            Debug.Assert(backupContent != null);

            // Remember values
            _primaryBack = primaryBack;
            _primaryText = primaryText;
            _primaryContent = primaryContent;
            _backupBack = backupBack;
            _backupText = backupText;
            _backupContent = backupContent;

            // Default state
            _apply = false;
            _override = true;
            _state = state;
        }
 /// <summary>
 /// Initialize a new instance of the LinkLabelBehaviorInherit class.
 /// </summary>
 /// <param name="inherit">Palette to inherit from.</param>
 /// <param name="linkBehavior">Link behavior to use.</param>
 public LinkLabelBehaviorInherit(IPaletteContent inherit,
                                 KryptonLinkBehavior linkBehavior)
 {
     Debug.Assert(inherit != null);
     _inherit = inherit;
     _linkBehavior = linkBehavior;
 }
        /// <summary>
        /// Initialize a new instance of the PaletteDataGridViewContentStates class.
        /// </summary>
        /// <param name="inherit">Source for inheriting defaulted values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteDataGridViewContentStates(IPaletteContent inherit,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default the initial values
            _draw = InheritBool.Inherit;
            _hint = PaletteTextHint.Inherit;
            _trim = PaletteTextTrim.Inherit;
            _color1 = Color.Empty;
            _color2 = Color.Empty;
            _colorStyle = PaletteColorStyle.Inherit;
            _colorAlign = PaletteRectangleAlign.Inherit;
            _colorAngle = -1;
            _imageStyle = PaletteImageStyle.Inherit;
            _imageAlign = PaletteRectangleAlign.Inherit;
            _multiLine = InheritBool.Inherit;
            _multiLineH = PaletteRelativeAlign.Inherit;
        }
示例#4
0
        /// <summary>
        /// Draw a drop down grid appropriate for a input control.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="cellRect">Available drawing rectangle space.</param>
        /// <param name="paletteContent">Content palette for getting colors.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawInputControlDropDownGlyph(RenderContext context,
                                                           Rectangle cellRect,
                                                           IPaletteContent paletteContent,
                                                           PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteContent != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (paletteContent == null) throw new ArgumentNullException("paletteContent");

            Color c1 = paletteContent.GetContentShortTextColor1(state);

            // Find the top left starting position for drawing lines
            int xStart = cellRect.Left + (cellRect.Right - cellRect.Left - 4) / 2;
            int yStart = cellRect.Top + (cellRect.Bottom - cellRect.Top - 3) / 2;

            using (Pen darkPen = new Pen(c1))
            {
                context.Graphics.DrawLine(darkPen, xStart, yStart, xStart + 4, yStart);
                context.Graphics.DrawLine(darkPen, xStart + 1, yStart + 1, xStart + 3, yStart + 1);
                context.Graphics.DrawLine(darkPen, xStart + 2, yStart + 2, xStart + 2, yStart + 1);
            }
        }
        /// <summary>
        /// Initialize a new instance of the PaletteContentInheritForced class.
        /// </summary>
        /// <param name="inherit">Border palette to inherit from.</param>
        public PaletteContentInheritForced(IPaletteContent inherit)
        {
            // Remember inheritance border
            _inherit = inherit;

            // Default settings
            _forceShortTextHCenter = false;
        }
 /// <summary>
 /// Initialize a new instance of the ViewDrawMenuItemContent class.
 /// </summary>
 /// <param name="palette">Source of palette display values.</param>
 /// <param name="values">Source of content values.</param>
 /// <param name="columnIndex">Menu item column index.</param>
 public ViewDrawMenuItemContent(IPaletteContent palette,
                                IContentValues values,
                                int columnIndex)
     : base(palette, values, VisualOrientation.Top)
 {
     _columnIndex = columnIndex;
     _overridePreferredWidth = 0;
 }
 /// <summary>
 /// Initialize a new instance of the ViewDrawEmptyContent class.
 /// </summary>
 /// <param name="paletteContentDisabled">Palette source for the disabled content.</param>
 /// <param name="paletteContentNormal">Palette source for the normal content.</param>
 public ViewDrawEmptyContent(IPaletteContent paletteContentDisabled,
                             IPaletteContent paletteContentNormal)
     : base(paletteContentNormal, null, VisualOrientation.Top)
 {
     Values = this;
     _paletteContentDisabled = paletteContentDisabled;
     _paletteContentNormal = paletteContentNormal;
 }
 /// <summary>
 /// Initialize a new instance of the PaletteDataGridViewContentCommon class.
 /// </summary>
 /// <param name="inherit">Source for inheriting defaulted values.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 public PaletteDataGridViewContentCommon(IPaletteContent inherit,
                                         NeedPaintHandler needPaint)
     : base(inherit, needPaint)
 {
     // Default the initial values
     _padding = CommonHelper.InheritPadding;
     _textH = PaletteRelativeAlign.Inherit;
     _textV = PaletteRelativeAlign.Inherit;
 }
        /// <summary>
        /// Initialize a new instance of the RibbonTabToContent class.
        /// </summary>
        /// <param name="ribbonGeneral">Source for general ribbon settings.</param>
        /// <param name="ribbonTabText">Source for ribbon tab settings.</param>
        /// <param name="content">Source for content settings.</param>
        public RibbonTabToContent(IPaletteRibbonGeneral ribbonGeneral,
                                  IPaletteRibbonText ribbonTabText,
                                  IPaletteContent content)
        {
            Debug.Assert(ribbonGeneral != null);
            Debug.Assert(ribbonTabText != null);
            Debug.Assert(content != null);

            _ribbonGeneral = ribbonGeneral;
            _ribbonTabText = ribbonTabText;
            _content = content;
        }
示例#10
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawContent class.
        /// </summary>
        /// <param name="paletteContent">Palette source for the content.</param>
        /// <param name="values">Reference to actual content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        public ViewDrawContent(IPaletteContent paletteContent, 
							   IContentValues values,
							   VisualOrientation orientation)
        {
            // Cache the starting values
            _paletteContent = paletteContent;
            _values = values;
            _orientation = orientation;

            // Default other state
            _drawOnComposition = false;
            _testForFocusCues = false;
        }
示例#11
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonKeyTip class.
        /// </summary>
        /// <param name="keyTipInfo">Key tip information to display.</param>
        /// <param name="paletteBack">Background palette for appearance.</param>
        /// <param name="paletteBorder">Border palette for appearance.</param>
        /// <param name="paletteContent">Content palette for appearance.</param>
        public ViewDrawRibbonKeyTip(KeyTipInfo keyTipInfo,
                                    IPaletteBack paletteBack,
                                    IPaletteBorder paletteBorder,
                                    IPaletteContent paletteContent)
            : base(paletteBack, paletteBorder)
        {
            _keyTipInfo = keyTipInfo;

            // Create view for the key tip text
            _drawContent = new ViewDrawContent(paletteContent, this, VisualOrientation.Top);

            // Add content as filler for ourself
            Add(_drawContent, ViewDockStyle.Fill);
        }
        /// <summary>
        /// Initialize a new instance of the PaletteRibbonTabContent class.
        /// </summary>
        /// <param name="paletteBack">Source for inheriting palette ribbon background.</param>
        /// <param name="paletteText">Source for inheriting palette ribbon text.</param>
        /// <param name="paletteContent">Source for inheriting palette content.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteRibbonTabContent(IPaletteRibbonBack paletteBack,
                                       IPaletteRibbonText paletteText,
                                       IPaletteContent paletteContent,
                                       NeedPaintHandler needPaint)
        {
            Debug.Assert(paletteBack != null);
            Debug.Assert(paletteText != null);
            Debug.Assert(paletteContent != null);

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Create storage that maps onto the inherit instances
            _paletteTabDraw = new PaletteRibbonDouble(paletteBack, paletteText, needPaint);
            _paletteContent = new PaletteNavContent(paletteContent, needPaint);
        }
        /// <summary>
        /// Initialize a new instance of the PaletteNavContent class.
        /// </summary>
        /// <param name="inherit">Source for inheriting defaulted values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteNavContent(IPaletteContent inherit,
                                 NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Create the content storage for sub objects
            _image = new PaletteContentImage(needPaint);
            _shortText = new PaletteNavContentText(needPaint);
            _longText = new PaletteNavContentText(needPaint);
        }
        /// <summary>
        /// Initialize a new instance of the PaletteInputControlContentStates class.
        /// </summary>
        /// <param name="inherit">Source for inheriting defaulted values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteInputControlContentStates(IPaletteContent inherit,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default the initial values
            _font = null;
            _color1 = Color.Empty;
            _padding = CommonHelper.InheritPadding;
        }
        /// <summary>
        /// Initialize a new instance of the PaletteContentInheritOverride class.
        /// </summary>
        /// <param name="primary">First choice inheritence.</param>
        /// <param name="backup">Backup inheritence.</param>
        /// <param name="overrideState">State used by the override.</param>
        /// <param name="apply">Should the override we used.</param>
        public PaletteContentInheritOverride(IPaletteContent primary,
											 IPaletteContent backup,
                                             PaletteState overrideState,
                                             bool apply)
        {
            Debug.Assert(primary != null);
            Debug.Assert(backup != null);

            // Store incoming values
            _primary = primary;
            _backup = backup;
            _apply = apply;
            _state = overrideState;

            // By default we do override the state
            _override = true;
        }
 /// <summary>
 /// Initialize a new instance of the ButtonSpecNavManagerLayoutHeaderBar class.
 /// </summary>
 /// <param name="control">Control that owns the button manager.</param>
 /// <param name="redirector">Palette redirector.</param>
 /// <param name="variableSpecs">Variable set of button specifications.</param>
 /// <param name="fixedSpecs">Fixed set of button specifications.</param>
 /// <param name="viewDockers">Array of target view dockers.</param>
 /// <param name="viewMetrics">Array of target metric providers.</param>
 /// <param name="viewMetricIntOutside">Array of target metrics for outside spacer size.</param>
 /// <param name="viewMetricIntInside">Array of target metrics for inside spacer size.</param>
 /// <param name="viewMetricPaddings">Array of target metrics for button padding.</param>
 /// <param name="getRenderer">Delegate for returning a tool strip renderer.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 /// <param name="paletteContent">Palette source for color remapping.</param>
 /// <param name="paletteState">Palette state for color remapping.</param>
 public ButtonSpecNavManagerLayoutHeaderBar(Control control,
                                            PaletteRedirect redirector,
                                            ButtonSpecCollectionBase variableSpecs,
                                            ButtonSpecCollectionBase fixedSpecs,
                                            ViewLayoutDocker[] viewDockers,
                                            IPaletteMetric[] viewMetrics,
                                            PaletteMetricInt[] viewMetricIntOutside,
                                            PaletteMetricInt[] viewMetricIntInside,
                                            PaletteMetricPadding[] viewMetricPaddings,
                                            GetToolStripRenderer getRenderer,
                                            NeedPaintHandler needPaint,
                                            IPaletteContent paletteContent,
                                            PaletteState paletteState)
     : base(control, redirector, variableSpecs, fixedSpecs, 
            viewDockers, viewMetrics, viewMetricIntOutside,
            viewMetricIntInside, viewMetricPaddings, getRenderer, 
            needPaint)
 {
     // Remember initial palette settings needed for color remapping
     _paletteContent = paletteContent;
     _paletteState = paletteState;
 }
示例#17
0
        /// <summary>
        /// Initialize a new instance of the LinkLabelController class.
        /// </summary>
        /// <param name="target">Target for state changes.</param>
        /// <param name="paletteDisabled">Palette to use in the disabled state.</param>
        /// <param name="paletteNormal">Palette to use in the normal state.</param>
        /// <param name="paletteTracking">Palette to use in the tracking state.</param>
        /// <param name="palettePressed">Palette to use in the pressed state.</param>
        /// <param name="pressed">Override to update with the pressed state.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public LinkLabelController(ViewDrawContent target,
                                   IPaletteContent paletteDisabled,
                                   IPaletteContent paletteNormal,
                                   IPaletteContent paletteTracking,
                                   IPaletteContent palettePressed,
                                   PaletteContentInheritOverride pressed,
                                   NeedPaintHandler needPaint)
        {
            Debug.Assert(target != null);

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Remember target for state changes
            _target = target;
            _paletteDisabled = paletteDisabled;
            _paletteNormal = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed = palettePressed;
            _pressed = pressed;

            // Default other properties
            _clickTime = new DateTime();
        }
示例#18
0
 /// <summary>
 /// Draw a grid row glyph.
 /// </summary>
 /// <param name="context">Render context.</param>
 /// <param name="rowGlyph">Row glyph.</param>
 /// <param name="cellRect">Available drawing rectangle space.</param>
 /// <param name="paletteContent">Palette to use for sourcing values.</param>
 /// <param name="state">State associated with rendering.</param>
 /// <param name="rtl">Should be drawn from right to left.</param>
 /// <returns>Remainder space left over for other drawing.</returns>
 public abstract Rectangle DrawGridRowGlyph(RenderContext context,
                                            GridRowGlyph rowGlyph,
                                            Rectangle cellRect,
                                            IPaletteContent paletteContent,
                                            PaletteState state,
                                            bool rtl);
示例#19
0
        /// <summary>
        /// Perform draw of content using provided memento.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="memento">Cached values from layout call.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If compisition, should glowing be drawn.</param>
        /// <param name="allowFocusRect">Allow drawing of focus rectangle.</param>
        public abstract void DrawContent(RenderContext context,
										 Rectangle displayRect,
										 IPaletteContent palette,
                                         IDisposable memento,
										 VisualOrientation orientation,
										 PaletteState state,
                                         bool composition,
                                         bool glowing,
                                         bool allowFocusRect);
 /// <summary>
 /// Sets the inheritence parent.
 /// </summary>
 public void SetInherit(IPaletteRibbonBack paletteBack,
                        IPaletteRibbonText paletteText,
                        IPaletteContent paletteContent)
 {
     _paletteTabDraw.SetInherit(paletteBack, paletteText);
     _paletteContent.SetInherit(paletteContent);
 }
示例#21
0
        private static void PositionAlignContent(StandardContentMemento memento,
                                                 IPaletteContent paletteContent,
                                                 PaletteState state,
                                                 RightToLeft rtl,
                                                 PaletteRelativeAlign alignH,
                                                 PaletteRelativeAlign alignV,
                                                 int cellX,
                                                 int cellY,
                                                 int cellWidth,
                                                 int cellHeight,
                                                 int spacingGap)
        {
            // Create client rectangle covering cell size
            Rectangle cellRect = new Rectangle(cellX, cellY, cellWidth, cellHeight);

            PaletteRelativeAlign drawHImage = paletteContent.GetContentImageH(state);
            PaletteRelativeAlign drawVImage = paletteContent.GetContentImageV(state);
            PaletteRelativeAlign drawHShort = paletteContent.GetContentShortTextH(state);
            PaletteRelativeAlign drawVShort = paletteContent.GetContentShortTextV(state);
            PaletteRelativeAlign drawHLong = paletteContent.GetContentLongTextH(state);
            PaletteRelativeAlign drawVLong = paletteContent.GetContentLongTextV(state);

            PaletteRelativeAlign posHImage = drawHImage;
            PaletteRelativeAlign posHShort = drawHShort;
            PaletteRelativeAlign posHLong = drawHLong;

            // If positioning in the center, then need extra processing
            if (alignH == PaletteRelativeAlign.Center)
            {
                // Find number of content and width of those in this cell
                int totalWidth = 0;
                int totalItems = 0;

                if (memento.DrawImage && (drawHImage == alignH) && (drawVImage == alignV))
                {
                    totalWidth += memento.ImageRect.Width;
                    totalItems++;
                }

                if (memento.DrawShortText && (drawHShort == alignH) && (drawVShort == alignV))
                {
                    totalWidth += memento.ShortTextRect.Width;
                    totalItems++;
                }

                if (memento.DrawLongText && (drawHLong == alignH) && (drawVLong == alignV))
                {
                    totalWidth += memento.LongTextRect.Width;
                    totalItems++;
                }

                // If more than one item is to be positioned
                if (totalItems > 1)
                {
                    // Add on required number of spacing gaps
                    totalWidth += (totalItems - 1) * spacingGap;

                    // Then center the space for the content
                    int halfWidth = (cellRect.Width - totalWidth) / 2;
                    cellRect.Width -= (halfWidth * 2);
                    cellRect.X += halfWidth;

                    // Ensure all content are placed near, so they fit exactly
                    posHImage = posHShort = posHLong = PaletteRelativeAlign.Near;
                }
            }

            // Do we need to position the image?
            if (memento.DrawImage && (drawHImage == alignH) && (drawVImage == alignV))
                memento.ImageRect.Location = PositionCellContent(rtl, posHImage, drawVImage, memento.ImageRect.Size, spacingGap, ref cellRect);

            // Do we need to position the short text?
            if (memento.DrawShortText && (drawHShort == alignH) && (drawVShort == alignV))
                memento.ShortTextRect.Location = PositionCellContent(rtl, posHShort, drawVShort, memento.ShortTextRect.Size, spacingGap, ref cellRect);

            // Do we need to position the long text?
            if (memento.DrawLongText && (drawHLong == alignH) && (drawVLong == alignV))
                memento.LongTextRect.Location = PositionCellContent(rtl, posHLong, drawVLong, memento.LongTextRect.Size, spacingGap, ref cellRect);
        }
示例#22
0
        private static void AllocateImageSpace(StandardContentMemento memento,
                                               IPaletteContent paletteContent,
                                               IContentValues contentValues,
                                               PaletteState state,
                                               Rectangle displayRect,
                                               RightToLeft rtl,
                                               ref Size[,] allocation)
        {
            // By default, we cannot draw the image
            memento.DrawImage = false;

            // Get the image details
            memento.Image = contentValues.GetImage(state);
            memento.ImageTransparentColor = contentValues.GetImageTransparentColor(state);

            // Is there any image to be drawn?
            if (memento.Image != null)
            {
                try
                {
                    // Cache the size of the image
                    memento.ImageRect.Size = memento.Image.Size;

                    // Check for enough space to show all of the image
                    if ((displayRect.Width >= memento.ImageRect.Width) &&
                        (displayRect.Height >= memento.ImageRect.Height))
                    {
                        // Convert from alignment enums to integers
                        int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentImageH(state));
                        int alignVIndex = (int)paletteContent.GetContentImageV(state);

                        // Bump the allocated space in the destination grid cell
                        allocation[alignHIndex, alignVIndex].Width += memento.ImageRect.Width;
                        allocation[alignHIndex, alignVIndex].Height += memento.ImageRect.Height;

                        // Yes, we do want to draw the image/icon
                        memento.DrawImage = true;
                    }
                }
                catch
                {
                    // Image is not valid, so do not use it!
                    memento.Image = null;
                    memento.DrawImage = false;
                }
            }
        }
示例#23
0
        /// <summary>
        /// Perform draw of content using provided memento.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="memento">Cached values from layout call.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition should glowing be drawn.</param>
        /// <param name="allowFocusRect">Allow drawing of focus rectangle.</param>
        public override void DrawContent(RenderContext context, 
										 Rectangle displayRect,
										 IPaletteContent palette,
										 IDisposable memento,
										 VisualOrientation orientation,
										 PaletteState state,
                                         bool composition,
                                         bool glowing,
                                         bool allowFocusRect)
        {
            Debug.Assert(context != null);
            Debug.Assert(memento != null);
            Debug.Assert(memento is StandardContentMemento);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Cast the incoming memento to the correct type
            StandardContentMemento standard = (StandardContentMemento)memento;

            if (standard.DrawImage)
            {
                DrawImageHelper(context,
                                standard.Image,
                                standard.ImageTransparentColor,
                                standard.ImageRect,
                                orientation,
                                palette.GetContentImageEffect(state),
                                palette.GetContentImageColorMap(state),
                                palette.GetContentImageColorTo(state));
            }

            if (standard.DrawShortText)
            {
                using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.ShortTextHint))
                {
                    // Get the rectangle to use when dealing with gradients
                    Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentShortTextColorAlign(state), standard.ShortTextRect);

                    // Use standard helper routine to create appropriate color brush
                    Color color1 = palette.GetContentShortTextColor1(state);
                    PaletteColorStyle colorStyle = palette.GetContentShortTextColorStyle(state);
                    using (Brush colorBrush = CreateColorBrush(gradientRect,
                                                               color1,
                                                               palette.GetContentShortTextColor2(state),
                                                               colorStyle,
                                                               palette.GetContentShortTextColorAngle(state),
                                                               orientation))
                    {
                        if (!AccurateText.DrawString(context.Graphics,
                                                     colorBrush,
                                                     standard.ShortTextRect,
                                                     context.Control.RightToLeft,
                                                     standard.Orientation,
                                                     composition,
                                                     glowing,
                                                     state,
                                                     standard.ShortTextMemento))
                        {
                            // Failed to draw means the font is likely to be invalid, get a fresh font
                            standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state);

                            // Try again using the new font
                            AccurateText.DrawString(context.Graphics,
                                                    colorBrush,
                                                    standard.ShortTextRect,
                                                    context.Control.RightToLeft,
                                                    standard.Orientation,
                                                    composition,
                                                    glowing,
                                                    state,
                                                    standard.ShortTextMemento);
                        }
                    }

                    Image shortImage = palette.GetContentShortTextImage(state);
                    PaletteImageStyle shortImageStyle = palette.GetContentShortTextImageStyle(state);

                    // Do we need to draw the image?
                    if (ShouldDrawImage(shortImage))
                    {
                        // Get the rectangle to use when dealing with gradients
                        Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentShortTextImageAlign(state), standard.ShortTextRect);

                        // Use standard helper routine to create appropriate image brush
                        using (Brush imageBrush = CreateImageBrush(imageRect, shortImage, shortImageStyle))
                        {
                            if (!AccurateText.DrawString(context.Graphics,
                                                         imageBrush,
                                                         standard.ShortTextRect,
                                                         context.Control.RightToLeft,
                                                         standard.Orientation,
                                                         composition,
                                                         glowing,
                                                         state,
                                                         standard.ShortTextMemento))
                            {
                                // Failed to draw means the font is likely to be invalid, get a fresh font
                                standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state);

                                AccurateText.DrawString(context.Graphics,
                                                        imageBrush,
                                                        standard.ShortTextRect,
                                                        context.Control.RightToLeft,
                                                        standard.Orientation,
                                                        composition,
                                                        glowing,
                                                        state,
                                                        standard.ShortTextMemento);
                            }
                        }
                    }
                }
            }

            if (standard.DrawLongText)
            {
                using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.LongTextHint))
                {
                    // Get the rectangle to use when dealing with gradients
                    Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentLongTextColorAlign(state), standard.LongTextRect);

                    // Use standard helper routine to create appropriate color brush
                    Color color1 = palette.GetContentLongTextColor1(state);
                    PaletteColorStyle colorStyle = palette.GetContentLongTextColorStyle(state);
                    using (Brush colorBrush = CreateColorBrush(gradientRect,
                                                               color1,
                                                               palette.GetContentLongTextColor2(state),
                                                               colorStyle,
                                                               palette.GetContentLongTextColorAngle(state),
                                                               orientation))
                    {
                        if (!AccurateText.DrawString(context.Graphics,
                                                     colorBrush,
                                                     standard.LongTextRect,
                                                     context.Control.RightToLeft,
                                                     standard.Orientation,
                                                     composition,
                                                     glowing,
                                                     state,
                                                     standard.LongTextMemento))
                        {
                            // Failed to draw means the font is likely to be invalid, get a fresh font
                            standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state);

                            AccurateText.DrawString(context.Graphics,
                                                    colorBrush,
                                                    standard.LongTextRect,
                                                    context.Control.RightToLeft,
                                                    standard.Orientation,
                                                    composition,
                                                    glowing,
                                                    state,
                                                    standard.LongTextMemento);
                        }
                    }

                    Image longImage = palette.GetContentLongTextImage(state);
                    PaletteImageStyle longImageStyle = palette.GetContentLongTextImageStyle(state);

                    // Do we need to draw the image?
                    if (ShouldDrawImage(longImage))
                    {
                        // Get the rectangle to use when dealing with gradients
                        Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentLongTextImageAlign(state), standard.LongTextRect);

                        // Use standard helper routine to create appropriate image brush
                        using (Brush imageBrush = CreateImageBrush(imageRect, longImage, longImageStyle))
                        {
                            if (!AccurateText.DrawString(context.Graphics,
                                                         imageBrush,
                                                         standard.LongTextRect,
                                                         context.Control.RightToLeft,
                                                         standard.Orientation,
                                                         composition,
                                                         glowing,
                                                         state,
                                                         standard.LongTextMemento))
                            {
                                // Failed to draw means the font is likely to be invalid, get a fresh font
                                standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state);

                                AccurateText.DrawString(context.Graphics,
                                                        imageBrush,
                                                        standard.LongTextRect,
                                                        context.Control.RightToLeft,
                                                        standard.Orientation,
                                                        composition,
                                                        glowing,
                                                        state,
                                                        standard.LongTextMemento);
                            }
                        }
                    }
                }
            }

            // Do we need to show this content has the focus?
            if (allowFocusRect && (palette.GetContentDrawFocus(state) == InheritBool.True))
            {
                // Place the rectangle 1 pixel inside the content display area
                displayRect.Inflate(-1, -1);

                // Use window forms provided helper class for drawing
                ControlPaint.DrawFocusRectangle(context.Graphics, displayRect);
            }
        }
示例#24
0
        /// <summary>
        /// Perform layout calculations on the provided content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="availableRect">Display area available for laying out.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Should draw on a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Memento with cached information.</returns>
        public override IDisposable LayoutContent(ViewLayoutContext context,
											      Rectangle availableRect,
											      IPaletteContent palette,
											      IContentValues values,
											      VisualOrientation orientation,
											      PaletteState state,
                                                  bool composition,
                                                  bool glowing)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);
            Debug.Assert(values != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Remember the original value, for use later
            Rectangle cacheDisplayRect = availableRect;

            // Grab the padding for the content
            Padding borderPadding = palette.GetContentPadding(state);

            // Is the content intended for a vertical drawing orientation?
            bool vertical = (orientation == VisualOrientation.Left) ||
                            (orientation == VisualOrientation.Right);

            // If we need to apply in a vertical orientation
            if (vertical)
            {
                // Our algorithm only works by assuming a left to right horizontal
                // orientation, so we adjust the display rect to that orientation
                // and then at the end adjust the memento produced back to the
                // required orientation again. 'AdjustForOrientation'
                int temp = availableRect.Width;
                availableRect.Width = availableRect.Height;
                availableRect.Height = temp;
            }

            // Apply padding to the rectangle
            availableRect.X += borderPadding.Left;
            availableRect.Y += borderPadding.Top;
            availableRect.Width -= borderPadding.Horizontal;
            availableRect.Height -= borderPadding.Vertical;

            // If we need to apply in a vertical orientation
            if (vertical)
            {
                // This is the display rect we need to use in 'AdjustForOrientation'
                // and cache it for later. The displayRect itself is modified during
                // the below process and so cannot be used directly.
                int temp = cacheDisplayRect.Width;
                cacheDisplayRect.Width = cacheDisplayRect.Height;
                cacheDisplayRect.Height = temp;
            }

            // Track the allocated space in each grid position
            Size[,] allocation = new Size[3, 3] { { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty } };

            // Create a memento to return to caller
            StandardContentMemento memento = new StandardContentMemento();

            // Cache the size of a spacing gap
            int spacingGap = palette.GetContentAdjacentGap(state);

            // Drawing vertical means we can ignore right to left, otherwise get value from control
            RightToLeft rtl = (vertical ? RightToLeft.No : context.Control.RightToLeft);

            // Allocate space for each required content in turn
            AllocateImageSpace(memento, palette, values, state, availableRect, rtl, ref allocation);
            AllocateShortTextSpace(context, context.Graphics, memento, palette, values, state, availableRect, rtl, spacingGap, ref allocation, composition, glowing);
            AllocateLongTextSpace(context, context.Graphics, memento, palette, values, state, availableRect, rtl, spacingGap, ref allocation, composition, glowing);

            // Find the width of the columns and heights of the rows
            int[] colWidths = AllocatedColumnWidths(allocation, -1);
            int[] rowHeights = AllocatedRowHeights(allocation);

            // Add up total allocated for rows and columns
            int allocatedWidth = AllocatedTotalWidth(allocation, -1, -1, spacingGap);
            int allocatedHeight = AllocatedTotalHeight(allocation);

            // Excess width to allocate?
            if (allocatedWidth < availableRect.Width)
                ApplyExcessSpace(availableRect.Width - allocatedWidth, ref colWidths);

            // Excess height to allocate?
            if (allocatedHeight < availableRect.Height)
                rowHeights[1] += (availableRect.Height - allocatedHeight);

            // Find x positions and y positions
            int col0 = availableRect.Left;
            int col1 = col0 + colWidths[0];

            // Do we need to add a spacing gap after the first column?
            if (((colWidths[0] > 0) && (colWidths[1] > 0)) ||
                ((colWidths[0] > 0) && (colWidths[1] == 0) && (colWidths[2] > 0)))
                col1 += spacingGap;

            int col2 = col1 + colWidths[1];

            // Do we need to add a spacing gap after the second column?
            if ((colWidths[1] > 0) && (colWidths[2] > 0))
                col2 += spacingGap;

            int row0 = availableRect.Top;
            int row1 = row0 + rowHeights[0];
            int row2 = row1 + rowHeights[1];

            // Decide on the ordering of the alignment to position
            PaletteRelativeAlign aAlign = (rtl == RightToLeft.Yes ? PaletteRelativeAlign.Far : PaletteRelativeAlign.Near);
            PaletteRelativeAlign bAlign = PaletteRelativeAlign.Center;
            PaletteRelativeAlign cAlign = (rtl == RightToLeft.Yes ? PaletteRelativeAlign.Near : PaletteRelativeAlign.Far);

            // Size and position the contents of each aligned cell
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Near, col0, row0, colWidths[0], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Center, col0, row1, colWidths[0], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Far, col0, row2, colWidths[0], rowHeights[2], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Near, col1, row0, colWidths[1], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Center, col1, row1, colWidths[1], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Far, col1, row2, colWidths[1], rowHeights[2], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Near, col2, row0, colWidths[2], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Center, col2, row1, colWidths[2], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Far, col2, row2, colWidths[2], rowHeights[2], spacingGap);

            // Ask the memento to adjust itself for the required orientation
            memento.AdjustForOrientation(orientation, cacheDisplayRect);

            return memento;
        }
示例#25
0
        /// <summary>
        /// Get the preferred size for drawing the content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Preferred size.</returns>
        public abstract Size GetContentPreferredSize(ViewLayoutContext context,
													 IPaletteContent palette,
													 IContentValues values,
													 VisualOrientation orientation,
													 PaletteState state,
                                                     bool composition,
                                                     bool glowing);
示例#26
0
 /// <summary>
 /// Draw a grid sorting direction glyph.
 /// </summary>
 /// <param name="context">Render context.</param>
 /// <param name="sortOrder">Sorting order of the glyph.</param>
 /// <param name="cellRect">Available drawing rectangle space.</param>
 /// <param name="paletteContent">Palette to use for sourcing values.</param>
 /// <param name="state">State associated with rendering.</param>
 /// <param name="rtl">Should be drawn from right to left.</param>
 /// <returns>Remainder space left over for other drawing.</returns>
 public abstract Rectangle DrawGridSortGlyph(RenderContext context,
                                             SortOrder sortOrder,
                                             Rectangle cellRect,
                                             IPaletteContent paletteContent,
                                             PaletteState state,
                                             bool rtl);
示例#27
0
 /// <summary>
 /// Draw a numeric up button image appropriate for a input control.
 /// </summary>
 /// <param name="context">Render context.</param>
 /// <param name="cellRect">Available drawing rectangle space.</param>
 /// <param name="paletteContent">Content palette for getting colors.</param>
 /// <param name="state">State associated with rendering.</param>
 public abstract void DrawInputControlNumericUpGlyph(RenderContext context,
                                                     Rectangle cellRect,
                                                     IPaletteContent paletteContent,
                                                     PaletteState state);
示例#28
0
        private static void AllocateShortTextSpace(ViewLayoutContext context,
                                                   Graphics g,
                                                   StandardContentMemento memento,
                                                   IPaletteContent paletteContent,
                                                   IContentValues contentValues,
                                                   PaletteState state,
                                                   Rectangle displayRect,
                                                   RightToLeft rtl,
                                                   int spacingGap,
                                                   ref Size[,] allocation,
                                                   bool composition,
                                                   bool glowing)
        {
            // By default, we cannot draw the text
            memento.DrawShortText = false;

            // Get the defined text for display
            string shortText = contentValues.GetShortText();

            // Is there any text to be drawn?
            if ((shortText != null) && (shortText.Length > 0))
            {
                // If the text is not allowed to span multiple lines
                if (paletteContent.GetContentShortTextMultiLine(state) == InheritBool.False)
                {
                    // Replace any carriage returns and newlines with just spaces
                    shortText = shortText.Replace("\r\n", " ");
                    shortText = shortText.Replace("\n", " ");
                    shortText = shortText.Replace("\r", " ");
                }

                // Convert from alignment enums to integers
                int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentShortTextH(state));
                int alignVIndex = (int)paletteContent.GetContentShortTextV(state);

                // Cache the rendering hint used
                memento.ShortTextHint = CommonHelper.PaletteTextHintToRenderingHint(paletteContent.GetContentShortTextHint(state));
                memento.ShortTextTrimming = paletteContent.GetContentShortTextTrim(state);

                bool fontChanged = false;
                Font textFont = paletteContent.GetContentShortTextFont(state);

                // Get the appropriate font to use in the caption area
                if (paletteContent.GetContentStyle() == PaletteContentStyle.HeaderForm)
                {
                    Font captionFont = ContentFontForButtonForm(context, textFont);
                    fontChanged = (captionFont != textFont);
                    textFont = captionFont;
                }

                // Get a pixel accurate measure of text drawing space needed
                memento.ShortTextMemento = AccurateText.MeasureString(g,
                                                                      rtl,
                                                                      shortText,
                                                                      textFont,
                                                                      memento.ShortTextTrimming,
                                                                      paletteContent.GetContentShortTextMultiLineH(state),
                                                                      paletteContent.GetContentShortTextPrefix(state),
                                                                      memento.ShortTextHint,
                                                                      composition,
                                                                      glowing,
                                                                      fontChanged);

                // Space required for short text starts with the text width itself
                Size requiredSpace = memento.ShortTextMemento.Size;

                // Find the space available given our required alignment
                if (AllocateAlignmentSpace(alignHIndex, alignVIndex,
                                           allocation, displayRect,
                                           spacingGap, memento.ShortTextTrimming,
                                           ref requiredSpace))
                {
                    // Allocate the actual space used up
                    // Cache the actual draw size of the text
                    memento.ShortTextRect.Size = requiredSpace;

                    // Mark the memento to draw the short text
                    memento.DrawShortText = true;
                }
            }
        }
示例#29
0
        /// <summary>
        /// Perform layout calculations on the provided content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="availableRect">Space available for laying out.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Memento with cached information.</returns>
        public abstract IDisposable LayoutContent(ViewLayoutContext context,
											      Rectangle availableRect,
											      IPaletteContent palette,
											      IContentValues values,
											      VisualOrientation orientation,
											      PaletteState state,
                                                  bool composition, 
                                                  bool glowing);
示例#30
0
        /// <summary>
        /// Get the preferred size for drawing the content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Should draw on a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Preferred size.</returns>
        public override Size GetContentPreferredSize(ViewLayoutContext context,
													 IPaletteContent palette,
													 IContentValues values,
													 VisualOrientation orientation,
                                                     PaletteState state,
                                                     bool composition,
                                                     bool glowing)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);
            Debug.Assert(values != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Provide a maximum sized rectangle for placing content into, in
            // order to work out how much of the space is actually allocated
            Rectangle displayRect = new Rectangle(Point.Empty, new Size(int.MaxValue, int.MaxValue));

            // Track the allocated space in each grid position
            Size[,] allocation = new Size[3, 3] { { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty } };

            // Create a memento for storing calculations
            using (StandardContentMemento memento = new StandardContentMemento())
            {
                // Cache the size of a spacing gap
                int spacingGap = palette.GetContentAdjacentGap(state);

                // Is the content intended for a vertical drawing orientation?
                bool vertical = (orientation == VisualOrientation.Left) ||
                                (orientation == VisualOrientation.Right);

                // Drawing vertical means we can ignore right to left, otherwise get value from control
                RightToLeft rtl = (vertical ? RightToLeft.No : context.Control.RightToLeft);

                // Allocate space for each required content in turn
                AllocateImageSpace(memento, palette, values, state, displayRect, rtl, ref allocation);
                AllocateShortTextSpace(context, context.Graphics, memento, palette, values, state, displayRect, rtl, spacingGap, ref allocation, composition, glowing);
                AllocateLongTextSpace(context, context.Graphics, memento, palette, values, state, displayRect, rtl, spacingGap, ref allocation, composition, glowing);

                // Add up total allocated for rows and columns
                int allocatedWidth = AllocatedTotalWidth(allocation, -1, -1, spacingGap);
                int allocatedHeight = AllocatedTotalHeight(allocation);

                // Grab the padding for the content
                Padding borderPadding = palette.GetContentPadding(state);

                // For the form level buttons we have to calculate the correct padding based on caption area
                PaletteContentStyle contentStyle = palette.GetContentStyle();
                if ((contentStyle == PaletteContentStyle.ButtonForm) ||
                    (contentStyle == PaletteContentStyle.ButtonFormClose))
                    borderPadding = ContentPaddingForButtonForm(borderPadding, context, allocatedHeight);

                // The preferred size needed depends on the orientation.
                switch (orientation)
                {
                    case VisualOrientation.Top:
                    case VisualOrientation.Bottom:
                        // Preferred size is the allocated space for the content plus the border padding
                        return new Size(allocatedWidth + borderPadding.Horizontal,
                                        allocatedHeight + borderPadding.Vertical);
                    case VisualOrientation.Left:
                    case VisualOrientation.Right:
                        // Preferred size is the allocated space for the content plus the border padding
                        return new Size(allocatedHeight + borderPadding.Vertical,
                                        allocatedWidth + borderPadding.Horizontal);
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        return Size.Empty;
                }
            }
        }