Пример #1
0
        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;
        }
Пример #2
0
        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 = Properties.Settings.Default.ShowOKAPIMenu; ;

            fillGeocacheAccounts();
        }