Esempio n. 1
0
        public void Test_ExtSizeF()
        {
            ExtSizeF sz = new ExtSizeF(11, 11);

            Assert.AreEqual(11, sz.Width);
            Assert.AreEqual(11, sz.Height);
            Assert.IsFalse(sz.IsEmpty);
            Assert.AreEqual("{Width=11, Height=11}", sz.ToString());
        }
Esempio n. 2
0
        private bool IsNarrowSegment(string text, float radius, float wedgeAngle, IFont font)
        {
            ExtSizeF size = fRenderer.GetTextSize(text, font);

            radius = radius + size.Height / 2.0f;

            float wedgeL = radius * (float)MathHelper.DegreesToRadians(wedgeAngle);

            return(wedgeL / size.Width <= 0.9f);
        }
Esempio n. 3
0
        public override void DrawArcText(string text, float centerX, float centerY, float radius,
                                         float startAngle, float wedgeAngle,
                                         bool inside, bool clockwise, IFont font, IBrush brush)
        {
            ExtSizeF size = GetTextSize(text, font);

            radius = radius + size.Height / 2.0f;

            float textAngle  = Math.Min((float)SysUtils.RadiansToDegrees((size.Width * 1.75f) / radius), wedgeAngle);
            float deltaAngle = (wedgeAngle - textAngle) / 2.0f;

            if (clockwise)
            {
                startAngle += deltaAngle;
            }
            else
            {
                startAngle += wedgeAngle - deltaAngle;
            }
            startAngle = -startAngle;

            Matrix previousTransformation = fCanvas.Transform;

            for (int i = 0; i < text.Length; ++i)
            {
                float offset = (textAngle * ((float)(i) / text.Length));
                float angle  = clockwise ? startAngle - offset : startAngle + offset;

                double radAngle     = angle * (Math.PI / 180.0d);
                float  x            = (float)(centerX + Math.Cos(radAngle) * radius);
                float  y            = (float)(centerY - Math.Sin(radAngle) * radius);
                float  charRotation = 90 - (inside ? angle : angle + 180);
                charRotation *= (float)(Math.PI / 180.0f);
                float cosine = (float)(Math.Cos(charRotation));
                float sine   = (float)(Math.Sin(charRotation));

                Matrix m = new Matrix(cosine, sine, -sine, cosine, x, y);
                m.Multiply(previousTransformation, MatrixOrder.Append);
                fCanvas.Transform = m;

                string chr = new string(text[i], 1);
                DrawString(chr, font, brush, 0, 0);
            }

            fCanvas.Transform = previousTransformation;
        }
Esempio n. 4
0
        public virtual void DrawArcText(string text, float centerX, float centerY,
                                        float radius, float startAngle, float wedgeAngle,
                                        bool inside, bool clockwise, IFont font, IBrush brush)
        {
            ExtSizeF size = GetTextSize(text, font);

            radius = radius + size.Height / 2.0f;

            float textAngle  = Math.Min((float)MathHelper.RadiansToDegrees((size.Width * 1.75f) / radius), wedgeAngle);
            float deltaAngle = (wedgeAngle - textAngle) / 2.0f;

            if (clockwise)
            {
                startAngle += deltaAngle;
            }
            else
            {
                startAngle += wedgeAngle - deltaAngle;
            }
            startAngle = -startAngle;

            for (int i = 0; i < text.Length; ++i)
            {
                float  offset       = (textAngle * ((float)(i) / text.Length));
                float  angle        = clockwise ? startAngle - offset : startAngle + offset;
                double radAngle     = angle * (Math.PI / 180.0d);
                float  x            = (float)(centerX + Math.Cos(radAngle) * radius);
                float  y            = (float)(centerY - Math.Sin(radAngle) * radius);
                float  charRotation = 90 - (inside ? angle : angle + 180);

                SaveTransform();
                TranslateTransform(x, y);
                RotateTransform(charRotation);
                DrawString(text.Substring(i, 1), font, brush, 0, 0);
                RestoreTransform();
            }
        }