Esempio n. 1
0
        void FillGeometry(Graphics graphics, SinTransform transform, Color color, Geometry geometry)
        {
            if (graphics == null ||
                geometry == null)
            {
                return;
            }

            GeometrySegmentator geometrySegmentator = new GeometrySegmentator(geometry);
            GeometryTransformer geometrySegmentatorPolarTransformer = new GeometryTransformer(geometrySegmentator, transform);

            graphics.FillGeometry(color, geometrySegmentatorPolarTransformer);
        }
Esempio n. 2
0
        void DrawGeometry(Graphics graphics, SinTransform transform, Color color, Geometry geometry, double thickness)
        {
            if (graphics == null ||
                geometry == null)
            {
                return;
            }

            GeometrySegmentator geometrySegmentator = new GeometrySegmentator(geometry);
            GeometryTransformer geometrySegmentatorPolarTransformer = new GeometryTransformer(geometrySegmentator, transform);

            graphics.DrawGeometry(color, geometrySegmentatorPolarTransformer, thickness);
        }
Esempio n. 3
0
 void DrawGeometry(Graphics graphics, SinTransform transform, Color color, Geometry geometry)
 {
     DrawGeometry(graphics, transform, color, geometry, 1);
 }
Esempio n. 4
0
        protected override void OnPaint(GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Graphics graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;


            SinTransform polarTransform = new SinTransform();

            polarTransform.SetSinScale(m_PeriodSlider.Value, m_AmplitudeSlider.Value);
            polarTransform.Shift = m_ShiftSlider.Value;
            polarTransform.SetTranslation((ClientWidth - m_TextBox.Width) / 2.0, (ClientHeight - m_TextBox.Height) / 2.0 - 10.0);


            //  Draw Background
            RectangleGeometry borderGeometry = new RectangleGeometry(0, 0, m_TextBox.Width, m_TextBox.Height);
            //  Just for little optimization
            GeometrySegmentator borderGeometrySegmentator = new GeometrySegmentator(borderGeometry);
            GeometryTransformer borderGeometrySegmentatorPolarTransformer = new GeometryTransformer(borderGeometrySegmentator, polarTransform);

            graphics.FillGeometry(Color.WhiteSmoke, borderGeometrySegmentatorPolarTransformer);


            //  Selection
            if (m_TextBox.HasSelectionAndVisible)
            {
                RectangleGeometry selectionGeometry = new RectangleGeometry(m_TextBox.SelectionBounds
                                                                            //  Just to prevent some artefacts
                                                                            - new PointI(0, 1) + new SizeI(0, 2));

                FillGeometry(graphics, polarTransform, m_TextBox.SelectionColor, selectionGeometry);
            }


            //  Caret
            if (m_TextBox.IsCaretVisible)
            {
                RectangleGeometry caretGeometry = new RectangleGeometry(m_TextBox.CaretBounds);

                FillGeometry(graphics, polarTransform, Color.Black, caretGeometry);
            }


            //  Draw Border
            graphics.DrawGeometry(Color.DodgerBlue, borderGeometrySegmentatorPolarTransformer, 2);


            //  Text
            Font         font         = m_TextBox.Font;
            GraphicsPath textGeometry = new GraphicsPath();

            textGeometry.AddString(
                m_TextBox.Text,
                font.FontFamily, font.Style, font.Size * 96.0 / 72.0, new Point(4, 1), StringFormat.GenericTypographic);
            FlattenCurveGeometry textFlattenGeometry = new FlattenCurveGeometry(textGeometry);
            //  Need for clip text
            Geometry clippedTextFlattenGeometry = new FlattenCurveGeometry(
                new CombinedGeometry(textFlattenGeometry, new RectangleGeometry(1, 1, m_TextBox.Width - 2, m_TextBox.Height - 2), CombinedGeometry.CombineMode.And));

            FillGeometry(graphics, polarTransform, m_TextBox.TextColor, clippedTextFlattenGeometry);
        }