예제 #1
0
        private void dgvOutputProviders_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex == 0)
            {
                var obj = dgvOutputProviders.CurrentRow.DataBoundItem;

                if (obj == null)
                {
                    return;
                }

                ActiveProviderInfo api = obj as ActiveProviderInfo;

                Type t = ProviderManager.Instance.HasConfigurationWindow(api.ProviderName);

                //check for null
                if (t != null)
                {
                    IProviderConfigurationEditor cw = ProviderManager.InitializeConfigurationWindow(t);

                    HostConfigurationWindow(cw, api);
                }
                else
                {
                    MessageBox.Show(string.Format("Sorry! No settings available for {0}.", api.ProviderName));
                }
            }
            //fix for the Active checkbox not causing the apply button to activate for options
            else if (e.RowIndex >= 0 && e.ColumnIndex > 0)
            {
                ApplyButton.Enabled = true;
            }
        }
예제 #2
0
        private void ProviderSettings_Click(object sender, EventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count <= 0)
            {
                return;
            }
            ListViewItem lvi = lbActiveInputProviders.SelectedItems[0];

            ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

            if (api == null)
            {
                return;
            }

            //get the usercontrol instance from Provider Manager
            var initSettings = ProviderManager.Instance.InitializeConfigurationWindow(api.ProviderName);

            if (initSettings == null)
            {
                return;
            }

            HostConfigurationWindow(initSettings, api);
        }
예제 #3
0
        private void HandleProviderSettingsEnableAndLoad()
        {
            bool result = false;

            if (lbActiveInputProviders.SelectedItems.Count > 0)
            {
                ListViewItem       lvi = lbActiveInputProviders.SelectedItems[0];
                ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();


                btnPreview.Enabled             = api != null;
                btnRemoveInputProvider.Enabled = api != null;
                ctxProviders.Enabled           = api != null;

                if (api != null)
                {
                    result = ProviderManager.Instance.HasConfigurationWindow(api.ProviderName) != null;
                }
            }
            else
            {
                btnPreview.Enabled             = false;
                btnRemoveInputProvider.Enabled = false;
                ctxProviders.Enabled           = false;
            }

            //enable or disable settings button depending on settings availability
            ProviderSettings.Enabled = result;
        }
예제 #4
0
        private void lbActiveInputProviders_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count > 0)
            {
                ListViewItem       lvi = lbActiveInputProviders.SelectedItems[0];
                ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

                api.ProviderLabel = e.Label;

                this.ApplyButton.Enabled = true;

                BindProviderListView();
            }
        }
예제 #5
0
        private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count > 0)
            {
                ListViewItem       lvi = lbActiveInputProviders.SelectedItems[0];
                ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

                ActiveProviderInfo apiDup = new ActiveProviderInfo(api.ProviderName)
                {
                    Active = true, ProviderConfig = api.ProviderConfig
                };
                InputProviderInfos.Add(apiDup);

                BindProviderListView();
            }
        }
예제 #6
0
        private void btnAddInput_Click(object sender, EventArgs e)
        {
            ApplyButton.Enabled = true;
            string name = cbProviders.SelectedItem.ToString();

            ActiveProviderInfo api = new ActiveProviderInfo(name)
            {
                Active = true
            };

            InputProviderInfos.Add(api);

            BindProviderListView();

            //BindingSource bsInput = new BindingSource();
            //bsInput.DataSource = InputProviderInfos;

            //lbActiveInputProviders.DataSource = bsInput;
            //lbActiveInputProviders.SelectedItem = api;
        }
예제 #7
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count <= 0)
            {
                return;
            }
            ListViewItem lvi = lbActiveInputProviders.SelectedItems[0];

            ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

            if (api == null)
            {
                return;
            }

            InputProviderPreview ipp = new InputProviderPreview();

            ipp.Provider = api;

            ipp.ShowDialog();
        }
예제 #8
0
        private void btnRemoveInputProvider_Click(object sender, EventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count <= 0)
            {
                return;
            }

            ApplyButton.Enabled = true;

            ListViewItem       lvi = lbActiveInputProviders.SelectedItems[0];
            ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

            InputProviderInfos.Remove(api);

            _ProvidersToRemove.Add(api.ProviderInstanceID);

            BindingSource bsInput = new BindingSource();

            bsInput.DataSource = InputProviderInfos;

            BindProviderListView();
        }
예제 #9
0
        private void HostConfigurationWindow(IProviderConfigurationEditor initSettings, ActiveProviderInfo api)
        {
            //dialog window which will house the user control
            ProviderSettingsWindow psw = new ProviderSettingsWindow();

            Bitmap img = (Bitmap)ProviderManager.GetProviderIcon(api.Instance.GetType());

            if (img != null)
            {
                psw.Icon = System.Drawing.Icon.FromHandle(img.GetHicon());
                img.Dispose();
            }

            //load the usercontrol into the window
            psw.LoadSettings(initSettings, api.ProviderName);

            //get current config string

            //load the configuration info into the user control
            initSettings.LoadConfiguration(api.ProviderConfig);

            //show the dialog box
            psw.ShowDialog();

            //if user clicked OK then call save to keep a copy of settings in memory
            if (initSettings.IsOK)
            {
                api.ProviderConfig = initSettings.SaveConfiguration();
                //activate apply option
                ApplyButton.Enabled = true;
            }
        }
예제 #10
0
        private void HostConfigurationWindow(IProviderConfigurationEditor initSettings, ActiveProviderInfo api)
        {
            //dialog window which will house the user control
            ProviderSettingsWindow psw = new ProviderSettingsWindow();

            Bitmap img = (Bitmap)ProviderManager.GetProviderIcon(api.Instance.GetType());
            if (img != null)
            {
                psw.Icon = System.Drawing.Icon.FromHandle(img.GetHicon());
                img.Dispose();
            }

            //load the usercontrol into the window
            psw.LoadSettings(initSettings, api.ProviderName);

            //get current config string

            //load the configuration info into the user control
            initSettings.LoadConfiguration(api.ProviderConfig);

            //show the dialog box
            psw.ShowDialog();

            //if user clicked OK then call save to keep a copy of settings in memory
            if (initSettings.IsOK)
            {
                api.ProviderConfig = initSettings.SaveConfiguration();
                //activate apply option
                ApplyButton.Enabled = true;
            }
        }
예제 #11
0
        private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lbActiveInputProviders.SelectedItems.Count > 0)
            {
                ListViewItem lvi = lbActiveInputProviders.SelectedItems[0];
                ActiveProviderInfo api = InputProviderInfos.Where(x => x.ProviderInstanceID == new Guid(lvi.SubItems[1].Text)).SingleOrDefault();

                ActiveProviderInfo apiDup = new ActiveProviderInfo(api.ProviderName) { Active=true, ProviderConfig=api.ProviderConfig };
                InputProviderInfos.Add(apiDup);

                BindProviderListView();
            }
        }
예제 #12
0
        private void btnAddInput_Click(object sender, EventArgs e)
        {
            ApplyButton.Enabled = true;
            string name = cbProviders.SelectedItem.ToString();

            ActiveProviderInfo api = new ActiveProviderInfo(name) { Active = true };
            InputProviderInfos.Add(api);

            BindProviderListView();

            //BindingSource bsInput = new BindingSource();
            //bsInput.DataSource = InputProviderInfos;

            //lbActiveInputProviders.DataSource = bsInput;
            //lbActiveInputProviders.SelectedItem = api;
        }