Exemplo n.º 1
0
        public override Visual CreateVisual(IRenderContext context)
        {
            VisualGroup container = new VisualGroup();

            var bounds     = Bounds;
            var width      = bounds.Width;
            var height     = bounds.Height;
            var cornerSize = Math.Min(width, height) * 0.4;

            var path = new GeneralPath();

            path.MoveTo(0, 0);
            path.LineTo(width - cornerSize, 0);
            path.LineTo(width, cornerSize);
            path.LineTo(width, height);
            path.LineTo(0, height);
            path.Close();
            container.Add(path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always));

            path = new GeneralPath();
            path.MoveTo(width - cornerSize, 0);
            path.LineTo(width - cornerSize, cornerSize);
            path.LineTo(width, cornerSize);
            container.Add(path.CreatePath(null, Pen, new Matrix2D(), FillMode.Never));

            container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush));
            container.SetCanvasArrangeRect(bounds.ToRectD());
            return(container);
        }
Exemplo n.º 2
0
        public override IVisual CreateVisual(IRenderContext context)
        {
            VisualGroup container = new VisualGroup();

            var bounds     = Bounds;
            var width      = bounds.Width;
            var height     = bounds.Height;
            var cornerSize = Math.Min(width, height) * 0.4;

            var path = new GeneralPath();

            path.MoveTo(0, 0);
            path.LineTo(width - cornerSize, 0);
            path.LineTo(width, cornerSize);
            path.LineTo(width, height);
            path.LineTo(0, height);
            path.Close();
            container.Add(new GeneralPathVisual(path)
            {
                Brush = Brush, Pen = Pen
            });

            path = new GeneralPath();
            path.MoveTo(width - cornerSize, 0);
            path.LineTo(width - cornerSize, cornerSize);
            path.LineTo(width, cornerSize);
            container.Add(new GeneralPathVisual(path)
            {
                Brush = null, Pen = Pen
            });

            container.Transform = new Matrix(1, 0, 0, 1, (float)Bounds.X, (float)Bounds.Y);
            return(container);
        }
Exemplo n.º 3
0
        private void UpdateChildren()
        {
            VisualGroup contentHost = GetTemplateChild("visualGroup") as VisualGroup;

            if (contentHost != null)
            {
                var oldVisual = contentHost.Children.Count == 1 ? contentHost.Children.ElementAt(0) : null;
                var newVisual = GetVisual();


                if (newVisual == null)
                {
                    if (oldVisual != null)
                    {
                        contentHost.Children.Clear();
                    }
                }
                else
                {
                    if (oldVisual != null)
                    {
                        if (!newVisual.Equals(oldVisual))
                        {
                            contentHost.Children[0] = newVisual;
                        }
                    }
                    else
                    {
                        contentHost.Add(newVisual);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override Visual CreateVisual(IRenderContext context, INode node)
        {
            UpdateIcon(node);
            if (Icon == null)
            {
                return(null);
            }

            var bounds = node.Layout.ToRectD();

            Icon.SetBounds(new RectD(PointD.Origin, bounds.ToSizeD()));
            var visual = Icon.CreateVisual(context);

            var container = new VisualGroup();

            if (visual != null)
            {
                container.Add(visual);
            }
            container.SetCanvasArrangeRect(new Rect(bounds.TopLeft, bounds.BottomRight));
            container.SetRenderDataCache(new IconData {
                ModCount = ModCount, Bounds = bounds
            });

            return(container);
        }
Exemplo n.º 5
0
        public override Visual CreateVisual(IRenderContext context)
        {
            VisualGroup container = new VisualGroup();
            var         bounds    = Bounds;
            var         width     = bounds.Width;
            var         height    = bounds.Height;

            var path = new GeneralPath();

            path.MoveTo(0, TopLeftRadius);
            path.QuadTo(0, 0, TopLeftRadius, 0);
            path.LineTo(width - TopRightRadius, 0);
            path.QuadTo(width, 0, width, TopRightRadius);
            path.LineTo(width, height - BottomRightRadius);
            path.QuadTo(width, height, width - BottomRightRadius, height);
            path.LineTo(BottomLeftRadius, height);
            path.QuadTo(0, height, 0, height - BottomRightRadius);
            path.Close();

            var pathVisual = path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always);

            container.Add(pathVisual);

            container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush));
            container.SetCanvasArrangeRect(bounds.ToRectD());
            return(container);
        }
Exemplo n.º 6
0
            /// <inheritdoc/>
            public Visual CreateVisual(IRenderContext context)
            {
                var container     = new VisualGroup();
                var delegateStyle = GetCurrentStyle(label, labelStyle);

                container.Add(delegateStyle.Renderer.GetVisualCreator(label, delegateStyle).CreateVisual(context));
                container.SetRenderDataCache(CreateRenderData());

                return(container);
            }
            /// <inheritdoc/>
            public virtual Visual CreateVisual(IRenderContext context)
            {
                var container = new VisualGroup();

                if (style.Type != EdgeType.Conversation)
                {
                    container.Add(delegateRenderer.GetVisualCreator(this.edge, this.style.delegateStyle).CreateVisual(context));
                }
                else
                {
                    container.Add(delegateRenderer.GetVisualCreator(this.edge, this.style.delegateStyle).CreateVisual(context));
                    var oldPen = style.delegateStyle.Pen;
                    style.delegateStyle.Pen = style.innerPen;
                    container.Add(delegateRenderer.GetVisualCreator(this.edge, this.style.delegateStyle).CreateVisual(context));
                    style.delegateStyle.Pen = oldPen;
                }
                container.SetRenderDataCache(style.Type);
                return(container);
            }
Exemplo n.º 8
0
        /// <summary>
        /// This method is called by the framework to create a <see cref="IVisual"/>
        /// that will be included into the <see cref="IRenderContext"/>.
        /// </summary>
        /// <param name="context">The context that describes where the visual will be used.</param>
        /// <returns>
        /// The arrow visual to include in the canvas object visual tree./>.
        /// </returns>
        /// <seealso cref="UpdateVisual"/>
        IVisual IVisualCreator.CreateVisual(IRenderContext context)
        {
            icon.SetBounds(new RectD(-Bounds.Width, -Bounds.Height / 2, Bounds.Width, Bounds.Height));
            var visualGroup = new VisualGroup();

            visualGroup.Add(icon.CreateVisual(context));

            // Rotate arrow and move it to correct position
            visualGroup.Transform = new Matrix((float)direction.X, (float)direction.Y, (float)-direction.Y, (float)direction.X, (float)anchor.X, (float)anchor.Y);

            return(visualGroup);
        }
Exemplo n.º 9
0
        public override Visual CreateVisual(IRenderContext context)
        {
            VisualGroup container = new VisualGroup();

            var rectangle = new Rectangle {
                RadiusX = CornerRadius, RadiusY = CornerRadius
            };

            UpdateRectangle(rectangle);
            container.Add(rectangle);

            container.SetRenderDataCache(new PathIconState(Bounds.Width, Bounds.Height, Pen, Brush));
            container.SetCanvasArrangeRect(Bounds.ToRectD());
            return(container);
        }
Exemplo n.º 10
0
        public override Visual CreateVisual(IRenderContext context)
        {
            VisualGroup container = new VisualGroup();

            var matrix2D = new Matrix2D();

            matrix2D.Scale(Math.Max(0, Bounds.Width), Math.Max(0, Bounds.Height));

            Path visual = Path.CreatePath(Brush, Pen, matrix2D, FillMode.FillClosedFigures);

            container.Add(visual);

            container.SetRenderDataCache(new PathIconState(Bounds.Width, Bounds.Height, Pen, Brush));
            container.SetCanvasArrangeRect(Bounds.ToRectD());
            return(container);
        }
Exemplo n.º 11
0
        public override Visual CreateVisual(IRenderContext context)
        {
            if (Bounds == null)
            {
                return(null);
            }
            var container = new VisualGroup();

            var iconBounds = new RectD(PointD.Origin, Bounds.ToSizeD());

            foreach (var icon in icons)
            {
                icon.SetBounds(iconBounds);
                container.Add(icon.CreateVisual(context));
            }

            container.SetCanvasArrangeRect(Bounds.ToRectD());
            container.SetRenderDataCache(Bounds.ToRectD());

            return(container);
        }
Exemplo n.º 12
0
        public override IVisual CreateVisual(IRenderContext context)
        {
            if (Bounds == null)
            {
                return(null);
            }

            var container = new VisualGroup();

            double offset = 0;

            foreach (var pathIcon in icons)
            {
                pathIcon.SetBounds(new RectD(offset, 0, innerIconSize.Width, innerIconSize.Height));
                container.Add(pathIcon.CreateVisual(context));
                offset += innerIconSize.Width + gap;
            }
            container.Transform = new Matrix(1, 0, 0, 1, (float)Bounds.X, (float)Bounds.Y);

            return(container);
        }
Exemplo n.º 13
0
        public override Visual CreateVisual(IRenderContext context)
        {
            if (Bounds == null)
            {
                return(null);
            }

            var container = new VisualGroup();

            double offset = 0;

            foreach (var pathIcon in icons)
            {
                pathIcon.SetBounds(new RectD(offset, 0, innerIconSize.Width, innerIconSize.Height));
                container.Add(pathIcon.CreateVisual(context));
                offset += innerIconSize.Width + gap;
            }
            container.SetCanvasArrangeRect(Bounds.ToRectD());
            container.SetRenderDataCache(Bounds.GetTopLeft());

            return(container);
        }
        protected override Visual CreateVisual(IRenderContext context, INode node)
        {
            var bounds    = node.Layout.ToRectD();
            var container = new VisualGroup();

            // task band
            var taskBandContainer = new VisualGroup();
            var bandIcon          = CreateTaskBandIcon(node);

            bandIcon.SetBounds(GetRelativeTaskNameBandBounds(node));
            taskBandContainer.Add(bandIcon.CreateVisual(context));
            taskBandContainer.SetRenderDataCache(bandIcon);
            container.Children.Add(taskBandContainer);

            var tpi = new List <IIcon>();
            // top participants
            double topOffset = 0;
            bool   first     = true;

            foreach (Participant participant in topParticipants)
            {
                var participantIcon = CreateParticipantIcon(participant, true, first);
                tpi.Add(participantIcon);
                var height = participant.GetSize();
                participantIcon.SetBounds(new RectD(0, topOffset, bounds.Width, height));
                container.Add(participantIcon.CreateVisual(context));
                topOffset += height;
                first      = false;
            }

            var bpi = new List <IIcon>();
            // bottom participants
            double bottomOffset = bounds.Height;

            first = true;
            foreach (Participant participant in bottomParticipants)
            {
                var participantIcon = CreateParticipantIcon(participant, false, first);
                bpi.Add(participantIcon);
                var height = participant.GetSize();
                bottomOffset -= height;
                participantIcon.SetBounds(new RectD(0, bottomOffset, bounds.Width, height));
                container.Add(participantIcon.CreateVisual(context));
                first = false;
            }

            // outline
            outlineIcon.SetBounds(new RectD(PointD.Origin, bounds.Size));
            container.Add(outlineIcon.CreateVisual(context));

            // messages
            if (InitiatingMessage)
            {
                UpdateInitiatingMessageIcon();
                var initiatingMessageIcon = InitiatingAtTop ? topInitiatingMessageIcon : bottomInitiatingMessageIcon;
                initiatingMessageIcon.SetBounds(new RectD(0, 0, bounds.Width, bounds.Height));
                container.Add(initiatingMessageIcon.CreateVisual(context));
            }
            if (ResponseMessage)
            {
                UpdateResponseMessageIcon();
                var responseMessageIcon = InitiatingAtTop ? bottomResponseMessageIcon : topResponseMessageIcon;
                responseMessageIcon.SetBounds(new RectD(0, 0, bounds.Width, bounds.Height));
                container.Add(responseMessageIcon.CreateVisual(context));
            }

            container.SetCanvasArrangeRect(new Rect(bounds.TopLeft, bounds.Size));
            container.SetRenderDataCache(new ChoreographyRenderData(bounds, ModCount + topParticipants.ModCount + bottomParticipants.ModCount)
            {
                TopParticipantIcons = tpi, BottomParticipantIcons = bpi
            });
            return(container);
        }