Example #1
0
        private void AddConfigTab(IOverlay overlay)
        {
            var label = overlay.GetType().Name;

            if (overlayNames.ContainsKey(label))
            {
                label = overlayNames[label];
            }

            var tabPage = new ConfigTabPage
            {
                Name      = overlay.Name,
                Text      = label,
                IsOverlay = true,
            };

            var control = overlay.CreateConfigControl();

            if (control != null)
            {
                control.Dock      = DockStyle.Fill;
                control.BackColor = SystemColors.ControlLightLight;
                tabPage.Controls.Add(control);

                this.tabControl.TabPages.Add(tabPage);
                ((GeneralConfigTab)_generalTab.Controls[0]).SetReadmeVisible(false);
            }
        }
Example #2
0
        private void AddConfigTab(IOverlay overlay)
        {
            var tabPage = new TabPage
            {
                Name = overlay.Name,
                Text = overlay.GetType().Name
            };

            var addon = pluginMain.Addons.FirstOrDefault(x => x.OverlayType == overlay.GetType());

            if (addon != null)
            {
                var control = addon.CreateOverlayConfigControlInstance(overlay);
                if (control != null)
                {
                    control.Dock      = DockStyle.Fill;
                    control.BackColor = SystemColors.ControlLightLight;
                    tabPage.Controls.Add(control);

                    this.tabControl.TabPages.Add(tabPage);
                    this.tabControl.SelectTab(tabPage);
                }
            }
        }
Example #3
0
        private void AddConfigTab(IOverlay overlay)
        {
            var tabPage = new TabPage
            {
                Name = overlay.Name,
                Text = overlay.GetType().Name
            };

            var control = overlay.CreateConfigControl();

            if (control != null)
            {
                control.Dock      = DockStyle.Fill;
                control.BackColor = SystemColors.ControlLightLight;
                tabPage.Controls.Add(control);

                this.tabControl.TabPages.Add(tabPage);
            }
        }
Example #4
0
        private void AddConfigTab(IOverlay overlay)
        {
            var tabPage = new TabPage
            {
                Name = overlay.Name,
                Text = overlay.Name
            };

            var addon = pluginMain.Addons.FirstOrDefault(x => x.OverlayType == overlay.GetType());
            if (addon != null)
            {
                var control = addon.CreateOverlayConfigControlInstance(overlay);
                if (control != null)
                {
                    control.Dock = DockStyle.Fill;
                    tabPage.Controls.Add(control);

                    this.tabControl.TabPages.Add(tabPage);
                }
            }
        }
Example #5
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            var preset = (IOverlayPreset)cbPreset.SelectedItem;
            var name   = textBox1.Text;

            if (NameValidator(name))
            {
                if (preset == null)
                {
                    MessageBox.Show(this, Resources.PromptSelectPreset, "OverlayPlugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DialogResult = DialogResult.None;
                    return;
                }

                if (preset.Url == "special:custom")
                {
                    if (cbType.SelectedItem == null)
                    {
                        MessageBox.Show(this, Resources.PromptSelectOverlayType, "OverlayPlugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DialogResult = DialogResult.None;
                        return;
                    }

                    var overlayType = ((KeyValuePair <string, Type>)cbType.SelectedItem).Value;
                    var parameters  = new NamedParameterOverloads();
                    parameters["config"] = null;
                    parameters["name"]   = name;

                    SelectedOverlay = (IOverlay)container.Resolve(overlayType, parameters);
                }
                else
                {
                    // Store the current preview position and size in the config object...
                    preview.SavePositionAndSize();

                    // ... and update the name as well.
                    preview.Config.Name = name;

                    if (preview.GetType() == typeof(Overlays.MiniParseOverlay))
                    {
                        // Reconstruct the overlay config to get rid of any event handlers the previous overlay
                        // registered. I should probably write a proper Dispose() implementation in MiniParseOverlay instead
                        // but this is much shorter and does the job just as well.
                        var config = JsonConvert.DeserializeObject <Overlays.MiniParseOverlayConfig>(JsonConvert.SerializeObject(preview.Config));

                        // Reconstruct the overlay to reset the preview state.
                        SelectedOverlay = new Overlays.MiniParseOverlay(config, name, container);
                        if (config.Url == "")
                        {
                            // If the preview didn't load, we try again here to avoid ending up with an empty overlay.
                            SelectedOverlay.Navigate(preset.Url.Replace("%%", pluginMain.ResourceUri));
                        }
                    }
                    else
                    {
                        SelectedOverlay = preview;
                    }
                }

                DialogResult = DialogResult.OK;
            }
            else
            {
                DialogResult = DialogResult.None;
            }
        }