Example #1
0
        protected static new void DrawDecorator(DiagramPaintEventArgs e, IGeometryHost geometryHost, float rotation, PointD centerRight, LinkDecorator decorator)
        {
            SizeD size = LinkShapeGeometry.SizeDecorator;
#endif
            double offsetBy = 0d;
            bool   doOffset = false;
            ILinkDecoratorSettings settings = decorator as ILinkDecoratorSettings;
            if (settings != null)
            {
                size     = settings.DecoratorSize;
                offsetBy = settings.OffsetBy;
                doOffset = !VGConstants.FuzzZero(offsetBy, VGConstants.FuzzDistance);
            }
            Graphics   g              = e.Graphics;
            RectangleD boundingRect   = new RectangleD(centerRight.X - size.Width, centerRight.Y - (size.Height / 2), size.Width, size.Height);
            Matrix     rotationMatrix = g.Transform;
            float      offsetX        = 0f;
            float      offsetY        = 0f;
            if (doOffset)
            {
                double rotationRadians = rotation * Math.PI / 180;
                offsetX = (float)(offsetBy * Math.Cos(rotationRadians));
                offsetY = (float)(offsetBy * Math.Sin(rotationRadians));
                rotationMatrix.Translate(offsetX, offsetY);
            }
            rotationMatrix.RotateAt(rotation, PointD.ToPointF(centerRight));
            g.Transform = rotationMatrix;
            decorator.DoPaintShape(boundingRect, geometryHost, e);
            rotationMatrix.RotateAt(-rotation, PointD.ToPointF(centerRight));
            if (doOffset)
            {
                rotationMatrix.Translate(-offsetX, -offsetY);
            }
            g.Transform = rotationMatrix;
        }
Example #2
0
        private static void ExcludeDecorator(Graphics g, ObliqueBinaryLinkShapeGeometry geometry, LinkDecorator decorator, PointD fromPoint, PointD toPoint)
        {
            SizeD size = LinkShapeGeometry.SizeDecorator;
#endif
            ILinkDecoratorSettings settings = decorator as ILinkDecoratorSettings;
            double offsetBy = double.NaN;
            if (settings != null)
            {
                size     = settings.DecoratorSize;
                offsetBy = settings.OffsetBy;
                if (VGConstants.FuzzZero(offsetBy, VGConstants.FuzzDistance))
                {
                    offsetBy = double.NaN;
                }
            }
            RectangleD bounds        = new RectangleD(fromPoint.X - size.Width, fromPoint.Y - (size.Height / 2), size.Width, size.Height);
            float      rotationAngle = geometry.CalculateRotationAngle(fromPoint, toPoint);
            ExcludeDecorator(g, bounds, rotationAngle, offsetBy, fromPoint);
        }