示例#1
0
        private void DrawTextScrn(int font, DrawBrush brush, Vector3d a, Vector3d dir, DrawTextOption opt, string s)
        {
            if (brush.GdiBrush == null)
            {
                return;
            }
            if (DC.Font(font) == null)
            {
                return;
            }

            if (opt.Option != 0)
            {
                Vector3d sz = MeasureText(font, s);

                if ((opt.Option | DrawTextOption.H_CENTER) != 0)
                {
                    double slen = sz.X / 2;

                    Vector3d ud = Vector3d.UnitX;

                    if (!dir.IsZero())
                    {
                        ud = dir.UnitVector();
                    }

                    a = a - (ud * slen);
                }
            }

            double angle = 0;

            if (!(dir.X == 0 && dir.Y == 0))
            {
                angle = CadMath.Angle2D(dir);
            }

            angle = CadMath.Rad2Deg(angle);

            DC.GdiGraphics.TranslateTransform((int)a.X, (int)a.Y);

            DC.GdiGraphics.RotateTransform((float)angle);

            Font  f = DC.Font(font);
            Brush b = brush.GdiBrush;

            DC.GdiGraphics.DrawString(s, f, b, 0, 0);

            DC.GdiGraphics.ResetTransform();
        }