/// <summary> /// This method comes from the principal menu. It's the option to create a project. /// </summary> /// <param name="sender"> /// Name of the object. /// </param> /// <param name="e"> /// This class contains no event data; it is used by events that do not pass state information to an event /// handler when an event is raised. If the event handler requires state information, the application must /// derive a class from this class to hold the data. /// </param> void NewFile(object sender, EventArgs e) { if (modified && scl != null) { var res = MessageBox.Show("Do you want to save your work?", "Creating a new SCL...", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (res == DialogResult.Yes) { SaveSCLFile(true); } if (res == DialogResult.Cancel) { return; } } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; var scln = new OpenSCL.Object(); this.scl = scln; this.Text = this.AppName + " - " + this.File; this.scl.Configuration.AddIED("TEMPLATE"); this.sclviewertree.scl = this.scl.Configuration; this.sclviewertree.title = GetSclTitle(); modified = true; this.Cursor = System.Windows.Forms.Cursors.Default; }
/// <summary> /// This method shows a dialog box to allow select an IED file (*.icd, *.cid) and show it /// on a tree. /// </summary> /// <param name="treeViewOpen"> /// Graphical component "TreeView" where some nodes of IED file will be added. /// </param> /// <returns> /// If the file that will be open has errors of XML sintax or an incorrect data according to the /// XSD files then a list of errors is returned, otherwise an empty list is returned. /// </returns> public List <ErrorsManagement> ImportIED(string filename, bool validate) { var list = new List <ErrorsManagement> (); if (validate) { var val = new ValidatingSCL(); list = val.ValidateFile(filename, xSDFiles); } if (list.Count == 0) { // Creating a SCL object System.Console.WriteLine("Deserializating file to Import..."); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); var ied = new OpenSCL.Object(); ied.Deserialize(filename); sw.Stop(); System.Console.WriteLine("Enlapsed Time:" + sw.ElapsedMilliseconds + " ms"); System.Console.WriteLine("Importing IED:..."); System.Diagnostics.Stopwatch swt = new System.Diagnostics.Stopwatch(); swt.Start(); // TODO: Add a dialog to show rejected IEDs if (this.scl != null) { this.scl.Configuration.ImportIED(ied.Configuration); } else { this.scl = ied; } swt.Stop(); System.Console.WriteLine("Enlapsed Time:" + swt.ElapsedMilliseconds + " ms"); System.Console.WriteLine("Creating TreeView:..."); System.Diagnostics.Stopwatch swc = new System.Diagnostics.Stopwatch(); swc.Start(); sclviewertree.scl = this.scl.Configuration; sclviewertree.title = GetSclTitle(); swc.Stop(); System.Console.WriteLine("Enlapsed Time:" + swc.ElapsedMilliseconds + " ms"); modified = true; } return(list); }
public void OpenSCLFile(string filename, bool validate) { List <ErrorsManagement> list = new List <ErrorsManagement> (); if (modified && scl != null) { var res = MessageBox.Show("Do you want to save your work?", "Openning a new SCL", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (res == DialogResult.Yes) { SaveSCLFile(true); } if (res == DialogResult.Cancel) { return; } } string f = ""; if (filename == null) { openDialog dlg = new openDialog(); var res = dlg.ShowDialog(); if (res == DialogResult.OK) { f = dlg.FileName; } else { return; } } else { f = filename; } if (validate) { //System.Windows.Forms.MessageBox.Show ("OpenDialog: Validating"); ValidatingSCL val = new ValidatingSCL(); list = val.ValidateFile(f, xSDFiles); } this.PropertyGridAttributes.SelectedObject = null; this.Cursor = System.Windows.Forms.Cursors.WaitCursor; this.scl = null; // Creating an SCL object System.Console.WriteLine("Deserializating file to SCLObject:..."); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); this.scl = new OpenSCL.Object(); this.scl.Deserialize(f); sw.Stop(); System.Console.WriteLine("Enlapsed Time:" + sw.ElapsedMilliseconds + " ms"); // Creating TreeView System.Console.WriteLine("Creating TreeView:..."); System.Diagnostics.Stopwatch swt = new System.Diagnostics.Stopwatch(); swt.Start(); string t = GetSclTitle(); this.sclviewertree.scl = this.scl.Configuration; this.sclviewertree.title = t; swt.Stop(); System.Console.WriteLine("Enlapsed Time:" + swt.ElapsedMilliseconds + " ms"); modified = false; this.Text = this.AppName + " - " + this.File; Console.WriteLine("File: " + scl.FileName + "Openend Modif = " + modified.ToString()); this.Cursor = System.Windows.Forms.Cursors.Default; if (list.Count == 0) { EnablePanels(null); } else { EnablePanels(list); } }