private void LoadEffectsFile(string filename) { if (File.Exists(filename)) { try { XmlDocument xDocM = new XmlDocument(); xDocM.Load(filename); XmlNode xDoc = xDocM.SelectSingleNode("ESSA"); XmlNodeList effects = xDoc.SelectNodes("Effect"); Filter thisFilter; int index = 0; foreach (XmlNode enode in effects) { if (enode.Attributes["Name"] == null) { MessageBox.Show("Encountered unnamed effect. Skipping."); continue; } thisFilter = new Filter(enode.Attributes["Name"].Value); if (enode.Attributes["Code"] != null) thisFilter.Code = enode.Attributes["Code"].Value; //add default options XmlNodeList options = enode.SelectNodes("Option"); foreach (XmlNode onode in options) { if (onode.Attributes["Name"] == null) continue; thisFilter.AddOption(onode.Attributes["Name"].Value, onode.InnerText); } //add default conditions XmlNodeList econditions = enode.SelectNodes("Condition"); foreach (XmlNode ecnode in econditions) { if ((ecnode.Attributes["ConditionOne"] == null) || (ecnode.Attributes["ConditionTwo"] == null) || (ecnode.Attributes["ConditionOperation"] == null)) { continue; } Condition thisCondition = new Condition(); thisCondition.ConditionOne = ecnode.Attributes["ConditionOne"].Value; thisCondition.ConditionTwo = ecnode.Attributes["ConditionTwo"].Value; thisCondition.ConditionOp = ecnode.Attributes["ConditionOperation"].Value; thisCondition.ConditionEnabled = (ecnode.Attributes["Enabled"] != null) ? (String.Equals(ecnode.Attributes["Enabled"].Value, "true", StringComparison.OrdinalIgnoreCase)) : true; thisFilter.AddCondition(thisCondition); } templateFilterColl.Add(thisFilter); menuItem15.MenuItems.Add(thisFilter.ToString(), new EventHandler(this.menuFilter_Click)); index+=1; } //templateFilterColl.Sort(); EventContext(); } catch (XmlException xmle) { MessageBox.Show(xmle.Message); } catch (Exception e) { MessageBox.Show(e.Message); } } }
public Form1(string[] args) { // // Required for Windows Form Designer support // FormMain = this; InitializeComponent(); Evaluate.FillOpsList(); listSSAg = Graphics.FromHwnd(listSSA.Handle); lineColl = new List<Line>(); layerColl = new System.Collections.Generic.List<Layer>(); templateFilterColl = new System.Collections.Generic.List<Filter>(); undoStack = new Stack(); redoStack = new Stack(); //CurFile = String.Empty; // Add the "raw code" filter as a default filter Filter raw = new Filter("Raw code", "$Code$"); FilterOption rawfo = new FilterOption("Code", ""); raw.AddOption(rawfo); templateFilterColl.Add(raw); string path = "effects.exml"; if (File.Exists(path)) LoadEffectsFile(path); enc = new System.Text.UnicodeEncoding(); Notebox.readNoteBoxes(); string arglower; foreach (string arg in args) { if (File.Exists(arg)) { arglower = arg.ToLower(Util.cfi); if (arglower.EndsWith(".xml")) LoadProject(arg); else if (arglower.EndsWith(".ass") || arglower.EndsWith(".ssa") || arglower.EndsWith(".assa")) LoadFile(args[0], null); } } listSSA.LabelEdit = false; }