GetElementFont() public method

public GetElementFont ( ) : Font
return System.Drawing.Font
Beispiel #1
0
        private void UpdateElementValues(ProjectLayoutElement zElement)
        {
            if (null != zElement)
            {
                m_bFireElementChangeEvents = false;
                numericElementX.Value = zElement.x;
                numericElementY.Value = zElement.y;
                numericElementW.Value = zElement.width;
                numericElementH.Value = zElement.height;
                numericElementRotation.Value = (decimal)zElement.rotation;
                numericElementBorderThickness.Value = (decimal)zElement.borderthickness;
                numericElementOutLineThickness.Value = (decimal)zElement.outlinethickness;
                numericLineSpace.Value = (decimal)zElement.lineheight;
                numericWordSpace.Value = (decimal)zElement.wordspace;
                checkFontAutoScale.Checked = zElement.autoscalefont;
                checkLockAspect.Checked = zElement.lockaspect;
                checkKeepOriginalSize.Checked = zElement.keeporiginalsize;
                numericElementOpacity.Value = (decimal)zElement.opacity;
                comboTextHorizontalAlign.SelectedIndex = zElement.horizontalalign;
                comboTextVerticalAlign.SelectedIndex = zElement.verticalalign;
                comboGraphicHorizontalAlign.SelectedIndex = zElement.horizontalalign;
                comboGraphicVerticalAlign.SelectedIndex = zElement.verticalalign;
                txtElementVariable.Text = zElement.variable;
                txtElementVariable.SelectionStart = zElement.variable.Length;
                txtElementVariable.SelectionLength = 0;
                ElementType eType = m_dictionaryElementTypes[zElement.type];
                switch (eType)
                {
                    case ElementType.Shape:
                        // configure the combo box and property grid for the shap
                        string sType = AbstractShape.GetShapeType(zElement.variable);
                        if (null != sType)
                        {
                            int nSelectedIndex;
                            if (dictionaryShapeTypeIndex.TryGetValue(sType, out nSelectedIndex))
                            {
                                comboShapeType.SelectedIndex = nSelectedIndex;
                                var zShape = (AbstractShape)comboShapeType.SelectedItem;
                                zShape.InitializeItem(zElement.variable);
                                // associated the prop grid with this shape object
                                propertyGridShape.SelectedObject = zShape;
                            }
                        }
                        break;
                    case ElementType.Text:
                        checkFontAutoScale.Visible = true;
                        lblWordSpacing.Visible = false;
                        numericWordSpace.Visible = false;
                        break;
                    case ElementType.FormattedText:
                        checkFontAutoScale.Visible = false;
                        lblWordSpacing.Visible = true;
                        numericWordSpace.Visible = true;
                        break;
                }
                comboElementType.SelectedIndex = (int)eType;
                UpdatePanelColors(zElement);
                groupBoxElement.Enabled = true;
                Font zFont = zElement.GetElementFont();
                zFont = zFont ?? DrawItem.DefaultFont;
                for (int nFontIndex = 0; nFontIndex < comboFontName.Items.Count; nFontIndex++)
                {
                    if (zFont.Name.Equals((string)comboFontName.Items[nFontIndex], StringComparison.CurrentCultureIgnoreCase))
                    {
                        comboFontName.SelectedIndex = nFontIndex;
                        break;
                    }
                }

                SetupElementFont(zFont);
                m_bFireElementChangeEvents = true;
            }
            else
            {
                groupBoxElement.Enabled = false;
            }
        }
Beispiel #2
0
        public static void DrawElement(Graphics zGraphics, Deck zDeck, ProjectLayoutElement zElement, ElementType eType, int nX, int nY, string sInput)
        {
            switch (eType)
            {
                case ElementType.Graphic:
                case ElementType.Shape:
                    sInput = sInput.Trim();
                    break;
            }

            Font zFont = null;
            Brush zBrush = null;
            Pen zBorderPen = null;

            Color colorFont = Color.Black;

            if (0 != zElement.borderthickness)
            {
                zBorderPen = 255 != zElement.opacity
                    ? new Pen(Color.FromArgb(zElement.opacity, zElement.GetElementBorderColor()), zElement.borderthickness)
                    : new Pen(zElement.GetElementBorderColor(), zElement.borderthickness);
            }

            // Setup
            switch (eType)
            {
                case ElementType.Text:
                case ElementType.FormattedText:
                    zFont = zElement.GetElementFont();
                    colorFont = zElement.GetElementColor();
                    zBrush = new SolidBrush(colorFont);
                    break;
                case ElementType.Graphic:
                case ElementType.Shape:
                    break;
                default:
                    return;
            }

            // NOTE: this is the first transform
            if (0 != zElement.rotation)
            {
                // center the internal element then rotate and restore
                zGraphics.TranslateTransform(zElement.x + nX + (zElement.width >> 1), zElement.y + nY + (zElement.height >> 1));
                zGraphics.RotateTransform(zElement.rotation);
                zGraphics.TranslateTransform(-(zElement.width >> 1), -(zElement.height >> 1));
            }
            else
            {
                zGraphics.TranslateTransform(zElement.x + nX, zElement.y + nY);
            }
            // TODO: an interface for all these would be more appropriate

            // Draw
            switch (eType)
            {
                case ElementType.Text:
                    DrawText(zGraphics, zElement, sInput, zBrush, zFont, colorFont);
                    break;
                case ElementType.FormattedText:
                    DrawFormattedText(zGraphics, zDeck, zElement, sInput, zBrush, zFont, colorFont);
                    break;
                case ElementType.Graphic:
                    DrawGraphic(zGraphics, sInput, zElement);
                    break;
                case ElementType.Shape:
                    ShapeManager.HandleShapeRender(zGraphics, sInput.ToLower(), zElement);
                    break;
            }

            if (null != zBorderPen)
            {
                // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
                zGraphics.DrawRectangle(zBorderPen, 0,0,zElement.width - 1, zElement.height - 1);
            }

            zGraphics.ResetTransform();
        }