Exemplo n.º 1
0
        private void FormLoaded(object sender, EventArgs e)
        {
            IGraph graph = graphControl.Graph;

            // Create a default editor input mode
            GraphEditorInputMode graphEditorInputMode = new GraphEditorInputMode();

            // Just for user convenience: disable node and edge creation,
            graphEditorInputMode.AllowCreateEdge = false;
            graphEditorInputMode.AllowCreateNode = false;
            // disable deleting items
            graphEditorInputMode.DeletableItems = GraphItemTypes.None;
            // disable node moving
            graphEditorInputMode.MovableItems = GraphItemTypes.None;
            // enable the undo feature
            graph.SetUndoEngineEnabled(true);

            // Finally, set the input mode to the graph control.
            graphControl.InputMode = graphEditorInputMode;

            // Create the rectangle that limits the movement of some nodes
            // and add it to the GraphControl.
            var boundaryRectangle = new RectD(20, 20, 480, 550);
            var rectangle         = new RectangleVisual(boundaryRectangle)
            {
                Pen = Pens.Black
            };

            graphControl.RootGroup.AddChild(rectangle, CanvasObjectDescriptors.Visual);

            RegisterReshapeHandleProvider(boundaryRectangle);

            CreateSampleGraph(graph);
        }
Exemplo n.º 2
0
            public override void Paint(IRenderContext ctx, Graphics g)
            {
                IRectangle rect            = Bounds.ToRectD().GetEnlarged(3);
                var        rectangleVisual = new RectangleVisual(rect)
                {
                    Pen = new Pen(Brushes.DarkGray)
                    {
                        DashStyle = DashStyle.Dot, Width = 2
                    }
                };

                rectangleVisual.Paint(ctx, g);
            }
        public IVisual CreateVisual(IRenderContext context)
        {
            rectangle = new MutableRectangle(RectD.FromCenter(Center, new SizeD(PageWidth + Margin, PageHeight + Margin)));
            var rectVisual = new RectangleVisual(rectangle)
            {
                Pen = new Pen(Color.Black, 1)
                {
                    DashStyle = DashStyle.Dash
                }
            };

            return(rectVisual);
        }
Exemplo n.º 4
0
        public IVisual UpdateVisual(IRenderContext context, IVisual oldVisual)
        {
            var cc = oldVisual as VisualGroup ?? new VisualGroup();

            var y     = bounds.Top;
            int count = 0;

            foreach (var divider in dividers)
            {
                float bottom = divider;

                var rectangle = new RectangleVisual(bounds.Left, y, bounds.Width, bottom - y)
                {
                    Brush = count % 2 == 1 ? lightBrush : darkBrush
                };
                if (cc.Children.Count <= count)
                {
                    cc.Children.Add(rectangle);
                }
                else
                {
                    cc.Children[count] = rectangle;
                }

                y = bottom;
                count++;
            }

            {
                var rectangle = new RectangleVisual(bounds.Left, y, bounds.Width, bounds.Bottom - y)
                {
                    Brush = count % 2 == 1 ? lightBrush : darkBrush
                };
                if (cc.Children.Count <= count)
                {
                    cc.Children.Add(rectangle);
                }
                else
                {
                    cc.Children[count] = rectangle;
                }
                count++;
            }

            while (cc.Children.Count > count)
            {
                cc.Children.RemoveAt(cc.Children.Count - 1);
            }
            return(cc);
        }
        private void FormLoaded(object sender, EventArgs e)
        {
            IGraph graph = graphControl.Graph;

            // Create a default editor input mode
            GraphEditorInputMode graphEditorInputMode = new GraphEditorInputMode();

            // Just for user convenience: disable node and edge creation,
            graphEditorInputMode.AllowCreateEdge = false;
            graphEditorInputMode.AllowCreateNode = false;
            // disable deleting items
            graphEditorInputMode.DeletableItems = GraphItemTypes.None;
            // don't show resize handles,
            graphEditorInputMode.ShowHandleItems = GraphItemTypes.None;
            // disable clipboard,
            graphEditorInputMode.AllowClipboardOperations = false;
            // and enable the undo feature.
            graph.SetUndoEngineEnabled(true);

            // Finally, set the input mode to the graph control.
            graphControl.InputMode = graphEditorInputMode;

            // Create the rectangle that limits the movement of some nodes
            // and add it to the GraphControl.
            var boundaryRectangle = new MutableRectangle(20, 20, 480, 400);
            var rectangle         = new RectangleVisual(boundaryRectangle)
            {
                Pen = Pens.Black
            };

            graphControl.RootGroup.AddChild(rectangle, CanvasObjectDescriptors.Visual);

            RegisterPositionHandler(boundaryRectangle);

            CreateSampleGraph(graph);
            // reset the Undo queue so the initial graph creation cannot be undone
            graph.GetUndoEngine().Clear();
        }
Exemplo n.º 6
0
        protected override VisualGroup CreateVisual(IRenderContext context, INode node)
        {
            var layout = node.Layout;

            // Get the background colors dependent on the collapse state
            var backgroundColor1 = CollapsedState == CollapsedState.Collapsed ? collapsedColor1 : expandedColor1;
            var backgroundColor2 = CollapsedState == CollapsedState.Collapsed ? collapsedColor2 : expandedColor2;

            var background = new RectangleVisual(0, 0, layout.Width, layout.Height)
            {
                Brush = new LinearGradientBrush(new PointF(0, 0), new PointF(0, (float)layout.Height), backgroundColor1, backgroundColor2),
                Pen   = Pens.LightGray
            };
            var symbol = new SymbolVisual(new Point((int)(layout.Width / 2), (int)(layout.Height / 2)), CollapsedState);

            return(new VisualGroup {
                Transform = new Matrix(1, 0, 0, 1, (float)layout.X, (float)layout.Y),
                Children =
                {
                    background, symbol
                }
            });
        }
Exemplo n.º 7
0
        protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup cc, IStripe stripe)
        {
            if (cc == null || cc.Children.Count < 2)
            {
                return(CreateVisual(context, stripe));
            }
            var     layout = stripe.Layout.ToRectD();
            InsetsD stripeInsets;

            StripeDescriptor descriptor;

            //Depending on the stripe type, we need to consider horizontal or vertical insets
            if (stripe is IColumn)
            {
                var col          = (IColumn)stripe;
                var actualInsets = col.GetActualInsets();
                stripeInsets = new InsetsD(0, actualInsets.Top, 0, actualInsets.Bottom);
            }
            else
            {
                var row          = (IRow)stripe;
                var actualInsets = row.GetActualInsets();
                stripeInsets = new InsetsD(actualInsets.Left, 0, actualInsets.Right, 0);
            }

            if (stripe.GetChildStripes().Any())
            {
                //Parent stripe - use the parent descriptor
                descriptor = ParentDescriptor;
            }
            else
            {
                int index;
                if (stripe is IColumn)
                {
                    var col = (IColumn)stripe;
                    //Get all leaf columns
                    var leafs = col.Table.RootColumn.GetLeaves().ToList();
                    //Determine the index
                    index = leafs.FindIndex(curr => col == curr);
                    //Use the correct descriptor
                    descriptor = index % 2 == 0 ? EvenLeafDescriptor : OddLeafDescriptor;
                }
                else
                {
                    var row   = (IRow)stripe;
                    var leafs = row.Table.RootRow.GetLeaves().ToList();
                    index      = leafs.FindIndex((curr) => row == curr);
                    descriptor = index % 2 == 0 ? EvenLeafDescriptor : OddLeafDescriptor;
                }
            }
            RectangleVisual rect = (RectangleVisual)cc.Children[0];

            rect.Rectangle = layout;
            rect.Brush     = descriptor.BackgroundBrush;
            var childIndex = 1;

            //Draw the insets
            if (stripeInsets.Left > 0)
            {
                if (childIndex < cc.Children.Count)
                {
                    rect           = (RectangleVisual)cc.Children[childIndex];
                    rect.Brush     = descriptor.InsetBrush;
                    rect.Rectangle = new RectD(layout.X, layout.Y, stripeInsets.Left, layout.Height);
                }
                else
                {
                    cc.Add(new RectangleVisual(layout.X, layout.Y, stripeInsets.Left, layout.Height)
                    {
                        Brush = descriptor.InsetBrush
                    });
                }
                childIndex++;
            }
            if (stripeInsets.Top > 0)
            {
                if (childIndex < cc.Children.Count)
                {
                    rect           = (RectangleVisual)cc.Children[childIndex];
                    rect.Brush     = descriptor.InsetBrush;
                    rect.Rectangle = new RectD(layout.X, layout.Y, layout.Width, stripeInsets.Top);
                }
                else
                {
                    cc.Add(new RectangleVisual(layout.X, layout.Y, layout.Width, stripeInsets.Top)
                    {
                        Brush = descriptor.InsetBrush
                    });
                }
                childIndex++;
            }
            if (stripeInsets.Right > 0)
            {
                if (childIndex < cc.Children.Count)
                {
                    rect           = (RectangleVisual)cc.Children[childIndex];
                    rect.Brush     = descriptor.InsetBrush;
                    rect.Rectangle = new RectD(layout.MaxX - stripeInsets.Right, layout.Y, stripeInsets.Right, layout.Height);
                }
                else
                {
                    cc.Add(new RectangleVisual(layout.MaxX - stripeInsets.Right, layout.Y, stripeInsets.Right, layout.Height)
                    {
                        Brush = descriptor.InsetBrush
                    });
                }
                childIndex++;
            }
            if (stripeInsets.Bottom > 0)
            {
                if (childIndex < cc.Children.Count)
                {
                    rect           = (RectangleVisual)cc.Children[childIndex];
                    rect.Brush     = descriptor.InsetBrush;
                    rect.Rectangle = new RectD(layout.X, layout.MaxY - stripeInsets.Bottom, layout.Width, stripeInsets.Bottom);
                }
                else
                {
                    cc.Add(new RectangleVisual(layout.X, layout.MaxY - stripeInsets.Bottom, layout.Width, stripeInsets.Bottom)
                    {
                        Brush = descriptor.InsetBrush
                    });
                }
                childIndex++;
            }
            if (childIndex < cc.Children.Count)
            {
                rect           = (RectangleVisual)cc.Children[childIndex];
                rect.Pen       = new Pen(descriptor.BorderBrush, descriptor.BorderThickness);
                rect.Rectangle = layout;
            }
            else
            {
                cc.Add(new RectangleVisual(layout)
                {
                    Pen = new Pen(descriptor.BorderBrush, descriptor.BorderThickness)
                });
            }
            childIndex++;
            while (cc.Children.Count > childIndex)
            {
                cc.Children.RemoveAt(childIndex);
            }
            return(cc);
        }
Exemplo n.º 8
0
        protected override VisualGroup CreateVisual(IRenderContext context, ILabel label)
        {
            var  group   = new VisualGroup();
            bool enabled = false;

            if (Button != null)
            {
                enabled = Button.CanExecute((INode)label.Owner, context.CanvasControl);
            }

            var labelLayout = label.GetLayout();
            var layout      = new RectD(labelLayout.AnchorX, labelLayout.AnchorY - label.PreferredSize.Height,
                                        label.PreferredSize.Width, label.PreferredSize.Height);
            Brush backgroundBrush;
            Brush foregroundBrush;
            Pen   foregroundPen;

            if (enabled)
            {
                // enabled style
                if (Icon != ButtonIcon.Increase)
                {
                    backgroundBrush = new LinearGradientBrush(layout.TopLeft, layout.BottomLeft,
                                                              BackgroundColor,
                                                              Mix(Color.White, BackgroundColor, 0.5d));
                }
                else
                {
                    backgroundBrush = new LinearGradientBrush(layout.TopLeft, layout.BottomLeft,
                                                              Mix(Color.White, BackgroundColor, 0.5d),
                                                              BackgroundColor);
                }
                foregroundPen   = new Pen(ForegroundColor);
                foregroundBrush = new SolidBrush(ForegroundColor);
            }
            else
            {
                // disabled style
                backgroundBrush = new LinearGradientBrush(layout.TopLeft, layout.BottomLeft,
                                                          Mix(Color.White, BackgroundColor, 0.7),
                                                          Mix(Color.White, BackgroundColor, 0.7));
                foregroundPen   = new Pen(Mix(Color.White, ForegroundColor, 0.7));
                foregroundBrush = new SolidBrush(Mix(Color.White, ForegroundColor, 0.7));
            }
            var backgroundRect = new RectangleVisual(layout)
            {
                Brush = backgroundBrush,
                Pen   = BorderPen
            };

            group.Add(backgroundRect);
            GeneralPath path;
            ShapeVisual pathPaintable;

            switch (Icon)
            {
            case ButtonIcon.Increase: // paint "up"-arrow
                path = new GeneralPath();
                path.MoveTo(layout.TopLeft + new PointD(layout.Width * 0.3, layout.Height * 0.7));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.7, layout.Height * 0.7));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.5, layout.Height * 0.3));
                path.Close();
                pathPaintable = new GeneralPathVisual(path)
                {
                    Brush = foregroundBrush
                };
                group.Add(pathPaintable);
                break;

            case ButtonIcon.Decrease: // paint "down"-arrow
                path = new GeneralPath();
                path.MoveTo(layout.TopLeft + new PointD(layout.Width * 0.3, layout.Height * 0.3));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.7, layout.Height * 0.3));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.5, layout.Height * 0.7));
                path.Close();
                pathPaintable = new GeneralPathVisual(path)
                {
                    Brush = foregroundBrush
                };
                group.Add(pathPaintable);
                break;

            case ButtonIcon.Toggle: // paint "check"
                path = new GeneralPath();
                path.MoveTo(layout.TopLeft + new PointD(layout.Width * 0.3, layout.Height * 0.5));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.5, layout.Height * 0.7));
                path.LineTo(layout.TopLeft + new PointD(layout.Width * 0.7, layout.Height * 0.3));;
                pathPaintable = new GeneralPathVisual(path)
                {
                    Pen = foregroundPen
                };
                group.Add(pathPaintable);
                break;

            case ButtonIcon.None: // paint nothing
                break;

            default: // can't happen
                throw new ArgumentOutOfRangeException();
            }
            return(group);
        }
Exemplo n.º 9
0
        protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup group, INode node1)
        {
            if (group == null || group.Children.Count != 6 + buttons.Count)
            {
                return(CreateVisual(context, node1));
            }
            group.Transform = new Matrix(1, 0, 0, 1, (float)node1.Layout.X, (float)node1.Layout.Y);
            var data = (LayerConstraintsInfo)node1.Tag;

            node.Tag = data;

            var x     = (float)insets.Left;
            var y     = (float)insets.Top;
            var width = (float)(node.Layout.Width - insets.HorizontalInsets - ButtonSize);
            //var height = (float)(font.GetHeight(graphics) + insets.VerticalInsets);
            var height = ButtonSize * 2;

            // update background
            group.Children[0] = DecoratedStyle.Renderer.GetVisualCreator(node, DecoratedStyle).UpdateVisual(context, group.Children[0]);

            // update labels
            if (data.Constraints)
            {
                if (group.Children[1] == null)
                {
                    var rectangle = new RectangleVisual(x, y, width, height)
                    {
                        Brush = GetBackgroundBrush(data)
                    };
                    group.Children[1] = rectangle;
                    string s        = data.ToString();
                    Brush  brush    = GetForegroundBrush(data);
                    IPoint location = new PointD(x + insets.Left, y + insets.Top);
                    group.Children[2] = new TextVisual {
                        Text = s, Font = font, Brush = brush, Location = location
                    };
                }
                else
                {
                    ((ShapeVisual)group.Children[1]).Brush = GetBackgroundBrush(data);
                    var textPaintable = (TextVisual)group.Children[2];
                    textPaintable.Brush = GetForegroundBrush(data);
                    textPaintable.Text  = data.ToString();
                }
            }
            else
            {
                if (group.Children[1] != null)
                {
                    group.Children[1] = VoidVisualCreator.Instance.CreateVisual(context);
                    group.Children[2] = VoidVisualCreator.Instance.CreateVisual(context);
                }
            }

            // paint buttons
            toggleStateStyle.Icon            = data.Constraints ? ButtonLabelStyle.ButtonIcon.Toggle : ButtonLabelStyle.ButtonIcon.None;
            toggleStateStyle.BackgroundColor = data.Constraints ? Color.Green : Color.Gray;
            int childIndex = 3;

            foreach (var button in buttons)
            {
                ILabel oldLabel = button.Visualization;
                var    icon     = ((ButtonLabelStyle)button.Visualization.Style).Icon;
                if (data.Constraints || icon == ButtonLabelStyle.ButtonIcon.Toggle || icon == ButtonLabelStyle.ButtonIcon.None)
                {
                    SimpleLabel label = new SimpleLabel(node, oldLabel.Text, oldLabel.LayoutParameter)
                    {
                        Style         = oldLabel.Style,
                        PreferredSize = oldLabel.PreferredSize
                    };
                    group.Children[childIndex] = label.Style.Renderer.GetVisualCreator(label, label.Style).UpdateVisual(context, group.Children[childIndex]);
                }
                else
                {
                    group.Children[childIndex] = VoidVisualCreator.Instance.CreateVisual(context);
                }
                childIndex++;
            }

            if (data.Constraints)
            {
                if (group.Children[childIndex] == null)
                {
                    double w         = width + ButtonSize;
                    var    rectangle = new RectangleVisual(x, y, w, height)
                    {
                        Pen = Pens.Black
                    };
                    group.Children[childIndex] = rectangle;
                    var line = new LineVisual(x + width, y, x + width, y + height)
                    {
                        Pen = Pens.Black
                    };
                    group.Children[childIndex + 1] = line;
                }
            }
            else
            {
                if (group.Children[childIndex] != null)
                {
                    group.Children[childIndex]     = VoidVisualCreator.Instance.CreateVisual(context);
                    group.Children[childIndex + 1] = VoidVisualCreator.Instance.CreateVisual(context);
                }
            }
            childIndex += 2;

            ((TextVisual)group.Children[childIndex]).Text = data.Constraints ? "Enabled" : "Disabled";
            return(group);
        }
Exemplo n.º 10
0
        protected override VisualGroup CreateVisual(IRenderContext context, INode node1)
        {
            var group = new VisualGroup();

            group.Transform = new Matrix(1, 0, 0, 1, (float)node1.Layout.X, (float)node1.Layout.Y);
            var data = (LayerConstraintsInfo)node1.Tag;

            node.Layout = new RectD(PointD.Origin, node1.Layout.GetSize());
            node.Tag    = data;

            var x     = (float)insets.Left;
            var y     = (float)insets.Top;
            var width = (float)(node.Layout.Width - insets.HorizontalInsets - ButtonSize);
            //var height = (float)(font.GetHeight(graphics) + insets.VerticalInsets);
            var height = ButtonSize * 2;

            // add background
            group.Add(DecoratedStyle.Renderer.GetVisualCreator(node, DecoratedStyle).CreateVisual(context));

            // paint label
            if (data.Constraints)
            {
                var rectangle = new RectangleVisual(x, y, width, height)
                {
                    Brush = GetBackgroundBrush(data)
                };
                group.Add(rectangle);
                group.Add(new TextVisual {
                    Text     = data.ToString(),
                    Font     = font,
                    Brush    = GetForegroundBrush(data),
                    Location = new PointD(x + insets.Left, y + insets.Top)
                });
            }
            else
            {
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
            }

            // paint buttons
            toggleStateStyle.Icon            = data.Constraints ? ButtonLabelStyle.ButtonIcon.Toggle : ButtonLabelStyle.ButtonIcon.None;
            toggleStateStyle.BackgroundColor = data.Constraints ? Color.Green : Color.Gray;
            foreach (var button in buttons)
            {
                ILabel buttonLabel = button.Visualization;
                var    icon        = ((ButtonLabelStyle)buttonLabel.Style).Icon;
                if (data.Constraints || icon == ButtonLabelStyle.ButtonIcon.Toggle || icon == ButtonLabelStyle.ButtonIcon.None)
                {
                    SimpleLabel label = new SimpleLabel(node, buttonLabel.Text, buttonLabel.LayoutParameter)
                    {
                        Style         = buttonLabel.Style,
                        PreferredSize = buttonLabel.PreferredSize
                    };
                    group.Add(label.Style.Renderer.GetVisualCreator(label, label.Style).CreateVisual(context));
                }
                else
                {
                    group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                }
            }

            if (data.Constraints)
            {
                double w         = width + ButtonSize;
                var    rectangle = new RectangleVisual(x, y, w, height)
                {
                    Pen = Pens.Black
                };
                group.Add(rectangle);
                var line = new LineVisual(x + width, y, x + width, y + height)
                {
                    Pen = Pens.Black
                };
                group.Add(line);
            }
            else
            {
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
            }

            group.Add(new TextVisual {
                Text     = data.Constraints ? "Enabled" : "Disabled",
                Font     = labelFont,
                Brush    = Brushes.Black,
                Location = new PointD(x + ButtonSize + 1, y + (float)node.Layout.Height + 1 - (float)insets.Bottom - font.Height - ButtonSize * 0.2f)
            });
            return(group);
        }
        protected override VisualGroup CreateVisual(IRenderContext context, INode node)
        {
            Color borderColor, backgroundColor1, backgroundColor2;

            if (((GraphControl)context.CanvasControl).CurrentItem == node)
            {
                borderColor      = Color.Orange;
                backgroundColor1 = Color.White;
                backgroundColor2 = Color.Orange;
            }
            else
            {
                borderColor      = Color.FromArgb(255, 24, 154, 231);
                backgroundColor1 = Color.FromArgb(255, 204, 255, 255);
                backgroundColor2 = Color.FromArgb(255, 24, 154, 231);
            }

            var layout = node.Layout;

            var employee = (Employee)node.Tag;

            var text = new TextVisual {
                Text     = GetShortName(employee.Name),
                Font     = new Font("Arial", 37, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(5, 5)
            };
            double locationX = layout.Width / 2 - text.GetBounds(context).Width / 2;
            double locationY = layout.Height / 2 - text.GetBounds(context).Height / 2;
            string s1        = GetShortName(employee.Name);
            Font   font1     = new Font("Arial", 37, FontStyle.Regular, GraphicsUnit.Pixel);
            Brush  brush1    = Brushes.Black;
            IPoint location1 = new PointD(locationX, locationY);

            text = new TextVisual {
                Text = s1, Font = font1, Brush = brush1, Location = location1
            };

            var ribbonColor = Color.Green;

            if (employee.Status == EmployeeStatus.Travel)
            {
                ribbonColor = Color.Purple;
            }
            if (employee.Status == EmployeeStatus.Unavailable)
            {
                ribbonColor = Color.Red;
            }

            var border = new RectangleVisual(0, 0, layout.Width, layout.Height)
            {
                Pen = new Pen(borderColor)
            };
            var background = new RectangleVisual(0, 0, layout.Width, layout.Height)
            {
                Brush = new LinearGradientBrush(new PointF(0, 0), new PointF((float)layout.Width, (float)layout.Height), backgroundColor1, backgroundColor2)
            };
            var ribbonPath = new GeneralPath();

            ribbonPath.MoveTo(0, 20);
            ribbonPath.LineTo(25, 0);
            ribbonPath.LineTo(40, 0);
            ribbonPath.LineTo(0, 35);
            ribbonPath.Close();
            var ribbon = new GeneralPathVisual(ribbonPath)
            {
                Brush = new SolidBrush(ribbonColor)
            };

            // Set a transform on the group, matching the node's location.
            // That way only the transform has to be updated instead of every single child visual.
            var transform = new Matrix();

            transform.Translate((float)layout.X, (float)layout.Y);

            var group = new VisualGroup
            {
                Transform = transform,
                Children  =
                {
                    border, background, text, ribbon
                }
            };

            return(group);
        }
        protected override VisualGroup CreateVisual(IRenderContext context, INode node)
        {
            // Fetch information for the child visuals
            var employee = (Employee)node.Tag;

            Color borderColor, backgroundColor1, backgroundColor2, ribbonColor;

            if (((GraphControl)context.CanvasControl).CurrentItem == node)
            {
                borderColor      = Color.Orange;
                backgroundColor1 = Color.White;
                backgroundColor2 = Color.Orange;
            }
            else
            {
                borderColor      = Color.FromArgb(255, 24, 154, 231);
                backgroundColor1 = Color.FromArgb(255, 204, 255, 255);
                backgroundColor2 = Color.FromArgb(255, 24, 154, 231);
            }

            if (employee.Status == EmployeeStatus.Travel)
            {
                ribbonColor = Color.Purple;
            }
            else if (employee.Status == EmployeeStatus.Unavailable)
            {
                ribbonColor = Color.Red;
            }
            else
            {
                ribbonColor = Color.Green;
            }

            var layout = node.Layout;

            var icon = GetIcon(employee.Icon);
            var iconScalingFactor = (layout.Height - 10d) / icon.Height;
            var iconWidth         = icon.Width * iconScalingFactor;

            var nameText = new TextVisual {
                Text     = employee.Name,
                Font     = new Font("Arial", 13, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(iconWidth + 10, 10)
            };
            var positionText = new TextVisual {
                Text     = employee.Position,
                Font     = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(iconWidth + 10, 35)
            };
            var emailText = new TextVisual {
                Text     = employee.Email,
                Font     = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(iconWidth + 10, 50)
            };
            var phone1Text = new TextVisual {
                Text     = employee.Phone,
                Font     = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(iconWidth + 10, 65)
            };
            var faxText = new TextVisual {
                Text     = employee.Fax,
                Font     = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel),
                Brush    = Brushes.Black,
                Location = new PointD(iconWidth + 10, 80)
            };

            var border = new RectangleVisual(0, 0, layout.Width, layout.Height)
            {
                Pen = new Pen(borderColor)
            };
            var background = new RectangleVisual(0, 0, layout.Width, layout.Height)
            {
                Brush = new LinearGradientBrush(new PointF(0, 0), new PointF((float)layout.Width, (float)layout.Height), backgroundColor1, backgroundColor2)
            };
            var iconVisual = new ImageVisual {
                Image     = icon,
                Rectangle = new RectD(5, 5, icon.Width * iconScalingFactor, icon.Height * iconScalingFactor)
            };

            IRectangle rect    = new RectD(layout.Width - 30, 5, 25, 25);
            var        circle1 = new EllipseVisual(rect)
            {
                Brush = new SolidBrush(ribbonColor)
            };
            IRectangle rect1   = new RectD(layout.Width - 25, 10, 15, 15);
            var        circle2 = new EllipseVisual(rect1)
            {
                Brush = Brushes.White
            };
            IRectangle rect2   = new RectD(layout.Width - 20, 15, 5, 5);
            var        circle3 = new EllipseVisual(rect2)
            {
                Brush = circle1.Brush
            };

            // Set a transform on the group, matching the node's location.
            // That way only the transform has to be updated instead of every single child visual.
            var transform = new Matrix();

            transform.Translate((float)layout.X, (float)layout.Y);

            var group = new VisualGroup {
                Transform = transform,
                Children  =
                {
                    border,
                    background,
                    iconVisual,
                    nameText,
                    positionText,
                    emailText,
                    phone1Text,
                    faxText,
                    circle1,
                    circle2,
                    circle3
                }
            };

            return(group);
        }