示例#1
0
        // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

        private async void SavePlugin(object sender, EventArgs e)
        {
            try
            {
                var provider = new PluginsProvider();

                if (plugin.Name != plugin.OriginalName &&
                    !string.IsNullOrWhiteSpace(plugin.OriginalName))
                {
                    await provider.Rename(plugin, plugin.Name);
                }
                else
                {
                    await provider.Save(plugin);
                }


                if (!single)
                {
                    UIHelper.ShowMessage($"{plugin.Name} has been saved");
                }
            }
            catch (Exception exc)
            {
                logger.WriteLine("error saving plugin", exc);
                UIHelper.ShowMessage("Plugin could not be saved; see log for details");                 // translate
            }
        }
示例#2
0
        protected override async void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (single)
            {
                pluginsBox.Enabled = false;
                nameBox.Text       = plugin.Name;
                cmdBox.Text        = plugin.Command;
                argsBox.Text       = plugin.Arguments;

                if (plugin.CreateNewPage)
                {
                    createRadio.Checked = true;
                }
                else
                {
                    updateRadio.Checked = true;
                }

                pageNameBox.Text = plugin.PageName;
                childBox.Checked = plugin.AsChildPage;
                timeoutBox.Value = plugin.Timeout;
                return;
            }

            var provider = new PluginsProvider();
            var names    = provider.GetNames().ToList();

            names.Sort();
            predefinedNames = names.ToArray();

            var binding = new BindingList <Plugin>();

            pluginsBox.DataSource    = binding;
            pluginsBox.DisplayMember = "Name";

            plugin = new Plugin
            {
                Name     = Resx.PluginDialog_newItem,
                PageName = this.PageName
            };

            binding.Add(plugin);

            foreach (var name in names)
            {
                var p = await provider.LoadByName(name);

                if (p != null)
                {
                    binding.Add(p);
                }
            }

            pluginsBox.SelectedIndex = 0;
            nameBox.Text             = plugin.Name;
            nameBox.Focus();
        }