private void InitializeGraph() { // create new nodestyle that delegates to other // styles for different zoom ranges var nodeStyle = new OrgChartNodeStyle(); // specify the three different zoom ranges overviewRange = new OrgChartNodeStyle.DoubleRange(0, 0.3); intermediateRange = new OrgChartNodeStyle.DoubleRange(0.3, 0.8); detailRange = new OrgChartNodeStyle.DoubleRange(0.8, Double.PositiveInfinity); // set different node styles for the zoom ranges nodeStyle.SetNodeStyle(overviewRange, new OverviewNodeStyle()); nodeStyle.SetNodeStyle(intermediateRange, new IntermediateNodeStyle()); DetailNodeStyle detailNodeStyle = new DetailNodeStyle(); // add buttons to detail node style ButtonDecoratorNodeStyle buttonDecorator = new ButtonDecoratorNodeStyle(); buttonDecorator.DecoratedStyle = detailNodeStyle; AddDecoratorButtons(buttonDecorator); nodeStyle.SetNodeStyle(detailRange, buttonDecorator); graphControl.Graph.NodeDefaults.Style = nodeStyle; graphControl.Graph.NodeDefaults.Size = new SizeD(250, 100); graphControl.Graph.EdgeDefaults.Style = new PolylineEdgeStyle { SmoothingLength = 10 }; }
public MyClickHandler(INode node, ButtonDecoratorNodeStyle style) { this.node = node; this.style = style; }
/// <summary> /// Adds the buttons to the <see cref="ButtonDecoratorNodeStyle" />. /// </summary> private void AddDecoratorButtons(ButtonDecoratorNodeStyle buttonDecorator) { int buttonSize = 14; // show parent button var b1 = new Button { Command = ShowParentCommand, CanExecuteHandler = CanExecuteShowParent, CommandParameter = Button.UseNodeParameter, CommandTarget = Button.UseCanvasControlTarget, // set a label as the button visualization Visualization = new SimpleLabel(null, "", FreeNodeLabelModel.Instance.CreateParameter( new PointD(1, 1), new PointD(-32, -32), PointD.Origin, PointD.Origin, 0)) { // style the label Style = new ButtonLabelStyle { BackgroundColor = Color.Black, ForegroundColor = Color.White, Icon = ButtonLabelStyle.ButtonIcon.ShowParent }, PreferredSize = new SizeD(buttonSize, buttonSize) } }; // set ButtonLabelStyle.Button so the style knows its owner ((ButtonLabelStyle)b1.Visualization.Style).Button = b1; buttonDecorator.Buttons.Add(b1); // hide parent button var b2 = new Button { Command = HideParentCommand, CanExecuteHandler = CanExecuteHideParent, CommandParameter = Button.UseNodeParameter, CommandTarget = Button.UseCanvasControlTarget, // set a label as the button visualization Visualization = new SimpleLabel(null, "", FreeNodeLabelModel.Instance.CreateParameter( new PointD(1, 1), new PointD(-17, -32), PointD.Origin, PointD.Origin, 0)) { // style the label Style = new ButtonLabelStyle { BackgroundColor = Color.Black, ForegroundColor = Color.White, Icon = ButtonLabelStyle.ButtonIcon.HideParent }, PreferredSize = new SizeD(buttonSize, buttonSize) } }; // set ButtonLabelStyle.Button so the style knows it's owner ((ButtonLabelStyle)b2.Visualization.Style).Button = b2; buttonDecorator.Buttons.Add(b2); // show children button var b3 = new Button { Command = ShowChildrenCommand, CanExecuteHandler = CanExecuteShowChildren, CommandParameter = Button.UseNodeParameter, CommandTarget = Button.UseCanvasControlTarget, // set a label as the button visualization Visualization = new SimpleLabel(null, "", FreeNodeLabelModel.Instance.CreateParameter( new PointD(1, 1), new PointD(-32, -17), PointD.Origin, PointD.Origin, 0)) { // style the label Style = new ButtonLabelStyle { BackgroundColor = Color.Black, ForegroundColor = Color.White, Icon = ButtonLabelStyle.ButtonIcon.ShowChildren }, PreferredSize = new SizeD(buttonSize, buttonSize) } }; // set ButtonLabelStyle.Button so the style knows it's owner ((ButtonLabelStyle)b3.Visualization.Style).Button = b3; buttonDecorator.Buttons.Add(b3); // hide children button var b4 = new Button { Command = HideChildrenCommand, CanExecuteHandler = CanExecuteHideChildren, CommandParameter = Button.UseNodeParameter, CommandTarget = Button.UseCanvasControlTarget, // set a label as the button visualization Visualization = new SimpleLabel(null, "", FreeNodeLabelModel.Instance.CreateParameter( new PointD(1, 1), new PointD(-17, -17), PointD.Origin, PointD.Origin, 0)) { // style the label Style = new ButtonLabelStyle { BackgroundColor = Color.Black, ForegroundColor = Color.White, Icon = ButtonLabelStyle.ButtonIcon.HideChildren }, PreferredSize = new SizeD(buttonSize, buttonSize) } }; // set ButtonLabelStyle.Button so the style knows it's owner ((ButtonLabelStyle)b4.Visualization.Style).Button = b4; buttonDecorator.Buttons.Add(b4); }