static ScalingLabelModel() { stretchModel = new InteriorStretchLabelModel(); stretchParameter = stretchModel.CreateParameter(InteriorStretchLabelModel.Position.Center); dummyNode = new SimpleNode(); dummyLabel = new SimpleLabel(dummyNode, "", stretchParameter); }
/// <inheritdoc /> protected override void InitializeFolderNodeLabels(FolderNodeState state, IFoldingView foldingView, INode viewNode, INode masterNode) { state.ClearLabels(); if (CopyLabels) { var labels = masterNode.Labels; if (labels.Count > 0) { for (var i = 0; i < labels.Count; i++) { var label = labels[i]; // If the node is a choreographyNode, just copy all Labels if (masterNode.Style is ChoreographyNodeStyle) { state.AddLabel(label.Text, label.LayoutParameter, label.Style, label.PreferredSize, label.Tag); } else { // if subProcessNode, create new Layout & Style var labelStyle = CreateLabelStyle(foldingView, null, label); var labelModel = new InteriorStretchLabelModel { Insets = new InsetsD(3, 3, 3, 3) }; var labelLayoutParameter = labelModel.CreateParameter(InteriorStretchLabelModel.Position.Center); state.AddLabel(label.Text, labelLayoutParameter ?? label.LayoutParameter, labelStyle ?? label.Style, label.PreferredSize, label.Tag); } } } } }
private void InitializeGraph() { var graph = graphControl.Graph; graph.NodeDefaults.Style = new ShapeNodeStyle { Brush = (Brush) new SolidColorBrush(Color.FromRgb(102, 153, 204)).GetAsFrozen(), Pen = null }; graph.EdgeDefaults.Style = new BezierEdgeStyle(new DemoEdgeStyleRenderer(graphControl.Selection, false)); // use a label model that stretches the label over the full node layout, with small insets var centerLabelModel = new InteriorStretchLabelModel { Insets = new InsetsD(3) }; graph.NodeDefaults.Labels.LayoutParameter = centerLabelModel.CreateParameter(InteriorStretchLabelModel.Position.Center); // set the default style for the node labels graph.NodeDefaults.Labels.Style = new DefaultLabelStyle { TextBrush = Brushes.White, TextWrapping = TextWrapping.Wrap, VerticalTextAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center }; // set the default node size graph.NodeDefaults.Size = new SizeD(80, 30); // add a node tag listener to change the node brush when the tag changes graph.NodeTagChanged += (sender, e) => { var item = e.Item; var tag = (CustomTag)item.Tag; if (item.Tag != null && e.OldValue != null && tag.brush != ((CustomTag)e.OldValue).brush) { ((ShapeNodeStyle)item.Style).Brush = ((CustomTag)item.Tag).brush; //GetNodeColor(item); graphControl.Invalidate(); } }; // enable the undo engine graph.SetUndoEngineEnabled(true); // disable all edge handles var edgeDecorator = graph.GetDecorator().EdgeDecorator; edgeDecorator.HandleProviderDecorator.HideImplementation(); edgeDecorator.SelectionDecorator.HideImplementation(); edgeDecorator.BendCreatorDecorator.HideImplementation(); edgeDecorator.PositionHandlerDecorator.HideImplementation(); graph.GetDecorator().BendDecorator.HandleProviderDecorator.HideImplementation(); // allow nodes to be only moved vertically graph.GetDecorator().NodeDecorator.PositionHandlerDecorator.SetImplementationWrapper((node, handler) => new HorizontallyConstrainedPositionHandler(handler)); graphControl.HighlightIndicatorManager = new HighlightManager(graphControl); }
/// <summary> /// Initializes the graph instance setting default styles /// and creating a small sample graph. /// </summary> protected virtual void InitializeGraph() { // Enable folding IFoldingView view = new FoldingManager().CreateFoldingView(); graphControl.Graph = view.Graph; // Get the master graph instance and enable undoability support. view.Manager.MasterGraph.SetUndoEngineEnabled(true); #region Configure grouping // get a hold of the group node defaults var groupNodeDefaults = view.Graph.GroupNodeDefaults; // configure the group node style. //PanelNodeStyle is a nice style especially suited for group nodes Color groupNodeColor = Color.FromArgb(255, 214, 229, 248); groupNodeDefaults.Style = new CollapsibleNodeStyleDecorator(new PanelNodeStyle { Color = groupNodeColor, Insets = new InsetsD(5, 20, 5, 5), LabelInsetsColor = groupNodeColor, }); // Set a different label style and parameter groupNodeDefaults.Labels.Style = new DefaultLabelStyle { TextAlignment = TextAlignment.Left }; var labelModel = new InteriorStretchLabelModel() { Insets = new InsetsD(15, 1, 1, 1) }; var param = labelModel.CreateParameter(InteriorStretchLabelModel.Position.North); groupNodeDefaults.Labels.LayoutParameter = param; #endregion #region Configure Graph defaults // Set the default node style Graph.NodeDefaults.Style = new ShinyPlateNodeStyle { Brush = Brushes.Orange }; // Set the default node label position to centered below the node with the FreeNodeLabelModel that supports label snapping Graph.NodeDefaults.Labels.LayoutParameter = FreeNodeLabelModel.Instance.CreateParameter( new PointD(0.5, 1.0), new PointD(0, 10), new PointD(0.5, 0.0), new PointD(0, 0), 0); // Set the default edge label position with the SmartEdgeLabelModel that supports label snapping Graph.EdgeDefaults.Labels.LayoutParameter = new SmartEdgeLabelModel().CreateParameterFromSource(0, 0, 0.5); #endregion }
/// <summary> /// Initializes the graph instance setting default styles /// and creating a small sample graph. /// </summary> private void InitializeGraph() { graphControl.ImportFromGraphML("Resources/sample.graphml"); graphControl.Graph.SetUndoEngineEnabled(true); #region Configure grouping // configure the group node style. //PanelNodeStyle is a nice style especially suited for group nodes Color groupNodeColor = Color.FromArgb(255, 214, 229, 248); Graph.GroupNodeDefaults.Style = new CollapsibleNodeStyleDecorator(new PanelNodeStyle { Color = groupNodeColor, Insets = new InsetsD(5, 20, 5, 5), LabelInsetsColor = Color.Bisque }); // Set a different label style and parameter Graph.GroupNodeDefaults.Labels.Style = new DefaultLabelStyle { StringFormat = { Alignment = StringAlignment.Far } }; var labelModel = new InteriorStretchLabelModel() { Insets = new InsetsD(15, 1, 1, 1) }; var param = labelModel.CreateParameter(InteriorStretchLabelModel.Position.North); Graph.GroupNodeDefaults.Labels.LayoutParameter = param; #endregion #region Configure Graph defaults // Set the default node style Graph.NodeDefaults.Style = new ShinyPlateNodeStyle { Brush = Brushes.Orange, DrawShadow = true }; // Set the default node label position to centered below the node with the FreeNodeLabelModel that supports label snapping Graph.NodeDefaults.Labels.LayoutParameter = FreeNodeLabelModel.Instance.CreateParameter( new PointD(0.5, 1.0), new PointD(0, 10), new PointD(0.5, 0.0), new PointD(0, 0), 0); // Set the default edge label position with the SmartEdgeLabelModel that supports label snapping Graph.EdgeDefaults.Labels.LayoutParameter = new SmartEdgeLabelModel().CreateParameterFromSource(0, 0, 0.5); #endregion }
/// <summary> /// Creates a group node for the sample graph with a specific styling. /// </summary> private static INode CreateGroupNode(IGraph graph, double x, double y, Color fillColor, string labelText) { var groupNode = graph.CreateGroupNode(); graph.SetStyle(groupNode, new PanelNodeStyle { Color = fillColor, LabelInsetsColor = fillColor, Insets = new InsetsD(5, 20, 5, 5) }); graph.SetNodeLayout(groupNode, new RectD(x, y, 130, 100)); // The label style and placement var labelStyle = new DefaultLabelStyle(); labelStyle.TextBrush = Brushes.White; var labelModel = new InteriorStretchLabelModel(); labelModel.Insets = new InsetsD(5, 2, 5, 4); var modelParameter = labelModel.CreateParameter(InteriorStretchLabelModel.Position.North); graph.AddLabel(groupNode, labelText, modelParameter, labelStyle); groupNode.Tag = fillColor; return(groupNode); }