private void btnEditSource_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var item = view.GetFocusedRow() as BibliographySource;

            if (item.IsNotNullOrMissing())
            {
                using (var dlg = new SourceForm(item, grid.DataSource as List <BibliographySource>)) {
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        dlg.Save();

                        Microsoft.Office.Interop.Word.Source src = null;
                        foreach (Microsoft.Office.Interop.Word.Source source in Document.Bibliography.Sources)
                        {
                            if (source.Tag == dlg.Source.Tag)
                            {
                                src = source;
                                break;
                            }
                        }
                        if (src != null)
                        {
                            var xml = GetXml(dlg.Source);

                            src.Delete();
                            Document.Bibliography.Sources.Add(xml.Trim());
                            LoadBibliography();
                        }
                    }
                }
            }
        }
        private void btnAddSource_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (var dlg = new SourceForm(grid.DataSource as List <BibliographySource>)) {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (dlg.Source != null)
                    {
                        dlg.Save();
                        var xml = GetXml(dlg.Source);

                        Document.Bibliography.Sources.Add(xml.Trim());
                        LoadBibliography();
                    }
                }
            }
        }
        private void Action(string tag)
        {
            switch (tag)
            {
            case "NEW_PROF":
                //NewProfile();
                break;

            case "SAVE_PROF":
                SaveProfile();
                break;

            case "ADD_FILES":
                AddFiles(AddFile.FILES);
                break;

            case "ADD_FOLDER":
                AddFiles(AddFile.FOLDER);
                break;

            case "REFRESH":
                InitWorkspace();
                InitHistory(_workspaceTable);
                break;

            case "UNBIND":
                Unbind();
                break;

            case "SERVER_CONFIG":
            case "OPTIONS":
                using (ConfigServerForm config = new ConfigServerForm(tag.Equals("SERVER_CONFIG") ? 1 : 0)) {
                    if (config.ShowDialog().Equals(DialogResult.OK))
                    {
                        InitSettings();
                    }
                }
                break;

            case "EXIT":
                Close();
                break;

            case "ABOUT":
                using (AboutForm about = new AboutForm()) {
                    about.ShowDialog();
                }
                break;

            case "HELP":
                using (HelpForm help = new HelpForm()) {
                    help.ShowDialog();
                }
                break;

            case "TOOLBAR":
                RegConfig.Set <bool>("Toolbar", hideToolbarToolStripMenuItem.Checked);
                toolStripUploader.Visible = hideToolbarToolStripMenuItem.Checked;
                break;

            case "STATUSBAR":
                RegConfig.Set <bool>("Statusbar", hideStatusbarToolStripMenuItem.Checked);
                statusStripUploader.Visible = hideStatusbarToolStripMenuItem.Checked;
                break;

            case "PROFILE_DETAILS":
                break;

            case "PROFILE_EXPLORER":
                RegConfig.Set <bool>("ProfileExplorer", profileExplorerToolStripMenuItem.Checked);
                splitContainer1.Panel1Collapsed = !profileExplorerToolStripMenuItem.Checked;
                break;

            case "LOGS":
                RegConfig.Set <bool>("Logs&Details", logsToolStripMenuItem.Checked);
                splitContainer2.Panel2Collapsed = !logsToolStripMenuItem.Checked;
                break;

            case "CLEAR_WORKSPACE":
                if (_workspacse != null)
                {
                    if (MessageBox.Show("Workspace will be deleted permanently!\nAre you sure you want to clear all workspace?", "Clear Workspace", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        List <Workspace> ws = _workspacse.GetProfiles();
                        if (ws.Count > 0)
                        {
                            foreach (Workspace w in ws)
                            {
                                _history.ClearHistory(w.Name.RemoveNonAlphaNumeric().ToLower());
                            }
                        }
                        _workspacse.ClearWorkspaces();
                        InitWorkspace();
                    }
                }
                break;

            case "CLEAR_LOGS":
                if (_logs != null)
                {
                    if (MessageBox.Show("Logs will be deleted permanently!\nAre you sure you want to clear all logs?", "Clear Logs", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        _logs.ClearAllLog();
                        _logs.Initialize(listLogs);
                    }
                }
                break;

            case "CLEAR_HISTORY":
                if (_selectedWorkspace != null)
                {
                    if (MessageBox.Show("History will be deleted permanently!\nAre you sure you want to clear all history?", "Clear History", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        _history.ClearHistory();
                        InitHistory(_selectedWorkspace.Name);
                    }
                }
                break;

            case "SOURCE_EXT":
            case "SOURCE_FOLDER":
                using (SourceForm s = new SourceForm(tag)) {
                    if (s.ShowDialog().Equals(DialogResult.OK))
                    {
                        string    extension = s.SourceName.StartsWith(".") ? s.SourceName : "." + s.SourceName;
                        RidSource rs        = new RidSource()
                        {
                            Name = (tag.Equals("SOURCE_EXT")) ? extension : s.SourceName,
                            Type = (tag.Equals("SOURCE_EXT")) ? "Extension" : "Folder"
                        };
                        _ridSources.Add(rs);
                        _ridSources.Initialize(listViewRids);
                        _listSources = _ridSources.GetSources();
                    }
                }
                break;

            default:
                break;
            }
        }