示例#1
0
        private void OpenFile(string filename)
        {
            // Is the file already open?
            foreach (DocumentView documentView in this.DocumentViews)
            {
                if (string.IsNullOrEmpty(documentView.Filename))
                {
                    continue;
                }

                if (StringComparer.OrdinalIgnoreCase.Equals(
                        Path.GetFullPath(documentView.Filename),
                        Path.GetFullPath(filename)))
                {
                    // Already open
                    this.ctlTabControl.SelectedTab = documentView.TabPage;
                    return;
                }
            }

            DocumentView newDocumentView = new DocumentView();

            newDocumentView.LoadFile(filename);
            this.AddTab(newDocumentView);
        }
示例#2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            MainForm mainForm = this.MainForm;

            if (mainForm == null)
            {
                throw new InvalidOperationException("No main form");
            }

            DocumentView documentView = mainForm.SelectedDocumentView;

            if (documentView == null || documentView.TermStore == null)
            {
                throw new InvalidOperationException("No document is selected");
            }

            LocalTermStore selectedTermStore = this.txtTermStore.SelectedItem as LocalTermStore;

            if (selectedTermStore == null)
            {
                throw new InvalidOperationException("No selection");
            }

            this.connector.Upload(documentView.TermStore, selectedTermStore.Id);
        }
示例#3
0
        private bool CloseTab(DocumentView documentView)
        {
            if (documentView.Modified)
            {
                this.ctlTabControl.SelectedTab = documentView.TabPage;

                string question;
                if (string.IsNullOrEmpty(documentView.Filename))
                {
                    question = "Save this file?";
                }
                else
                {
                    question = "Save changes to this file?\r\n\r\n" + documentView.Filename;
                }

                switch (MessageBox.Show(question, "Save Changes",
                                        MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                {
                case DialogResult.Cancel:
                    return(false);

                case DialogResult.Yes:
                    documentView.SaveFile();
                    break;
                }
            }

            this.ctlTabControl.TabPages.Remove(documentView.TabPage);
            documentView.NotifyRemoved();
            this.UpdateUI();
            return(true);
        }
示例#4
0
        public void AddTab(DocumentView documentView)
        {
            TabPage tabPage = new TabPage();

            documentView.Dock = DockStyle.Fill;
            tabPage.Controls.Add(documentView);
            this.ctlTabControl.TabPages.Insert(0, tabPage);
            this.ctlTabControl.SelectedTab = tabPage;
            documentView.NotifyAdded(tabPage);
            this.UpdateUI();
        }
示例#5
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            LocalTermStore selectedTermStore = this.txtTermStore.SelectedItem as LocalTermStore;

            if (selectedTermStore == null)
            {
                throw new InvalidOperationException("No selection");
            }

            MainForm mainForm = this.MainForm;

            if (mainForm == null)
            {
                throw new InvalidOperationException("No main form");
            }

            DocumentView documentView = null;

            using (DownloadTaxonomyForm downloadForm = new DownloadTaxonomyForm(selectedTermStore))
            {
                downloadForm.ShowDialog(this);

                using (DownloadProgressForm progressForm = new DownloadProgressForm())
                {
                    progressForm.ShowDialog(delegate()
                    {
                        // @@ Improve this
                        progressForm.ProgressBar.Style = ProgressBarStyle.Marquee;

                        ClientConnectorDownloadOptions options = downloadForm.GetTaxonomyReadOptions();

                        LocalTermStore termStoreCopy = new LocalTermStore(selectedTermStore.Id, selectedTermStore.Name);
                        this.connector.Download(termStoreCopy, options);

                        documentView = new DocumentView();
                        documentView.LoadTermStore(termStoreCopy);
                    }
                                            );
                }
            }

            if (documentView != null)
            {
                mainForm.AddTab(documentView);
            }
        }
示例#6
0
        private void mnuFileSaveAs_Click(object sender, EventArgs e)
        {
            DocumentView documentView = this.SelectedDocumentView;

            if (documentView == null)
            {
                return;
            }

            try
            {
                this.ctlSaveFileDialog.FileName         = Path.GetFileName(documentView.Filename);
                this.ctlSaveFileDialog.InitialDirectory = Path.GetDirectoryName(documentView.Filename);
            }
            catch {  }

            if (this.ctlSaveFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            documentView.SaveFile(this.ctlSaveFileDialog.FileName);
        }
示例#7
0
        private void mnuFileNew_Click(object sender, EventArgs e)
        {
            DocumentView documentView = new DocumentView();

            this.AddTab(documentView);
        }