Example #1
0
        private void toolStripLabelRemove_Click(object sender, EventArgs e)
        {
            if (tabControlExperts.SelectedIndex > -1)
            {
                ExpertInformation info = ((ExpertEditorControl)tabControlExperts.SelectedTab.Controls[0]).ExpertInformation;
                if (info.IsSavedLocally == false)
                {
                    DialogResult result = MessageBox.Show("Expert [" + info.Name + "] not saved. Save changes now?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {// Yes.
                        info.SaveLocal();
                    }
                    else if (result == DialogResult.No)
                    {// No, just continue.
                    }
                    else
                    {// Cancel operation.
                        return;
                    }
                }

                ExpertEditorControl control = (ExpertEditorControl)tabControlExperts.SelectedTab.Controls[0];
                control.ExpertUpdateEvent -= new ExpertEditorControl.ExpertUpdatedDelegate(editorControl_ExpertUpdateEvent);
                tabControlExperts.TabPages.Remove(tabControlExperts.SelectedTab);
            }
        }
Example #2
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            if (listViewExperts.SelectedItems.Count != 1)
            {
                return;
            }

            ExpertInformation info = (ExpertInformation)listViewExperts.SelectedItems[0].Tag;

            foreach (TabPage page in tabControlExperts.TabPages)
            {
                ExpertEditorControl control = (ExpertEditorControl)page.Controls[0];
                if (control.ExpertInformation == info)
                {// Already editting it.
                    tabControlExperts.SelectedTab = page;
                    return;
                }
            }

            ExpertEditorControl editorControl = new ExpertEditorControl();

            editorControl.ExpertInformation  = info;
            editorControl.ExpertUpdateEvent += new ExpertEditorControl.ExpertUpdatedDelegate(editorControl_ExpertUpdateEvent);
            TabPage newPage = new TabPage(info.Name);

            editorControl.Dock = DockStyle.Fill;
            newPage.Controls.Add(editorControl);
            tabControlExperts.TabPages.Add(newPage);
            tabControlExperts.SelectedTab = newPage;
        }
Example #3
0
        private void toolStripButtonDeleteExpert_Click(object sender, EventArgs e)
        {
            if (listViewExperts.SelectedItems.Count != 1)
            {
                return;
            }

            ExpertInformation expertInfo = (ExpertInformation)listViewExperts.SelectedItems[0].Tag;

            if (MessageBox.Show("Delete expert [" + expertInfo.Name + "]. Are you sure?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            // Remove page if in edit.
            foreach (TabPage page in tabControlExperts.TabPages)
            {
                ExpertEditorControl control = (ExpertEditorControl)page.Controls[0];
                control.ExpertUpdateEvent -= new ExpertEditorControl.ExpertUpdatedDelegate(editorControl_ExpertUpdateEvent);

                if (control.ExpertInformation == expertInfo)
                {// Already editting it.
                    tabControlExperts.TabPages.Remove(page);
                    break;
                }
            }

            if (expertInfo.IsExternal == false)
            {
                if (MessageBox.Show("Delete expert local (" + Path.GetFileName(expertInfo.FilePath) + ") file?", "Delete file?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    expertInfo.DeleteLocal();
                }
            }

            ExpertManager.RemoveExpert(expertInfo);
            UpdateUI(true);
        }
 void editorControl_ExpertUpdateEvent(ExpertEditorControl editorControl)
 {
     this.UpdateUI(true);
 }
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            if (listViewExperts.SelectedItems.Count != 1)
            {
                return;
            }

            ExpertInformation info = (ExpertInformation)listViewExperts.SelectedItems[0].Tag;

            foreach (TabPage page in tabControlExperts.TabPages)
            {
                ExpertEditorControl control = (ExpertEditorControl)page.Controls[0];
                if (control.ExpertInformation == info)
                {// Already editting it.
                    tabControlExperts.SelectedTab = page;
                    return;
                }
            }

            ExpertEditorControl editorControl = new ExpertEditorControl();
            editorControl.ExpertInformation = info;
            editorControl.ExpertUpdateEvent += new ExpertEditorControl.ExpertUpdatedDelegate(editorControl_ExpertUpdateEvent);
            TabPage newPage = new TabPage(info.Name);
            editorControl.Dock = DockStyle.Fill;
            newPage.Controls.Add(editorControl);
            tabControlExperts.TabPages.Add(newPage);
            tabControlExperts.SelectedTab = newPage;
        }
Example #6
0
 void editorControl_ExpertUpdateEvent(ExpertEditorControl editorControl)
 {
     this.UpdateUI(true);
 }