Exemple #1
0
        private void MainForm_Closing(object sender, FormClosingEventArgs e)
        {
            try
            {
                string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), AppConfigManager.Name);
                if (m_bSaveLayout)
                {
                    AppConfigManager.Setting.App.LastOpenedFiles.Clear();

                    foreach (IDockContent content in dockPanel.Documents)
                    {
                        DocumentForm doc = content as DocumentForm;
                        if (doc != null)
                        {
                            if (!AppConfigManager.Setting.App.LastOpenedFiles.Contains(doc.FilePath))
                            {
                                AppConfigManager.Setting.App.LastOpenedFiles.Add(doc.FilePath);
                            }
                        }
                    }
                    XmlHelper.XmlSerializeToFile(AppConfigManager.Setting, configFile);
                }
                else if (File.Exists(configFile))
                {
                    File.Delete(configFile);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        /// <summary>
        /// 设置文件的格式
        /// </summary>
        /// <param name="form"></param>
        private void SetLanguage(DocumentForm form)
        {
            if (form == null)
            {
                return;
            }
            string language = new FileInfo(form.FilePath).Extension.Replace(".", "");

            if ("ini".Equals(language, StringComparison.OrdinalIgnoreCase))
            {
                // Reset/set all styles and prepare _scintilla for custom lexing
                form.IniLexer = true;
                IniLexer.Init(form.Scintilla);
            }
            else
            {
                // Use a built-in lexer and configuration
                form.IniLexer = false;
                form.Scintilla.ConfigurationManager.Language = language;

                // Smart indenting...
                if ("cs".Equals(language, StringComparison.OrdinalIgnoreCase))
                {
                    form.Scintilla.Indentation.SmartIndentType = SmartIndent.CPP;
                }
                else
                {
                    form.Scintilla.Indentation.SmartIndentType = SmartIndent.None;
                }
            }
        }
Exemple #3
0
        private DocumentForm NewDocument()
        {
            DocumentForm doc = new DocumentForm();

            SetScintillaToCurrentOptions(doc);
            doc.Text = String.Format(CultureInfo.CurrentCulture, "{0}{1}", NEW_DOCUMENT_TEXT, ++_newDocumentCount);
            doc.Show(dockPanel);
            toolIncremental.Searcher.Scintilla = doc.Scintilla;
            return(doc);
        }
Exemple #4
0
        private DocumentForm NewDocument()
        {
            DocumentForm doc = new DocumentForm();

            SetScintillaToCurrentOptions(doc);
            doc.Text = String.Format(CultureInfo.CurrentCulture, "{0}{1}", NEW_DOCUMENT_TEXT, ++_newDocumentCount);
            if (lineNumbersToolStripMenuItem.Checked)
            {
                doc.Scintilla.Margins.Margin0.Width = LINE_NUMBERS_MARGIN_WIDTH;
            }
            doc.Show(dockPanel);
            toolIncremental.Searcher.Scintilla = doc.Scintilla;
            return(doc);
        }
Exemple #5
0
        private DocumentForm OpenFile(string filePath)
        {
            DocumentForm doc = new DocumentForm();

            SetScintillaToCurrentOptions(doc);
            doc.Scintilla.Text = File.ReadAllText(filePath);
            doc.Scintilla.UndoRedo.EmptyUndoBuffer();
            doc.Scintilla.Modified = false;
            doc.Text     = Path.GetFileName(filePath);
            doc.FilePath = filePath;
            doc.Show(dockPanel);
            toolIncremental.Searcher.Scintilla = doc.Scintilla;

            return(doc);
        }
Exemple #6
0
        public DocumentForm OpenFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }

            foreach (DocumentForm documentForm in dockPanel.Documents)
            {
                if (filePath.EqualIgnoreCase(documentForm.FilePath))
                {
                    documentForm.Select();
                    return(documentForm);
                }
            }

            DocumentForm doc      = new DocumentForm();
            Encoding     encoding = Encoding.Default;
            //以下代码执行顺序必须调整,SCide判断编码有点不准
            //doc.Scintilla.Text = FileHelper.Read(filePath, out encoding);
            //doc.Scintilla.Encoding = encoding;

            //调整为:
            string content = FileHelper.Read(filePath, out encoding);

            doc.Scintilla.Encoding = encoding;
            doc.Scintilla.Text     = content;

            doc.Scintilla.UndoRedo.EmptyUndoBuffer();
            doc.Scintilla.Modified = false;
            doc.Text     = Path.GetFileName(filePath);
            doc.FilePath = filePath;
            if (lineNumbersToolStripMenuItem.Checked)
            {
                doc.Scintilla.Margins.Margin0.Width = LINE_NUMBERS_MARGIN_WIDTH;
            }
            doc.Show(dockPanel);
            toolIncremental.Searcher.Scintilla = doc.Scintilla;
            encodingToolStripStatusLabel.Text  = encoding.BodyName;
            SetLanguage(doc);
            return(doc);
        }
Exemple #7
0
        private void SetScintillaToCurrentOptions(DocumentForm doc)
        {
            // Turn on line numbers?
            if (lineNumbersToolStripMenuItem.Checked)
            {
                doc.Scintilla.Margins.Margin0.Width = LINE_NUMBERS_MARGIN_WIDTH;
            }
            else
            {
                doc.Scintilla.Margins.Margin0.Width = 0;
            }

            // Turn on white space?
            if (whitespaceToolStripMenuItem.Checked)
            {
                doc.Scintilla.Whitespace.Mode = WhitespaceMode.VisibleAlways;
            }
            else
            {
                doc.Scintilla.Whitespace.Mode = WhitespaceMode.Invisible;
            }

            // Turn on word wrap?
            if (wordWrapToolStripMenuItem.Checked)
            {
                doc.Scintilla.LineWrapping.Mode = LineWrappingMode.Word;
            }
            else
            {
                doc.Scintilla.LineWrapping.Mode = LineWrappingMode.None;
            }

            // Show EOL?
            doc.Scintilla.EndOfLine.IsVisible = endOfLineToolStripMenuItem.Checked;

            // Set the zoom
            doc.Scintilla.Zoom = _zoomLevel;

            //doc.Scintilla.IsReadOnly = true;
        }
Exemple #8
0
        private void SetScintillaToCurrentOptions(DocumentForm doc)
        {
            // Turn on line numbers?
            if (lineNumbersToolStripMenuItem.Checked)
                doc.Scintilla.Margins.Margin0.Width = LINE_NUMBERS_MARGIN_WIDTH;
            else
                doc.Scintilla.Margins.Margin0.Width = 0;

            // Turn on white space?
            if (whitespaceToolStripMenuItem.Checked)
                doc.Scintilla.Whitespace.Mode = WhitespaceMode.VisibleAlways;
            else
                doc.Scintilla.Whitespace.Mode = WhitespaceMode.Invisible;

            // Turn on word wrap?
            if (wordWrapToolStripMenuItem.Checked)
                doc.Scintilla.LineWrapping.Mode = LineWrappingMode.Word;
            else
                doc.Scintilla.LineWrapping.Mode = LineWrappingMode.None;

            // Show EOL?
            doc.Scintilla.EndOfLine.IsVisible = endOfLineToolStripMenuItem.Checked;

            // Set the zoom
            doc.Scintilla.Zoom = _zoomLevel;

            //doc.Scintilla.IsReadOnly = true;
        }
Exemple #9
0
        private DocumentForm OpenFile(string filePath)
        {
            DocumentForm doc = new DocumentForm();
            SetScintillaToCurrentOptions(doc);
            doc.Scintilla.Text = File.ReadAllText(filePath);
            doc.Scintilla.UndoRedo.EmptyUndoBuffer();
            doc.Scintilla.Modified = false;
            doc.Text = Path.GetFileName(filePath);
            doc.FilePath = filePath;
            doc.Show(dockPanel);
            toolIncremental.Searcher.Scintilla = doc.Scintilla;

            return doc;
        }
Exemple #10
0
 private DocumentForm NewDocument()
 {
     DocumentForm doc = new DocumentForm();
     SetScintillaToCurrentOptions(doc);
     doc.Text = String.Format(CultureInfo.CurrentCulture, "{0}{1}", NEW_DOCUMENT_TEXT, ++_newDocumentCount);
     doc.Show(dockPanel);
     toolIncremental.Searcher.Scintilla = doc.Scintilla;
     return doc;
 }