public MainForm() { InitializeComponent(); if (!Settings.Default.LastSize.IsEmpty) { StartPosition = FormStartPosition.Manual; Location = Settings.Default.LastLocation; Size = Settings.Default.LastSize; splitContainer1.SplitterDistance = Settings.Default.SplitterPosition; } this.treeView1.AllowDrop = true; this.graphControl1.AllowDrop = true; this.treeView1.MouseDown += new MouseEventHandler(listBox1_MouseDown); this.treeView1.DragOver += new DragEventHandler(listBox1_DragOver); this.graphControl1.DragEnter += new DragEventHandler(treeView1_DragEnter); this.graphControl1.DragDrop += new DragEventHandler(treeView1_DragDrop); IDictionary <Guid, Type> filterTypes = FiltersHelper.GetFilterTypes(); UpdateTreeView(filterTypes); if (File.Exists(PathToXml)) { GraphBundle graphBundle = GraphLoader.Load(PathToXml); graphControl1.LoadGraph(graphBundle); } else { graphControl1.LoadGraph(new GraphBundle()); } }
private GraphBundle LoadInternal(string path) { var xDoc = XDocument.Load(path); if (xDoc.Root == null) { return(null); } if (xDoc.Root.Name != GraphFileFormat.NodeRoot) { return(null); } var result = new GraphBundle(); var filtersNode = xDoc.Root.Element(GraphFileFormat.Ver_0_1.Node_Filters); if (filtersNode != null) { filtersNode .Elements(GraphFileFormat.Ver_0_1.Node_Filter) .Select(GetFilter) .ToList() .ForEach(result.Graph.AddFilter); filtersNode .Elements(GraphFileFormat.Ver_0_1.Node_Filter) .ToList() .ForEach(element => ProcessConnections(element, result.Graph)); } var locationsNode = xDoc.Root.Element(GraphFileFormat.Ver_0_1.Node_Locations); if (locationsNode != null) { locationsNode .Elements(GraphFileFormat.Ver_0_1.Node_Location) .Select(GetLocation) .ToList() .ForEach(x => result.Locations[x.Key] = x.Value); } return(result); }