public void Push(InfoLevel level, string text) { Gtk.Box hbox = new Gtk.Box(Orientation.Horizontal, 6); Gtk.Image image = new Gtk.Image(imageNames[(int)level], Gtk.IconSize.SmallToolbar); hbox.Add(image); hbox.Add(new Gtk.Label(text)); base.Add(hbox); itemList.Add(hbox); this.ShowAll(); }
public MainWindow(Builder builder, IntPtr handle) : base(handle) { builder.Autoconnect(this); DeleteEvent += OnDeleteEvent; startStopCameraToggleButton.Toggled += HandleStartStopClicked; video = new VideoWidget(); video.Expand = true; box2.Add(video); video.Show(); map = new Map.FileMapWidget(); map.Expand = true; mapBox.Add(map); map.Show(); parser.FrameParsed += HandleFrameParsed; serial_port = new RS232(AppConfiguration.Instance.GetString("Communication", "PortName"), AppConfiguration.Instance.GetInt("Communication", "BaudRate")); serial_port.DataReceived += DataReceivedHandler; }
public TilesetEditor(Tileset t) { Gtk.Builder builder = new Builder(); builder.AddFromString(Helper.ReadResourceFile("LynnaLab.Glade.TilesetEditor.ui")); builder.Autoconnect(this); tilesetSpinButtonContainer = (Gtk.Box)builder.GetObject("tilesetSpinButtonContainer"); tilesetVreContainer = (Gtk.Box)builder.GetObject("tilesetVreContainer"); tilesetViewerContainer = (Gtk.Box)builder.GetObject("tilesetViewerContainer"); subTileContainer = (Gtk.Box)builder.GetObject("subTileContainer"); subTileGfxContainer = (Gtk.Box)builder.GetObject("subTileGfxContainer"); paletteEditorContainer = (Gtk.Box)builder.GetObject("paletteEditorContainer"); paletteFrameLabel = (Gtk.Label)builder.GetObject("paletteFrameLabel"); base.Child = (Gtk.Widget)builder.GetObject("TilesetEditor"); tilesetviewer1 = new TilesetViewer(); tilesetviewer1.AddTileSelectedHandler(delegate(object sender, int index) { subTileEditor.SetTileIndex(index); }); tilesetViewerContainer.Add(tilesetviewer1); subTileGfxViewer = new GfxViewer(); subTileGfxViewer.SelectionColor = CairoHelper.ConvertColor(0, 256, 0); subTileGfxViewer.AddTileSelectedHandler(delegate(object sender, int index) { if (subTileEditor != null) { subTileEditor.SubTileIndex = (byte)(index ^ 0x80); } }); subTileGfxContainer.Add(subTileGfxViewer); subTileEditor = new SubTileEditor(this); subTileContainer.Add(subTileEditor); paletteEditor = new PaletteEditor(); paletteEditorContainer.Add(paletteEditor); tilesetSpinButton = new SpinButtonHexadecimal(); tilesetSpinButtonContainer.Add(tilesetSpinButton); SetTileset(t); tilesetSpinButton.ValueChanged += TilesetSpinButtonChanged; tilesetEventWrapper.Bind <int>("TileModifiedEvent", OnTileModified); tilesetEventWrapper.Bind <EventArgs>("PaletteHeaderGroupModifiedEvent", OnPalettesChanged); }
public void InitIE(Gtk.Box w) { HoldingWidget = w; Browser = new System.Windows.Forms.WebBrowser(); w.SetSizeRequest(500, 500); Browser.Height = 500; // w.GdkWindow.FrameExtents.Height; Browser.Width = 500; // w.GdkWindow.FrameExtents.Width; Browser.Navigate("about:blank"); Browser.Document.Write(String.Empty); WebSocket = new Gtk.Socket(); WebSocket.SetSizeRequest(Browser.Width, Browser.Height); w.Add(WebSocket); WebSocket.Realize(); WebSocket.Show(); WebSocket.UnmapEvent += Socket_UnmapEvent; IntPtr browser_handle = Browser.Handle; IntPtr window_handle = (IntPtr)WebSocket.Id; NativeMethods.SetParent(browser_handle, window_handle); /// Another interesting issue is that on Windows, the WebBrowser control by default is /// effectively an IE7 browser, and I don't think you can easily change that without /// changing registry settings. The lack of JSON parsing in IE7 triggers errors in google maps. /// See https://code.google.com/p/gmaps-api-issues/issues/detail?id=9004 for the details. /// Including the meta tag of <meta http-equiv="X-UA-Compatible" content="IE=edge"/> /// fixes the problem, but we can't do that in the HTML that we set as InnerHtml in the /// LoadHTML function, as the meta tag triggers a restart of the browser, so it /// just reloads "about:blank", without the new innerHTML, and we get a blank browser. /// Hence we set the browser type here. /// Another way to get around this problem is to add JSON.Parse support available from /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON /// into the HTML Script added when loading Google Maps /// I am taking the belts-and-braces approach of doing both, primarily because the /// meta tag, while probably the technically better" solution, sometimes doesn't work. /// 10/8/17 - I've added yet another "fix" for this problem: the installer now writes a /// registry key requesting that IE 11 be used for ApsimNG.exe (and for ApsimNG.vshost.exe, /// so it also works when run from Visual Studio). Browser.DocumentText = @"<!DOCTYPE html> <html> <head> <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,10""/> </head> </html>"; }
public void InitIE(Gtk.Box w) { wb = new System.Windows.Forms.WebBrowser(); w.SetSizeRequest(500, 500); wb.Height = 500; // w.GdkWindow.FrameExtents.Height; wb.Width = 500; // w.GdkWindow.FrameExtents.Width; socket.SetSizeRequest(wb.Width, wb.Height); w.Add(socket); socket.Realize(); socket.Show(); IntPtr browser_handle = wb.Handle; IntPtr window_handle = (IntPtr)socket.Id; SetParent(browser_handle, window_handle); }
// Called when room index (or season) is changed void OnRoomChanged() { if (ActiveRoom == null) { return; } eventGroup.Lock(); roomSpinButton.Value = ActiveRoom.Index; warpEditor.SetMap(ActiveRoom.Index >> 8, ActiveRoom.Index & 0xff); SetTileset(ActiveRoomLayout.Tileset); if (roomVre == null) { // This only runs once roomVre = new ValueReferenceEditor(Project, ActiveRoom.ValueReferenceGroup); roomVre.AddWidgetToRight("Tileset", editTilesetButton); roomVreHolder.Add(roomVre); roomVre.ShowAll(); roomTilesetModifiedEventWrapper.Bind <ValueModifiedEventArgs>("ModifiedEvent", (sender, args) => SetTileset((sender as ValueReference).GetIntValue(), ActiveSeason)); } else { roomVre.ReplaceValueReferenceGroup(ActiveRoom.ValueReferenceGroup); } // Watch for changes to this room's tileset roomTilesetModifiedEventWrapper.ReplaceEventSource(ActiveRoom.ValueReferenceGroup["Tileset"]); // Watch for changes to the chest UpdateChestData(); eventGroup.Unlock(); UpdateLayoutGroupWarning(); }
// Constructor public WarpEditor(MainWindow main) { mainWindow = main; Gtk.Builder builder = new Builder(); builder.AddFromString(Helper.ReadResourceFile("LynnaLab.Glade.WarpEditor.ui")); builder.Autoconnect(this); mainVBox = (Gtk.Box)builder.GetObject("mainVBox"); destInfoLabel = (Gtk.Label)builder.GetObject("destInfoLabel"); warpSourceTypeLabel = (Gtk.Label)builder.GetObject("warpSourceTypeLabel"); valueEditorContainer = (Gtk.Container)builder.GetObject("valueEditorContainer"); destEditorContainer = (Gtk.Container)builder.GetObject("destEditorContainer"); warpSourceBoxContainer = (Gtk.Container)builder.GetObject("warpSourceBoxContainer"); warpSourceFrame = (Gtk.Frame)builder.GetObject("warpSourceFrame"); warpDestFrame = (Gtk.Frame)builder.GetObject("warpDestFrame"); infoBarHolder = (Gtk.Box)builder.GetObject("infoBarHolder"); base.Child = (Gtk.Widget)builder.GetObject("WarpEditor"); infoBar = new InfoBar(); infoBarHolder.Add(infoBar); }
public void Attach(Gtk.Orientation orientation_new) { Gtk.Box.BoxChild child = null; Box box; switch (Orientation) { case Gtk.Orientation.Vertical: box = main_hbox; break; case Gtk.Orientation.Horizontal: { box = framework_vbox; break; } default: throw new InvalidOperationException(); } bool contained = false; foreach (var ch in box.AllChildren) { if (ch == this) { contained = true; break; } } if (contained == true) { box.Remove(this); } Orientation = (Gtk.Orientation)orientation_new; switch (Orientation) { case Gtk.Orientation.Vertical: main_hbox.Add(this); main_hbox.ReorderChild(this, 0); child = ((Gtk.Box.BoxChild)(main_hbox[this])); break; case Gtk.Orientation.Horizontal: framework_vbox.Add(this); framework_vbox.ReorderChild(this, 1); child = ((Gtk.Box.BoxChild)(framework_vbox[this])); break; default: throw new InvalidOperationException(); } child.Expand = false; child.Fill = false; ShowAll(); InitCompleted = true; }
// TODO: pass in a label which it will update with the name from the combobox? public ComboBoxFromConstants(bool showHelp = true, bool vertical = false, bool showSpin = true) { this.Name = "LynnaLab.ComboBoxFromConstants"; Gtk.Box box2 = new Gtk.HBox(); box2.Spacing = 6; // Container child LynnaLab.ComboBoxFromConstants.Gtk.Container+ContainerChild if (vertical) { this.box1 = new Gtk.VBox(); } else { this.box1 = new Gtk.HBox(); } // Container child box1.Gtk.Box+BoxChild this.spinButton = new LynnaLab.SpinButtonHexadecimal(); this.spinButton.CanFocus = true; this.spinButton.Name = "spinButton"; this.spinButton.Adjustment.Upper = 255D; this.spinButton.Adjustment.PageIncrement = 16D; this.spinButton.Adjustment.StepIncrement = 1D; this.spinButton.ClimbRate = 1D; this.spinButton.Digits = 2; this.spinButton.Numeric = true; if (showSpin) { box2.Add(spinButton); box2.SetChildPacking(spinButton, expand: false, fill: false, padding: 0, pack_type: Gtk.PackType.Start); box1.Add(box2); } // Container child box1.Gtk.Box+BoxChild this.combobox1 = new Gtk.ComboBoxText(); this.combobox1.Name = "combobox1"; this.box1.Add(this.combobox1); box1.SetChildPacking(this.combobox1, false, false, 0, Gtk.PackType.Start); this.spinButton.ValueChanged += new System.EventHandler(this.OnSpinButtonValueChanged); this.combobox1.Changed += new System.EventHandler(this.OnCombobox1Changed); if (showHelp) { // When clicking the "help" button, create a popup with documentation for // possible values. (It checks for a "@values" field in the documentation.) Gtk.Button helpButton = new Gtk.Button("?"); helpButton.CanFocus = false; helpButton.Clicked += delegate(object sender, EventArgs e) { if (DefaultDocumentation == null) { return; } DocumentationDialog d = new DocumentationDialog(DefaultDocumentation); d.Run(); d.Dispose(); }; box2.PackStart(helpButton, false, false, 0); } Gtk.Frame frame = new Gtk.Frame(); frame.Add(box1); this.Add(frame); }