internal LayerEnumerator(Layer l) { this.l = l; Reset(); }
private List<Layer> LoadProject(string filename) { //Returns a List of Layers which represents the layers of the project (layerColl/lColl) if (File.Exists(filename)) { try { XmlDocument xDocM = new XmlDocument(); xDocM.Load(filename); XmlNode xDoc = xDocM.SelectSingleNode("PSSA"); XmlNodeList filelist = xDoc.SelectNodes("Files"); foreach (XmlNode filenode in filelist) { XmlNodeList ssalist = filenode.SelectNodes("SSA"); foreach (XmlNode ssanode in ssalist) if (File.Exists(ssanode.InnerText)) LoadFile(ssanode.InnerText, null); XmlNodeList effectfilelist = filenode.SelectNodes("EffectFile"); foreach (XmlNode effectfilenode in effectfilelist) if (File.Exists(effectfilenode.InnerText)) LoadEffectsFile(effectfilenode.InnerText); } XmlNodeList layers = xDoc.SelectNodes("Layer"); System.Collections.Generic.List<Layer> lColl = new System.Collections.Generic.List<Layer>(); Layer thisLayer; Filter thisFilter, templateFilter; Condition thisCondition; int repetitions; foreach (XmlNode lnode in layers) { thisLayer = new Layer(); thisLayer.Enabled = (lnode.Attributes["Enabled"] != null) ? (String.Compare(lnode.Attributes["Enabled"].Value, "true", true) == 0) : true; thisLayer.PerSyllable = (lnode.Attributes["PerSyllable"] != null) ? (String.Compare(lnode.Attributes["PerSyllable"].Value, "true", true) == 0) : false; thisLayer.SyllablePerLine = !(thisLayer.PerSyllable) && (lnode.Attributes["SyllablePerLine"] != null) ? (String.Compare(lnode.Attributes["SyllablePerLine"].Value, "true", true) == 0) : false; thisLayer.AddAll = (lnode.Attributes["AddAll"] != null) ? (String.Compare(lnode.Attributes["AddAll"].Value, "true", true) == 0) : false; thisLayer.AddOnce = (lnode.Attributes["AddOnce"] != null) ? (String.Compare(lnode.Attributes["AddOnce"].Value, "true", true) == 0) : false; thisLayer.AddText = (lnode.Attributes["DontAddText"] != null) ? (String.Compare(lnode.Attributes["DontAddText"].Value, "false", true) == 0) : true; thisLayer.AddK = (lnode.Attributes["RemoveK"] != null) ? (String.Compare(lnode.Attributes["RemoveK"].Value, "false", true) == 0) : true; thisLayer.AddASSA = (lnode.Attributes["AddASSA"] != null) ? (String.Compare(lnode.Attributes["AddASSA"].Value, "true", true) == 0) : true; thisLayer.AddBracket = (lnode.Attributes["AddClosingBracket"] != null) ? (String.Compare(lnode.Attributes["AddClosingBracket"].Value, "true", true) == 0) : true; thisLayer.Name = (lnode.Attributes["Name"] != null) ? lnode.Attributes["Name"].Value : "Layer " + layerColl.Count.ToString(Util.nfi); if ((lnode.Attributes["Repetitions"] != null) && (int.TryParse(lnode.Attributes["Repetitions"].Value,System.Globalization.NumberStyles.Integer,Util.nfi,out repetitions))) { try { if (repetitions > 0) thisLayer.Repetitions = repetitions; } catch { } } // Repetitions is 1 by default, so we only need to set if it's different XmlNodeList effects = lnode.SelectNodes("Effect"); foreach (XmlNode enode in effects) { if (enode.Attributes["Name"] == null) { MessageBox.Show("Encountered unnamed effect. Skipping."); continue; } templateFilter = GetTemplateFilterFromName(enode.Attributes["Name"].Value); if (templateFilter == null) { MessageBox.Show("Could not find effect " + enode.Attributes["Name"].Value + ", skipping effect"); continue; } thisFilter = (Filter)templateFilter.Clone(); thisFilter.Enabled = (enode.Attributes["Enabled"] != null) ? (String.Compare(enode.Attributes["Enabled"].Value, "true", true) == 0) : true; if (enode.Attributes["InstanceName"] != null) thisFilter.Name = enode.Attributes["InstanceName"].Value; //override default options where present XmlNodeList options = enode.SelectNodes("Option"); foreach (XmlNode onode in options) { if (onode.Attributes["Name"] == null) continue; thisFilter.SetOptionValueByName(onode.Attributes["Name"].Value, onode.InnerText); } XmlNodeList econditions = enode.SelectNodes("Condition"); foreach (XmlNode ecnode in econditions) { if ((ecnode.Attributes["ConditionOne"] == null) || (ecnode.Attributes["ConditionTwo"] == null) || (ecnode.Attributes["ConditionOperation"] == null)) { continue; } 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.Compare(ecnode.Attributes["Enabled"].Value, "true", true) == 0) : true; thisFilter.AddCondition(thisCondition); } thisLayer.AddFilter(thisFilter); } XmlNodeList lconditions = lnode.SelectNodes("Condition"); foreach (XmlNode lcnode in lconditions) { if ((lcnode.Attributes["ConditionOne"] == null) || (lcnode.Attributes["ConditionTwo"] == null) || (lcnode.Attributes["ConditionOperation"] == null)) { continue; } thisCondition = new Condition(); thisCondition.ConditionOne = lcnode.Attributes["ConditionOne"].Value; thisCondition.ConditionTwo = lcnode.Attributes["ConditionTwo"].Value; thisCondition.ConditionOp = lcnode.Attributes["ConditionOperation"].Value; thisCondition.ConditionEnabled = (lcnode.Attributes["Enabled"] != null) ? (String.Compare(lcnode.Attributes["Enabled"].Value, "true", true) == 0) : true; thisLayer.AddCondition(thisCondition); } lColl.Add(thisLayer); } EventContext(); return lColl; } catch (Exception e) { MessageBox.Show(e.Message); return new System.Collections.Generic.List<Layer>(); } } return new System.Collections.Generic.List<Layer>(); }
private void treeKaraoke_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { if (treeKaraoke.SelectedNode.Level == 0) { CurLayer = (Layer)layerColl[e.Node.Index]; RedrawLayerConditions(); panelLayer.Visible = !(panelEffect.Visible = false); } else { CurLayer = (Layer)layerColl[e.Node.Parent.Index]; RedrawOptionsList(); RedrawEffectConditions(); panelEffect.Visible = !(panelLayer.Visible = false); } }
private void cmdNewLayer_Click(object sender, System.EventArgs e) { Layer nl = new Layer(); nl.Enabled = true; nl.Name = "Layer " + (layerColl.Count).ToString(Util.nfi); layerColl.Add(nl); TreeNode tn = new TreeNode("Layer " + (layerColl.Count-1).ToString(Util.nfi)); tn.Checked = true; treeKaraoke.SelectedNode = treeKaraoke.Nodes[treeKaraoke.Nodes.Add(tn)]; }