Beispiel #1
0
        /// <summary>
        /// Apply to the VisualElement specified the Image properties of the current View.
        /// Derived class can call this method to apply the settings to custom VisualElement.
        /// </summary>
        /// <param name="elementImage"></param>
        protected virtual void PrepareVisualElementText(CellContext context, DevAge.Drawing.VisualElements.IText element)
        {
            if (element is DevAge.Drawing.VisualElements.TextRenderer)
            {
                DevAge.Drawing.VisualElements.TextRenderer elementText = (DevAge.Drawing.VisualElements.TextRenderer)element;

                elementText.Font            = GetDrawingFont(context.Grid);
                elementText.ForeColor       = ForeColor;
                elementText.TextFormatFlags = TextFormatFlags.Default;
                if (WordWrap)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.WordBreak;
                }
                if (TrimmingMode == TrimmingMode.Char)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.EndEllipsis;
                }
                else if (TrimmingMode == TrimmingMode.Word)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.WordEllipsis;
                }
                elementText.TextFormatFlags |= DevAge.Windows.Forms.Utilities.ContentAligmentToTextFormatFlags(TextAlignment);
            }
            else if (element is DevAge.Drawing.VisualElements.TextGDI)
            {
                DevAge.Drawing.VisualElements.TextGDI elementTextGDI = (DevAge.Drawing.VisualElements.TextGDI)element;

                elementTextGDI.Font      = GetDrawingFont(context.Grid);
                elementTextGDI.ForeColor = ForeColor;
                if (WordWrap)
                {
                    elementTextGDI.StringFormat.FormatFlags = (StringFormatFlags)0;
                }
                else
                {
                    elementTextGDI.StringFormat.FormatFlags = StringFormatFlags.NoWrap;
                }
                if (TrimmingMode == TrimmingMode.Char)
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.Character;
                }
                else if (TrimmingMode == TrimmingMode.Word)
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.Word;
                }
                else
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.None;
                }
                elementTextGDI.Alignment = TextAlignment;
            }

            //I have already set the TextFormatFlags for the alignment so the Anchor is not necessary. I have removed this code for performance reasons.
            //element.AnchorArea = new DevAge.Drawing.AnchorArea(TextAlignment, false);
            element.Value = context.GetDisplayText();
        }
Beispiel #2
0
        /// <summary>
        /// Apply to the VisualElement specified the Image properties of the current View.
        /// Derived class can call this method to apply the settings to custom VisualElement.
        /// </summary>
        protected virtual void PrepareVisualElementText(CellContext context)
        {
            if (ElementText is DevAge.Drawing.VisualElements.TextRenderer)
            {
                DevAge.Drawing.VisualElements.TextRenderer elementText = (DevAge.Drawing.VisualElements.TextRenderer)ElementText;

                elementText.TextFormatFlags = TextFormatFlags.Default | TextFormatFlags.NoPrefix;
                if (WordWrap)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.WordBreak;
                }
                if (TrimmingMode == TrimmingMode.Char)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.EndEllipsis;
                }
                else if (TrimmingMode == TrimmingMode.Word)
                {
                    elementText.TextFormatFlags |= TextFormatFlags.WordEllipsis;
                }
                elementText.TextFormatFlags |= DevAge.Windows.Forms.Utilities.ContentAligmentToTextFormatFlags(TextAlignment);
            }
            else if (ElementText is DevAge.Drawing.VisualElements.TextGDI)
            {
                DevAge.Drawing.VisualElements.TextGDI elementTextGDI = (DevAge.Drawing.VisualElements.TextGDI)ElementText;

                /*[email protected]: any formatflags set explicitly using ElementText
                 * will be of no use if it is simply reassigned when wordwrap is set to true*/
                //if (WordWrap)
                //    elementTextGDI.StringFormat.FormatFlags = (StringFormatFlags)0;
                if (!WordWrap)
                {
                    elementTextGDI.StringFormat.FormatFlags |= StringFormatFlags.NoWrap;
                }
                if (TrimmingMode == TrimmingMode.Char)
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.EllipsisCharacter;
                }
                else if (TrimmingMode == TrimmingMode.Word)
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.EllipsisWord;
                }
                else
                {
                    elementTextGDI.StringFormat.Trimming = StringTrimming.None;
                }
                elementTextGDI.Alignment = TextAlignment;
            }

            ElementText.Font      = GetDrawingFont(context.Grid);
            ElementText.ForeColor = ForeColor;
            //I have already set the TextFormatFlags for the alignment so the Anchor is not necessary. I have removed this code for performance reasons.
            //element.AnchorArea = new DevAge.Drawing.AnchorArea(TextAlignment, false);

            ElementText.Value = context.DisplayText;
        }
Beispiel #3
0
        private void Test_TextRenderer(Graphics gr)
        {
            DevAge.Drawing.VisualElements.TextRenderer text = new DevAge.Drawing.VisualElements.TextRenderer("Test text performance");

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 1000; i++)
                {
                    text.Draw(cache, panelDraw.ClientRectangle);
                }
            }
        }
Beispiel #4
0
        private void SetupCommonGridResources()
        {
            _columnHeaderView             = new SourceGrid.Cells.Views.ColumnHeader();
            _columnHeaderView.ElementText = new RotatedText(-60);
            _columnHeaderView.BackColor   = Color.LightYellow;

            _textRenderer = new DevAge.Drawing.VisualElements.TextRenderer();

            _defaultView = new SourceGrid.Cells.Views.Cell();
            _defaultView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            _defaultViewClearType             = new SourceGrid.Cells.Views.Cell();
            _defaultViewClearType.ElementText = _textRenderer;

            _yellowView             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _yellowView.BackColor   = Color.LightYellow;
            _yellowView.ElementText = _defaultView.ElementText;

            _lightGray             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _lightGray.BackColor   = Color.LightGray;
            _lightGray.ElementText = _defaultView.ElementText;

            _whiteView             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _whiteView.BackColor   = Color.White;
            _whiteView.ElementText = _defaultView.ElementText;

            _lightGreen             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _lightGreen.BackColor   = Color.LightGreen;
            _lightGreen.ElementText = _defaultView.ElementText;

            _darkGreen             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _darkGreen.BackColor   = Color.DarkGreen;
            _darkGreen.ForeColor   = Color.White;
            _darkGreen.ElementText = _defaultView.ElementText;

            _highlightView               = new SourceGrid.Cells.Views.Cell();
            _highlightView.BackColor     = Color.LightPink;
            _highlightView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            _highlightView.ElementText   = _defaultView.ElementText;
        }
Beispiel #5
0
        private void Test_TextRenderer(Graphics gr)
        {
            DevAge.Drawing.VisualElements.TextRenderer text = new DevAge.Drawing.VisualElements.TextRenderer("Test text performance");

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 1000; i++)
                    text.Draw(cache, panelDraw.ClientRectangle);
            }
        }
Beispiel #6
0
    private void SetupCommonGridResources()
    {
      _columnHeaderView = new SourceGrid.Cells.Views.ColumnHeader();
      _columnHeaderView.ElementText = new RotatedText(-60);
      _columnHeaderView.BackColor = Color.LightYellow;

      _textRenderer = new DevAge.Drawing.VisualElements.TextRenderer();

      _defaultView = new SourceGrid.Cells.Views.Cell();
      _defaultView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

      _defaultViewClearType = new SourceGrid.Cells.Views.Cell();
      _defaultViewClearType.ElementText = _textRenderer;

      _yellowView = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _yellowView.BackColor = Color.LightYellow;
      _yellowView.ElementText = _defaultView.ElementText;

      _lightGray = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _lightGray.BackColor = Color.LightGray;
      _lightGray.ElementText = _defaultView.ElementText;

      _whiteView = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _whiteView.BackColor = Color.White;
      _whiteView.ElementText = _defaultView.ElementText;

      _lightGreen = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _lightGreen.BackColor = Color.LightGreen;
      _lightGreen.ElementText = _defaultView.ElementText;

      _darkGreen = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _darkGreen.BackColor = Color.DarkGreen;
      _darkGreen.ForeColor = Color.White;
      _darkGreen.ElementText = _defaultView.ElementText;

      _highlightView = new SourceGrid.Cells.Views.Cell();
      _highlightView.BackColor = Color.LightPink;
      _highlightView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
      _highlightView.ElementText = _defaultView.ElementText;
    }