public frmMain() { InitializeComponent(); //DirectoryInfo di = new DirectoryInfo(); outstream = new MyStream(Shell); Shell.CommandEntered += new UILibrary.EventCommandEntered(Shell_CommandEntered); engine = new PythonEngine(); engine.AddToPath(Environment.CurrentDirectory); string exepath = Environment.CurrentDirectory; engine.Import("clr"); engine.SetStandardOutput(outstream); engine.SetStandardError(new MyStream(Shell)); engine.Execute("import clr;clr.AddReferenceToFile(\"Interop.SAPbobsCOM.dll\")"); engine.Execute("import SAPbobsCOM;import System;import System.IO;import System.Text;import System.Collections"); IronPython.Runtime.List objecttypes = engine.EvaluateAs<IronPython.Runtime.List>("dir(SAPbobsCOM.BoObjectTypes)"); foreach (string otype in objecttypes) { if (otype.StartsWith("o")) { string handle; int endcut = 2; if (otype.ToUpper().EndsWith("US")) { endcut = 1; } else if (otype.ToUpper().EndsWith("HES")) { endcut = 3; } else if (otype.ToUpper().EndsWith("S")) { endcut = 2; } else { endcut = 1; } handle = otype.Substring(1, otype.Length - endcut).ToUpper(); if (handle.EndsWith("IE")) { handle = handle.Substring(0, handle.Length - 2) + "Y"; } engine.Globals[handle] = engine.EvaluateAs<BoObjectTypes>("SAPbobsCOM.BoObjectTypes." + otype); B1ObjectList.Add(handle, engine.Globals[handle]); } } System.Collections.Generic.List<string> enums = new System.Collections.Generic.List<string>(); Assembly[] domainAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly ass in domainAssemblies) { if (ass.FullName.Contains("SAPbobsCOM")) { Type[] types = ass.GetTypes(); foreach (Type type in types) { if (type.IsEnum) { string[] enumnames = System.Enum.GetNames(type); Array enumvalues = System.Enum.GetValues(type); for (int enumindex = 0; enumindex < enumnames.Length; enumindex++) { engine.Globals[enumnames[enumindex]] = enumvalues.GetValue(enumindex); if (!enumnames[enumindex].StartsWith("o")) { B1EnumList.Add(enumnames[enumindex], enumvalues.GetValue(enumindex)); B1EnumValues.Add(enumnames[enumindex], enumvalues.GetValue(enumindex).GetType().Name); Type enumclass = enumvalues.GetValue(enumindex).GetType(); if (!B1EnumClassList.Contains(enumclass.Name)) { B1EnumClassList.Add(enumclass.Name); } } engine.Globals[enumnames[enumindex].ToLower()] = enumvalues.GetValue(enumindex); engine.Globals[enumnames[enumindex].ToUpper()] = enumvalues.GetValue(enumindex); enums.Add(type.Name + ":" + enumvalues.GetValue(enumindex)); } } } } } engine.Globals["enumvalues"] = enums; foreach (string key in B1ObjectList.Keys) { this.cmbRefObjects.Items.Add(key); } foreach (string key in B1EnumList.Keys) { this.cmbRefEnum.Items.Add(key); } foreach (string key in B1EnumClassList) { this.cmbEnumInfo.Items.Add(key); } SyntaxDocument doc = new SyntaxDocument(); doc.SyntaxFile = "Python.syn"; this.codeEditor.Document = doc; }
public FormatRangeCollection(SyntaxDocument document) { _Document = document; }
/// <summary> /// Exports the content of a SyntaxDocument to a HTML formatted string /// </summary> /// <param name="doc">SyntaxDocument object to export from</param> /// <param name="ImagePath">File path tho the images to use in the HTML string</param> /// <returns></returns> public string Export(SyntaxDocument doc,string ImagePath) { return this.Export (doc,System.Drawing.Color.Transparent, ImagePath,""); }
/// <summary> /// Exports the content of a SyntaxDocument to a HTML formatted string /// </summary> /// <param name="doc">SyntaxDocument object to export from</param> /// <param name="BGColor">HTML color string to use as background color</param> /// <param name="ImagePath">File path tho the images to use in the HTML string</param> /// <param name="Style">HTML style string that should be applied to the output</param> /// <returns></returns> public string Export(SyntaxDocument doc,System.Drawing.Color BGColor,string ImagePath,string Style) { sb=new System.Text.StringBuilder (); doc.ParseAll (true); int i=0; string guid=DateTime.Now.Ticks.ToString (); //style=\"font-family:courier new;font-size:13px;\" if (BGColor.A ==0) Out("<table ><tr><td nowrap><div style=\""+ Style +"\">"); else Out("<table style=\"background-color:" + GetHTMLColor (BGColor) + ";" + Style + "\"><tr><td nowrap><div>"); foreach (Row r in doc) { i++; if (r.CanFold) { RenderCollapsed(r.VirtualCollapsedRow,r,i,ImagePath,guid); Out("<div style=\"display:block;\" id=\"open" + guid+"_"+i.ToString () + "\">"); string img="minus.gif"; try { if (r.Expansion_StartSegment.Parent.Parent == null) img = "minusNoTopLine.gif"; } catch { } Out ("<img src=\"" + ImagePath + img + "\" align=top onclick=\"open" + guid+"_"+i.ToString () +".style.display='none'; closed" + guid+"_"+i.ToString () +".style.display='block'; \">"); } else { if (r.CanFoldEndPart) { Out ("<img src=\"" + ImagePath + "L.gif\" align=top>"); } else { if (r.HasExpansionLine) { Out ("<img src=\"" + ImagePath + "I.gif\" align=top>"); } else { Out ("<img src=\"" + ImagePath + "clear.gif\" align=top>"); } } } foreach (Word w in r) { write (w.Text,w.Style); } if (r.CanFoldEndPart) Out("</div>\n"); else Out("<br>\n"); } Out("</div></td></tr></table>"); return this.sb.ToString (); }
public static void SetSyntax(SyntaxDocument editor, SyntaxLanguage language) { Stream xml = GetSyntaxStream(GetSyntaxFileName(language)); editor.Parser.Init(Language.FromSyntaxFile(xml)); }
public static void SetSyntax(SyntaxDocument editor, string filename) { editor.Parser.Init(CodeEditorSyntaxLoader.LanguageList.GetLanguageFromFile(filename)); }
public SourceCodePrintDocument(SyntaxDocument document) : base() { this.Document = document; }
public void AttachDocument(SyntaxDocument document) { //_Document=document; if (_Document != null) { _Document.ParsingCompleted -= new EventHandler(this.OnParsingCompleted); _Document.Parsing -= new EventHandler(this.OnParse); _Document.Change -= new EventHandler(this.OnChange); } if (document == null) document = new SyntaxDocument(); _Document = document; if (this._Document != null) { _Document.ParsingCompleted += new EventHandler(this.OnParsingCompleted); _Document.Parsing += new EventHandler(this.OnParse); _Document.Change += new EventHandler(this.OnChange); } this.Redraw(); }
public void AttachDocument(SyntaxDocument document) { //_Document=document; if (_Document != null) { _Document.ParsingCompleted -= this.OnParsingCompleted; _Document.Parsing -= this.OnParse; _Document.Change -= this.OnChange; _Document.SyntaxDataChanged -= this.OnSyntaxDataChanged; } if (document == null) document = new SyntaxDocument(); _Document = document; if (this._Document != null) { _Document.ParsingCompleted += this.OnParsingCompleted; _Document.Parsing += this.OnParse; _Document.Change += this.OnChange; _Document.SyntaxDataChanged += this.OnSyntaxDataChanged; } this.Redraw(); if (this._Document != null && this._Document.SyntaxData != null) { OnSyntaxDataChanged(this, EventArgs.Empty); } }
/// <summary> /// Exports the content of a SyntaxDocument to a HTML formatted string /// </summary> /// <param name="doc">SyntaxDocument object to export from</param> /// <param name="ImagePath">File path tho the images to use in the HTML string</param> /// <returns></returns> public string Export(SyntaxDocument doc,string ImagePath) { return this.Export (doc,Colors.Transparent, ImagePath,""); }
public void InitializeComponent() { components = new Container(); var lineMarginRender1 = new LineMarginRender(); Editor = new CodeEditorControl(); Document = new SyntaxDocument(components); SuspendLayout(); // // editor // Editor.ActiveView = ActiveView.BottomRight; Editor.AllowBreakPoints = false; Editor.AutoListPosition = null; Editor.AutoListSelectedText = "a123"; Editor.AutoListVisible = false; Editor.ChildBorderStyle = ControlBorderStyle.None; Editor.CopyAsRTF = false; Editor.Dock = DockStyle.Fill; Editor.Document = Document; Editor.InfoTipCount = 1; Editor.InfoTipPosition = null; Editor.InfoTipSelectedIndex = 1; Editor.InfoTipVisible = false; lineMarginRender1.Bounds = new Rectangle(19, 0, 19, 16); Editor.LineMarginRender = lineMarginRender1; Editor.Location = new Point(0, 0); Editor.LockCursorUpdate = false; Editor.Name = "editor"; Editor.ParseOnPaste = true; Editor.Saved = false; Editor.ShowScopeIndicator = false; Editor.ShowTabGuides = true; Editor.Size = new Size(680, 383); Editor.SmoothScroll = true; Editor.SplitView = false; Editor.SplitviewH = -4; Editor.SplitviewV = -4; Editor.TabGuideColor = Color.FromArgb(244, 243, 234); Editor.TabIndex = 0; Editor.TextDrawStyle = TextDrawType.SingleBorder; Editor.WhitespaceColor = SystemColors.ControlDark; Editor.Click += editor_Click; Editor.TextChanged += EditorTextChanged; Editor.FontName = "Courier New"; Editor.FontSize = 10; // // document // Document.Lines = new[]{ "" }; Document.MaxUndoBufferSize = 1000; Document.Modified = false; Document.UndoStep = 0; // // CodeTab // ClientSize = new Size(680, 383); Controls.Add(Editor); DockableAreas = DockAreas.Document; DoubleBuffered = true; FormBorderStyle = FormBorderStyle.FixedSingle; Name = "CodeTab"; ShowIcon = false; ShowInTaskbar = false; TabText = "[ Document ]"; Text = "[ Document ]"; Load += CodeTab_Load; ResumeLayout(false); }