public MindMap() { InitializeComponent(); // the model is a tree of MindMapData, indexed by strings var model = new TreeModel <MindMapData, String>(); nodePalette.Model = new TreeModel <MindMapData, String>(); // Default root node, will be replaced if anything is loaded model.NodesSource = new ObservableCollection <MindMapData>() { new MindMapData() { Key = "/", Category = "Root", Text = "Mind Map", Location = new Point(0, 0) } }; // Initialize it from data in an XML file that is an embedded resource String xml = Demo.MainPage.Instance.LoadText("MindMap", "xml"); model.Load <MindMapData>(XElement.Parse(xml), "MindMapData"); nodePalette.Model.NodesSource = new ObservableCollection <MindMapData>() { new MindMapData() { Key = "Note", Category = "Note", Text = "Note", Figure = NodeFigure.Rectangle }, new MindMapData() { Key = "Title", Category = "Title", Text = "Title", Figure = NodeFigure.Rectangle } }; model.Modifiable = true; model.HasUndoManager = true; myDiagram.Model = model; myDiagram.AllowDrop = true; myDiagram.InitialLayoutCompleted += (s, e) => { LayoutAll(); }; myDiagram.ClickCreatingTool.DoubleClick = true; myDiagram.ClickCreatingTool.PrototypeData = new MindMapData() { LayoutId = "None", Key = "/", Figure = NodeFigure.Rectangle }; myDiagram.NodeCreated += myDiagram_NodeCreated; myDiagram.SelectionMoved += myDiagram_SelectionMoved; myDiagram.SelectionDeleting += myDiagram_SelectionDeleting; printButton.Command = myDiagram.CommandHandler.PrintCommand; myDiagram.MouseRightButtonUp += CreateChild; }
public OrgChartBus() { InitializeComponent(); // create the initial model var model = new TreeModel <Employee, int>(); model.ChildNodesPath = ""; // don't use each node data's collection of children // initialize it from data in an XML file that is an embedded resource String xml = Demo.MainPage.Instance.LoadText("OrgChartBus", "xml"); model.Load <Employee>(XElement.Parse(xml), "Employee"); model.Modifiable = true; // allow user modification model.HasUndoManager = true; // support undo/redo myDiagram.Model = model; }