예제 #1
0
        /// <summary>
        /// Gets the text trimming to use for long text.
        /// </summary>
        /// <param name="style">Content style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>PaletteTextTrim value.</returns>
        public override PaletteTextTrim GetContentLongTextTrim(PaletteContentStyle style, PaletteState state)
        {
            IPaletteContent inherit = GetInherit(state);

            if (inherit != null)
            {
                return(inherit.GetContentLongTextTrim(state));
            }
            else
            {
                return(Target.GetContentLongTextTrim(style, state));
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the text trimming to use for long text.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>PaletteTextTrim value.</returns>
        public virtual PaletteTextTrim GetContentLongTextTrim(PaletteState state)
        {
            if (Apply)
            {
                PaletteTextTrim ret = _primaryContent.GetContentLongTextTrim(Override ? OverrideState : state);

                if (ret == PaletteTextTrim.Inherit)
                {
                    ret = _backupContent.GetContentLongTextTrim(state);
                }

                return(ret);
            }
            else
            {
                return(_backupContent.GetContentLongTextTrim(state));
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the text trimming to use for long text.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>PaletteTextTrim value.</returns>
        public override PaletteTextTrim GetContentLongTextTrim(PaletteState state)
        {
            if (_apply)
            {
                PaletteTextTrim ret = _primary.GetContentLongTextTrim(_override ? _state : state);

                if (ret == PaletteTextTrim.Inherit)
                {
                    ret = _backup.GetContentLongTextTrim(state);
                }

                return(ret);
            }
            else
            {
                return(_backup.GetContentLongTextTrim(state));
            }
        }
예제 #4
0
 /// <summary>
 /// Gets the text trimming to use for long text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>PaletteTextTrim value.</returns>
 public override PaletteTextTrim GetContentLongTextTrim(PaletteState state)
 {
     return(_inherit.GetContentLongTextTrim(state));
 }
예제 #5
0
        /// <summary>
        /// Gets the text trimming to use for long text.
        /// </summary>
        /// <param name="style">Content style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>PaletteTextTrim value.</returns>
        public override PaletteTextTrim GetContentLongTextTrim(PaletteContentStyle style, PaletteState state)
        {
            IPaletteContent inherit = GetInherit(state);

            return(inherit?.GetContentLongTextTrim(state) ?? Target.GetContentLongTextTrim(style, state));
        }
예제 #6
0
        private static void AllocateLongTextSpace(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.DrawLongText = false;

            // Get the defined text for display
            string longText = contentValues.GetLongText();

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

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

                // Cache the rendering hint used
                memento.LongTextHint = CommonHelper.PaletteTextHintToRenderingHint(paletteContent.GetContentLongTextHint(state));
                memento.LongTextTrimming = paletteContent.GetContentLongTextTrim(state);

                bool fontChanged = false;
                Font textFont = paletteContent.GetContentLongTextFont(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.LongTextMemento = AccurateText.MeasureString(g,
                                                                     rtl,
                                                                     longText,
                                                                     textFont,
                                                                     memento.LongTextTrimming,
                                                                     paletteContent.GetContentLongTextMultiLineH(state),
                                                                     paletteContent.GetContentLongTextPrefix(state),
                                                                     memento.LongTextHint,
                                                                     composition,
                                                                     glowing,
                                                                     fontChanged);

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

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

                    // Mark the memento to draw the long text
                    memento.DrawLongText = true;
                }
            }
        }
 /// <summary>
 /// Gets the text trimming to use for long text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>PaletteTextTrim value.</returns>
 public virtual PaletteTextTrim GetContentLongTextTrim(PaletteState state)
 {
     return(_content.GetContentLongTextTrim(state));
 }
예제 #8
0
 /// <summary>
 /// Gets the text trimming to use for long text.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>PaletteTextTrim value.</returns>
 public override PaletteTextTrim GetContentLongTextTrim(PaletteState state) => _inherit.GetContentLongTextTrim(state);