Exemple #1
0
        public void Draw(Graphics g) // root ruler
        {
            boxId = RulerBoxId.Origin;

            rulerBrushHighlight = rulerBrushLight1;

            PointF[] selPts;
            using (Matrix m = stage.GetDynamicMatrix())
            {
                if (!stage.IsEditingRoot)
                {
                    m.Multiply(stage.GetCurrentMatrix(), MatrixOrder.Append);
                }
                selPts = stage.Selection.GetTransformedPoints(m);
            }
            Rectangle selRect = selPts.GetBounds();

            Point rulerCenter = new Point(RulerSize, RulerSize);

            useProportionalRulers = true;
            using (Matrix rootM = stage.GetCalculatedRootMatrix())
            {
                DrawRulers(g, rulerCenter, new Rectangle(Point.Empty, stage.CanvasSize), stage.vexObject.ViewPort.SysRectangle(), selRect, rootM);
            }
        }
Exemple #2
0
        public void DrawAt(Graphics g, Point center, Rectangle selRect, Matrix mx)
        {
            boxId = RulerBoxId.NestedOrigin;

            g.SmoothingMode     = SmoothingMode.None;
            rulerBrushHighlight = rulerBrushLight2;

            Rectangle ruler      = new Rectangle(0, 0, 500, 500);
            Rectangle itemBounds = new Rectangle(0, 0, 480, 480);

            useProportionalRulers = false;
            DrawRulers(g, center, ruler, itemBounds, selRect, mx);
        }
Exemple #3
0
        private void DrawRulers(Graphics g, Point rulerCenter, Rectangle rulerLimits, Rectangle highlightLimits, Rectangle selRect, Matrix mx)
        {
            g.SmoothingMode = SmoothingMode.None;
            //g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;

            Point zeroCamera = Point.Round(GdiRenderer.GetTransformedPoint(Point.Empty, mx, false));

            //Rectangle maxRuler = new Rectangle(0, 0, 10000, 10000);
            Rectangle maxRuler = new Rectangle(Point.Empty, stage.CanvasSize);

            PointF[] pts = maxRuler.PointFs();
            GdiRenderer.TransformPoints(pts, mx, false);
            PointF tl        = pts[0];
            PointF tr        = pts[1];
            PointF bl        = pts[3];
            double angleXRad = Math.Atan2(tr.Y - tl.Y, tr.X - tl.X);
            float  angleX    = (float)(angleXRad * 180f / Math.PI);
            double scaleX    = (tr.X - tl.X) / (double)maxRuler.Width;
            double scaleY    = (bl.Y - tl.Y) / (double)maxRuler.Height;

            GraphicsState gsOrg = g.Save();

            //g.TranslateTransform(-mx.OffsetX, -mx.OffsetY, MatrixOrder.Append);
            g.RotateTransform(angleX, MatrixOrder.Append);
            g.TranslateTransform(rulerCenter.X, rulerCenter.Y, MatrixOrder.Append);
            if (boxId == RulerBoxId.Origin)
            {
                if (localMatrix != null)
                {
                    localMatrix.Dispose();
                }
                localMatrix = g.Transform.Clone();
            }

            g.FillRectangle(rulerBrush, topLeftBox);
            g.DrawLines(darkPen, topLeftOutline);

            rects[(int)RulerBoxId.Origin + (int)boxId] = topLeftBox;

            DrawRulers(g,
                       rulerLimits.Left,
                       rulerLimits.Right,
                       zeroCamera.X - rulerCenter.X,
                       (float)scaleX,
                       highlightLimits.X,
                       highlightLimits.Width,
                       selRect);

            g.TranslateTransform(-rulerCenter.X, -rulerCenter.Y, MatrixOrder.Append);
            g.RotateTransform(-90, MatrixOrder.Append);
            g.TranslateTransform(rulerCenter.X, rulerCenter.Y, MatrixOrder.Append);

            boxId += boxesPerRuler;
            DrawRulers(g,
                       -rulerLimits.Bottom,
                       -rulerLimits.Top,
                       zeroCamera.Y - rulerCenter.Y,
                       (float)scaleY,
                       highlightLimits.Height,
                       highlightLimits.Y,
                       selRect);

            //stage.CurrentEditItem.guides.DrawHGuides(g);

            g.Restore(gsOrg);
            g.SmoothingMode = SmoothingMode.HighQuality;
        }