Beispiel #1
0
        /// <summary>
        /// Draws the specified text string at the specified location with the specified Brush and Font objects.
        /// </summary>
        /// <param name="s">String to draw.</param>
        /// <param name="font">Font that defines the text format of the string.</param>
        /// <param name="brush">Brush that determines the color and texture of the drawn text.</param>
        /// <param name="rectangleF">System.Drawing.RectangleF structure that specifies the location of the drawn text.</param>
        /// <param name="format">System.Drawing.StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.</param>
        public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF, StringFormat2 format)
        {
            if (format != null && rectangleF.Width > 0)
            {
                switch (format.Alignment)
                {
                case StringAlignment2.Center:
                    rectangleF.X += (rectangleF.Width - MeasureString(s, font, (int)rectangleF.Width, format).Width) * 0.5f;
                    break;

                case StringAlignment2.Far:
                    rectangleF.X += rectangleF.Width - MeasureString(s, font, (int)rectangleF.Width, format).Width;
                    break;
                }
            }
            textList.Add(new Text {
                X          = rectangleF.X,
                Y          = rectangleF.Y + (font.Height * 0.5f),
                FontFamily = font.Name,
                FontSize   = font.Size * 1.2f,
                FontWeight = font.Bold ? "bold" : "normal",
                Value      = s,
                Fill       = BrushColor(brush),
                Transform  = Transform
            });
        }
Beispiel #2
0
 public MockBulletFormat2(Font2 font = null)
 {
     if (font==null)
         this.font  = new MockFont();
     else
         this.font = font;
 }
        public void DrawEndedGood(GameTime currentTime) // Winner screen
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            spriteBatch.Draw(Background, Vector2.Zero, Color.White);

            string FinalScore = String.Format("Final score = {0}", Score);

            Vector2 StringDimensions = Font1.MeasureString(FinalScore);

            int XPos = (900 - (int)StringDimensions.X) / 2;

            spriteBatch.DrawString(Font1, FinalScore, new Vector2(XPos, 250), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("PRESS 'ESC' TO EXIT GAME");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "PRESS 'ESC' TO EXIT GAME", new Vector2(XPos, 350), Color.LimeGreen);

            StringDimensions = Font2.MeasureString("YOU WIN");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font2, "YOU WIN", new Vector2(XPos, 140), Color.LimeGreen);

            StringDimensions = Font3.MeasureString("Free for public use Earth photo, credit: NASA");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font3, "Free for public use Earth photo, credit: NASA", new Vector2(XPos, 630), Color.White);

            spriteBatch.End();
        }
Beispiel #4
0
        public Size2 MeasureString(string text, Font2 font)
        {
            SetFont(font);
            Chunk chunk = new Chunk(text, PdfGraphicUtils.GetFont(font));

            return(new Size2(chunk.GetWidthPoint() * 1.5f, font.Height * 0.5f * 1.5f));
        }
        public static Font GetFont(Font2 font)
        {
            Font f = FontFactory.GetFont("c:/windows/fonts/arial.ttf", BaseFont.CP1252, BaseFont.EMBEDDED,
                                         font.Size * 0.667f, font.Bold ? 1 : 0);

            try {
                string file;
                switch (font.Name)
                {
                case "Lucida Sans Unicode":
                    file = "c:/windows/fonts/L_10646.TTF";
                    break;

                case "Arial Unicode MS":
                    file = "c:/windows/fonts/ARIALUNI.TTF";
                    break;

                default:
                    file = $"c:/windows/fonts/{font.Name}.ttf";
                    break;
                }
                if (File.Exists(file))
                {
                    f = FontFactory.GetFont(file, BaseFont.CP1252, BaseFont.EMBEDDED, font.Size * 0.667f, font.Bold ? 1 : 0);
                }
            } catch (Exception) {
                // do nothing
            }
            return(f);
        }
Beispiel #6
0
 public BasicView()
 {
     BackColor = Color2.White;
     ForeColor = Color2.Black;
     Visible   = true;
     Font      = new Font2("Microsoft Sans Serif", 8.25f, FontStyle2.Regular);
 }
Beispiel #7
0
 public BasicView()
 {
     BackColor = Color2.White;
     ForeColor = Color2.Black;
     Visible = true;
     Font = new Font2("Microsoft Sans Serif", 8.25f, FontStyle2.Regular);
 }
Beispiel #8
0
        public void DrawString(string s, Font2 font, Brush2 brush, float x, float y)
        {
            StringFormat2 format = new StringFormat2 {
                Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near
            };

            DrawString(s, font, brush, new Rectangle2(new Point2(x, y), MeasureString(s, font)), format);
        }
Beispiel #9
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Type", true, out subEle);
            subEle.Value = Type.ToString();

            ele.TryPathTo("X", true, out subEle);
            subEle.Value = X.ToString();

            ele.TryPathTo("Y", true, out subEle);
            subEle.Value = Y.ToString();

            ele.TryPathTo("Width", true, out subEle);
            subEle.Value = Width.ToString();

            ele.TryPathTo("Height", true, out subEle);
            subEle.Value = Height.ToString();

            ele.TryPathTo("Orientation", true, out subEle);
            subEle.Value = Orientation.ToString("G15");

            ele.TryPathTo("Font1/Font", true, out subEle);
            subEle.Value = Font1.ToString();

            ele.TryPathTo("Font1/Color/Red", true, out subEle);
            subEle.Value = Font1Red.ToString("G15");

            ele.TryPathTo("Font1/Color/Green", true, out subEle);
            subEle.Value = Font1Green.ToString("G15");

            ele.TryPathTo("Font1/Color/Blue", true, out subEle);
            subEle.Value = Font1Blue.ToString("G15");

            ele.TryPathTo("Font1/Alignment", true, out subEle);
            subEle.Value = Font1Alignment.ToString();

            ele.TryPathTo("Unknown1", true, out subEle);
            subEle.Value = Unknown1.ToHex();

            ele.TryPathTo("Font2/Font", true, out subEle);
            subEle.Value = Font2.ToString();

            ele.TryPathTo("Font2/Color/Red", true, out subEle);
            subEle.Value = Font2Red.ToString("G15");

            ele.TryPathTo("Font2/Color/Green", true, out subEle);
            subEle.Value = Font2Green.ToString("G15");

            ele.TryPathTo("Font2/Color/Blue", true, out subEle);
            subEle.Value = Font2Blue.ToString("G15");

            ele.TryPathTo("Unknown2", true, out subEle);
            subEle.Value = Unknown2.ToHex();

            ele.TryPathTo("Stats", true, out subEle);
            subEle.Value = Stats.ToString();
        }
        internal static void DoPaint(IGraphics g, DataGridView grid)
        {
            Pen2          p            = new Pen2(GraphUtils.ToColor2(grid.GridColor));
            float         x            = grid.Location.X;
            float         y            = grid.Location.Y;
            Brush2        text         = new Brush2(GraphUtils.ToColor2(grid.ColumnHeadersDefaultCellStyle.ForeColor));
            Font2         headerFont   = GraphUtils.ToFont2(grid.ColumnHeadersDefaultCellStyle.Font);
            StringFormat2 headerformat = new StringFormat2 {
                Alignment     = StringAlignment2.Near,
                LineAlignment = StringAlignment2.Center
            };

            for (int c = 0; c < grid.Columns.Count; c++)
            {
                Brush2 header = new Brush2(GraphUtils.ToColor2(grid.Columns[c].HeaderCell.Style.BackColor));
                if (header.Color.IsEmpty || header.Color == Color2.Transparent || header.Color == Color2.Black ||
                    header.Color.Name == "0")
                {
                    header.Color = GraphUtils.ToColor2(grid.ColumnHeadersDefaultCellStyle.BackColor);
                }
                g.FillRectangle(header, x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight);
                g.DrawRectangle(p, x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight);
                g.DrawString(grid.Columns[c].HeaderText, headerFont, text,
                             new Rectangle2(x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight), headerformat);
                x += grid.Columns[c].Width;
            }
            y += grid.ColumnHeadersHeight;
            for (int r = 0; r < grid.Rows.Count; r++)
            {
                x = grid.Location.X;
                for (int c = 0; c < grid.Columns.Count; c++)
                {
                    Color2 backcolor = GetBackColor(grid, r, c);
                    Color2 forecolor = GetForeColor(grid, r, c);
                    if (!backcolor.IsEmpty)
                    {
                        g.FillRectangle(new Brush2(backcolor), x, y, grid.Columns[c].Width, grid.Rows[r].Height);
                    }
                    g.DrawRectangle(p, x, y, grid.Columns[c].Width, grid.Rows[r].Height);
                    object value = grid.Rows[r].Cells[c].Value;
                    if (value != null)
                    {
                        Font2         font       = GraphUtils.ToFont2(grid.DefaultCellStyle.Font);
                        StringFormat2 cellformat = GetStringFormat(grid.Columns[c].DefaultCellStyle.Alignment);
                        string        t          = value.ToString();
                        if (!string.IsNullOrEmpty(grid.Columns[c].DefaultCellStyle.Format))
                        {
                            string format = "{0:" + grid.Columns[c].DefaultCellStyle.Format.ToLower() + "}";
                            t = string.Format(format, value);
                        }
                        g.DrawString(t, font, new Brush2(forecolor), new Rectangle2(x, y, grid.Columns[c].Width, grid.Rows[r].Height),
                                     cellformat);
                    }
                    x += grid.Columns[c].Width;
                }
                y += grid.Rows[r].Height;
            }
        }
Beispiel #11
0
        public void TestMonospaceFont()
        {
            var font2         = new Font2("Courier New", 9);
            var convertedFont = GraphUtils.ToFont(font2);
            var nativeFont    = new Font(FontFamily.GenericMonospace, 9);

            Assert.AreEqual(nativeFont.Name, convertedFont.Name);
            Assert.AreEqual(nativeFont.Size, convertedFont.Size);
        }
Beispiel #12
0
        public void TestArialUnicode()
        {
            var font2 = new Font2("Arial Unicode MS", 9, FontStyle2.Regular);
            var font  = PdfGraphicUtils.GetFont(font2);

            Assert.IsNotNull(font.BaseFont);
            var convertedFont = GraphUtils.ToFont(font2);

            Assert.IsNotNull(convertedFont);
        }
Beispiel #13
0
 public MockBulletFormat2(Font2 font = null)
 {
     if (font == null)
     {
         this.font = new MockFont();
     }
     else
     {
         this.font = font;
     }
 }
Beispiel #14
0
        private void InitializeUI()
        {
            _HPBar.Size = new Vector2(_HPBar.Texture.Width, _HPBar.Texture.Height);
            _window.Text.Add(new UIText("Lifes: " + _arena.Me.Lifes.ToString(), new Vector2(40, 40), _window.Clr));
            var s = "Health";

            _window.Text.Add(new UIText(s, new Vector2(TVSGame.Resolution.X / 2 - Font2.MeasureString(s).X / 2, 3), _window.Clr));
            _window.Text.Add(new UIText("Ammo: " + _arena.Me.AmmoCount.ToString(), new Vector2(40, 75), _ammoWindow.Clr));
#if DEBUG
            _debugWindow.Text.Add(new UIText("Escape Button timer: " + _inputTest.ToString(), new Vector2(700, 40), _debugWindow.Clr));
            _debugWindow.Text.Add(new UIText("Framerate: " + (1 / _frameRate), new Vector2(700, 60), _debugWindow.Clr));
#endif
        }
        public void QueryFontColor(Font2 fontIn, Color2 colorIn, out Font2 font, out Color2 color)
        {
            font  = null;
            color = Color2.Empty;
            FontDialog fontDialog = new FontDialog {
                ShowColor = true,
                Font      = GraphUtils.ToFont(fontIn),
                Color     = GraphUtils.ToColor(colorIn)
            };

            if (fontDialog.ShowDialog() != DialogResult.Cancel)
            {
                font  = GraphUtils.ToFont2(fontDialog.Font);
                color = GraphUtils.ToColor2(fontDialog.Color);
            }
            fontDialog.Dispose();
        }
Beispiel #16
0
        public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF, StringFormat2 format)
        {
            template.BeginText();
            SetFont(font);
            SetBrush(brush);
            float x    = rectangleF.X;
            float y    = Math.Max(0, rectangleF.Y - rectangleF.Height / 2);
            Size2 size = MeasureString(s, font);

            if (format != null)
            {
                switch (format.Alignment)
                {
                case StringAlignment2.Center:
                    x = x + (rectangleF.Width - size.Width) / 2f;
                    break;

                case StringAlignment2.Near:
                    x = x + 2;
                    break;

                case StringAlignment2.Far:
                    x = x + (rectangleF.Width - size.Width) - 2;
                    break;
                }
                switch (format.LineAlignment)
                {
                case StringAlignment2.Center:
                    y = y + font.Height / 2f;
                    break;

                case StringAlignment2.Near:
                    y = y + 2;
                    break;

                case StringAlignment2.Far:
                    y = y + font.Height;
                    break;
                }
            }
            template.SetTextMatrix(x, currentHeight - y - font.Height * 0.5f * 1.5f);
            template.ShowText(s.TrimStart().TrimEnd());
            template.EndText();
        }
        public bool QueryFontColor(Font2 fontIn, Color2 colorIn, out Font2 font, out Color2 color)
        {
            font  = null;
            color = Color2.Empty;
            FontDialog fontDialog = new FontDialog {
                ShowColor = true,
                Font      = GraphUtils.ToFont(fontIn),
                Color     = GraphUtils.ToColor(colorIn)
            };
            bool ok = fontDialog.ShowDialog() == DialogResult.OK;

            if (ok)
            {
                font  = GraphUtils.ToFont2(fontDialog.Font);
                color = GraphUtils.ToColor2(fontDialog.Color);
            }
            fontDialog.Dispose();
            return(ok);
        }
        // apply text formats to textbox & placeholer
        public void ApplyTextEffect(string fontFamily, string fontColor, int fontSizeToIncrease, int fontTransparency)
        {
            PowerPoint.Shape shape = ShapeUtil.GetTextShapeToProcess(Shapes);
            if (shape == null)
            {
                return;
            }

            // a hack to enable the textbox layout
            shape.Width = shape.Width;

            shape.Fill.Visible = MsoTriState.msoFalse;
            shape.Line.Visible = MsoTriState.msoFalse;

            Font2 font = shape.TextFrame2.TextRange.TrimText().Font;

            if (!string.IsNullOrEmpty(fontColor))
            {
                font.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(fontColor));
            }

            if (!StringUtil.IsEmpty(fontFamily))
            {
                shape.TextEffect.FontName = fontFamily;
            }

            if (StringUtil.IsEmpty(shape.Tags[Tag.OriginalFontSize]))
            {
                shape.Tags.Add(Tag.OriginalFontSize, shape.TextEffect.FontSize.ToString(CultureInfo.InvariantCulture));
            }

            if (fontSizeToIncrease != -1)
            {
                shape.TextFrame.AutoSize  = PowerPoint.PpAutoSize.ppAutoSizeNone;
                shape.TextEffect.FontSize = float.Parse(shape.Tags[Tag.OriginalFontSize]) + fontSizeToIncrease;
            }

            if (fontTransparency != -1)
            {
                font.Fill.Transparency = (float)fontTransparency / 100;
            }
        }
        public void DrawControls(GameTime currentTime) // Controls screen
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            spriteBatch.Draw(Background, Vector2.Zero, Color.White);

            Vector2 StringDimensions = Font1.MeasureString("LEFT ARROW KEY = MOVE LEFT");

            int XPos = (900 - (int)StringDimensions.X) / 2;

            spriteBatch.DrawString(Font1, "LEFT ARROW KEY = MOVE LEFT", new Vector2(XPos, 200), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("RIGHT ARROW KEY = MOVE RIGHT");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "RIGHT ARROW KEY = MOVE RIGHT", new Vector2(XPos, 250), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("SPACEBAR = SHOOT");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "SPACEBAR = SHOOT", new Vector2(XPos, 300), Color.LimeGreen);

            StringDimensions = Font2.MeasureString("CONTROLS");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font2, "CONTROLS", new Vector2(XPos, 90), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("PRESS BACKSPACE TO RETURN TO START SCREEN");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "PRESS BACKSPACE TO RETURN TO START SCREEN", new Vector2(XPos, 400), Color.LimeGreen);

            StringDimensions = Font3.MeasureString("Free for public use Earth photo, credit: NASA");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font3, "Free for public use Earth photo, credit: NASA", new Vector2(XPos, 630), Color.White);

            spriteBatch.End();
        }
Beispiel #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="font"></param>
        /// <param name="width"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public SizeF MeasureString(string text, Font2 font, int width, StringFormat2 format)
        {
            TextFormatFlags flags = new TextFormatFlags();

            if (format != null)
            {
                switch (format.Alignment)
                {
                case StringAlignment2.Center:
                    flags = TextFormatFlags.HorizontalCenter;
                    break;

                case StringAlignment2.Near:
                    flags = TextFormatFlags.Left | TextFormatFlags.Top;
                    break;

                case StringAlignment2.Far:
                    flags = TextFormatFlags.Right | TextFormatFlags.Bottom;
                    break;
                }
            }
            return(TextRenderer.MeasureText(text, GraphUtils.ToFont(font), new Size(width, font.Height), flags));
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>

        // DRAWING CODE
        public void DrawStarted(GameTime gameTime) // Start screen
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            spriteBatch.Draw(Background, Vector2.Zero, Color.White);

            Vector2 StringDimensions = Font2.MeasureString("SPACE");

            int XPos = (900 - (int)StringDimensions.X) / 2;

            spriteBatch.DrawString(Font2, "SPACE", new Vector2(XPos, 100), Color.LimeGreen);

            StringDimensions = Font2.MeasureString("INVADERS");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font2, "INVADERS", new Vector2(XPos, 230), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("PRESS ENTER TO START GAME");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "PRESS ENTER TO START GAME", new Vector2(XPos, 350), Color.LimeGreen);

            StringDimensions = Font1.MeasureString("PRESS 'C' TO VIEW CONTROLS");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font1, "PRESS 'C' TO VIEW CONTROLS", new Vector2(XPos, 385), Color.LimeGreen);

            StringDimensions = Font3.MeasureString("Free for public use Earth photo, credit: NASA");

            XPos = (900 - (int)StringDimensions.X) / 2;
            spriteBatch.DrawString(Font3, "Free for public use Earth photo, credit: NASA", new Vector2(XPos, 630), Color.White);

            spriteBatch.End();
        }
Beispiel #22
0
 public Size2 MeasureString(string text, Font2 font, float width)
 {
     throw new System.NotImplementedException();
 }
Beispiel #23
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     throw new System.NotImplementedException();
 }
Beispiel #24
0
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 location)
 {
     throw new System.NotImplementedException();
 }
Beispiel #25
0
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 point, StringFormat2 format)
 {
     throw new System.NotImplementedException();
 }
Beispiel #26
0
 public void DrawString(string s, Font2 font, Brush2 brush, float x, float y)
 {
     throw new System.NotImplementedException();
 }
Beispiel #27
0
        private void SetFont(Font2 font)
        {
            Font f = PdfGraphicUtils.GetFont(font);

            template.SetFontAndSize(f.BaseFont, font.Size);
        }
Beispiel #28
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     DrawString(s, font, brush, rectangleF, new StringFormat2());
 }
Beispiel #29
0
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 location)
 {
     DrawString(s, font, brush, new Rectangle2(location, new Size2(0, 0)), new StringFormat2());
 }
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     throw new System.NotImplementedException();
 }
 public Size2 MeasureString(string text, Font2 font, float width)
 {
     throw new System.NotImplementedException();
 }
Beispiel #32
0
 private static void DrawString(IGraphics g, string s, Font2 font, Brush2 brush, float x, float y)
 {
     try{
         g.DrawString(s, font, brush, x, y);
     } catch (Exception) {}
 }
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 location)
 {
     throw new System.NotImplementedException();
 }
Beispiel #34
0
        public void OnPaint(IGraphics g, int xm, int ym, int width, int height)
        {
            if (!Visible)
            {
                return;
            }
            if (TotalMax == double.NegativeInfinity)
            {
                return;
            }
            if ((indicator1 != -1 && indicator2 != -1) || (ZoomType == AxisZoomType.Indicate && !IsFullZoom()))
            {
                if (IsValid())
                {
                    PaintIndicator(g, width, height);
                }
            }
            Pen2   forePen     = new Pen2(ForeColor, LineWidth);
            Pen2   majorTicPen = new Pen2(ForeColor, MajorTickLineWidth);
            Pen2   minorTicPen = new Pen2(ForeColor, MinorTickLineWidth);
            Brush2 brush       = new Brush2(ForeColor);

            g.SmoothingMode = SmoothingMode2.AntiAlias;
            string label = Text ?? "";
            float  x0;
            float  y0;
            int    decade = 0;

            double[][] tics = null;
            double     max  = 0;

            if (IsValid())
            {
                decade = (int)Math.Floor(Math.Log(Math.Max(Math.Abs(VisibleMax), Math.Abs(VisibleMin))) / Math.Log(10));
                if (decade > 0 && decade < MaxNumIntegerDigits)
                {
                    decade = 0;
                }
                if (decade != 0 && !IsLogarithmic)
                {
                    label += " [1" + ToSuperscript(decade) + ']';
                }
                tics = GetTics(GetLength(width, height));
                if (tics == null)
                {
                    return;
                }
                max = Math.Max(Math.Abs(ArrayUtils.Max(tics[0])), Math.Abs(ArrayUtils.Min(tics[0])));
            }
            Font2 font = labelFont;

            while (g.MeasureString(label, font).Width > Math.Max(width, height) * 0.95f && font.Size > 5f)
            {
                font = new Font2(font.Name, font.Size - 0.5f, font.Style);
            }
            switch (Positioning)
            {
            case AxisPositioning.Top:
                y0 = height - 1;
                g.DrawLine(forePen, xm, ym + y0, xm + width, ym + y0);
                if (IsValid() && tics != null)
                {
                    int previousstringEnd = -Sign * int.MaxValue;
                    for (int i = 0; i < tics[0].Length; i++)
                    {
                        x0 = ModelToView(tics[0][i], width, height);
                        g.DrawLine(majorTicPen, xm + x0, ym + y0, xm + x0, ym + y0 - MajorTickLength);
                        string s   = GetTicLabel(tics[0][i], decade, max);
                        int    w   = (int)g.MeasureString(s, numbersFont).Width;
                        int    pos = (int)(x0 - w / 2.0);
                        pos = Math.Max(-2, pos);
                        pos = Math.Min(width - w + 2, pos);
                        if (Sign * pos > Sign * previousstringEnd)
                        {
                            DrawString(g, s, numbersFont, brush, xm + pos + 1, ym + y0 - MajorTickLength - numbersFont.Height);
                            previousstringEnd = pos + Sign * w;
                        }
                    }
                    for (int i = 0; i < tics[1].Length; i++)
                    {
                        x0 = ModelToView(tics[1][i], width, height);
                        g.DrawLine(minorTicPen, xm + x0, ym + y0, xm + x0, ym + y0 - MinorTickLength);
                    }
                }
                DrawString(g, label, font, brush, xm + (width) / 2 - (int)g.MeasureString(label, font).Width / 2,
                           ym + y0 - MajorTickLength - labelFont.Height - 12);
                break;

            case AxisPositioning.Left:
                x0 = width - 1;
                g.DrawLine(forePen, xm + x0, ym, xm + x0, ym + height);
                if (IsValid() && tics != null)
                {
                    int previousstringEnd = -Sign * Int32.MaxValue;
                    for (int i = 0; i < tics[0].Length; i++)
                    {
                        y0 = ModelToView(tics[0][i], width, height);
                        g.DrawLine(majorTicPen, xm + x0, ym + y0, xm + x0 - MajorTickLength, ym + y0);
                        string s   = GetTicLabel(tics[0][i], decade, max);
                        int    w   = (int)g.MeasureString(s, numbersFont).Width;
                        int    pos = (int)(y0 + w / 2.0) + 1;
                        pos = Math.Max(w - 2, pos);
                        pos = Math.Min(height + 2, pos);
                        if (Sign * pos > Sign * previousstringEnd)
                        {
                            g.RotateTransform(-90);
                            DrawString(g, s, numbersFont, brush, -pos - ym, xm + x0 - MajorTickLength - numbersFont.Height);
                            g.RotateTransform(90);
                            previousstringEnd = pos + Sign * w;
                        }
                    }
                    for (int i = 0; i < tics[1].Length; i++)
                    {
                        y0 = ModelToView(tics[1][i], width, height);
                        g.DrawLine(minorTicPen, xm + x0, ym + y0, xm + x0 - MinorTickLength, ym + y0);
                    }
                }
                g.RotateTransform(-90);
                float x = -height / 2 - (int)g.MeasureString(label, font).Width / 2;
                float y = x0 - MajorTickLength - labelFont.Height - numbersFont.Height - 10;
                if (y < 0)
                {
                    y = 0;
                }
                DrawString(g, label, font, brush, -ym + x, xm + y - 2);
                g.RotateTransform(90);
                break;

            case AxisPositioning.Bottom:
                y0 = 0;
                g.DrawLine(forePen, xm, ym + y0, xm + width, ym + y0);
                if (IsValid() && tics != null)
                {
                    int previousstringEnd = -Sign * Int32.MaxValue;
                    for (int i = 0; i < tics[0].Length; i++)
                    {
                        x0 = ModelToView(tics[0][i], width, height);
                        g.DrawLine(majorTicPen, xm + x0, ym + y0, xm + x0, ym + y0 + MajorTickLength);
                        string s   = GetTicLabel(tics[0][i], decade, max);
                        int    w   = (int)g.MeasureString(s, numbersFont).Width;
                        int    pos = (int)(x0 - w / 2.0);
                        pos = Math.Max(-2, pos);
                        pos = Math.Min(width - w + 2, pos);
                        if (Sign * pos > Sign * previousstringEnd)
                        {
                            DrawString(g, s, numbersFont, brush, xm + pos + 1, ym + y0 + 1 + MajorTickLength - 1);
                            previousstringEnd = pos + Sign * w;
                        }
                    }
                    for (int i = 0; i < tics[1].Length; i++)
                    {
                        x0 = ModelToView(tics[1][i], width, height);
                        g.DrawLine(minorTicPen, xm + x0, ym + y0, xm + x0, ym + y0 + MinorTickLength);
                    }
                }
                DrawString(g, label, font, brush, xm + (width) / 2 - (int)g.MeasureString(label, font).Width / 2,
                           ym + y0 + MajorTickLength + 12);
                break;

            case AxisPositioning.Right:
                x0 = 0;
                g.DrawLine(forePen, xm + x0, ym, xm + x0, ym + height);
                if (IsValid() && tics != null)
                {
                    int previousstringEnd = -Sign * Int32.MaxValue;
                    for (int i = 0; i < tics[0].Length; i++)
                    {
                        y0 = ModelToView(tics[0][i], width, height);
                        g.DrawLine(majorTicPen, xm + x0, ym + y0, xm + x0 + MajorTickLength, ym + y0);
                        string s   = GetTicLabel(tics[0][i], decade, max);
                        int    w   = (int)g.MeasureString(s, numbersFont).Width;
                        int    pos = (int)(y0 - w / 2.0);
                        pos = Math.Max(-2, pos);
                        pos = Math.Min(height - w + 2, pos);
                        if (Sign * pos > Sign * previousstringEnd)
                        {
                            g.RotateTransform(90);
                            DrawString(g, s, numbersFont, brush, ym + pos + 1, -xm - MajorTickLength - numbersFont.Height * 0.99f);
                            g.RotateTransform(-90);
                            previousstringEnd = pos + Sign * w;
                        }
                    }
                    for (int i = 0; i < tics[1].Length; i++)
                    {
                        y0 = ModelToView(tics[1][i], width, height);
                        g.DrawLine(minorTicPen, xm + x0, ym + y0, xm + x0 + MinorTickLength, ym + y0);
                    }
                }
                g.RotateTransform(90);
                DrawString(g, label, font, brush, ym + height / 2 - (int)g.MeasureString(label, font).Width / 2,
                           -xm - MajorTickLength - numbersFont.Height - labelFont.Height - 3);
                g.RotateTransform(-90);
                break;
            }
        }
 public void DrawString(string s, Font2 font, Brush2 brush, float x, float y)
 {
     throw new System.NotImplementedException();
 }
Beispiel #36
0
 public static Font ToFont(Font2 f)
 {
     return(new Font(f.Name, f.Size, ToFontStyle(f.Style)));
 }
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 point, StringFormat2 format)
 {
     throw new System.NotImplementedException();
 }