public async Task Execute(SequenceInfo si) { if (si != null) { try { foreach (SequenceInfo.ActionInfo ai in si.Actions) { var p = Utils.PluginSupport.PluginByName(Core, ai.Plugin); if (p != null) { if (string.IsNullOrEmpty(ai.SubAction)) { await p.ActionAsync(ai.Action); } else { await p.ActionAsync(string.Format("{0}|{1}", ai.Action, ai.SubAction)); } } } } catch { } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { listView1.Items.Clear(); SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null) { button1.Enabled = true; button2.Enabled = true; button7.Enabled = true; button3.Enabled = textBox1.Text.Length > 0 && (from a in _sequenceInfos where a.Name == textBox1.Text select a).FirstOrDefault() == null; button4.Enabled = textBox1.Text.Length > 0 && (from a in _sequenceInfos where a.Name == textBox1.Text select a).FirstOrDefault() == null; foreach (var a in si.Actions) { ListViewItem lvi = new ListViewItem(new string[] { Utils.LanguageSupport.Instance.GetTranslation(a.Plugin), Utils.LanguageSupport.Instance.GetTranslation(a.Action), Utils.LanguageSupport.Instance.GetTranslation(a.SubAction) }); lvi.Tag = a; listView1.Items.Add(lvi); } } else { button1.Enabled = false; button2.Enabled = false; button7.Enabled = false; button4.Enabled = false; } }
private void button7_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null) { using (SelectActionForm dlg = new SelectActionForm(Core)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dlg.SelectedAction != null) { si.Actions.Add(dlg.SelectedAction); ListViewItem lvi = new ListViewItem(new string[] { Utils.LanguageSupport.Instance.GetTranslation(dlg.SelectedAction.Plugin), Utils.LanguageSupport.Instance.GetTranslation(dlg.SelectedAction.Action), Utils.LanguageSupport.Instance.GetTranslation(dlg.SelectedAction.SubAction) }); lvi.Tag = dlg.SelectedAction; listView1.Items.Add(lvi); SequenceInfo.SaveActionSequences(_sequenceInfos); } } } } }
private void button5_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null && listView1.SelectedItems.Count > 0) { si.Actions.Remove(listView1.SelectedItems[0].Tag as SequenceInfo.ActionInfo); listView1.Items.Remove(listView1.SelectedItems[0]); } }
private async void button1_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null) { this.Enabled = false; toolStripStatusLabel1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_EXECUTING); statusStrip1.Refresh(); await Execute(si); this.Enabled = true; toolStripStatusLabel1.Text = ""; } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null && listView1.SelectedItems.Count > 0) { button5.Enabled = true; button6.Enabled = listView1.SelectedIndices[0] > 0; button8.Enabled = listView1.SelectedIndices[0] < listView1.Items.Count - 1; } else { button5.Enabled = false; button6.Enabled = false; button8.Enabled = false; } }
private void button2_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null) { Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); (this.OwnerPlugin as ActionList).DeleteAction(si.Name); main.RemoveAction(OwnerPlugin, "Action sequence", si.Name); comboBox1.Items.Remove(si); comboBox1_SelectedIndexChanged(this, EventArgs.Empty); _sequenceInfos.Remove(si); SequenceInfo.SaveActionSequences(_sequenceInfos); } }
public ActionListForm(Framework.Interfaces.IPlugin owner, Framework.Interfaces.ICore core) : base(owner, core) { InitializeComponent(); var p = PluginSettings.Instance.WindowPos; if (p != null && !p.IsEmpty) { this.Bounds = p; this.StartPosition = FormStartPosition.Manual; } SelectedLanguageChanged(this, EventArgs.Empty); _sequenceInfos = SequenceInfo.GetActionSequences(); comboBox1.Items.AddRange(_sequenceInfos.ToArray()); }
private void button3_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { SequenceInfo si = new SequenceInfo(); si.Name = textBox1.Text; _sequenceInfos.Add(si); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); (this.OwnerPlugin as ActionList).AddNewAction(si.Name); main.AddAction(OwnerPlugin, "Action sequence", si.Name); comboBox1.Items.Add(si); comboBox1.SelectedItem = si; comboBox1_SelectedIndexChanged(this, EventArgs.Empty); SequenceInfo.SaveActionSequences(_sequenceInfos); } }
public static List <SequenceInfo> GetActionSequences() { List <SequenceInfo> result = new List <SequenceInfo>(); try { string xml = PluginSettings.Instance.ActionSequences; if (!string.IsNullOrEmpty(xml)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlElement root = doc.DocumentElement; XmlNodeList bmNodes = root.SelectNodes("sequence"); if (bmNodes != null) { foreach (XmlNode n in bmNodes) { SequenceInfo bm = new SequenceInfo(); bm.Name = n.SelectSingleNode("Name").InnerText; XmlNodeList anl = n.SelectSingleNode("actions").SelectNodes("action"); if (anl != null) { foreach (XmlNode an in anl) { ActionInfo ai = new ActionInfo(); ai.Plugin = an.SelectSingleNode("Plugin").InnerText; ai.Action = an.SelectSingleNode("Action").InnerText; ai.SubAction = an.SelectSingleNode("SubAction").InnerText; bm.Actions.Add(ai); } } result.Add(bm); } } } } catch { } return(result); }
public static List<SequenceInfo> GetActionSequences() { List<SequenceInfo> result = new List<SequenceInfo>(); try { string xml = PluginSettings.Instance.ActionSequences; if (!string.IsNullOrEmpty(xml)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlElement root = doc.DocumentElement; XmlNodeList bmNodes = root.SelectNodes("sequence"); if (bmNodes != null) { foreach (XmlNode n in bmNodes) { SequenceInfo bm = new SequenceInfo(); bm.Name = n.SelectSingleNode("Name").InnerText; XmlNodeList anl = n.SelectSingleNode("actions").SelectNodes("action"); if (anl != null) { foreach (XmlNode an in anl) { ActionInfo ai = new ActionInfo(); ai.Plugin = an.SelectSingleNode("Plugin").InnerText; ai.Action = an.SelectSingleNode("Action").InnerText; ai.SubAction = an.SelectSingleNode("SubAction").InnerText; bm.Actions.Add(ai); } } result.Add(bm); } } } } catch { } return result; }
private void button4_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null) { Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); (this.OwnerPlugin as ActionList).DeleteAction(si.Name); main.RemoveAction(OwnerPlugin, "Action sequence", si.Name); si.Name = textBox1.Text; (this.OwnerPlugin as ActionList).AddNewAction(si.Name); main.AddAction(OwnerPlugin, "Action sequence", si.Name); typeof(ComboBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, comboBox1, new object[] { }); comboBox1_SelectedIndexChanged(this, EventArgs.Empty); SequenceInfo.SaveActionSequences(_sequenceInfos); } }
public static List<SequenceInfo> GetActionSequences(string filename) { List<SequenceInfo> result = new List<SequenceInfo>(); try { if (System.IO.File.Exists(filename)) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlElement root = doc.DocumentElement; XmlNodeList bmNodes = root.SelectNodes("sequence"); if (bmNodes != null) { foreach (XmlNode n in bmNodes) { SequenceInfo bm = new SequenceInfo(); bm.Name = n.SelectSingleNode("Name").InnerText; XmlNodeList anl = n.SelectSingleNode("actions").SelectNodes("action"); if (anl != null) { foreach (XmlNode an in anl) { ActionInfo ai = new ActionInfo(); ai.Plugin = an.SelectSingleNode("Plugin").InnerText; ai.Action = an.SelectSingleNode("Action").InnerText; ai.SubAction = an.SelectSingleNode("SubAction").InnerText; bm.Actions.Add(ai); } } result.Add(bm); } } } } catch { } return result; }
private void button8_Click(object sender, EventArgs e) { SequenceInfo si = comboBox1.SelectedItem as SequenceInfo; if (si != null && listView1.SelectedItems.Count > 0 && listView1.SelectedIndices[0] < listView1.Items.Count - 1) { SequenceInfo.ActionInfo ai = listView1.SelectedItems[0].Tag as SequenceInfo.ActionInfo; if (ai != null) { int index = listView1.SelectedIndices[0] + 1; si.Actions.Remove(ai); si.Actions.Insert(index, ai); comboBox1_SelectedIndexChanged(this, EventArgs.Empty); listView1.Items[index].Selected = true; listView1_SelectedIndexChanged(this, EventArgs.Empty); SequenceInfo.SaveActionSequences(_sequenceInfos); } } }
private void button3_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { SequenceInfo si = new SequenceInfo(); si.Name = textBox1.Text; _sequenceInfos.Add(si); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); (this.OwnerPlugin as ActionList).AddNewAction(si.Name); main.AddAction(OwnerPlugin, "Action sequence", si.Name); comboBox1.Items.Add(si); comboBox1.SelectedItem = si; comboBox1_SelectedIndexChanged(this, EventArgs.Empty); SequenceInfo.SaveActionSequences(_settingsFile, _sequenceInfos); } }