/// <summary> /// Constructor from a Graph file /// </summary> /// <param name="graphFileName">Path of Graph File to load</param> public DSGraphEditPanel(string graphFileName) { InitializeComponent(); int hr = 0; // create filter graph _graph = (IFilterGraph) new FilterGraph(); _filterGraphCreated = true; // give the filter graph to the DaggerUIGraph dsDaggerUIGraph1._Graph = _graph; // mark it as having been created internally dsDaggerUIGraph1._filterGraphCreated = true; #if DEBUG rot = new DsROTEntry(_graph); #endif // Initialize items common to all constructors Init(); // try to load the graph from IStorage try { hr = FilterGraphTools.LoadGraphFile(_graphBuilder, graphFileName); Marshal.ThrowExceptionForHR(hr); } catch (Exception ex) { // release the filtergraph and rethrow the exception Marshal.ReleaseComObject(_graph); throw ex; } // get the state _mediaControl.GetState(100, out _mediaState); // Have the graph signal event via window callbacks for performance _mediaEventEx = (IMediaEventEx)_graph; hr = _mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // sync the loaded graph and arrange the nodes dsDaggerUIGraph1.SyncGraphs(null); dsDaggerUIGraph1.ArrangeNodes(AutoArrangeStyle.All); }
public bool LoadGraph(string filename, on_graph_load onload) { try { Clear(); FilterGraphTools.LoadGraphFile(graphBuilder, filename); onload(); ReloadGraph(); return(true); } catch (COMException e) { ShowCOMException(e, "Error loading graph " + filename); } catch (Exception e) { MessageBox.Show(e.Message, "Can't load graph"); } return(false); }