private void RefreshSecretObject(SecretBundle s) { PropertyObject = new PropertyObjectSecret(s, SecretObject_PropertyChanged); uxPropertyGridSecret.SelectedObject = PropertyObject; uxTextBoxValue.SetHighlighting(PropertyObject.ContentType.ToSyntaxHighlightingMode()); uxTextBoxName.Text = PropertyObject.Name; ToggleCertificateMode(PropertyObject.ContentType.IsCertificate()); uxTextBoxValue.Text = PropertyObject.Value; uxTextBoxValue.Refresh(); }
//------------------------------------------------------------------------ private void SaveAsSymitar() { frmFileOpen saveAs = new frmFileOpen(fileName); DialogResult result = saveAs.ShowDialog(Util.MainForm); if (result == DialogResult.Cancel) { saveAs.Dispose(); return; } if (result == DialogResult.No) { saveAs.Dispose(); SaveAsLocal(); return; } if (saveAs.saveAsIsLocal) //not a Local Filesystem file, but a LOCAL mounted Filesystem file { fileLocal = saveAs.saveAsLocal.Path + '\\' + saveAs.saveAsName; if (SaveLocal()) { fileOrigin = Origin.LOCAL; fileType = FileTypeFromExtension(fileLocal); Icon = IconFromType(fileType); } } else { SymInst inst = saveAs.saveAsInst; fileSym = new SymFile(inst.Parent.IP, inst.SymDir, saveAs.saveAsName, DateTime.Now, icsEditor.Text.Length, saveAs.saveAsType); fileName = saveAs.saveAsName; if (SaveSymitar()) { fileOrigin = Origin.SYM; fileType = FileTypeFromSymFile(fileSym); Icon = IconFromType(fileType); if (fileType == ProjectFile.FileType.REPGEN) { icsEditor.SetHighlighting("RepGen"); completer = new RepGenComplete(); folder = new RepGenFold(); icsEditor.Document.FoldingManager.FoldingStrategy = folder; } else if (fileType == ProjectFile.FileType.LETTER) { icsEditor.SetHighlighting("Default"); icsEditor.Document.FoldingManager.FoldingStrategy = new ICSharpCode.TextEditor.Document.IndentFoldingStrategy(); } SetModified(false, true); } } }
public void loadScriptCommands(TabPage newPage) { textBox.ActiveTextAreaControl.TextArea.KeyPress += new KeyPressEventHandler(this.onKeyPress); textBox.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(this.onKeyUp); textBox.ActiveTextAreaControl.TextArea.KeyDown += new System.Windows.Forms.KeyEventHandler(this.onKeyDown); textBox.ActiveTextAreaControl.TextArea.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.onPreviewKeyDown); textBox.Document.DocumentChanged += new DocumentEventHandler(this.onTextChanged); textBox.Dock = System.Windows.Forms.DockStyle.Fill; textBox.Font = new Font("Courier New", 10); textBox.IsReadOnly = false; newPage.Controls.Add(textBox); textBox.ShowInvalidLines = false; textBox.ShowSpaces = false; textBox.ShowEOLMarkers = false; textBox.ShowTabs = false; textBox.ShowHRuler = false; textBox.ShowMatchingBracket = false; textBox.ShowVRuler = false; textBox.SetHighlighting("AthenaScript"); tabPage = newPage; }
//======================================================================== // Constructors //======================================================================== //Common Constructor Helper private void _initPre(string name, ProjectFile.FileType type) { InitializeComponent(); icsEditor = new TextEditorControl(); icsEditor.Dock = DockStyle.Fill; icsEditor.Document.DocumentChanged += icsEditor_DocumentChanged; icsEditor.ActiveTextAreaControl.TextArea.MouseDown += new MouseEventHandler(icsEditor_MouseDown); icsEditor.VRulerRow = 132; icsEditor.IndentStyle = IndentStyle.Smart; if (type == ProjectFile.FileType.REPGEN) { icsEditor.SetHighlighting("RepGen"); completer = new RepGenComplete(); folder = new RepGenFold(); icsEditor.Document.FoldingManager.FoldingStrategy = folder; } Controls.Add(icsEditor); DockAreas = DockAreas.Document; Text = fileName = name; Icon = IconFromType(type); fileType = type; }
/// <summary> /// Called when new file was created and added to project. /// </summary> /// <param name="file">File descriptor.</param> /// <param name="exists">True if file already exists in file system (just adding, without creating).</param> /// <returns>Form control as IDE document content.</returns> public Control onNewFile(IdeProject.File file, bool exists) { // create text editor control that will be able to edit our scripts. TextEditorControl editor = new TextEditorControl(); editor.Dock = DockStyle.Fill; editor.IsReadOnly = false; // here we can inject syntax highlighting for Tiny BASIC language. try { editor.SetHighlighting("TinyBASIC"); } catch (Exception exc) { while (exc.InnerException != null) { exc = exc.InnerException; } MessageBox.Show(@"Error occurred during Syntax Highlight binding to code editor:" + Environment.NewLine + exc.Message, Constants.NAME + @" Plugin Exception"); } editor.Encoding = Encoding.ASCII; // make sure that we wants to use ASCII encoding. if (!exists) { // setup editor content and save it to file if file does not exists. editor.Text = Constants.FILE_TEMPLATE; editor.SaveFile(mBridge.GetProjectPath() + @"\" + file.relativePath); } else { // or load file to editor otherwise. editor.LoadFile(mBridge.GetProjectPath() + @"\" + file.relativePath); } editor.Encoding = Encoding.ASCII; return(editor); }
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); } }
public TextEditorControl CreateEditor() { var tab = new TabPage(); var editor = new TextEditorControl { Dock = DockStyle.Fill }; editor.Font = new Font("Consolas", 10, FontStyle.Regular); editor.SetHighlighting("SQL"); tab.Controls.Add(editor); tabControl1.TabPages.Add(tab); tab.Text = "new" + tabControl1.TabPages.Count + ".osql"; this.ActiveControl = editor; return(editor); }
public FdoSqlQueryCtl() { InitializeComponent(); _editor = new TextEditorControl(); _editor.Dock = DockStyle.Fill; _editor.SetHighlighting("SQL"); this.Controls.Add(_editor); }
private void initControls() { editor = new TextEditorControl(); editor.SetHighlighting("C#"); editor.ShowLineNumbers = true; //CodeCompletionKeyHandler.Attach(UIManager.Instance.TopView, editor, FileName); //editor.KeyDown += new CodeCompletionKeyHandler(); }
private void TvProject_AfterSelect(object sender, TreeViewEventArgs e) { string tabName = null; if (tvProject.SelectedNode.Tag == null) { return; } if (tvProject.SelectedNode.Parent != null && tvProject.SelectedNode.Parent.Text == "References") { tabName = "Object Browser"; } else { tabName = tvProject.SelectedNode.Text; } foreach (TabPage page in tcCodeFiles.TabPages) { if (page.Text == tabName) { if (tabName == "Object Browser") { ((ucObjectBrowser)page.Controls[0]).loadAssemby(tvProject.SelectedNode.Tag.ToString()); } tcCodeFiles.SelectTab(page); return; } } TabPage newPage = new TabPage(tabName); if (tabName != "Object Browser") { TextEditorControl tec = new TextEditorControl(); ICSharpCode.TextEditor.Document.FileSyntaxModeProvider provider = new ICSharpCode.TextEditor.Document.FileSyntaxModeProvider(Application.StartupPath); ICSharpCode.TextEditor.Document.HighlightingManager manager = new ICSharpCode.TextEditor.Document.HighlightingManager(); manager.AddSyntaxModeFileProvider(provider); tec.SetHighlighting("C#"); tec.Dock = DockStyle.Fill; tec.Text = tvProject.SelectedNode.Tag.ToString(); tec.Tag = tvProject.SelectedNode; tec.TextChanged += (rtbSender, rtbE) => { ((TreeNode)((TextEditorControl)rtbSender).Tag).Tag = ((TextEditorControl)rtbSender).Text; }; newPage.Controls.Add(tec); } else { ucObjectBrowser objectBrowser = new ucObjectBrowser(tvProject.SelectedNode.Tag.ToString()); objectBrowser.Dock = DockStyle.Fill; newPage.Controls.Add(objectBrowser); } tcCodeFiles.TabPages.Add(newPage); tcCodeFiles.SelectTab(newPage); }
void NewEditor() { TextEditorControl txt = new TextEditorControl(); txt.ContextMenuStrip = ctxEditor; txt.Dock = System.Windows.Forms.DockStyle.Fill; txt.IsReadOnly = false; txt.SetHighlighting("SQL"); // Activate the highlighting, use the name from the SyntaxDefinition node. txt.TextChanged += new EventHandler(TextEditor_TextChanged); SourceGrid.Grid grid = new SourceGrid.Grid(); grid.ContextMenuStrip = this.ctxResults; grid.Dock = System.Windows.Forms.DockStyle.Bottom; grid.EnableSort = true; //grid.Location = new System.Drawing.Point(220, 293); //grid.MinimumSize = new System.Drawing.Size(0, 100); grid.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows; grid.SelectionMode = SourceGrid.GridSelectionMode.Cell; //grid.Size = new System.Drawing.Size(774, 200); grid.Height = 200; grid.TabIndex = 10; grid.TabStop = true; grid.ToolTipText = ""; grid.SelectionMode = SourceGrid.GridSelectionMode.Cell; Splitter splitter = new Splitter(); splitter.BackColor = System.Drawing.SystemColors.ActiveBorder; splitter.Dock = System.Windows.Forms.DockStyle.Bottom; splitter.Location = new System.Drawing.Point(220, 288); splitter.Size = new System.Drawing.Size(774, 5); splitter.TabIndex = 11; splitter.TabStop = false; splitter.Tag = grid; splitter.DoubleClick += new EventHandler(GridSplitter_DoubleClick); TabPage page = new TabPage(); page.Text = string.Format("SQLQuery{0}.sql", tabControl1.TabCount + 1); page.Controls.Add(txt); page.Controls.Add(splitter); page.Controls.Add(grid); page.Tag = grid; tabControl1.MouseUp += TabPageOnMouseUp; tabControl1.TabPages.Add(page); tabControl1.SelectTab(page); // Set teh current text control and grid textEditorControl1 = txt; grid1 = grid; }
internal static void SetTextBoxStyle(TextEditorControl editor) { editor.ShowEOLMarkers = false; editor.ShowHRuler = false; editor.ShowInvalidLines = false; editor.ShowSpaces = false; editor.ShowTabs = false; editor.ShowMatchingBracket = true; editor.AllowCaretBeyondEOL = false; editor.ShowVRuler = false; editor.ImeMode = ImeMode.On; editor.SetHighlighting("TSQL"); }
public static TextEditorControl open(this TextEditorControl textEditorControl, string sourceCodeFile) { return((TextEditorControl)textEditorControl.invokeOnThread( () => { if (sourceCodeFile.fileExists()) { textEditorControl.LoadFile(sourceCodeFile); } else { textEditorControl.SetHighlighting("C#"); textEditorControl.Document.TextContent = sourceCodeFile; } return textEditorControl; })); }
void ChangeSyntax(object sender, EventArgs e) { if (control != null) { MenuCheckBox item = (MenuCheckBox)sender; foreach (MenuCheckBox i in menuCommands) { i.Checked = false; } item.Checked = true; try { control.SetHighlighting(item.Text); } catch (HighlightingDefinitionInvalidException ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } control.Refresh(); } }
public PlistEditControl(FATabStrip tabStrip, string title, PlistInfo p = null) { Editor = new TextEditorControl(); Tab = new FATabStripItem(); Tab.Title = title; Tab.Controls.Add(Editor); Editor.Dock = DockStyle.Fill; if (p == null) { p = new PlistInfo(); } Pinfo = p; Editor.Text = p.Content; Editor.SetHighlighting("XML"); Editor.TextChanged += Editor_TextChanged; Editor.IsReadOnly = true; tabStrip.AddTab(Tab); Saved = true; }
public void SetupIntellisense(TextEditorControl control) { _control = control; control.SetHighlighting((SupportedLanguage == SupportedLanguage.CSharp) ? "C#" : "VBNET"); control.ShowEOLMarkers = false; control.ShowInvalidLines = false; HostCallbackImplementation.Register(this); CodeCompletionKeyHandler.Attach(this, control); ToolTipProvider.Attach(this, control); ProjectContentRegistry = new ProjectContentRegistry(); // Default .NET 2.0 registry // Persistence lets SharpDevelop.Dom create a cache file on disk so that // future starts are faster. // It also caches XML documentation files in an on-disk hash table, thus // reducing memory usage. try { if (Settings.Default.CacheFiles) { var persistencePath = Path.Combine(Path.GetTempPath(), ReflexilPersistence); var persistenceCheck = Path.Combine(persistencePath, ReflexilPersistenceCheck); Directory.CreateDirectory(persistencePath); // Check write/access to directory File.WriteAllText(persistenceCheck, @"Using cache!"); // Check write file rights File.ReadAllText(persistenceCheck); // Check read file rights ProjectContentRegistry.ActivatePersistence(persistencePath); } } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { // don't use cache file } ProjectContent = new DefaultProjectContent { Language = LanguageProperties }; ParseInformation = new ParseInformation(new DefaultCompilationUnit(ProjectContent)); }
private TextEditorControl CreateTextBox() { var tb = new TextEditorControl(); tb.IsReadOnly = true; // TODO: set proper highlighting. tb.SetHighlighting("C#"); var high = (ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy)tb.Document.HighlightingStrategy; var def = high.Rules.First(); var delim = " ,().:\t\n\r"; for (int i = 0; i < def.Delimiters.Length; ++i) { def.Delimiters[i] = delim.Contains((char)i); } tb.ShowLineNumbers = false; tb.ShowInvalidLines = false; tb.ShowVRuler = false; tb.ActiveTextAreaControl.TextArea.ToolTipRequest += OnToolTipRequest; tb.ActiveTextAreaControl.TextArea.MouseMove += OnTextAreaMouseMove; string[] tryFonts = new[] { "Consolas", "Lucida Console" }; foreach (var fontName in tryFonts) { tb.Font = new Font(fontName, 9, FontStyle.Regular); if (tb.Font.Name == fontName) { break; } } if (!tryFonts.Contains(tb.Font.Name)) { tb.Font = new Font(FontFamily.GenericMonospace, 9); } return(tb); }
public static void BindBsonData(this TextEditorControl txt, TaskData data) { var index = 0; var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) { var json = new JsonWriter(writer) { Pretty = true, Indent = 2 }; if (data.Result.Count > 0) { foreach (var value in data.Result) { if (data.Result?.Count > 1) { sb.AppendLine($"/* {index++ + 1} */"); } json.Serialize(value); sb.AppendLine(); } if (data.LimitExceeded) { sb.AppendLine(); sb.AppendLine("/* Limit exceeded */"); } } else { sb.AppendLine("no result"); } } txt.SetHighlighting("JSON"); txt.Text = sb.ToString(); }
private void frmEditor_Load(object sender, EventArgs e) { OutputTextEditor = new TextEditorControl(); OutputTextEditor.Font = new Font("Consolas", 10, FontStyle.Regular); OutputTextEditor.Dock = DockStyle.Fill; OutputTextEditor.IsReadOnly = true; OutputTextEditor.ShowLineNumbers = false; OutputTextEditor.ShowHRuler = false; OutputTextEditor.SetHighlighting("SQL"); groupBox1.Controls.Add(OutputTextEditor); var consoleWriter = new ConsoleWriter(); consoleWriter.WriteEvent += ConsoleWriter_WriteEvent; consoleWriter.WriteLineEvent += ConsoleWriter_WriteLineEvent; Console.SetOut(consoleWriter); CreateEditor(); }
public static void BindParameter(this TextEditorControl txt, TaskData data) { txt.SuspendLayout(); txt.Clear(); txt.SetHighlighting("JSON"); var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) { var w = new JsonWriter(writer) { Pretty = true, Indent = 2 }; w.Serialize(data.Parameters ?? BsonValue.Null); } txt.Text = sb.ToString(); txt.ResumeLayout(); }
private void CreateEditorForFile(LuaFile file) { TextEditorControl tec = new TextEditorControl(); file.Editor = tec; tec.Dock = DockStyle.Fill; tec.Text = file.Contents; tec.IsReadOnly = true; tec.SetHighlighting("Lua"); tec.IsIconBarVisible = true; tec.Document.ReadOnly = true; tec.ActiveTextAreaControl.TextArea.IconBarMargin.MouseDown += IconBarMargin_MouseDown; tec.Document.BookmarkManager.Removed += bm_Removed; tec.ActiveTextAreaControl.TextArea.MouseUp += TextArea_MouseUp; tec.ActiveTextAreaControl.TextArea.MouseEnter += TextArea_MouseEnter; ArrowMark am = new ArrowMark(tec.Document, new TextLocation(0, 0)); am.IsEnabled = false; file.Arrow = am; tec.Document.BookmarkManager.AddMark(am); }
/// <summary> /// Called when project file is loaded into IDE as document. /// </summary> /// <param name="file">File descriptor.</param> /// <returns>Form control as IDE document content.</returns> public Control onLoadFile(IdeProject.File file) { TextEditorControl editor = new TextEditorControl(); editor.Dock = DockStyle.Fill; editor.IsReadOnly = false; try { editor.SetHighlighting("TinyBASIC"); } catch (Exception exc) { while (exc.InnerException != null) { exc = exc.InnerException; } MessageBox.Show(@"Error occurred during Syntax Highlight binding to code editor:" + Environment.NewLine + exc.Message, Constants.NAME + @" Plugin Exception"); } editor.Encoding = Encoding.ASCII; editor.LoadFile(mBridge.GetProjectPath() + @"\" + file.relativePath); editor.Encoding = Encoding.ASCII; return(editor); }
private void Form1_Load(object sender, EventArgs e) { string sampleCode = @"using ICSharpCode.TextEditor; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ICSharpCodeTextEditor { public partial class Form1 : Form { private TextEditorControl textEditor = null; public Form1() { InitializeComponent(); textEditor = new TextEditorControl(); textEditor.Dock = DockStyle.Fill; this.pContainer.Controls.Add(textEditor); textEditor.TextChanged += TextEditor_TextChanged; } private void TextEditor_TextChanged(object sender, EventArgs e) { //更新,以便进行代码折叠 textEditor.Document.FoldingManager.UpdateFoldings(null, null); } private void btnFormatCSharp_Click(object sender, EventArgs e) { textEditor.Text = JackWangCUMT.WinForm.CSharpFormatHelper.FormatCSharpCode(textEditor.Text); } private void Form1_Load(object sender, EventArgs e) { if(textEditor!=null) { textEditor.SetHighlighting(""C#""); textEditor.Encoding = System.Text.Encoding.UTF8; textEditor.Document.FoldingManager.FoldingStrategy = new JackWangCUMT.WinForm.MingFolding(); } } } } "; //textEditor.SetHighlighting("C#"); //textEditor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#"); textEditor.Encoding = System.Text.Encoding.UTF8; textEditor.Font = new Font("Hack", 12); textEditor.Document.FoldingManager.FoldingStrategy = new JackWangCUMT.WinForm.MingFolding(); textEditor.Text = sampleCode; //自定义代码高亮 string path = Application.StartupPath + "\\HighLighting"; FileSyntaxModeProvider fsmp; if (Directory.Exists(path)) { fsmp = new FileSyntaxModeProvider(path); HighlightingManager.Manager.AddSyntaxModeFileProvider(fsmp); textEditor.SetHighlighting("JackC#"); } }
public FlowchartTE(Procedure cProc, TabInfo ti, List <string> allNodes = null, bool fromDiagram = false) { InitializeComponent(); this.sourceTab = ti; OpenFromDiagram = fromDiagram; //Create the text editor TextEditorControl te = new TextEditorControl(); //te.TextEditorProperties.NativeDrawText = Settings.winAPITextRender; te.TextEditorProperties.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; Settings.SetTextAreaFont(te); //te.AllowCaretBeyondEOL = true; te.EnableFolding = false; te.BorderStyle = BorderStyle.FixedSingle; te.LineViewerStyle = LineViewerStyle.FullRow; te.ShowVRuler = false; te.TextEditorProperties.IndentStyle = IndentStyle.Smart; te.TextEditorProperties.ConvertTabsToSpaces = Settings.tabsToSpaces; te.TextEditorProperties.TabIndent = Settings.tabSize; te.TextEditorProperties.IndentationSize = Settings.tabSize; // Activate the highlighting, use the name from the SyntaxDefinition node. te.TextEditorProperties.DarkScheme = ColorTheme.IsDarkTheme; te.SetHighlighting(ColorTheme.HighlightingScheme); te.OptionsChanged(); te.Text = GetProcedureCode(ti.textEditor.Document, cProc); textEditor = te; // events te.TextChanged += CodeChangedTimer; te.ActiveTextAreaControl.TextArea.ToolTipRequest += TextArea_ToolTipRequest; te.ActiveTextAreaControl.TextArea.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab) { if (Utilities.AutoCompleteKeyWord(textEditor.ActiveTextAreaControl)) { e.IsInputKey = true; } } }; te.ActiveTextAreaControl.Caret.PositionChanged += delegate(object sender, EventArgs e) { Utilities.SelectedTextColorRegion(new TextLocation(), textEditor.ActiveTextAreaControl); }; //te.ActiveTextAreaControl.TextArea.MouseDown += delegate(object sender, MouseEventArgs e) { // if (e.Button == MouseButtons.Left) // Utilities.SelectedTextColorRegion(textEditor.ActiveTextAreaControl); //}; splitContainer.Panel1.Controls.Add(te); cForm = new Form(); cForm.ClientSize = this.Size; cForm.Controls.Add(this); cForm.FormBorderStyle = FormBorderStyle.Sizable; cForm.StartPosition = FormStartPosition.CenterScreen; cForm.Icon = Properties.Resources.CodeText; NodeName = cProc.name; cForm.FormClosing += cForm_FormClosing; te.Dock = DockStyle.Fill; this.Dock = DockStyle.Fill; timer.Tick += CodeChanged; if (allNodes == null) { allNodes = DialogueParser.GetAllNodesName(PI.procs); } cmbNodesName.Items.AddRange(allNodes.ToArray()); cmbNodesName.SelectedIndex = 0; LoadCustomCode(); ParseCode(); dgvMessages.ClearSelection(); }
public void SetHighlighter(string name) { textEditorControl.SetHighlighting(name); }