private void CreateTags() { TextTag tag; tag = new TextTag (NORMAL_TAG); tag.Style = Pango.Style.Normal; Buffer.TagTable.Add (tag); normalTag = tag; tag = new TextTag (TALK_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "#560303"; tag.Style = Pango.Style.Normal; Buffer.TagTable.Add (tag); talkTag = tag; tag = new TextTag (COMMAND_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "#030356"; tag.Style = Pango.Style.Normal; Buffer.TagTable.Add (tag); commandTag = tag; tag = new TextTag (GAMEAD_TAG); tag.Weight = Pango.Weight.Normal; tag.Foreground = "#909090"; tag.Style = Pango.Style.Italic; Buffer.TagTable.Add (tag); gameadTag = tag; tag = new TextTag (MESSAGE_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "#309030"; tag.Style = Pango.Style.Normal; Buffer.TagTable.Add (tag); messageTag = tag; tag = new TextTag (USERNAME_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "#801010"; tag.Underline = Pango.Underline.Single; Buffer.TagTable.Add (tag); usernameTag = tag; tag = new TextTag (USERMSG_TAG); tag.Weight = Pango.Weight.Normal; tag.Foreground = "#808020"; tag.Style = Pango.Style.Normal; Buffer.TagTable.Add (tag); usermsgTag = tag; }
public void Init() { GallioBodyTagFactory factory = new GallioBodyTagFactory(); structuredStream = factory.CreateAssertionFailureStructuredStream(); bodyTag = structuredStream.Body; assertionFailureMarkerTag = GetFirstChildMarkerTag(bodyTag); expectedValueToBeTrueSectionTag = GetFirstChildSectionTag(assertionFailureMarkerTag); expectedValueToBeTrueTextTag = GetFirstChildTextTag(expectedValueToBeTrueSectionTag); monoSpaceMarkerTag = GetSecondChildMarkerTag(expectedValueToBeTrueSectionTag); textTagAfterMonoSpaceMarkerTag = GetThirdChildTextTag(expectedValueToBeTrueSectionTag); stackTraceMarkerTag = GetFourthChildMarkerTag(expectedValueToBeTrueSectionTag); stackTraceTextTag = GetFirstChildTextTag(stackTraceMarkerTag); codeLocationMarkerTag = GetSecondChildMarkerTag(stackTraceMarkerTag); codeLocationTextTag = GetFirstChildTextTag(codeLocationMarkerTag); }
public FancyWindow() : base("A Fancy Text Editor (TM)") { DeleteEvent += (o, a) => Application.Quit(); Grid grid = new Grid(); Add(grid); Toolbar toolbar = new Toolbar(); grid.Attach(toolbar, 1, 1, 1, 1); TextView textview = new TextView(); grid.Attach(textview, 1, 2, 1, 1); TextTag boldTag = new TextTag("BoldTag"); boldTag.Weight = Weight.Bold; TextTag italicTag = new TextTag("ItalicTag"); italicTag.Style = Pango.Style.Italic; TextTag underlineTag = new TextTag("UnderlineTag"); underlineTag.Underline = Pango.Underline.Single; TextBuffer buffer = textview.Buffer; buffer.TagTable.Add(boldTag); buffer.TagTable.Add(italicTag); buffer.TagTable.Add(underlineTag); ToolButton toolButtonBold = new ToolButton(Stock.Bold); toolbar.Insert(toolButtonBold, 0); toolButtonBold.Clicked += delegate { TextIter startIter, endIter; buffer.GetSelectionBounds(out startIter, out endIter); byte[] byteTextView = buffer.Serialize(buffer, buffer.RegisterSerializeTagset(null), startIter, endIter); string s = Encoding.UTF8.GetString(byteTextView); Console.WriteLine(s); if (s.Contains("<attr name=\"weight\" type=\"gint\" value=\"700\" />")) { buffer.RemoveTag(boldTag, startIter, endIter); } else { buffer.ApplyTag(boldTag, startIter, endIter); } }; ToolButton toolButtonItalic = new ToolButton(Stock.Italic); toolbar.Insert(toolButtonItalic, 1); toolButtonItalic.Clicked += delegate(object sender, EventArgs e) { TextIter startIter, endIter; buffer.GetSelectionBounds(out startIter, out endIter); byte[] byteTextView = buffer.Serialize(buffer, buffer.RegisterSerializeTagset(null), startIter, endIter); string s = Encoding.UTF8.GetString(byteTextView); Console.WriteLine(s); if (s.Contains("<attr name=\"style\" type=\"PangoStyle\" value=\"PANGO_STYLE_ITALIC\" />")) { buffer.RemoveTag(italicTag, startIter, endIter); } else { buffer.ApplyTag(italicTag, startIter, endIter); } }; ToolButton toolButtonUnderline = new ToolButton(Stock.Underline); toolbar.Insert(toolButtonUnderline, 2); toolButtonUnderline.Clicked += delegate(object sender, EventArgs e) { TextIter startIter, endIter; buffer.GetSelectionBounds(out startIter, out endIter); byte[] byteTextView = buffer.Serialize(buffer, buffer.RegisterSerializeTagset(null), startIter, endIter); string s = Encoding.UTF8.GetString(byteTextView); Console.WriteLine(s); if (s.Contains("<attr name=\"underline\" type=\"PangoUnderline\" value=\"PANGO_UNDERLINE_LOW\" />")) { buffer.RemoveTag(underlineTag, startIter, endIter); } else { buffer.ApplyTag(underlineTag, startIter, endIter); } }; SeparatorToolItem separator = new SeparatorToolItem(); toolbar.Insert(separator, 3); textview.HeightRequest = 400; textview.WidthRequest = 600; /* Setup tag * TextTag tag = new TextTag("helloworld-tag"); * tag.Scale = Pango.Scale.XXLarge; * tag.Style = Pango.Style.Italic; * tag.Underline = Pango.Underline.Double; * tag.Foreground = "blue"; * tag.Background = "pink"; * tag.Justification = Justification.Center; * TextBuffer buffer = textview.Buffer; * buffer.TagTable.Add(tag); * * * // Insert "Hello world!" into textview buffer * TextIter insertIter = buffer.StartIter; * buffer.InsertWithTagsByName(ref insertIter, "Hello World!\n", "helloworld-tag"); * buffer.Insert(ref insertIter, "Simple Hello World!"); * */ ShowAll(); }
public void VisitTextTag(TextTag tag) { WriteHtmlEncodedWithBreaks(writer, tag.Text); }
/// <summary> /// Display a table. /// </summary> /// <param name="insertPos"></param> /// <param name="table"></param> /// <param name="indent"></param> private void DisplayTable(ref TextIter insertPos, Table table, int indent) { int spaceWidth = MeasureText(" "); // Setup tab stops for the table. TabArray tabs = new TabArray(table.ColumnDefinitions.Count(), true); int cumWidth = 0; Dictionary <int, int> columnWidths = new Dictionary <int, int>(); for (int i = 0; i < table.ColumnDefinitions.Count(); i++) { // The i-th tab stop will be set to the cumulative column width // of the first i columns (including padding). columnWidths[i] = GetColumnWidth(table, i); cumWidth += columnWidths[i]; tabs.SetTab(i, TabAlign.Left, cumWidth); } // Create a TextTag containing the custom tab stops. // This TextTag will be applied to all text in the table. TextTag tableTag = new TextTag(Guid.NewGuid().ToString()); tableTag.Tabs = tabs; tableTag.WrapMode = Gtk.WrapMode.None; textView.Buffer.TagTable.Add(tableTag); for (int i = 0; i < table.Count; i++) { TableRow row = (TableRow)table[i]; for (int j = 0; j < Math.Min(table.ColumnDefinitions.Count(), row.Count); j++) { if (row[j] is TableCell cell) { // Figure out which tags to use for this cell. We always // need to use the tableTag (which includes the tab stops) // but if it's the top row, we also include the bold tag. TextTag[] tags; if (row.IsHeader) { tags = new TextTag[2] { tableTag, textView.Buffer.TagTable.Lookup("Bold") } } ; else { tags = new TextTag[1] { tableTag } }; TableColumnAlign?alignment = table.ColumnDefinitions[j].Alignment; // If the column is center- or right-aligned, we will insert // some whitespace characters to pad out the text. if (alignment == TableColumnAlign.Center || alignment == TableColumnAlign.Right) { // Calculate the width of the cell contents. int cellWidth = MeasureText(GetCellRawText(cell)); // Number of whitespace characters we can fit will be the // number of spare pixels in the cell (width of cell - width // of cell text) divided by the width of a single space char. int spareSpace = (columnWidths[j] - cellWidth) / spaceWidth; if (spareSpace >= 2) { // The number of spaces to insert will be either the total // amount we can fit if right-aligning, or half that amount // if center-aligning. int numSpaces = alignment == TableColumnAlign.Center ? spareSpace / 2 : spareSpace; string whitespace = new string(' ', spareSpace / 2); textView.Buffer.Insert(ref insertPos, whitespace); } } // Recursively process all markdown blocks inside this cell. In // theory, this supports both blocks and inline content. In practice // I wouldn't recommend using blocks inside a table cell. ProcessMarkdownBlocks(cell, ref insertPos, textView, indent, false, tags); if (j != row.Count - 1) { textView.Buffer.InsertWithTags(ref insertPos, "\t", tableTag); } } else { // This shouldn't happen. throw new Exception($"Unknown cell type {row[(int)j].GetType()}."); } } // Insert a newline after each row - except the last row. if (i + 1 < table.Count) { textView.Buffer.Insert(ref insertPos, "\n"); } } }
public GtkErrorDialog(Window parent, string title, string message, AlertButton[] buttons) { if (string.IsNullOrEmpty(title)) { throw new ArgumentException(); } if (buttons == null) { throw new ArgumentException(); } Title = BrandingService.ApplicationName; TransientFor = parent; Modal = true; WindowPosition = Gtk.WindowPosition.CenterOnParent; DefaultWidth = 624; DefaultHeight = 142; this.VBox.BorderWidth = 2; var hbox = new HBox() { Spacing = 6, BorderWidth = 12, }; var errorImage = new Image(Gtk.Stock.DialogError, IconSize.Dialog) { Yalign = 0F, }; hbox.PackStart(errorImage, false, false, 0); this.VBox.Add(hbox); var vbox = new VBox() { Spacing = 6, }; hbox.PackEnd(vbox, true, true, 0); var titleLabel = new Label() { Markup = "<b>" + GLib.Markup.EscapeText(title) + "</b>", Xalign = 0F, }; vbox.PackStart(titleLabel, false, false, 0); if (!string.IsNullOrWhiteSpace(message)) { message = message.Trim(); var descriptionLabel = new Label(message) { Xalign = 0F, Selectable = true, }; descriptionLabel.LineWrap = true; descriptionLabel.WidthRequest = 500; descriptionLabel.ModifyBg(StateType.Normal, new Gdk.Color(255, 0, 0)); vbox.PackStart(descriptionLabel, false, false, 0); } expander = new Expander(GettextCatalog.GetString("Details")) { CanFocus = true, Visible = false, }; vbox.PackEnd(expander, true, true, 0); var sw = new ScrolledWindow() { HeightRequest = 180, ShadowType = ShadowType.Out, }; expander.Add(sw); detailsTextView = new TextView() { CanFocus = true, }; detailsTextView.KeyPressEvent += TextViewKeyPressed; sw.Add(detailsTextView); var aa = this.ActionArea; aa.Spacing = 10; aa.LayoutStyle = ButtonBoxStyle.End; aa.BorderWidth = 5; aa.Homogeneous = true; expander.Activated += delegate { this.AllowGrow = expander.Expanded; GLib.Timeout.Add(100, delegate { Resize(DefaultWidth, 1); return(false); }); }; tagNoWrap = new TextTag("nowrap"); tagNoWrap.WrapMode = WrapMode.None; detailsTextView.Buffer.TagTable.Add(tagNoWrap); tagWrap = new TextTag("wrap"); tagWrap.WrapMode = WrapMode.Word; detailsTextView.Buffer.TagTable.Add(tagWrap); this.Buttons = buttons; for (int i = 0; i < Buttons.Length; i++) { Gtk.Button button; button = new Gtk.Button(Buttons[i].Label); button.ShowAll(); AddActionWidget(button, i); } Child.ShowAll(); Hide(); }
public override void VisitTextTag(TextTag tag) { Length += tag.Text.Length; }
private void CreateTags() { TextTag tag; tag = new TextTag (NORMAL_TAG); tag.Style = Pango.Style.Normal; view.Buffer.TagTable.Add (tag); normalTag = tag; tag = new TextTag (MOVENUMBER_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "#404040"; tag.Style = Pango.Style.Normal; view.Buffer.TagTable.Add (tag); movenumberTag = tag; tag = new TextTag (MOVE_TAG); tag.Style = Pango.Style.Normal; tag.FontDesc = Pango.FontDescription. FromString ("monospace"); //tag.Weight = Pango.Weight.Bold; view.Buffer.TagTable.Add (tag); moveTag = tag; tag = new TextTag (HEADING_TAG); tag.Weight = Pango.Weight.Bold; tag.Foreground = "brown"; tag.PixelsBelowLines = 10; tag.Scale = Pango.Scale.XLarge; view.Buffer.TagTable.Add (tag); headingTag = tag; tag = new TextTag (BOLD_TAG); tag.Weight = Pango.Weight.Bold; view.Buffer.TagTable.Add (tag); boldTag = tag; tag = new TextTag (GAMETAGNAME_TAG); tag.Weight = Pango.Weight.Bold; tag.RightMargin = 20; view.Buffer.TagTable.Add (tag); gametagnameTag = tag; tag = new TextTag (HIGHLIGHTED_TAG); tag.Weight = Pango.Weight.Bold; tag.Scale = Pango.Scale.XLarge; //tag.Foreground = "#803030"; view.Buffer.TagTable.Add (tag); highlightedTag = tag; tag = new TextTag (COMMENT_TAG); tag.Style = Pango.Style.Italic; tag.PixelsBelowLines = 5; tag.PixelsAboveLines = 5; tag.Foreground = "#303060"; commentTag = tag; view.Buffer.TagTable.Add (tag); }
private byte[] m_byBuff = new byte[4096]; // Recieved data buffer public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); // Connection m_server_ip = "127.0.0.1"; m_server_port = 10001; // Create tags for color-formatted text tagInfo = new Gtk.TextTag("info"); tagInfo.BackgroundGdk = new Gdk.Color(255, 255, 255); tagWarning = new Gtk.TextTag("warning"); tagWarning.BackgroundGdk = new Gdk.Color(255, 255, 153); tagError = new Gtk.TextTag("error"); tagError.BackgroundGdk = new Gdk.Color(255, 153, 153); tagDebug = new Gtk.TextTag("debug"); tagDebug.BackgroundGdk = new Gdk.Color(224, 224, 224); TextBuffer textbuffer1 = textview1.Buffer; textbuffer1.TagTable.Add(tagInfo); textbuffer1.TagTable.Add(tagWarning); textbuffer1.TagTable.Add(tagError); textbuffer1.TagTable.Add(tagDebug); // Create completion dictionary ListStore lua_api = new ListStore(typeof(string)); lua_api.AppendValues("Device.frame_count"); lua_api.AppendValues("Device.last_delta_time"); lua_api.AppendValues("Device.start"); lua_api.AppendValues("Device.stop"); lua_api.AppendValues("Device.create_resource_package"); lua_api.AppendValues("Device.destroy_resource_package"); lua_api.AppendValues("Window.show"); lua_api.AppendValues("Window.hide"); lua_api.AppendValues("Window.get_size"); lua_api.AppendValues("Window.get_position"); lua_api.AppendValues("Window.resize"); lua_api.AppendValues("Window.move"); lua_api.AppendValues("Window.minimize"); lua_api.AppendValues("Window.restore"); lua_api.AppendValues("Window.is_resizable"); lua_api.AppendValues("Window.set_resizable"); lua_api.AppendValues("Window.show_cursor"); lua_api.AppendValues("Window.get_cursor_xy"); lua_api.AppendValues("Window.set_cursor_xy"); lua_api.AppendValues("Window.title"); lua_api.AppendValues("Window.set_title"); lua_api.AppendValues("Math.deg_to_rad"); lua_api.AppendValues("Math.rad_to_deg"); lua_api.AppendValues("Math.next_pow_2"); lua_api.AppendValues("Math.is_pow_2"); lua_api.AppendValues("Math.ceil"); lua_api.AppendValues("Math.floor"); lua_api.AppendValues("Math.sqrt"); lua_api.AppendValues("Math.inv_sqrt"); lua_api.AppendValues("Math.sin"); lua_api.AppendValues("Math.cos"); lua_api.AppendValues("Math.asin"); lua_api.AppendValues("Math.acos"); lua_api.AppendValues("Math.tan"); lua_api.AppendValues("Math.atan2"); lua_api.AppendValues("Math.abs"); lua_api.AppendValues("Math.fmod"); lua_api.AppendValues("Vector2.new"); lua_api.AppendValues("Vector2.val"); lua_api.AppendValues("Vector2.add"); lua_api.AppendValues("Vector2.sub"); lua_api.AppendValues("Vector2.mul"); lua_api.AppendValues("Vector2.div"); lua_api.AppendValues("Vector2.dot"); lua_api.AppendValues("Vector2.equals"); lua_api.AppendValues("Vector2.lower"); lua_api.AppendValues("Vector2.greater"); lua_api.AppendValues("Vector2.length"); lua_api.AppendValues("Vector2.squared_length"); lua_api.AppendValues("Vector2.set_length"); lua_api.AppendValues("Vector2.normalize"); lua_api.AppendValues("Vector2.negate"); lua_api.AppendValues("Vector2.get_distance_to"); lua_api.AppendValues("Vector2.get_angle_between"); lua_api.AppendValues("Vector2.zero"); lua_api.AppendValues("Vector3.new"); lua_api.AppendValues("Vector3.val"); lua_api.AppendValues("Vector3.add"); lua_api.AppendValues("Vector3.sub"); lua_api.AppendValues("Vector3.mul"); lua_api.AppendValues("Vector3.div"); lua_api.AppendValues("Vector3.dot"); lua_api.AppendValues("Vector3.cross"); lua_api.AppendValues("Vector3.equals"); lua_api.AppendValues("Vector3.lower"); lua_api.AppendValues("Vector3.greater"); lua_api.AppendValues("Vector3.length"); lua_api.AppendValues("Vector3.squared_length"); lua_api.AppendValues("Vector3.set_length"); lua_api.AppendValues("Vector3.normalize"); lua_api.AppendValues("Vector3.negate"); lua_api.AppendValues("Vector3.get_distance_to"); lua_api.AppendValues("Vector3.get_angle_between"); lua_api.AppendValues("Vector3.zero"); lua_api.AppendValues("Quaternion.new"); lua_api.AppendValues("Quaternion.negate"); lua_api.AppendValues("Quaternion.load_identity"); lua_api.AppendValues("Quaternion.length"); lua_api.AppendValues("Quaternion.conjugate"); lua_api.AppendValues("Quaternion.inverse"); lua_api.AppendValues("Quaternion.cross"); lua_api.AppendValues("Quaternion.mul"); lua_api.AppendValues("Quaternion.pow"); lua_api.AppendValues("StringSetting.value"); lua_api.AppendValues("StringSetting.synopsis"); lua_api.AppendValues("StringSetting.update"); lua_api.AppendValues("IntSetting.value"); lua_api.AppendValues("IntSetting.synopsis"); lua_api.AppendValues("IntSetting.min"); lua_api.AppendValues("IntSetting.max"); lua_api.AppendValues("IntSetting.update"); lua_api.AppendValues("FloatSetting.value"); lua_api.AppendValues("FloatSetting.synopsis"); lua_api.AppendValues("FloatSetting.min"); lua_api.AppendValues("FloatSetting.max"); lua_api.AppendValues("FloatSetting.update"); lua_api.AppendValues("Mouse.button_pressed"); lua_api.AppendValues("Mouse.button_released"); lua_api.AppendValues("Mouse.any_pressed"); lua_api.AppendValues("Mouse.any_released"); lua_api.AppendValues("Mouse.cursor_xy"); lua_api.AppendValues("Mouse.set_cursor_xy"); lua_api.AppendValues("Mouse.cursor_relative_xy"); lua_api.AppendValues("Mouse.set_cursor_relative_xy"); lua_api.AppendValues("Mouse.MB_LEFT"); lua_api.AppendValues("Mouse.KB_MIDDLE"); lua_api.AppendValues("Mouse.MB_RIGHT"); lua_api.AppendValues("Keyboard.modifier_pressed"); lua_api.AppendValues("Keyboard.button_pressed"); lua_api.AppendValues("Keyboard.button_released"); lua_api.AppendValues("Keyboard.any_pressed"); lua_api.AppendValues("Keyboard.any_released"); lua_api.AppendValues("Keyboard.TAB"); lua_api.AppendValues("Keyboard.ENTER"); lua_api.AppendValues("Keyboard.ESCAPE"); lua_api.AppendValues("Keyboard.SPACE"); lua_api.AppendValues("Keyboard.BACKSPACE"); lua_api.AppendValues("Keyboard.KP_0"); lua_api.AppendValues("Keyboard.KP_1"); lua_api.AppendValues("Keyboard.KP_2"); lua_api.AppendValues("Keyboard.KP_3"); lua_api.AppendValues("Keyboard.KP_4"); lua_api.AppendValues("Keyboard.KP_5"); lua_api.AppendValues("Keyboard.KP_6"); lua_api.AppendValues("Keyboard.KP_7"); lua_api.AppendValues("Keyboard.KP_8"); lua_api.AppendValues("Keyboard.KP_9"); lua_api.AppendValues("Keyboard.F1"); lua_api.AppendValues("Keyboard.F2"); lua_api.AppendValues("Keyboard.F3"); lua_api.AppendValues("Keyboard.F4"); lua_api.AppendValues("Keyboard.F5"); lua_api.AppendValues("Keyboard.F6"); lua_api.AppendValues("Keyboard.F7"); lua_api.AppendValues("Keyboard.F8"); lua_api.AppendValues("Keyboard.F9"); lua_api.AppendValues("Keyboard.F10"); lua_api.AppendValues("Keyboard.F11"); lua_api.AppendValues("Keyboard.F12"); lua_api.AppendValues("Keyboard.HOME"); lua_api.AppendValues("Keyboard.LEFT"); lua_api.AppendValues("Keyboard.UP"); lua_api.AppendValues("Keyboard.RIGHT"); lua_api.AppendValues("Keyboard.DOWN"); lua_api.AppendValues("Keyboard.PAGE_UP"); lua_api.AppendValues("Keyboard.PAGE_DOWN"); lua_api.AppendValues("Keyboard.LCONTROL"); lua_api.AppendValues("Keyboard.RCONTROL"); lua_api.AppendValues("Keyboard.LSHIFT"); lua_api.AppendValues("Keyboard.RSHIFT"); lua_api.AppendValues("Keyboard.CAPS_LOCK"); lua_api.AppendValues("Keyboard.LALT"); lua_api.AppendValues("Keyboard.RALT"); lua_api.AppendValues("Keyboard.LSUPER"); lua_api.AppendValues("Keyboard.RSUPER"); lua_api.AppendValues("Keyboard.NUM_0"); lua_api.AppendValues("Keyboard.NUM_1"); lua_api.AppendValues("Keyboard.NUM_2"); lua_api.AppendValues("Keyboard.NUM_3"); lua_api.AppendValues("Keyboard.NUM_4"); lua_api.AppendValues("Keyboard.NUM_5"); lua_api.AppendValues("Keyboard.NUM_6"); lua_api.AppendValues("Keyboard.NUM_7"); lua_api.AppendValues("Keyboard.NUM_8"); lua_api.AppendValues("Keyboard.NUM_9"); lua_api.AppendValues("Keyboard.A"); lua_api.AppendValues("Keyboard.B"); lua_api.AppendValues("Keyboard.C"); lua_api.AppendValues("Keyboard.D"); lua_api.AppendValues("Keyboard.E"); lua_api.AppendValues("Keyboard.F"); lua_api.AppendValues("Keyboard.G"); lua_api.AppendValues("Keyboard.H"); lua_api.AppendValues("Keyboard.I"); lua_api.AppendValues("Keyboard.J"); lua_api.AppendValues("Keyboard.K"); lua_api.AppendValues("Keyboard.L"); lua_api.AppendValues("Keyboard.M"); lua_api.AppendValues("Keyboard.N"); lua_api.AppendValues("Keyboard.O"); lua_api.AppendValues("Keyboard.P"); lua_api.AppendValues("Keyboard.Q"); lua_api.AppendValues("Keyboard.R"); lua_api.AppendValues("Keyboard.S"); lua_api.AppendValues("Keyboard.T"); lua_api.AppendValues("Keyboard.U"); lua_api.AppendValues("Keyboard.V"); lua_api.AppendValues("Keyboard.W"); lua_api.AppendValues("Keyboard.X"); lua_api.AppendValues("Keyboard.Y"); lua_api.AppendValues("Keyboard.Z"); lua_api.AppendValues("Keyboard.a"); lua_api.AppendValues("Keyboard.b"); lua_api.AppendValues("Keyboard.c"); lua_api.AppendValues("Keyboard.d"); lua_api.AppendValues("Keyboard.e"); lua_api.AppendValues("Keyboard.f"); lua_api.AppendValues("Keyboard.g"); lua_api.AppendValues("Keyboard.h"); lua_api.AppendValues("Keyboard.i"); lua_api.AppendValues("Keyboard.j"); lua_api.AppendValues("Keyboard.k"); lua_api.AppendValues("Keyboard.l"); lua_api.AppendValues("Keyboard.m"); lua_api.AppendValues("Keyboard.n"); lua_api.AppendValues("Keyboard.o"); lua_api.AppendValues("Keyboard.p"); lua_api.AppendValues("Keyboard.q"); lua_api.AppendValues("Keyboard.r"); lua_api.AppendValues("Keyboard.s"); lua_api.AppendValues("Keyboard.t"); lua_api.AppendValues("Keyboard.u"); lua_api.AppendValues("Keyboard.v"); lua_api.AppendValues("Keyboard.w"); lua_api.AppendValues("Keyboard.x"); lua_api.AppendValues("Keyboard.y"); lua_api.AppendValues("Keyboard.z"); lua_api.AppendValues("ResourcePackage.load"); lua_api.AppendValues("ResourcePackage.unload"); lua_api.AppendValues("ResourcePackage.flush"); lua_api.AppendValues("ResourcePackage.has_loaded"); lua_api.AppendValues("Camera.local_position"); lua_api.AppendValues("Camera.local_rotation"); lua_api.AppendValues("Camera.local_pose"); lua_api.AppendValues("Camera.world_position"); lua_api.AppendValues("Camera.world_rotation"); lua_api.AppendValues("Camera.world_pose"); lua_api.AppendValues("Camera.set_local_position"); lua_api.AppendValues("Camera.set_local_rotation"); lua_api.AppendValues("Camera.set_local_pose"); lua_api.AppendValues("Camera.set_projection_type"); lua_api.AppendValues("Camera.projection_type"); lua_api.AppendValues("Camera.fov"); lua_api.AppendValues("Camera.set_fov"); lua_api.AppendValues("Camera.aspect"); lua_api.AppendValues("Camera.set_aspect"); lua_api.AppendValues("Camera.near_clip_distance"); lua_api.AppendValues("Camera.set_near_clip_distance"); lua_api.AppendValues("Camera.far_clip_distance"); lua_api.AppendValues("Camera.set_far_clip_distance"); lua_api.AppendValues("Mesh.local_position"); lua_api.AppendValues("Mesh.local_rotation"); lua_api.AppendValues("Mesh.local_pose"); lua_api.AppendValues("Mesh.world_position"); lua_api.AppendValues("Mesh.world_rotation"); lua_api.AppendValues("Mesh.world_pose"); lua_api.AppendValues("Mesh.set_local_position"); lua_api.AppendValues("Mesh.set_local_rotation"); lua_api.AppendValues("Mesh.set_local_pose"); lua_api.AppendValues("Unit.local_position"); lua_api.AppendValues("Unit.local_rotation"); lua_api.AppendValues("Unit.local_pose"); lua_api.AppendValues("Unit.world_position"); lua_api.AppendValues("Unit.world_rotation"); lua_api.AppendValues("Unit.world_pose"); lua_api.AppendValues("Unit.set_local_position"); lua_api.AppendValues("Unit.set_local_rotation"); lua_api.AppendValues("Unit.set_local_pose"); lua_api.AppendValues("World.spawn_unit"); lua_api.AppendValues("World.play_sound"); lua_api.AppendValues("World.pause_sound"); lua_api.AppendValues("World.link_sound"); lua_api.AppendValues("World.set_listener"); lua_api.AppendValues("World.set_sound_position"); lua_api.AppendValues("World.set_sound_range"); lua_api.AppendValues("World.set_sound_volume"); entry1.Completion = new EntryCompletion(); entry1.Completion.Model = lua_api; entry1.Completion.TextColumn = 0; }
public OutputConsole() { buffer = new Gtk.TextBuffer(new Gtk.TextTagTable()); textEditorControl = new Gtk.TextView(buffer); textEditorControl.Editable = true; sw = new ScrolledWindow(); sw.ShadowType = ShadowType.Out; sw.Add(textEditorControl); this.PackStart(sw, true, true, 0); vbt = new VBox(); Gdk.Pixbuf clear_pixbuf = MainClass.Tools.GetIconFromStock("file-new.png", IconSize.SmallToolbar); Button btnClear = new Button(new Gtk.Image(clear_pixbuf)); btnClear.TooltipText = MainClass.Languages.Translate("clear"); btnClear.Relief = ReliefStyle.None; btnClear.CanFocus = false; btnClear.WidthRequest = btnClear.HeightRequest = 24; btnClear.Clicked += delegate(object sender, EventArgs e) { Clear(); }; Gdk.Pixbuf save_pixbuf = MainClass.Tools.GetIconFromStock("save.png", IconSize.SmallToolbar); Button btnSave = new Button(new Gtk.Image(save_pixbuf)); btnSave.TooltipText = MainClass.Languages.Translate("save"); btnSave.Relief = ReliefStyle.None; btnSave.CanFocus = false; btnSave.WidthRequest = btnSave.HeightRequest = 24; btnSave.Clicked += delegate(object sender, EventArgs e) { Save(); }; vbt.WidthRequest = 24; vbt.PackStart(btnClear, false, false, 0); vbt.PackStart(btnSave, false, false, 0); this.PackEnd(vbt, false, false, 0); bold = new TextTag("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add(bold); errorTag = new TextTag("error"); errorTag.Foreground = "red"; buffer.TagTable.Add(errorTag); consoleLogTag = new TextTag("consoleLog"); consoleLogTag.Foreground = "darkgrey"; buffer.TagTable.Add(consoleLogTag); tag = new TextTag("0"); tag.LeftMargin = 10; buffer.TagTable.Add(tag); tags.Add(tag); endMark = buffer.CreateMark("end-mark", buffer.EndIter, false); outputDispatcher = new GLib.TimeoutHandler(OutputDispatchHandler); customFont = Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont); textEditorControl.ModifyFont(customFont); textEditorControl.KeyPressEvent += HandleTextEditorControlKeyPressEvent; this.ShowAll(); }
//TextIter iter; protected void AddEntry(string entry, TextTag tag, bool newline = true) => infoView.AddEntry(entry, tag, newline);
private void ConfigureDlg() { ybuttonExport.Clicked += (sender, e) => { var parentWindow = GetParentWindow(this); var folderChooser = new FileChooserDialog("Выберите папку выгрузки", parentWindow, FileChooserAction.SelectFolder, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Accept); folderChooser.ShowAll(); if ((ResponseType)folderChooser.Run() == ResponseType.Accept) { if (folderChooser.CurrentFolder == null) { folderChooser.Destroy(); return; } ViewModel.FolderPath = folderChooser.CurrentFolder; var shortpath = folderChooser.CurrentFolder; if (folderChooser.CurrentFolder.Length > 25) { shortpath = "..." + shortpath.Substring(shortpath.Length - 25); } ybuttonExport.Label = shortpath; folderChooser.Destroy(); } else { folderChooser.Destroy(); } }; enummenubuttonExport.ItemsEnum = typeof(ExportType); enummenubuttonExport.EnumItemClicked += (sender, e) => { ViewModel.ExportCommand.Execute(e.ItemEnum); }; enummenubuttonLoadActions.ItemsEnum = typeof(LoadAction); enummenubuttonLoadActions.EnumItemClicked += (sender, e) => { ViewModel.LoadActionCommand.Execute(e.ItemEnum); }; enummenubuttonConfirmUpdate.ItemsEnum = typeof(ConfirmUpdateAction); enummenubuttonConfirmUpdate.EnumItemClicked += (sender, e) => { ViewModel.ConfirmUpdateDataCommand.Execute(e.ItemEnum); }; ycheckDontChangeSellPrice.Binding.AddBinding(ViewModel, vm => vm.DontChangeSellPrice, w => w.Active); ycheckDontChangeSellPrice.Active = true; ycheckDontChangeSellPrice.TooltipText = "При включении у всех заменяемых номенклатур будут удалены все старые цены и будет создана одна новая цена, указанная в файле"; ybuttonConfirmLoadNew.Clicked += (sender, e) => { ViewModel.ConfirmLoadNewCommand.Execute(); }; yfilechooserbuttonImport.Binding.AddBinding(ViewModel, vm => vm.FilePath, w => w.Filename); var fileFilter = new FileFilter(); fileFilter.AddPattern("*.csv"); yfilechooserbuttonImport.Filter = fileFilter; yfilechooserbuttonImport.Title = "Выберите csv файл"; ytreeviewNomenclatures.ColumnsConfig = FluentColumnsConfig <NomenclatureCatalogNode> .Create() .AddColumn("Действие") .MinWidth(120) .AddComboRenderer(x => x.ConflictSolveAction) .SetDisplayFunc(x => x.GetEnumTitle()) .FillItems(((ConflictSolveAction[])Enum.GetValues(typeof(ConflictSolveAction))).ToList()) .AddSetter((c, n) => { c.Editable = n.Source == Source.File && n.Status == NodeStatus.Conflict && n.DuplicateOf != null && ViewModel.CurrentState == LoadAction.LoadNew; switch (ViewModel.CurrentState) { case LoadAction.LoadNew: if (n.DuplicateOf == null || n.Source == Source.Base || !c.Editable) { c.Text = ""; } break; case LoadAction.UpdateData: if (n.ConflictSolveAction != ConflictSolveAction.Ignore) { c.Text = ""; } break; } }) .AddColumn("Источник") .AddEnumRenderer((x) => x.Source) .XAlign(0.5f) .AddColumn("Статус") .AddTextRenderer((x) => x.Status.GetEnumTitle()) .XAlign(0.5f) .AddColumn("ID номенклатуры") .AddTextRenderer(x => x.Id.ToString()) .AddSetter((c, n) => { if (n.Id == null) { c.Text = "Новый"; } }) .XAlign(0.5f) .AddColumn("Наименование") .AddTextRenderer(x => x.Name) .WrapMode(Pango.WrapMode.WordChar) .WrapWidth(400) .AddColumn("ID группы товаров") .AddNumericRenderer(x => x.GroupId) .XAlign(0.5f) .AddColumn("ID поставщика") .AddNumericRenderer(x => x.ShipperCounterpartyId) .XAlign(0.5f) .AddColumn("Цена продажи") .AddNumericRenderer(x => x.SellPrice).Digits(2).WidthChars(10) .XAlign(1) .AddColumn("Единицы измерения") .AddNumericRenderer(x => x.MeasurementUnit) .XAlign(0.5f) .AddColumn("Папка 1С") .HeaderAlignment(0.5f) .AddNumericRenderer(x => x.Folder1cName) .XAlign(0.5f) .AddColumn("Категория") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.NomenclatureCategory) .XAlign(0.5f) .AddColumn("Объем тары") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.TareVolume) .XAlign(0.5f) .AddColumn("Вид оборудования") .AddTextRenderer(x => x.EquipmentKindName) .XAlign(0.5f) .AddColumn("Доступность для продажи") .AddTextRenderer(x => x.SaleCategory) .XAlign(0.5f) .AddColumn("Тип залога") .AddTextRenderer(x => x.TypeOfDepositCategory) .XAlign(0.5f) .AddColumn("Тип топлива") .AddTextRenderer(x => x.FuelTypeName) .XAlign(0.5f) .RowCells() .AddSetter((CellRendererText c, NomenclatureCatalogNode n) => { c.CellBackgroundGdk = GetGdkColor(n.BackgroundColor); c.ForegroundGdk = GetGdkColor(n.ForegroundColor); }) .Finish(); ViewModel.PropertyChanged += (sender, e) => { Application.Invoke((s, args) => { if (e.PropertyName == nameof(ViewModel.ProgressBarValue)) { progressbar.Adjustment.Value = ViewModel.ProgressBarValue; } if (e.PropertyName == nameof(ViewModel.ProgressBarUpper)) { progressbar.Adjustment.Upper = ViewModel.ProgressBarUpper; } if (e.PropertyName == nameof(ViewModel.Items)) { ytreeviewNomenclatures.ItemsDataSource = ViewModel.Items; } if (e.PropertyName == nameof(ViewModel.IsConfirmUpdateDataButtonVisible)) { enummenubuttonConfirmUpdate.Visible = ViewModel.IsConfirmUpdateDataButtonVisible; } if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible)) { ycheckDontChangeSellPrice.Visible = ViewModel.IsConfirmUpdateDataButtonVisible; } if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible)) { ybuttonConfirmLoadNew.Visible = ViewModel.IsConfirmLoadNewButtonVisible; } }); }; TextTagTable textTags = new TextTagTable(); var darkredtag = new TextTag("DarkRed"); darkredtag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkRed); textTags.Add(darkredtag); var redtag = new TextTag("red"); redtag.ForegroundGdk = GetGdkColor(ConsoleColor.Red); textTags.Add(redtag); var greentag = new TextTag("Green"); greentag.ForegroundGdk = GetGdkColor(ConsoleColor.Green); textTags.Add(greentag); var darkgreentag = new TextTag("DrakGreen"); darkgreentag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkGreen); textTags.Add(darkgreentag); var blackTag = new TextTag("Black"); blackTag.ForegroundGdk = GetGdkColor(ConsoleColor.Black); textTags.Add(blackTag); var yellowTag = new TextTag("Yellow"); yellowTag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkYellow); textTags.Add(yellowTag); ViewModel.ProgressBarMessagesUpdated += (aList, aIdx) => { Application.Invoke((s, args) => { TextBuffer tempBuffer = new TextBuffer(textTags); foreach (ColoredMessage message in ViewModel.ProgressBarMessages) { TextIter iter = tempBuffer.EndIter; switch (message.Color) { case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, blackTag); break; case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkredtag); break; case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, greentag); break; case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, yellowTag); break; case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkgreentag); break; case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, redtag); break; default: throw new NotImplementedException("Цвет не настроен"); } } ytextviewProgressStatus.Buffer = tempBuffer; ScrollToEnd(); }); }; ytreeviewNomenclatures.Selection.Changed += (sender, e) => { Application.Invoke((s, args) => { ytextviewNodeMessages.Buffer.Clear(); TextBuffer tempBuffer = new TextBuffer(textTags); var node = ytreeviewNomenclatures.GetSelectedObject <NomenclatureCatalogNode>(); if (node == null) { ytextviewNodeMessages.Buffer.Text = "Выберите запись для просмотра ошибок"; return; } foreach (ColoredMessage message in node.ErrorMessages) { TextIter iter = tempBuffer.EndIter; switch (message.Color) { case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", blackTag); break; case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkredtag); break; case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", greentag); break; case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", yellowTag); break; case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkgreentag); break; case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", redtag); break; default: throw new NotImplementedException("Цвет не настроен"); } } if (!node.ErrorMessages.Any() && node.Source == Source.File) { TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, "Ошибок нет\n", darkgreentag); } if (node.Source == Source.Base) { TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, "Данные из базы\n", blackTag); } ytextviewNodeMessages.Buffer = tempBuffer; ScrollToEnd(); }); }; }
/// <summary> /// Constructor /// </summary> public MainView(ViewBase owner = null) : base(owner) { MasterView = this; numberOfButtons = 0; baseFont = Rc.GetStyle(new Label()).FontDescription.Copy(); defaultBaseSize = baseFont.Size / Pango.Scale.PangoScale; FontSize = Utility.Configuration.Settings.BaseFontSize; Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade"); window1 = (Window)builder.GetObject("window1"); progressBar = (ProgressBar)builder.GetObject("progressBar"); statusWindow = (TextView)builder.GetObject("StatusWindow"); stopButton = (Button)builder.GetObject("stopButton"); notebook1 = (Notebook)builder.GetObject("notebook1"); notebook2 = (Notebook)builder.GetObject("notebook2"); vbox1 = (VBox)builder.GetObject("vbox1"); vbox2 = (VBox)builder.GetObject("vbox2"); hpaned1 = (HPaned)builder.GetObject("hpaned1"); hbox1 = (HBox)builder.GetObject("hbox1"); mainWidget = window1; window1.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); listButtonView1 = new ListButtonView(this); listButtonView1.ButtonsAreToolbar = true; EventBox labelBox = new EventBox(); Label label = new Label("NOTE: This version of APSIM writes .apsimx files as JSON, not XML. These files cannot be opened with older versions of APSIM."); labelBox.Add(label); if (!Utility.Configuration.Settings.DarkTheme) { labelBox.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0x00)); // yellow } vbox1.PackStart(labelBox, false, true, 0); vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0); listButtonView2 = new ListButtonView(this); listButtonView2.ButtonsAreToolbar = true; vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home")); notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home")); hbox1.HeightRequest = 20; TextTag tag = new TextTag("error"); tag.Foreground = "red"; statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("warning"); tag.Foreground = "brown"; statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("normal"); tag.Foreground = "blue"; statusWindow.Visible = false; stopButton.Image = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12)); stopButton.ImagePosition = PositionType.Right; stopButton.Image.Visible = true; stopButton.Clicked += OnStopClicked; window1.DeleteEvent += OnClosing; listButtonView1.ListView.MainWidget.ScrollEvent += ListView_ScrollEvent; listButtonView2.ListView.MainWidget.ScrollEvent += ListView_ScrollEvent; listButtonView1.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent; listButtonView2.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent; //window1.ShowAll(); if (ProcessUtilities.CurrentOS.IsMac) { InitMac(); } if ((uint)Environment.OSVersion.Platform <= 3) { RefreshTheme(); } }
public void VisitTextTag(TextTag tag) { textBuilder.Append(tag.Text); }
private void append(string line, TextTag tag, bool newline) { TextIter iter = Buffer.EndIter; Buffer.InsertWithTags (ref iter, line, tag); if (newline) Buffer.InsertWithTags (ref iter, "\n", tag); ScrollToIter (Buffer.EndIter, 0, false, 0, 0); }
/// <summary>Constructor</summary> public MainView(ViewBase owner = null) : base(owner) { numberOfButtons = 0; if ((uint)Environment.OSVersion.Platform <= 3) { Gtk.Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".gtkrc")); } baseFont = Gtk.Rc.GetStyle(new Label()).FontDescription.Copy(); defaultBaseSize = baseFont.Size / Pango.Scale.PangoScale; FontSize = Utility.Configuration.Settings.BaseFontSize; Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade"); window1 = (Window)builder.GetObject("window1"); progressBar = (ProgressBar)builder.GetObject("progressBar"); StatusWindow = (TextView)builder.GetObject("StatusWindow"); stopButton = (Button)builder.GetObject("stopButton"); notebook1 = (Notebook)builder.GetObject("notebook1"); notebook2 = (Notebook)builder.GetObject("notebook2"); vbox1 = (VBox)builder.GetObject("vbox1"); vbox2 = (VBox)builder.GetObject("vbox2"); hpaned1 = (HPaned)builder.GetObject("hpaned1"); hbox1 = (HBox)builder.GetObject("hbox1"); _mainWidget = window1; window1.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); listButtonView1 = new ListButtonView(this); listButtonView1.ButtonsAreToolbar = true; vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0); listButtonView2 = new ListButtonView(this); listButtonView2.ButtonsAreToolbar = true; vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; notebook1.SetMenuLabel(vbox1, new Label(indexTabText)); notebook2.SetMenuLabel(vbox2, new Label(indexTabText)); hbox1.HeightRequest = 20; TextTag tag = new TextTag("error"); tag.Foreground = "red"; StatusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("warning"); tag.Foreground = "brown"; StatusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("normal"); tag.Foreground = "blue"; StatusWindow.ModifyBase(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xf0)); StatusWindow.Visible = false; stopButton.Image = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12)); stopButton.ImagePosition = PositionType.Right; stopButton.Image.Visible = true; stopButton.Clicked += OnStopClicked; window1.DeleteEvent += OnClosing; listButtonView1.ListView.MainWidget.ScrollEvent += ListView_ScrollEvent; listButtonView2.ListView.MainWidget.ScrollEvent += ListView_ScrollEvent; listButtonView1.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent; listButtonView2.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent; //window1.ShowAll(); if (APSIM.Shared.Utilities.ProcessUtilities.CurrentOS.IsMac) { InitMac(); } }
public QueuedTextWrite(LogViewProgressMonitor monitor, string text, TextTag tag) { Monitor = monitor; Text = new System.Text.StringBuilder(text); Tag = tag; }
public void Reclaim(TextTag textTag) { Destroy(textTag.gameObject); }
public QueuedTextWrite(string text, TextTag tag) { Text = new System.Text.StringBuilder(text); Tag = tag; }
/// <inheritdoc /> public virtual void VisitTextTag(TextTag tag) { }
protected void MoveToNextState() { TextBuffer tb; TextTag tag; TextIter ti; switch (calState) { case CalibrationState.ZeroActual: if (!forced) { valTb.enableTouch = false; valTb.backgroundColor = "grey1"; valTb.TextChangedEvent -= OnValueTextBoxTextChanged; } valTb.text = GetCalibrationValue().ToString("F2"); valTb.QueueDraw(); actionBtn.text = "Zero Value"; actionBtn.QueueDraw(); tb = tv.Buffer; if (!string.IsNullOrWhiteSpace(zeroValueInstructions)) { tb.Text = zeroValueInstructions; } else { tb.Text = "Place the instrument in its zero state.\n" + "Once value has settled, press the button.\n\n"; } tag = new TextTag(null); tag.ForegroundGdk = TouchColor.NewGtkColor("seca"); tb.TagTable.Add(tag); ti = tb.EndIter; tb.InsertWithTags(ref ti, string.Format("Previous zero value: {0:F2}", calArgs.zeroValue), tag); tv.QueueDraw(); calState = CalibrationState.ZeroValue; break; case CalibrationState.ZeroValue: if (!forced) { valTb.enableTouch = true; valTb.backgroundColor = "grey1"; valTb.TextChangedEvent += OnValueTextBoxTextChanged; } valTb.text = "Enter Actual"; valTb.QueueDraw(); actionBtn.text = "Full Scale Actual"; actionBtn.QueueDraw(); tb = tv.Buffer; if (!string.IsNullOrWhiteSpace(fullScaleActualInstructions)) { tb.Text = fullScaleActualInstructions; } else { tb.Text = "Please enter the full scale actual value.\n" + "Once the full scale value is entered press the button.\n\n"; } tag = new TextTag(null); tag.ForegroundGdk = TouchColor.NewGtkColor("seca"); tb.TagTable.Add(tag); ti = tb.EndIter; tb.InsertWithTags(ref ti, string.Format("Previous full scale actual: {0:F2}", calArgs.fullScaleActual), tag); tv.QueueDraw(); calState = CalibrationState.FullScaleActual; break; case CalibrationState.FullScaleActual: if (!forced) { valTb.enableTouch = false; valTb.backgroundColor = "grey1"; valTb.TextChangedEvent -= OnValueTextBoxTextChanged; } valTb.text = GetCalibrationValue().ToString("F2"); valTb.QueueDraw(); actionBtn.text = "Full Scale Value"; actionBtn.QueueDraw(); tb = tv.Buffer; if (!string.IsNullOrWhiteSpace(fullScaleValueInstructions)) { tb.Text = fullScaleValueInstructions; } else { tb.Text = "Please the instrument in its full scale state.\n" + "Once value has settled, press the button.\n\n"; } tag = new TextTag(null); tag.ForegroundGdk = TouchColor.NewGtkColor("seca"); tb.TagTable.Add(tag); ti = tb.EndIter; tb.InsertWithTags(ref ti, string.Format("Previous full scale value: {0:F2}", calArgs.fullScaleValue), tag); tv.QueueDraw(); calState = CalibrationState.FullScaleValue; break; case CalibrationState.FullScaleValue: CalibrationCompleteEvent?.Invoke(calArgs); Destroy(); break; default: break; } }
/// <inheritdoc /> public virtual void VisitTextTag(TextTag tag) { Append(tag.Text); }
public override void UpdateVariables(Dictionary<string, TemplateObject> vars) { Color = ColorTag.For(vars["color"]); Text = new TextTag(vars["text"].ToString()); ChatMode = new TextTag(vars["chat_mode"].ToString()); base.UpdateVariables(vars); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); // Be sure to start with a consistent window title. InfoTitle = null; // Prepare using status bar. _SbCtxActivity = this.statusbar1.GetContextId("Activity like loading or cleaning up"); _SbCtxState = this.statusbar1.GetContextId("State of affairs"); _SbCtxError = this.statusbar1.GetContextId("Error message, should stay visible"); // Prepare using TextView. TextTagTable tagTable = this.textviewText.Buffer.TagTable; // Current notes element _TagCurrentNotesElement = new TextTag("current_notes_element"); _TagCurrentNotesElement.Background = "lightgreen"; _TagCurrentNotesElement.BackgroundSet = true; tagTable.Add(_TagCurrentNotesElement); _TagCurrentNotesElementLinewise = new TextTag("current_notes_element_linewise"); _TagCurrentNotesElementLinewise.ParagraphBackground = "lightgreen"; tagTable.Add(_TagCurrentNotesElementLinewise); // Error parse issue _TagErrorParseIssue = new TextTag("error_parse_issue"); _TagErrorParseIssue.Background = "red"; _TagErrorParseIssue.BackgroundSet = true; tagTable.Add(_TagErrorParseIssue); _TagErrorParseIssueLinewise = new TextTag("error_parse_issue_linewise"); _TagErrorParseIssueLinewise.ParagraphBackground = "red"; tagTable.Add(_TagErrorParseIssueLinewise); // Warning parse issue _TagWarningParseIssue = new TextTag("warning_parse_issue"); _TagWarningParseIssue.Background = "orange"; _TagWarningParseIssue.BackgroundSet = true; tagTable.Add(_TagWarningParseIssue); _TagWarningParseIssueLinewise = new TextTag("warning_parse_issue_linewise"); _TagWarningParseIssueLinewise.ParagraphBackground = "orange"; tagTable.Add(_TagWarningParseIssueLinewise); // Semantic types: _TagsSemanticType = new Dictionary<SemanticType, TextTag>(); // Type var typeSemanticTypeTag = new TextTag("syntax_type"); typeSemanticTypeTag.Foreground = "green"; typeSemanticTypeTag.ForegroundSet = true; tagTable.Add(typeSemanticTypeTag); this._TagsSemanticType.Add(SemanticType.Type, typeSemanticTypeTag); // Identifier var identifierSemanticTypeTag = new TextTag("syntax_identifier"); identifierSemanticTypeTag.Foreground = "darkcyan"; identifierSemanticTypeTag.ForegroundSet = true; tagTable.Add(identifierSemanticTypeTag); this._TagsSemanticType.Add(SemanticType.Identifier, identifierSemanticTypeTag); // Constant var constantSemanticTypeTag = new TextTag("syntax_constant"); constantSemanticTypeTag.Foreground = "darkred"; constantSemanticTypeTag.ForegroundSet = true; tagTable.Add(constantSemanticTypeTag); this._TagsSemanticType.Add(SemanticType.Constant, constantSemanticTypeTag); // Keyword var keywordSemanticTypeTag = new TextTag("syntax_keyword"); keywordSemanticTypeTag.Foreground = "darkorange"; keywordSemanticTypeTag.ForegroundSet = true; tagTable.Add(keywordSemanticTypeTag); this._TagsSemanticType.Add(SemanticType.Keyword, keywordSemanticTypeTag); // Set up NodeView. this.nodeviewNotes.NodeStore = new NodeStore(typeof(NotesElementTreeNode)); this.nodeviewNotes.AppendColumn("Summary", new CellRendererText(), "text", 0, "foreground", 3); var cellRendererLine = new CellRendererText(); cellRendererLine.Alignment = Pango.Alignment.Right; this.nodeviewNotes.AppendColumn("Line", cellRendererLine, "text", 1, "foreground", 3); var cellRendererTotalLines = new CellRendererText(); cellRendererTotalLines.Alignment = Pango.Alignment.Right; this.nodeviewNotes.AppendColumn("# Lines", cellRendererTotalLines, "text", 2, "foreground", 3); var cellRendererParseIssues = new CellRendererText(); cellRendererParseIssues.Alignment = Pango.Alignment.Right; cellRendererParseIssues.Foreground = "red"; this.nodeviewNotes.AppendColumn("# Issues", cellRendererParseIssues, "text", 4); this.nodeviewNotes.NodeSelection.Changed += NodeviewNotes_NodeSelection_Changed; this.nodeviewNotes.KeyReleaseEvent += NodeviewNotes_KeyReleaseEvent; // Set up recent menu. Debug.Print("[MainWindow] ctor: Searching for 'Recent' menu..."); foreach (Widget widget in this.menubar1) { Debug.Print("[MainWindow] ctor: Examining widget: {0}", widget); var menuItem = widget as MenuItem; if (object.ReferenceEquals(menuItem, null)) { Debug.Print("[MainWindow] ctor: Widget is not a MenuItem. Skipping."); continue; } var menu = menuItem.Submenu as Menu; if (object.ReferenceEquals(menu, null)) { Debug.Print("[MainWindow] ctor: MenuItem's submenu is not a Menu. Skipping."); continue; } if (object.ReferenceEquals(menu.Action, this.FileAction)) { Debug.Print("[MainWindow] ctor: Menu is not the 'File' menu. Skipping."); continue; } Debug.Print("[MainWindow] ctor: Found 'File' menu."); foreach (Widget widget2 in menu) { Debug.Print("[MainWindow] ctor: File menu: Examining widget: {0}", widget2); var menuItem2 = widget2 as MenuItem; if (object.ReferenceEquals(menuItem2, null)) { Debug.Print("[MainWindow] ctor: File menu: Widget is not a MenuItem. Skipping."); continue; } if (object.ReferenceEquals(menuItem2.Action, this.RecentAction)) { Debug.Print("[MainWindow] ctor: File menu: Found 'Recent' menu item."); this.RecentMenu = menuItem2.Submenu as Menu; if (object.ReferenceEquals(this.RecentMenu, null)) { Debug.Print("[MainWindow] ctor: File menu: Can't handle 'Recent' submenu. Breaking out."); break; } break; } } if (!object.ReferenceEquals(this.RecentMenu, null)) break; } if (object.ReferenceEquals(this.RecentMenu, null)) Debug.Print("[MainWindow] ctor: Couldn't find 'Recent' menu."); UpdateRecentMenu(); // Set up signals. Doing this manually should be cleaner // than an association getting lost in the auto-generated code... RecentManager.Default.Changed += (sender, e) => UpdateRecentMenu(); this.openAction.Activated += OpenAction_Activated; this.closeAction.Activated += (object sender, EventArgs e) => CloseFile(); this.quitAction.Activated += (object sender, EventArgs e) => Application.Quit(); }
/// <summary> /// Text is normal text and contains words, spaces and tags /// tags are like HTML tags /// examples are given bellow /// </summary> /// <param name="text"></param> /// <returns></returns> // examples of tags: // <tag> // <tag attr1=val1> // <tag attr2="val1" attr3='val3' attr4=val5> public List <SMWordBase> WordListFromString(string text) { List <SMWordBase> list = new List <SMWordBase>(); TextParseMode mode = TextParseMode.General; StringBuilder word = new StringBuilder(); StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); RunningFormat fmt = new RunningFormat(); TextTag tt = new TextTag(); string argumentName = ""; fmt.SetFontStyle(Font.Style); fmt.fontSize = Font.Size; fmt.fontName = Font.Name; fmt.defaultFontSize = fmt.fontSize; foreach (char readedChar in text) { if (mode == TextParseMode.General) { if (readedChar == '&') { mode = TextParseMode.SpecChar; sb.Clear(); continue; } else if (readedChar == '<') { mode = TextParseMode.WaitForTagNameStart; sb.Clear(); continue; } else if (Char.IsWhiteSpace(readedChar)) { ClearWordBuffer(list, word, fmt); if (readedChar == '\n') { list.Add(new SMWordSpecial(Font) { Type = SMWordSpecialType.Newline }); } else if (readedChar == '\r') { } else { AppendWord(list, " ", fmt); } } else { word.Append(readedChar); } } else if (mode == TextParseMode.SpecChar) { if (readedChar == ';') { word.Append(GetCharFromCode(sb.ToString())); mode = TextParseMode.General; } else { sb.Append(readedChar); } } else if (mode == TextParseMode.WaitForTagNameStart) { if (readedChar == '>') { mode = TextParseMode.General; } else if (!Char.IsWhiteSpace(readedChar)) { sb.Append(readedChar); mode = TextParseMode.ReadTagName; } } else if (mode == TextParseMode.ReadTagName) { if (Char.IsWhiteSpace(readedChar)) { tt.tag = sb.ToString(); sb.Clear(); mode = TextParseMode.WaitForArgOrEnd; } else if (readedChar == '>') { tt.tag = sb.ToString(); mode = TextParseMode.General; AppendTag(list, word, tt, fmt); tt.Clear(); } else { sb.Append(readedChar); } } else if (mode == TextParseMode.WaitForArgOrEnd) { if (readedChar == '>') { mode = TextParseMode.General; AppendTag(list, word, tt, fmt); tt.Clear(); } else if (Char.IsWhiteSpace(readedChar)) { } else { sb.Clear(); sb.Append(readedChar); mode = TextParseMode.ReadArgName; } } else if (mode == TextParseMode.ReadArgName) { if (readedChar == '>') { mode = TextParseMode.General; if (sb.Length > 0) { tt.attrs.Add(sb.ToString(), string.Empty); AppendTag(list, word, tt, fmt); tt.Clear(); } } else if (readedChar == '=') { argumentName = sb.ToString(); sb.Clear(); mode = TextParseMode.WaitForArgValue; } else if (Char.IsWhiteSpace(readedChar)) { argumentName = sb.ToString(); sb.Clear(); mode = TextParseMode.WaitForAssignOrEnd; } else { sb.Append(readedChar); } } else if (mode == TextParseMode.WaitForAssignOrEnd) { if (readedChar == '=') { mode = TextParseMode.WaitForArgValue; } else if (readedChar == '>') { mode = TextParseMode.General; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, string.Empty); AppendTag(list, word, tt, fmt); tt.Clear(); } } else if (!Char.IsWhiteSpace(readedChar)) { mode = TextParseMode.ReadArgName; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, string.Empty); } sb.Clear(); sb.Append(readedChar); } } else if (mode == TextParseMode.WaitForArgValue) { if (readedChar == '>') { mode = TextParseMode.General; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, string.Empty); AppendTag(list, word, tt, fmt); tt.Clear(); } } else if (readedChar == '\"') { sb.Clear(); mode = TextParseMode.ReadArgValueString; } else if (readedChar == '\'') { sb.Clear(); mode = TextParseMode.ReadArgValueQuote; } else if (!Char.IsWhiteSpace(readedChar)) { sb.Clear(); sb.Append(readedChar); mode = TextParseMode.ReadArgValue; } } else if (mode == TextParseMode.ReadArgValue) { if (readedChar == '>') { mode = TextParseMode.General; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, sb.ToString()); AppendTag(list, word, tt, fmt); tt.Clear(); } } else if (readedChar == '&') { sb2.Clear(); mode = TextParseMode.ReadArgValueSpecChar; } else if (Char.IsWhiteSpace(readedChar)) { mode = TextParseMode.WaitForArgOrEnd; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, sb.ToString()); sb.Clear(); argumentName = ""; } } else { sb.Append(readedChar); } } else if (mode == TextParseMode.ReadArgValueSpecChar) { if (readedChar == ';') { sb.Append(GetCharFromCode(sb2.ToString())); mode = TextParseMode.ReadArgValue; } else { sb2.Append(readedChar); } } else if (mode == TextParseMode.ReadArgValueString) { if (readedChar == '&') { sb2.Clear(); mode = TextParseMode.ReadArgValueStringSpecChar; } else if (readedChar == '\"') { mode = TextParseMode.WaitForArgOrEnd; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, sb.ToString()); sb.Clear(); argumentName = ""; } } else { sb.Append(readedChar); } } else if (mode == TextParseMode.ReadArgValueStringSpecChar) { if (readedChar == ';') { sb.Append(GetCharFromCode(sb2.ToString())); mode = TextParseMode.ReadArgValueString; } else { sb2.Append(readedChar); } } else if (mode == TextParseMode.ReadArgValueQuote) { if (readedChar == '&') { sb2.Clear(); mode = TextParseMode.ReadArgValueQuoteSpecChar; } else if (readedChar == '\"') { mode = TextParseMode.WaitForArgOrEnd; if (argumentName.Length > 0) { tt.attrs.Add(argumentName, sb.ToString()); sb.Clear(); argumentName = ""; } } else { sb.Append(readedChar); } } else if (mode == TextParseMode.ReadArgValueQuoteSpecChar) { if (readedChar == ';') { sb.Append(GetCharFromCode(sb2.ToString())); mode = TextParseMode.ReadArgValueQuote; } else { sb2.Append(readedChar); } } } // finalization if (word.Length > 0) { AppendWord(list, word.ToString(), fmt); word.Clear(); } // set first editable as focused foreach (SMWordBase wb in list) { if (wb is SMWordToken) { SMWordToken wt = (SMWordToken)wb; if (wt.Editable) { wt.Focused = true; break; } } } return(list); }
/// <summary>Create TextView styles.</summary> private void CreateStyles(TextView textView) { var heading1 = new TextTag("Heading1"); heading1.SizePoints = 30; heading1.Weight = Pango.Weight.Bold; textView.Buffer.TagTable.Add(heading1); var heading2 = new TextTag("Heading2"); heading2.SizePoints = 25; heading2.Weight = Pango.Weight.Bold; textView.Buffer.TagTable.Add(heading2); var heading3 = new TextTag("Heading3"); heading3.SizePoints = 20; heading3.Weight = Pango.Weight.Bold; textView.Buffer.TagTable.Add(heading3); var code = new TextTag("Code"); code.Font = "monospace"; textView.Buffer.TagTable.Add(code); var bold = new TextTag("Bold"); bold.Weight = Pango.Weight.Bold; textView.Buffer.TagTable.Add(bold); var italic = new TextTag("Italic"); italic.Style = Pango.Style.Italic; textView.Buffer.TagTable.Add(italic); var indent1 = new TextTag("Indent1"); indent1.LeftMargin = indentSize; textView.Buffer.TagTable.Add(indent1); var indent2 = new TextTag("Indent2"); indent2.LeftMargin = 2 * indentSize; textView.Buffer.TagTable.Add(indent2); var indent3 = new TextTag("Indent3"); indent3.LeftMargin = 3 * indentSize; textView.Buffer.TagTable.Add(indent3); var subscript = new TextTag("Subscript"); subscript.Rise = 0; subscript.Scale = Pango.Scale.XSmall; textView.Buffer.TagTable.Add(subscript); var superscript = new TextTag("Superscript"); superscript.Rise = 8192; superscript.Scale = Pango.Scale.XSmall; textView.Buffer.TagTable.Add(superscript); var strikethrough = new TextTag("Strikethrough"); strikethrough.Strikethrough = true; textView.Buffer.TagTable.Add(strikethrough); }
private void AppendTag(List <SMWordBase> list, StringBuilder word, TextTag tt, RunningFormat fmt) { // TODO switch (tt.tag) { case "draggable": fmt.dragResponse = SMDragResponse.Drag; break; case "/draggable": ClearWordBuffer(list, word, fmt); fmt.dragResponse = SMDragResponse.None; break; case "drop": { SMWordToken wt = new SMWordToken(Font); wt.text = tt.attrs.ContainsKey("text") ? tt.attrs["text"] : "_____"; wt.tag = tt.attrs.ContainsKey("tag") ? tt.attrs["tag"] : ""; wt.Draggable = SMDragResponse.None; wt.Cardinality = SMConnectionCardinality.One; wt.Evaluation = EvaluationType; list.Add(wt); } break; case "edit": { SMWordToken wt = new SMWordToken(Font); wt.text = tt.attrs.ContainsKey("text") ? tt.attrs["text"] : "_____"; wt.tag = tt.attrs.ContainsKey("tag") ? tt.attrs["tag"] : ""; wt.Draggable = SMDragResponse.None; wt.Editable = true; wt.Cardinality = SMConnectionCardinality.One; wt.Evaluation = EvaluationType; list.Add(wt); } break; case "page": ClearWordBuffer(list, word, fmt); list.Add(new SMWordSpecial(Font) { Type = SMWordSpecialType.NewPage }); break; case "hr": ClearWordBuffer(list, word, fmt); list.Add(new SMWordSpecial(Font) { Type = SMWordSpecialType.HorizontalLine }); break; case "br": ClearWordBuffer(list, word, fmt); list.Add(new SMWordSpecial(Font) { Type = SMWordSpecialType.Newline }); AppendWord(list, "\n", fmt); break; case "col": ClearWordBuffer(list, word, fmt); list.Add(new SMWordSpecial(Font) { Type = SMWordSpecialType.NewColumn }); //AppendWord(list, "\n", control, fmt); break; case "r": ClearWordBuffer(list, word, fmt); fmt.Bold = false; fmt.Italic = false; fmt.Strikeout = false; fmt.Underline = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "/r": ClearWordBuffer(list, word, fmt); fmt.Bold = Font.Bold; fmt.Italic = Font.Italic; fmt.Underline = Font.Underline; fmt.Strikeout = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "b": ClearWordBuffer(list, word, fmt); fmt.Bold = true; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "/b": ClearWordBuffer(list, word, fmt); fmt.Bold = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "i": ClearWordBuffer(list, word, fmt); fmt.Italic = true; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "/i": ClearWordBuffer(list, word, fmt); fmt.Italic = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "u": ClearWordBuffer(list, word, fmt); fmt.Underline = true; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "/u": ClearWordBuffer(list, word, fmt); fmt.Underline = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "so": ClearWordBuffer(list, word, fmt); fmt.Strikeout = true; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; case "/so": ClearWordBuffer(list, word, fmt); fmt.Strikeout = false; //fmt.fontStyleValid = (fmt.fontStyle != control.Style.Font.Style); break; default: if (tt.tag.StartsWith("fs")) { int arg = 0; if (int.TryParse(tt.tag.Substring(2), out arg)) { fmt.fontSize = (float)arg / 100 * fmt.defaultFontSize; fmt.lineOffset = (float)arg / 100 - 1f; } } break; } }
private void TagButtonClicked(object sender, EventArgs args) { if (this.IsFocus) { return; } this.IsFocus = true; // Get cursor back! ToggleButton caller = (ToggleButton)sender; TextTag checkTag = (caller == boldButton) ? BoldTag : ItalicTag; TextIter startIt, endIt; // Is text selected? if (!Buffer.GetSelectionBounds(out startIt, out endIt)) { // Check if Cursor is inside a word var currIt = Buffer.GetIterAtOffset(Buffer.CursorPosition); if (currIt.InsideWord() && !currIt.StartsWord()) { // Apply tag to whole word startIt = currIt; while (!startIt.StartsWord() && !startIt.IsStart) { startIt.BackwardChar(); } endIt = currIt; while (!endIt.EndsWord() && !endIt.IsEnd) { endIt.ForwardChar(); } } else // Somehwere between words // Apply tag when user writes on this offset { applyIter = currIt; foreach (var tag in currIt.Tags) { activeTags.Add(tag); } if (caller.Active) { activeTags.Add(checkTag); } else { activeTags.Remove(checkTag); } return; // User has to give new input } } if (caller.Active) { Buffer.ApplyTag(checkTag, startIt, endIt); } else { Buffer.RemoveTag(checkTag, startIt, endIt); } }
// Update is called once per frame void FixedUpdate() { age += Time.deltaTime; // get more hungry/thirsty hunger += Time.deltaTime * 0.01f; thirst += Time.deltaTime * 0.01f; float percentGrown = age / genome["ageToReproduce"].value(); if (percentGrown <= 1) { size = percentGrown * genome["size"].value(); } else { size = genome["size"].value(); } this.gameObject.transform.localScale = new Vector3(size, size, size); // die if you ded if (hunger >= 1 || thirst >= 1 || age > maxAge) { Die(); } // mode changing logic if (thirst > 0.4) // these threshold should be part of the genome! { mode = "thirsty"; } else if (hunger > 0.6) { mode = "hungry"; } else { if (recoveryTime > 0) { recoveryTime -= Time.deltaTime; mode = "hungry"; } else if (size < genome["size"].value()) { mode = "hungry"; } else { mode = "frisky"; } } // do actions, according to mode bool didFindSomething = false; switch (mode) { case "hungry": didFindSomething = FixedUpdateHungry(); break; case "thirsty": didFindSomething = FixedUpdateThirsty(); break; case "frisky": didFindSomething = FixedUpdateFrisky(); break; } if (didFindSomething) { wanderLocation = nullVector; } else { FixedUpdateWander(); } // Update our status to the text overs TextTag myTextTag = gameObject.GetComponent <TextTag>(); myTextTag.SetText("Hunger: " + hunger.ToString("0.00")); }
private PhotoEditorUI(ArrayList selectedphotos, DeskFlickrUI.ModeSelected mode) { Glade.XML gxml = new Glade.XML(null, "organizer.glade", "window2", null); gxml.Autoconnect(this); _isconflictmode = (mode == DeskFlickrUI.ModeSelected.ConflictMode); _isuploadmode = (mode == DeskFlickrUI.ModeSelected.UploadMode); _isblogmode = (mode == DeskFlickrUI.ModeSelected.BlogMode); if (mode == DeskFlickrUI.ModeSelected.BlogAndConflictMode) { _isconflictmode = true; _isblogmode = true; } _tags = new ArrayList(); _comments = new ArrayList(); window2.Title = "Edit information for " + selectedphotos.Count + " photos"; window2.SetIconFromFile(DeskFlickrUI.ICON_PATH); notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Information"); notebook1.NextPage(); notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Tags"); notebook1.NextPage(); notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Comments"); tips = new Tooltips(); SetCommentsToolBar(); tips.Enable(); SetCommentsTree(); if (_isconflictmode) { notebook1.NextPage(); notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Information at Server"); } else { notebook1.RemovePage(3); } if (_isblogmode) { notebook1.NextPage(); notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Blog Entry"); notebook1.Page = 3; // Default page is blog entry if editor is in Blog mode. } else { if (_isconflictmode) { notebook1.RemovePage(4); } else { notebook1.RemovePage(3); } notebook1.Page = 0; // Default page is photo editing. } table1.SetColSpacing(0, 50); // Set Labels label6.Text = "Edit"; label5.Text = "Title:"; label4.Text = "Description:"; label3.Text = "Visibility:"; label2.Text = "License:"; if (_isuploadmode) { label2.Sensitive = false; } // Labels for blog tab. label17.Text = "Title: "; label18.Text = "Description: "; // Search box label15.Markup = "<span weight='bold'>Search: </span>"; entry2.Changed += new EventHandler(OnFilterEntryChanged); // Revert button button9.Label = "Revert Photo(s)"; button9.Clicked += new EventHandler(OnRevertButtonClicked); // entry1.ModifyFont(Pango.FontDescription.FromString("FreeSerif 10")); SetPrivacyComboBox(); SetLicenseComboBox(); SetTagTreeView(); // Make previous and next buttons insensitive. They'll become sensitive // only when the user ticks the 'Per Photo' checkbutton. button3.Sensitive = false; button4.Sensitive = false; checkbutton1.Toggled += new EventHandler(OnPerPageCheckToggled); button3.Clicked += new EventHandler(OnPrevButtonClick); button4.Clicked += new EventHandler(OnNextButtonClick); button5.Clicked += new EventHandler(OnSaveButtonClick); button6.Clicked += new EventHandler(OnCancelButtonClick); entry1.Changed += new EventHandler(OnTitleChanged); textview5.Buffer.Changed += new EventHandler(OnDescChanged); combobox1.Changed += new EventHandler(OnPrivacyChanged); combobox2.Changed += new EventHandler(OnLicenseChanged); entry4.Changed += new EventHandler(OnBlogTitleChanged); textview7.Buffer.Changed += new EventHandler(OnBlogDescChanged); textview3.Buffer.Changed += new EventHandler(OnTagsChanged); TextTag texttag = new TextTag("conflict"); texttag.Font = "Times Italic 10"; texttag.WrapMode = WrapMode.Word; texttag.ForegroundGdk = new Gdk.Color(0x99, 0, 0); textview4.Buffer.TagTable.Add(texttag); // Showing photos should be the last step. this._selectedphotos = selectedphotos; if (selectedphotos.Count == 1) { checkbutton1.Sensitive = false; ShowInformationForCurrentPhoto(); } else { EmbedCommonInformation(); } // Save a copy of the original photos, so that only those photos // which have been edited, would have their dirty bit set. Advantage: // this would reduce the number of dirty photos, and hence there'll // be lesser photos to update when sycing with server. _originalphotos = new System.Collections.Generic.Dictionary <string, Photo>(); foreach (DeskFlickrUI.SelectedPhoto sel in _selectedphotos) { Photo p = sel.photo; _originalphotos.Add(p.Id, new Photo(p)); } eventbox5.ButtonPressEvent += OnLinkPressed; eventbox5.EnterNotifyEvent += MouseOnLink; eventbox5.LeaveNotifyEvent += MouseLeftLink; window2.ShowAll(); }
void UpdateGeometry(double X, double Y, double zoomFactor) { // Clear old geometry _geometry.Clear(); _textTags.Clear(); // Open a StreamGeometryContext that can be used to describe this StreamGeometry // object's contents. using (StreamGeometryContext ctx = _geometry.Open()) { Int64 totalTimeMS = 0; Int64 numSteps = FASTBuildMonitorControl.GetCurrentBuildTimeMS() / (_bigTimeUnit * 1000); Int64 remainder = FASTBuildMonitorControl.GetCurrentBuildTimeMS() % (_bigTimeUnit * 1000); numSteps += remainder > 0 ? 2 : 1; Int64 timeLimitMS = numSteps * _bigTimeUnit * 1000; while (totalTimeMS <= timeLimitMS) { bool bDrawBigMarker = totalTimeMS % (_bigTimeUnit * 1000) == 0; double x = X + zoomFactor * FASTBuildMonitorControl.pix_per_second * totalTimeMS / 1000.0f; // TODO: activate culling optimization //if (x >= _savedTimebarViewPort.X && x <= _savedTimebarViewPort.Y) { double height = bDrawBigMarker ? 5.0f : 2.0f; ctx.BeginFigure(new Point(x, Y), true /* is filled */, false /* is closed */); // Draw a line to the next specified point. ctx.LineTo(new Point(x, Y + height), true /* is stroked */, false /* is smooth join */); if (bDrawBigMarker) { string formattedText = FASTBuildMonitorControl.GetTimeFormattedString(totalTimeMS); Point textSize = TextUtils.ComputeTextSize(formattedText); double horizontalCorrection = textSize.X / 2.0f; TextTag newTag = new TextTag(formattedText, x - horizontalCorrection, Y + height + 2); _textTags.Add(newTag); } } totalTimeMS += _smallTimeUnit * 1000; } } }
/// <summary> /// Constructor /// </summary> public MainView(ViewBase owner = null) : base(owner) { MasterView = this; numberOfButtons = 0; Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade"); window1 = (Window)builder.GetObject("window1"); progressBar = (ProgressBar)builder.GetObject("progressBar"); statusWindow = (TextView)builder.GetObject("StatusWindow"); stopButton = (Button)builder.GetObject("stopButton"); notebook1 = (Notebook)builder.GetObject("notebook1"); notebook2 = (Notebook)builder.GetObject("notebook2"); vbox1 = (VBox)builder.GetObject("vbox1"); vbox2 = (VBox)builder.GetObject("vbox2"); hpaned1 = (HPaned)builder.GetObject("hpaned1"); hbox1 = (HBox)builder.GetObject("hbox1"); mainWidget = window1; window1.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); listButtonView1 = new ListButtonView(this); listButtonView1.ButtonsAreToolbar = true; vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0); listButtonView2 = new ListButtonView(this); listButtonView2.ButtonsAreToolbar = true; vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home")); notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home")); hbox1.HeightRequest = 20; TextTag tag = new TextTag("error"); tag.Foreground = "red"; statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("warning"); tag.Foreground = "brown"; statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("normal"); tag.Foreground = "blue"; statusWindow.Visible = false; stopButton.Image = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12)); stopButton.ImagePosition = PositionType.Right; stopButton.Image.Visible = true; stopButton.Clicked += OnStopClicked; window1.DeleteEvent += OnClosing; if (ProcessUtilities.CurrentOS.IsWindows && Utility.Configuration.Settings.Font == null) { // Default font on Windows is Segoe UI. Will fallback to sans if unavailable. Utility.Configuration.Settings.Font = Pango.FontDescription.FromString("Segoe UI 11"); } // Can't set font until widgets are initialised. if (Utility.Configuration.Settings.Font != null) { ChangeFont(Utility.Configuration.Settings.Font); } //window1.ShowAll(); if (ProcessUtilities.CurrentOS.IsMac) { InitMac(); //Utility.Configuration.Settings.DarkTheme = Utility.MacUtilities.DarkThemeEnabled(); } if (!ProcessUtilities.CurrentOS.IsLinux) { RefreshTheme(); } }
public void RegisterTag(TextTag tag, object sender) { hexTV.Buffer.TagTable.Add(tag); asciiTV.Buffer.TagTable.Add(tag); }
/// <summary> /// Constructor /// </summary> public MainView(ViewBase owner = null) : base(owner) { MasterView = this; numberOfButtons = 0; Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade"); window1 = (Window)builder.GetObject("window1"); progressBar = (ProgressBar)builder.GetObject("progressBar"); statusWindow = (TextView)builder.GetObject("StatusWindow"); stopButton = (Button)builder.GetObject("stopButton"); notebook1 = (Notebook)builder.GetObject("notebook1"); notebook2 = (Notebook)builder.GetObject("notebook2"); vbox1 = (VBox)builder.GetObject("vbox1"); vbox2 = (VBox)builder.GetObject("vbox2"); hpaned1 = (HPaned)builder.GetObject("hpaned1"); hbox1 = (HBox)builder.GetObject("hbox1"); mainWidget = window1; window1.Icon = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png"); listButtonView1 = new ListButtonView(this); listButtonView1.ButtonsAreToolbar = true; vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0); listButtonView2 = new ListButtonView(this); listButtonView2.ButtonsAreToolbar = true; vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0); hpaned1.PositionSet = true; hpaned1.Child2.Hide(); hpaned1.Child2.NoShowAll = true; notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home")); notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home")); notebook1.SwitchPage += OnChangeTab; notebook2.SwitchPage += OnChangeTab; notebook1.GetTabLabel(notebook1.Children[0]).Name = "selected-tab"; hbox1.HeightRequest = 20; TextTag tag = new TextTag("error"); // Make errors orange-ish in dark mode. if (Utility.Configuration.Settings.DarkTheme) { tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(1)); } else { tag.Foreground = "red"; } statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("warning"); // Make warnings yellow in dark mode. if (Utility.Configuration.Settings.DarkTheme) { tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(7)); } else { tag.Foreground = "brown"; } statusWindow.Buffer.TagTable.Add(tag); tag = new TextTag("normal"); tag.Foreground = "blue"; statusWindow.Visible = false; stopButton.Image = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12)); stopButton.ImagePosition = PositionType.Right; stopButton.Image.Visible = true; stopButton.Clicked += OnStopClicked; window1.DeleteEvent += OnClosing; // If font is null, or font family is null, or font size is 0, fallback // to the default font (on windows only). Pango.FontDescription f = null; if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName)) { f = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName); } if (ProcessUtilities.CurrentOS.IsWindows && (string.IsNullOrEmpty(Utility.Configuration.Settings.FontName) || f.Family == null || f.Size == 0)) { // Default font on Windows is Segoe UI. Will fallback to sans if unavailable. Utility.Configuration.Settings.FontName = Pango.FontDescription.FromString("Segoe UI 11").ToString(); } // Can't set font until widgets are initialised. if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName)) { Pango.FontDescription font = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName); ChangeFont(font); } //window1.ShowAll(); if (ProcessUtilities.CurrentOS.IsMac) { InitMac(); //Utility.Configuration.Settings.DarkTheme = Utility.MacUtilities.DarkThemeEnabled(); } if (!ProcessUtilities.CurrentOS.IsLinux) { RefreshTheme(); } #if NETCOREAPP LoadStylesheets(); #endif }
private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; using (var exportOperation = new ExportOperation( mode, new OrderParametersProvider(new ParametersProvider()), dateStart, dateEnd, null)) { this.exportInProgress = true; UpdateExportSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportSensitivity(); exportData = exportOperation.Result; } labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); labelTotalSales.Text = exportData.Objects .OfType <SalesDocumentNode>() .Count() .ToString(); labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU")); labelExportedSum.Markup = $"<span foreground=\"{(exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red")}\">" + $"{exportData.ExportedTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU"))}</span>"; labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
private void CreateTags(TextBuffer buffer) { Gdk.RGBA white = new Gdk.RGBA(); white.Parse("#ffffff"); Gdk.RGBA commentColour = new Gdk.RGBA(); commentColour.Parse("#5b814c"); Gdk.RGBA opCodeColour = new Gdk.RGBA(); opCodeColour.Parse("#81331e"); Gdk.RGBA keywordColour = new Gdk.RGBA(); keywordColour.Parse("#F92672"); Gdk.RGBA variableColour = new Gdk.RGBA(); variableColour.Parse("#A6E22E"); Gdk.RGBA constantColour = new Gdk.RGBA(); constantColour.Parse("#AE81FF"); Gdk.RGBA addressFgColour = new Gdk.RGBA(); addressFgColour.Parse("#8F908A"); Gdk.RGBA addressBgColour = new Gdk.RGBA(); addressBgColour.Parse("#2F3129"); Gdk.RGBA backgroundColour = new Gdk.RGBA(); backgroundColour.Parse("#272822"); TextTag tag = new TextTag("keyword") { Weight = Pango.Weight.Normal, ForegroundRgba = keywordColour, BackgroundRgba = backgroundColour }; buffer.TagTable.Add(tag); tag = new TextTag("variable") { Weight = Pango.Weight.Normal, ForegroundRgba = variableColour, BackgroundRgba = backgroundColour }; buffer.TagTable.Add(tag); tag = new TextTag("constant") { Weight = Pango.Weight.Normal, ForegroundRgba = constantColour, BackgroundRgba = backgroundColour }; buffer.TagTable.Add(tag); tag = new TextTag("address") { Weight = Pango.Weight.Bold, ForegroundRgba = addressFgColour, BackgroundRgba = addressBgColour }; buffer.TagTable.Add(tag); tag = new TextTag("opCode") { Weight = Pango.Weight.Normal, ForegroundRgba = opCodeColour, BackgroundRgba = addressBgColour }; buffer.TagTable.Add(tag); tag = new TextTag("white") { Weight = Pango.Weight.Normal, ForegroundRgba = white, BackgroundRgba = backgroundColour }; buffer.TagTable.Add(tag); tag = new TextTag("comment") { Weight = Pango.Weight.Normal, Style = Pango.Style.Italic, ForegroundRgba = commentColour, BackgroundRgba = backgroundColour }; buffer.TagTable.Add(tag); }
public void OpenSourceFile(List <CodeRecord> recs) { if (recs.Count == 0) { return; } var filename = recs [0].SourceFile; var origfile = filename; var fbname = System.IO.Path.GetFileName(filename); if (openFiles.Contains(filename)) { return; } if (fsmap.SourceMap.ContainsKey(filename)) { filename = fsmap.SourceMap[filename]; } while (!File.Exists(filename)) { var fc = new FileChooserDialog("Locate source file " + origfile, this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select", ResponseType.Apply); fc.Filter = new Gtk.FileFilter() { Name = fbname }; fc.Filter.AddPattern(fbname); fc.Response += (o, args) => { Console.Error.WriteLine(fc.Filename); fc.Hide(); }; fc.Run(); if (fc.Filename != null) { filename = System.IO.Path.Combine(fc.Filename, fbname); } else { return; } } fsmap.AddMapping(origfile, filename); openFiles.Add(origfile); SourceLanguage language = sourceManager.GetLanguage("c-sharp"); var buf = new SourceBuffer(language); TextTag visitedOnce = new TextTag("visited_once") { Background = VisitedOnceBG }; TextTag visitedMore = new TextTag("visited_more") { Background = VisitedMoreBG }; buf.TagTable.Add(visitedOnce); buf.TagTable.Add(visitedMore); buf.HighlightSyntax = true; buf.Text = System.IO.File.ReadAllText(filename); var page = new SourcePage(); var sv = new SourceView(buf); // sv.ScrollToIter (buf.GetIterAtLineOffset (22, 0), 1.1, false, 0.0, 0.0); sv.HighlightCurrentLine = true; sv.Editable = false; sv.ShowLineNumbers = true; var fp = System.IO.Path.GetFullPath(filename); page.Window.Add(sv); page.SetHeadingText(fp); page.SetSubHeadingText(""); var fname = System.IO.Path.GetFileName(filename); var tab = CloserTabLabel.InsertTabPage(notebook1, page, fname); tab.CloseKeyData = filename; page.ShowAll(); int total_lines = 0; int covered_lines = 0; buf.Text = File.ReadAllText(filename); foreach (var rec in recs) { RenderCoverage(buf, rec); total_lines += rec.GetLines().Length; covered_lines += rec.GetHits(); } double cov = (1.0 * covered_lines) / total_lines; page.SetCoverage(cov); notebook1.Page = notebook1.NPages - 1; sourceviews [filename] = sv; }
/// <summary> /// Reads the next tag from the tokens. /// </summary> private ITag Read() { ITag t = null; if (IsTagStart()) { Token t1, t2; t1 = t2 = GetToken(); TokenCollection tc = new TokenCollection(); do { this.index++; t2.Next = GetToken(); t2 = t2.Next; tc.Add(t2); } while (!IsTagEnd()); tc.Remove(tc.Last); this.index++; //if (tc.Count == 1 && tc[0] != null && tc[0].TokenKind == TokenKind.Comment) //{ // return new TextTag(); //} try { t = Read(tc); } catch (Exception.TemplateException) { throw; } catch (System.Exception e) { throw new Exception.ParseException(string.Concat("Parse error:", tc, "\r\nError message:", e.Message), tc.First.BeginLine, tc.First.BeginColumn);//标签分析异常 } if (t != null) { t.FirstToken = t1; if (t.Children.Count == 0 || t.LastToken == null || t2.CompareTo(t.LastToken) > 0) { t.LastToken = t2; } } else { throw new Exception.ParseException(string.Concat("Unexpected tag:", tc), tc.First.BeginLine, tc.First.BeginColumn); //未知的标签 } } else { t = new TextTag(); t.FirstToken = GetToken(); t.LastToken = null; this.index++; } return(t); }
/// <summary>Constructs the argument with input text.</summary> /// <param name="_text">The input text.</param> /// <param name="wasquoted">Whether the argument was quoted at input time.</param> /// <param name="perfect">Whether the argument must parse back "perfectly" (meaning, it will ToString to the exact original input).</param> /// <param name="_engine">The backing script engine.</param> public TextArgumentBit(string _text, bool wasquoted, bool perfect, ScriptEngine _engine) { Engine = _engine; if (wasquoted) { InputValue = new TextTag(_text); ResType = TextTag.TYPE; return; } else if (_text == "true") { InputValue = BooleanTag.TRUE; ResType = BooleanTag.TYPE; return; } else if (_text == "false") { InputValue = BooleanTag.FALSE; ResType = BooleanTag.TYPE; return; } else if (_text == "&{NULL}") { InputValue = NullTag.NULL_VALUE; ResType = NullTag.TYPE; return; } else if (long.TryParse(_text, out long ti) && ti.ToString() == _text) { InputValue = new IntegerTag(ti); ResType = IntegerTag.TYPE; return; } else if (double.TryParse(_text, out double tn) && (!perfect || tn.ToString() == _text)) { InputValue = new NumberTag(tn); ResType = NumberTag.TYPE; return; } else if (_text.Contains('|')) { if (_text.Contains(':')) { MapTag map = MapTag.For(_text); if (map.ToString() == _text) { InputValue = map; ResType = MapTag.TYPE; return; } } ListTag list = ListTag.For(_text); if (list.ToString() == _text) { InputValue = list; ResType = ListTag.TYPE; return; } } InputValue = new TextTag(_text); ResType = TextTag.TYPE; }
private void UpdateGameDetails(TextBuffer buffer, ref TextIter iter) { PrintTitle (buffer, ref iter); if (game == null) return; if (game.Comment != null) { buffer.InsertWithTags (ref iter, game.Comment, commentTag); buffer.Insert (ref iter, "\n"); } int i = 0; int moveno = 1; foreach (PGNChessMove move in game.Moves) { if (i % 2 == 0) { buffer.InsertWithTags (ref iter, moveno. ToString (), movenumberTag); moveno++; buffer.Insert (ref iter, ". "); } string markstr = i.ToString (); string text = move.DetailedMove; buffer.CreateMark (markstr, iter, true); // left gravity TextTag link_tag = new TextTag (null); tag_links[link_tag] = i; taglinks.Add (link_tag); buffer.TagTable.Add (link_tag); buffer.InsertWithTags (ref iter, text, moveTag, link_tag); marks[markstr] = text.Length; buffer.Insert (ref iter, " "); if (move.comment != null) { buffer.Insert (ref iter, "\n"); buffer.InsertWithTags (ref iter, FormatComment (move. comment), commentTag); buffer.Insert (ref iter, "\n"); } i++; } }
public override void VisitTextTag(TextTag tag) { if (currentBuilder == null) return; switch (currentMarkerClass) { case Marker.ExceptionTypeClass: currentBuilder.Type.Append(tag.Text); break; case Marker.ExceptionMessageClass: currentBuilder.Message.Append(tag.Text); break; case Marker.ExceptionPropertyNameClass: FlushExceptionProperty(string.Empty); currentExceptionPropertyName = tag.Text; break; case Marker.ExceptionPropertyValueClass: FlushExceptionProperty(tag.Text); break; case Marker.StackTraceClass: currentBuilder.StackTrace.Append(tag.Text); break; } }