当前位置: 首页>>代码示例>>C#>>正文


C# TextEditorControl.LoadFile方法代码示例

本文整理汇总了C#中ICSharpCode.TextEditor.TextEditorControl.LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditorControl.LoadFile方法的具体用法?C# TextEditorControl.LoadFile怎么用?C# TextEditorControl.LoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.TextEditor.TextEditorControl的用法示例。


在下文中一共展示了TextEditorControl.LoadFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DocumentPanel

        public DocumentPanel(string fileName)
        {
            InitializeComponent();
            _fileName = fileName;
            TabText = _fileName;
            if (PlatformSupport.Platform == PlatformType.Windows)
            {
                Icon = Properties.Resources.document_properties;

                // SharpDevelop text editor is Windows only.
                var txtDocument = new TextEditorControl {Dock = DockStyle.Fill, IsReadOnly = true, Name = "txtDocument"};
                Controls.Add(txtDocument);

                txtDocument.SetHighlighting("SMI"); // Activate the highlighting, use the name from the SyntaxDefinition node.
                txtDocument.LoadFile(_fileName);
            }
            else
            {
                var txtDocument = new RichTextBox {Dock = DockStyle.Fill, Name = "txtDocument", ReadOnly = true};
                Controls.Add(txtDocument);

                txtDocument.LoadFile(_fileName, RichTextBoxStreamType.PlainText);
            }
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:24,代码来源:DocumentPanel.cs

示例2: Open

        public TabInfo Open(string file, OpenType type, bool addToMRU = true, bool alwaysNew = false)
        {
            if (type == OpenType.File) {
                if (!Path.IsPathRooted(file)) {
                    file = Path.GetFullPath(file);
                }
                //Add this file to the recent files list
                if (addToMRU) {
                    Settings.AddRecentFile(file);
                }
                UpdateRecentList();
                //If this is an int, decompile
                if (string.Compare(Path.GetExtension(file), ".int", true) == 0) {
                    var compiler = new Compiler();
                    string decomp = compiler.Decompile(file);
                    if (decomp == null) {
                        MessageBox.Show("Decompilation of '" + file + "' was not successful", "Error");
                        return null;
                    } else {
                        file = decomp;
                        type = OpenType.Text;
                    }
                } else {
                    //Check if the file is already open
                    for (int i = 0; i < tabs.Count; i++) {
                        if (string.Compare(tabs[i].filepath, file, true) == 0) {
                            tabControl1.SelectTab(i);
                            return tabs[i];
                        }
                    }
                }
            }
            //Create the text editor and set up the tab
            ICSharpCode.TextEditor.TextEditorControl te = new ICSharpCode.TextEditor.TextEditorControl();
            te.ShowVRuler = false;
            te.Document.FoldingManager.FoldingStrategy = new CodeFolder();
            te.IndentStyle = IndentStyle.Smart;
            te.ConvertTabsToSpaces = Settings.tabsToSpaces;
            te.TabIndent = Settings.tabSize;
            te.Document.TextEditorProperties.IndentationSize = Settings.tabSize;
            if (type == OpenType.File)
                te.LoadFile(file, false, true);
            else if (type == OpenType.Text)
                te.Text = file;
            if (type == OpenType.File && string.Compare(Path.GetExtension(file), ".msg", true) == 0)
                te.SetHighlighting("msg");
            else
                te.SetHighlighting("ssl"); // Activate the highlighting, use the name from the SyntaxDefinition node.
            te.TextChanged += textChanged;
            te.ActiveTextAreaControl.TextArea.MouseDown += delegate(object a1, MouseEventArgs a2) {
                if (a2.Button == MouseButtons.Left)
                    UpdateEditorToolStripMenu();
                lbAutocomplete.Hide();
            };
            te.ActiveTextAreaControl.TextArea.KeyPress += KeyPressed;
            te.HorizontalScroll.Visible = false;

            te.ActiveTextAreaControl.TextArea.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs a2) {
                if (lbAutocomplete.Visible) {
                    if ((a2.KeyCode == Keys.Down || a2.KeyCode == Keys.Up || a2.KeyCode == Keys.Tab)) {
                        lbAutocomplete.Focus();
                        lbAutocomplete.SelectedIndex = 0;
                    } else if (a2.KeyCode == Keys.Escape) {
                        lbAutocomplete.Hide();
                    }
                } else {
                    if (toolTipAC.Active && a2.KeyCode != Keys.Left && a2.KeyCode != Keys.Right)
                        toolTipAC.Hide(panel1);
                }
            };

            TabInfo ti = new TabInfo();
            ti.textEditor = te;
            ti.changed = false;
            if (type == OpenType.File && !alwaysNew) {
                ti.filepath = file;
                ti.filename = Path.GetFileName(file);
            } else {
                ti.filepath = null;
                ti.filename = unsaved;
            }
            ti.index = tabControl1.TabCount;
            te.ActiveTextAreaControl.TextArea.ToolTipRequest += new ToolTipRequestEventHandler(TextArea_ToolTipRequest);
            te.ContextMenuStrip = editorMenuStrip;

            tabs.Add(ti);
            TabPage tp = new TabPage(ti.filename);
            tp.Controls.Add(te);
            te.Dock = DockStyle.Fill;

            tabControl1.TabPages.Add(tp);
            if (type == OpenType.File & !alwaysNew) {
                tp.ToolTipText = ti.filepath;
                System.String ext = Path.GetExtension(file).ToLower();
                if (ext == ".ssl" || ext == ".h") {
                    ti.shouldParse = true;
                    ti.needsParse = true;
                    if (Settings.autoOpenMsgs && ti.filepath != null)
                        AssossciateMsg(ti, false);
                }
//.........这里部分代码省略.........
开发者ID:phobos2077,项目名称:sfall_script_editor,代码行数:101,代码来源:TextEditor.cs

示例3: OpenFiles

        private void OpenFiles(string[] fns, string caption)
        {
            // Open file(s)
            foreach (string fn in fns)
            {
                FrmDocument dummyDoc = new FrmDocument(); ;
                TextEditorControl editor = new TextEditorControl();

                try
                {
                    if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
                    {
                        dummyDoc = CreateNewDocument(Path.GetFileName(fn));
                        dummyDoc.MdiParent = this;
                        dummyDoc.Show();
                    }
                    else
                    {
                        foreach (IDockContent content in dockPanel.Documents)
                        {
                            dummyDoc = content as FrmDocument;
                            if (dummyDoc != null)
                            {
                                editor = dummyDoc.Controls[0] as TextEditorControl;
                                if (editor.FileName == fn)
                                {
                                    content.DockHandler.Show();
                                    return;
                                }
                            }
                        }

                        dummyDoc = CreateNewDocument(Path.GetFileName(fn));
                        editor = dummyDoc.Controls[0] as TextEditorControl;
                        editor.LoadFile(fn);
                        editor.Document.DocumentChanged += new DocumentEventHandler(Document_DocumentChanged);
                        // Modified flag is set during loading because the document 
                        // "changes" (from nothing to something). So, clear it again.
                        SetModifiedFlag(editor, false);
                        if (!String.IsNullOrEmpty(caption))
                            dummyDoc.Text = caption;
                        dummyDoc.LastWriteTime = new FileInfo(fn).LastWriteTime;
                        dummyDoc.Show(dockPanel);
                    }
                    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().Name);
                    dummyDoc.Close();
                    dummyDoc.Dispose();
                    return;
                }

                // ICSharpCode.TextEditor doesn't have any built-in code folding
                // strategies, so I've included a simple one. Apparently, the
                // foldings are not updated automatically, so in this demo the user
                // cannot add or remove folding regions after loading the file.
                editor.Document.FoldingManager.FoldingStrategy = new RegionFoldingStrategy();
                editor.Document.FoldingManager.UpdateFoldings(null, null);
            }
        }
开发者ID:jojozhuang,项目名称:Projects,代码行数:62,代码来源:MainForm.cs

示例4: Init

        private void Init()
        {
            //sourceCodeTextEditorControl = this.FindName("sourceCodeTextEditorControl") as TextEditorControl;
            editor = winFormHost.Child as TextEditorControl;

            if (!Directory.Exists("Teszt"))
                Directory.CreateDirectory("Teszt");
            if (File.Exists("Teszt\\teszt.psi"))
                editor.LoadFile("Teszt\\teszt.psi");

            // DynamicHighLight Settings
            HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(@"References\SyntaxRes\"));

            // HighLightting Strategy Name is Psimulex
            editor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("Psimulex");

            currentCommandToHighLight = 0;
        }
开发者ID:hunpody,项目名称:psimulex,代码行数:18,代码来源:mainWindow.xaml.cs


注:本文中的ICSharpCode.TextEditor.TextEditorControl.LoadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。