示例#1
0
        /// <summary>
        /// Gets the horizontal relative alignment of the short text.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>RelativeAlignment value.</returns>
        public virtual PaletteRelativeAlign GetContentShortTextH(PaletteState state)
        {
            if (Apply)
            {
                PaletteRelativeAlign ret = _primaryContent.GetContentShortTextH(Override ? OverrideState : state);

                if (ret == PaletteRelativeAlign.Inherit)
                {
                    ret = _backupContent.GetContentShortTextH(state);
                }

                return(ret);
            }
            else
            {
                return(_backupContent.GetContentShortTextH(state));
            }
        }
示例#2
0
 /// <summary>
 /// Gets the horizontal relative alignment of the short text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public override PaletteRelativeAlign GetContentShortTextH(PaletteState state)
 {
     return(_cellStyle.Alignment switch
     {
         DataGridViewContentAlignment.TopLeft or DataGridViewContentAlignment.MiddleLeft or DataGridViewContentAlignment.BottomLeft => PaletteRelativeAlign.Near,
         DataGridViewContentAlignment.TopCenter or DataGridViewContentAlignment.MiddleCenter or DataGridViewContentAlignment.BottomCenter => PaletteRelativeAlign.Center,
         DataGridViewContentAlignment.TopRight or DataGridViewContentAlignment.MiddleRight or DataGridViewContentAlignment.BottomRight => PaletteRelativeAlign.Far,
         _ => _inherit.GetContentShortTextH(state)
     });
示例#3
0
        /// <summary>
        /// Gets the horizontal relative alignment of the short text.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>RelativeAlignment value.</returns>
        public override PaletteRelativeAlign GetContentShortTextH(PaletteState state)
        {
            if (_apply)
            {
                PaletteRelativeAlign ret = _primary.GetContentShortTextH(_override ? _state : state);

                if (ret == PaletteRelativeAlign.Inherit)
                {
                    ret = _backup.GetContentShortTextH(state);
                }

                return(ret);
            }
            else
            {
                return(_backup.GetContentShortTextH(state));
            }
        }
 /// <summary>
 /// Gets the horizontal relative alignment of the short text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public override PaletteRelativeAlign GetContentShortTextH(PaletteState state)
 {
     if (ForceShortTextHCenter)
     {
         return(PaletteRelativeAlign.Center);
     }
     else
     {
         return(_inherit.GetContentShortTextH(state));
     }
 }
示例#5
0
 /// <summary>
 /// Gets the actual content short text horizontal alignment value.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public PaletteRelativeAlign GetContentShortTextH(PaletteState state)
 {
     if (_shortText.TextH != PaletteRelativeAlign.Inherit)
     {
         return(_shortText.TextH);
     }
     else
     {
         return(_inherit.GetContentShortTextH(state));
     }
 }
        /// <summary>
        /// Gets the horizontal relative alignment of the short text.
        /// </summary>
        /// <param name="style">Content style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>RelativeAlignment value.</returns>
        public override PaletteRelativeAlign GetContentShortTextH(PaletteContentStyle style, PaletteState state)
        {
            IPaletteContent inherit = GetInherit(state);

            if (inherit != null)
            {
                return(inherit.GetContentShortTextH(state));
            }
            else
            {
                return(Target.GetContentShortTextH(style, state));
            }
        }
示例#7
0
        /// <summary>
        /// Gets the horizontal relative alignment of the short text.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>RelativeAlignment value.</returns>
        public override PaletteRelativeAlign GetContentShortTextH(PaletteState state)
        {
            switch (_cellStyle.Alignment)
            {
            case DataGridViewContentAlignment.TopLeft:
            case DataGridViewContentAlignment.MiddleLeft:
            case DataGridViewContentAlignment.BottomLeft:
                return(PaletteRelativeAlign.Near);

            case DataGridViewContentAlignment.TopCenter:
            case DataGridViewContentAlignment.MiddleCenter:
            case DataGridViewContentAlignment.BottomCenter:
                return(PaletteRelativeAlign.Center);

            case DataGridViewContentAlignment.TopRight:
            case DataGridViewContentAlignment.MiddleRight:
            case DataGridViewContentAlignment.BottomRight:
                return(PaletteRelativeAlign.Far);

            case DataGridViewContentAlignment.NotSet:
            default:
                return(_inherit.GetContentShortTextH(state));
            }
        }
示例#8
0
        /// <summary>
        /// Gets the horizontal relative alignment of the short text.
        /// </summary>
        /// <param name="style">Content style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>RelativeAlignment value.</returns>
        public override PaletteRelativeAlign GetContentShortTextH(PaletteContentStyle style, PaletteState state)
        {
            IPaletteContent inherit = GetInherit(state);

            return(inherit?.GetContentShortTextH(state) ?? Target.GetContentShortTextH(style, state));
        }
 /// <summary>
 /// Gets the horizontal relative alignment of the short text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public override PaletteRelativeAlign GetContentShortTextH(PaletteState state)
 {
     return(_inherit.GetContentShortTextH(state));
 }
示例#10
0
 /// <summary>
 /// Gets the horizontal relative alignment of the short text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public override PaletteRelativeAlign GetContentShortTextH(PaletteState state) => ForceShortTextHCenter
             ? PaletteRelativeAlign.Center
             : _inherit.GetContentShortTextH(state);
示例#11
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);
        }
示例#12
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;
                }
            }
        }
 /// <summary>
 /// Gets the horizontal relative alignment of the short text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>RelativeAlignment value.</returns>
 public virtual PaletteRelativeAlign GetContentShortTextH(PaletteState state)
 {
     return(_content.GetContentShortTextH(state));
 }