public SettingsPanel(Framework.Interfaces.ICore core) { InitializeComponent(); this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_INFO); this.buttonClear.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CLEAR); List <Framework.Data.ShortcutInfo> scuts = core.ShortcutInfo; List <Framework.Interfaces.IPlugin> pins = core.GetPlugins(); foreach (Framework.Interfaces.IPlugin p in pins) { List <string> actions = p.GetActionSubactionList('@'); foreach (string act in actions) { string[] parts = act.Split(new char[] { '@' }); ListViewItem lvi = new ListViewItem(new string[] { p.GetType().ToString(), Utils.LanguageSupport.Instance.GetTranslation(parts[0]), parts.Length == 1?"": Utils.LanguageSupport.Instance.GetTranslation(parts[1]), "" }); lvi.Tag = p; listView1.Items.Add(lvi); Framework.Data.ShortcutInfo sc = (from t in scuts where t.PluginType == p.GetType().ToString() && t.PluginAction == parts[0] && (parts.Length == 1 || t.PluginSubAction == parts[1]) select t).FirstOrDefault(); lvi.SubItems[0].Tag = p.GetType().ToString(); lvi.SubItems[1].Tag = parts[0]; lvi.SubItems[2].Tag = parts.Length == 1?"":parts[1]; if (sc != null) { lvi.SubItems[3].Text = sc.ShortcutKeyString; lvi.SubItems[3].Tag = sc.ShortcutKeys; } else { lvi.SubItems[3].Tag = null; } } } }
public SettingsPanel(Framework.Interfaces.ICore core) : this() { this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_INFO); this.buttonSort.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SORT); //first the selected if (PluginSettings.Instance.Startup != null && PluginSettings.Instance.Startup.Count > 0) { foreach (string s in PluginSettings.Instance.Startup) { string[] parts = s.Split(new char[] { '@' }, 2); Framework.Interfaces.IPlugin p = Utils.PluginSupport.PluginByName(core, parts[0]); if (p != null) { List <string> actions = p.GetActionSubactionList('@'); if (actions.Contains(parts[1])) { string[] act = parts[1].Split(new char[] { '@' }); ListViewItem lvi = new ListViewItem(new string[] { p.GetType().ToString(), Utils.LanguageSupport.Instance.GetTranslation(parts[0]), act.Length == 1 ? "" : Utils.LanguageSupport.Instance.GetTranslation(act[1]), "" }); lvi.Tag = s; lvi.Checked = true; listView1.Items.Add(lvi); } } } } List <Framework.Interfaces.IPlugin> pins = core.GetPlugins(); foreach (Framework.Interfaces.IPlugin p in pins) { List <string> actions = p.GetActionSubactionList('@'); foreach (string act in actions) { string stag = string.Format("{0}@{1}", p.GetType(), act); if ((PluginSettings.Instance.Startup == null || !PluginSettings.Instance.Startup.Contains(stag))) { string[] parts = act.Split(new char[] { '@' }); ListViewItem lvi = new ListViewItem(new string[] { p.GetType().ToString(), Utils.LanguageSupport.Instance.GetTranslation(parts[0]), parts.Length == 1 ? "" : Utils.LanguageSupport.Instance.GetTranslation(parts[1]), "" }); lvi.Tag = stag; lvi.Checked = false; listView1.Items.Add(lvi); } } } ListViewColumnSorter lvs = new ListViewColumnSorter(); listView1.ListViewItemSorter = lvs; listView1.Sort(); }
public FormSettings(Framework.Interfaces.ICore core, Utils.BasePlugin.Plugin ownerPlugin) : this() { this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE); this.tabPageGeneral.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_GENERAL); this.groupBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_GCCOMACCOUNT); this.buttonAuthorize.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_AUTHORIZE); this.groupBox2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_PLUGINS); this.buttonApply.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_APPLY); this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_NAME); this.label2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_API); this.label3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_MENBERSHIP); this.label7.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_INTERNALSTORAGE); this.checkBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_LOADINBACKGROUND); _core = core; _ownerPlugin = ownerPlugin; _pluginList = core.GetPlugins(); List <string> allPlugins = core.GetAllDetectedPlugins(); checkedListBoxPlugins.Items.AddRange(allPlugins.ToArray()); foreach (Framework.Interfaces.IPlugin p in _pluginList) { int index = checkedListBoxPlugins.Items.IndexOf(p.GetType().FullName); if (index >= 0) { checkedListBoxPlugins.SetItemChecked(index, true); } List <UserControl> pnls = p.CreateConfigurationPanels(); if (pnls != null && pnls.Count > 0) { _ucList.AddRange(pnls.ToArray()); //create tab TabPage tp = new TabPage(Utils.LanguageSupport.Instance.GetTranslation(p.FriendlyName)); tp.AutoScroll = true; tabControlSettings.TabPages.Add(tp); //add controls FlowLayoutPanel fp = new FlowLayoutPanel(); tp.Controls.Add(fp); fp.Dock = DockStyle.Fill; fp.Controls.AddRange(pnls.ToArray()); } } comboBoxInternalStorage.Items.AddRange(core.GetAvailableInternalStoragePlugins().ToArray()); comboBoxInternalStorage.SelectedItem = core.ActiveInternalStoragePlugin; textBoxUsername.Text = core.GeocachingComAccount.AccountName; labelApiEnabled.Text = string.IsNullOrEmpty(core.GeocachingComAccount.APIToken) ? Utils.LanguageSupport.Instance.GetTranslation(STR_NO) : Utils.LanguageSupport.Instance.GetTranslation(STR_YES); labelApiMembership.Text = string.IsNullOrEmpty(core.GeocachingComAccount.MemberType) ? "-" : core.GeocachingComAccount.MemberType; checkBox1.Checked = core.LoadLogsInBackground; }
public SelectActionForm(Framework.Interfaces.ICore core) : this() { this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE); this.button1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SELECT); this.listView1.Columns[0].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_PLUGIN); this.listView1.Columns[1].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ACTION); this.listView1.Columns[2].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SUBACTION); char[] sep = new char[] { '|' }; List <SequenceInfo.ActionInfo> allActions = new List <SequenceInfo.ActionInfo>(); List <Framework.Interfaces.IPlugin> plugins = core.GetPlugins(); foreach (var p in plugins) { List <string> actions = p.GetActionSubactionList(sep[0]); foreach (string s in actions) { string[] parts = s.Split(sep, 2); SequenceInfo.ActionInfo ai = new SequenceInfo.ActionInfo(); ai.Plugin = p.GetType().ToString(); ai.Action = parts[0]; if (parts.Length == 2) { ai.SubAction = parts[1]; } else { ai.SubAction = ""; } allActions.Add(ai); } } var allact = (from a in allActions select a).OrderBy(x => x.Plugin).ThenBy(x => x.Action).ThenBy(x => x.SubAction); foreach (var a in allact) { 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); } listView1.ListViewItemSorter = new Utils.ListViewColumnSorter(); (listView1.ListViewItemSorter as Utils.ListViewColumnSorter).SortColumn = 0; (listView1.ListViewItemSorter as Utils.ListViewColumnSorter).Order = SortOrder.Ascending; }
private FormProgressHandler(Framework.Interfaces.ICore core, Form owner) { _owner = owner; _context = SynchronizationContext.Current; if (_context == null) { _context = new SynchronizationContext(); } List <Framework.Interfaces.IPlugin> pl = core.GetPlugins(); foreach (Framework.Interfaces.IPlugin p in pl) { p.EndProgress += new Framework.EventArguments.ProgressEventHandler(p_EndProgress); p.StartProgress += new Framework.EventArguments.ProgressEventHandler(p_StartProgress); p.UpdateProgress += new Framework.EventArguments.ProgressEventHandler(p_UpdateProgress); } core.PluginAdded += new Framework.EventArguments.PluginEventHandler(core_PluginAdded); }
public void Dispose() { if (_uniqueInstance == this) { _uniqueInstance = null; } if (_frmDlg != null) { _frmDlg.Dispose(); _frmDlg = null; } if (_core != null) { List <Framework.Interfaces.IPlugin> pl = _core.GetPlugins(); foreach (Framework.Interfaces.IPlugin p in pl) { p.EndProgress -= new Framework.EventArguments.ProgressEventHandler(p_EndProgress); p.StartProgress -= new Framework.EventArguments.ProgressEventHandler(p_StartProgress); p.UpdateProgress -= new Framework.EventArguments.ProgressEventHandler(p_UpdateProgress); } } }
public FormSettingsTreeView(Framework.Interfaces.ICore core, Utils.BasePlugin.Plugin ownerPlugin) : this() { this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE); this.groupBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_GCCOMACCOUNT); this.buttonAuthorize.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_AUTHORIZE); this.groupBox2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_INTERNALSTORAGE); this.buttonApply.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_APPLY); this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_NAME); this.label2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_API); this.label3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_MENBERSHIP); this.checkBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_LOADINBACKGROUND); this.checkBox2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_AUTOSAVEONCLOSE); this.button1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CLEARAUTHORIZE); this.groupBox3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_OTHERACCOUNTNAMES); this.listView1.Columns[0].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CODEPREFIX); this.listView1.Columns[1].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ACCOUNTNAME); this.label7.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CODEPREFIX); this.label8.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ACCOUNTNAME); this.checkBox3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SHOWOKAPIMENU); TreeNode tn; tn = new TreeNode(Utils.LanguageSupport.Instance.GetTranslation(STR_GENERAL)); tn.Tag = panelGeneral; treeView1.Nodes.Add(tn); foreach (var t in Enum.GetNames(typeof(Framework.PluginType))) { tn = new TreeNode(Utils.LanguageSupport.Instance.GetTranslation(PluginTypeToString(t))); tn.Tag = (Framework.PluginType)Enum.Parse(typeof(Framework.PluginType), t); treeView1.Nodes.Add(tn); } _core = core; _ownerPlugin = ownerPlugin; _pluginList = core.GetPlugins(); List <string> allPlugins = core.GetAllDetectedPlugins(); checkedListBoxPlugins.Items.AddRange(allPlugins.ToArray()); foreach (Framework.Interfaces.IPlugin p in _pluginList) { int index = checkedListBoxPlugins.Items.IndexOf(p.GetType().FullName); if (index >= 0) { checkedListBoxPlugins.SetItemChecked(index, true); } List <UserControl> pnls = p.CreateConfigurationPanels(); if (pnls != null && pnls.Count > 0) { _ucList.AddRange(pnls.ToArray()); int yPos = 0; foreach (UserControl uc in pnls) { uc.Location = new Point(0, yPos); yPos += uc.Height; uc.Visible = false; splitContainer1.Panel2.Controls.Add(uc); } foreach (TreeNode t in treeView1.Nodes) { if (t.Tag != null && t.Tag.GetType() == typeof(Framework.PluginType)) { if ((Framework.PluginType)t.Tag == p.PluginType) { tn = new TreeNode(Utils.LanguageSupport.Instance.GetTranslation(p.FriendlyName)); tn.Tag = pnls; t.Nodes.Add(tn); break; } } } } } //delete the plugin nodes with no childs (settings) int i = 1; while (i < treeView1.Nodes.Count) { TreeNode t = treeView1.Nodes[i]; if (t.Tag != null && t.Tag.GetType() == typeof(Framework.PluginType)) { if (t.Nodes.Count == 0) { treeView1.Nodes.RemoveAt(i); } else { i++; } } } treeView1.ExpandAll(); treeView1.SelectedNode = treeView1.Nodes[0]; comboBoxInternalStorage.Items.AddRange(core.GetAvailableInternalStoragePlugins().ToArray()); comboBoxInternalStorage.SelectedItem = core.ActiveInternalStoragePlugin; textBoxUsername.Text = core.GeocachingComAccount.AccountName; labelApiEnabled.Text = string.IsNullOrEmpty(core.GeocachingComAccount.APIToken) ? Utils.LanguageSupport.Instance.GetTranslation(STR_NO) : Utils.LanguageSupport.Instance.GetTranslation(STR_YES); labelApiMembership.Text = string.IsNullOrEmpty(core.GeocachingComAccount.MemberType) ? "-" : core.GeocachingComAccount.MemberType; checkBox1.Checked = core.LoadLogsInBackground; checkBox2.Checked = core.AutoSaveOnClose; checkBox3.Checked = PluginSettings.Instance.ShowOKAPIMenu;; fillGeocacheAccounts(); }
public static Framework.Interfaces.IPlugin PluginByName(Framework.Interfaces.ICore core, string pluginName) { List <Framework.Interfaces.IPlugin> pins = core.GetPlugins(); return((from a in pins where a.GetType().ToString().ToLower() == pluginName.ToLower() select a).FirstOrDefault()); }