public static void CenterChildToParent(Gtk.Window parent, Gtk.Window child) { if (parent == null || child == null) { return; } int parentX = 0; int parentY = 0; int parentW = 0; int parentH = 0; parent.GetPosition(out parentX, out parentY); parent.GetSize(out parentW, out parentH); int w = 0; int h = 0; child.GetSize(out w, out h); var x = parentX + Convert.ToInt32((parentW - w) / 2); var y = parentY + Convert.ToInt32((parentH - h) / 2); if (x <= 0) { x = 0; } if (y <= 0) { y = 0; } child.Move(x, y); child.KeepAbove = true; }
public static void SaveConfiguration() { SteticMain.Configuration.WidgetLibraries.Clear(); SteticMain.Configuration.WidgetLibraries.AddRange(SteticApp.GetWidgetLibraries()); MainWindow.GetPosition(out Configuration.WindowX, out Configuration.WindowY); MainWindow.GetSize(out Configuration.WindowWidth, out Configuration.WindowHeight); Configuration.WindowState = MainWindow.GdkWindow.State; Configuration.ShowNonContainerWarning = SteticApp.ShowNonContainerWarning; string file = Path.Combine(SteticMain.ConfigDir, "configuration.xml"); try { if (!Directory.Exists(SteticMain.ConfigDir)) { Directory.CreateDirectory(SteticMain.ConfigDir); } using (StreamWriter sw = new StreamWriter(file)) { XmlSerializer ser = new XmlSerializer(typeof(Configuration)); ser.Serialize(sw, Configuration); } } catch (Exception ex) { // Ignore exceptions while writing the recents file Console.WriteLine(ex); } }
void Close() { int x, y, width, height; mainWindow.GetPosition(out x, out y); mainWindow.GetSize(out width, out height); bool maximized = ((mainWindow.GdkWindow.State & Gdk.WindowState.Maximized) > 0); Preferences.Set(Preferences.MAIN_WINDOW_MAXIMIZED, maximized); if (!maximized) { Preferences.Set(Preferences.MAIN_WINDOW_X, x); Preferences.Set(Preferences.MAIN_WINDOW_Y, y); Preferences.Set(Preferences.MAIN_WINDOW_WIDTH, width); Preferences.Set(Preferences.MAIN_WINDOW_HEIGHT, height); } Preferences.Set(Preferences.MAIN_WINDOW_HPANED, hpaned1.Position); Preferences.Set(Preferences.BROWSER_SELECTION, ldapTreeView.BrowserSelectionMethod); #if ENABLE_AVAHI finder.Stop(); #endif program.Quit(); }
private void SaveAllProgramSettings() { WindowAttrStruct windowAttr; mainWindow.GetSize(out (windowAttr.Width), out (windowAttr.Height)); mainWindow.GetPosition(out (windowAttr.X), out (windowAttr.Y)); config.Window = windowAttr; config.SaveProgramSettings(); }
/* * * PRETTY THINGS * */ public static void ResizeIfNeeded(Gtk.Window win) { int winX, winY; win.GetSize(out winX, out winY); int maxY = ScreenHeightFitted(true); if (winY > maxY) { win.Resize(winX, maxY); } }
/// <summary>Centers a window relative to its parent.</summary> static void CenterWindow(Gtk.Window child, Gtk.Window parent) { child.Child.Show(); int w, h, winw, winh, x, y, winx, winy; child.GetSize(out w, out h); parent.GetSize(out winw, out winh); parent.GetPosition(out winx, out winy); x = Math.Max(0, (winw - w) / 2) + winx; y = Math.Max(0, (winh - h) / 2) + winy; child.Move(x, y); }
void showHideSide(sideModes newSideMode) { /* * Window size A * Store window size just before showing side content store gui size. */ if (sideMode == sideModes.HIDDEN) { encoder_configuration.GetSize(out windowWidth, out windowHeight); } //update sideMode value sideMode = newSideMode; //change gui if (sideMode == sideModes.MANAGE) { notebook_side.CurrentPage = 0; } else if (sideMode == sideModes.CAPTUREINERTIAL) { notebook_side.CurrentPage = 1; } notebook_side.Visible = (sideMode != sideModes.HIDDEN); button_encoder_capture_inertial_cancel.Sensitive = (sideMode != sideModes.CAPTUREINERTIAL); //button_encoder_capture_inertial_finish.Sensitive = (sideMode != sideModes.CAPTUREINERTIAL); /* * Window size B * Retrieve window size when side content is hided again */ if (sideMode == sideModes.HIDDEN) { encoder_configuration.Resize(windowWidth, windowHeight); } }
/// <summary>Centers a window relative to its parent.</summary> static void CenterWindow(Gtk.Window child, Gtk.Window parent) { child.Child.Show(); int w, h, winw, winh, x, y, winx, winy; if (child.Visible) { child.GetSize(out w, out h); } else { w = child.DefaultSize.Width; h = child.DefaultSize.Height; } parent.GetSize(out winw, out winh); parent.GetPosition(out winx, out winy); x = Math.Max(0, (winw - w) / 2) + winx; y = Math.Max(0, (winh - h) / 2) + winy; child.Move(x, y); }
void OnActivateToolbar(object sender, System.EventArgs args) { int width, height; Requisition minimum_size, natural_size; toolbar.GetPreferredSize(out minimum_size, out natural_size); app_window.GetSize(out width, out height); toolbar.Visible = !toolbar.Visible; if (toolbar.Visible) { toolbar.ShowArrow = false; } toolbar_orientation_menuitem.Sensitive = toolbar.Visible; if (Preferences.Get <bool> (Preferences.ToolbarShowKey) != toolbar.Visible) { Preferences.Set <bool> (Preferences.ToolbarShowKey, toolbar.Visible); Preferences.Save(); } app_window.Resize(width, height - natural_size.Height); }
public void UpdatePosition(int iconboxWidth, Pane currentPane, Rectangle resultsOffset, Rectangle normalOffset) { Gtk.Application.Invoke(delegate { Gdk.Rectangle geo, main, results; w.GetPosition(out main.X, out main.Y); w.GetSize(out main.Width, out main.Height); geo = w.Screen.GetMonitorGeometry(GetMonitor()); main = CalculateBasePosition(geo, main, normalOffset); w.Move(main.X, main.Y); if (r == null) { return; } //position resultsWindow r.GetSize(out results.Width, out results.Height); results.Y = main.Y + main.Height + resultsOffset.Y; results.X = main.X + iconboxWidth * (int)currentPane + resultsOffset.X; r.Move(results.X, results.Y); }); }
void OnActivateToolbar(object sender, System.EventArgs args) { int width, height; Requisition requisition; requisition = toolbar.SizeRequest(); app_window.GetSize(out width, out height); toolbar.Visible = !toolbar.Visible; if (toolbar.Visible) { toolbar.ShowArrow = false; } toolbar_orientation_menuitem.Sensitive = toolbar.Visible; if (Preferences.Get <bool> (Preferences.ToolbarShowKey) != toolbar.Visible) { Preferences.Set <bool> (Preferences.ToolbarShowKey, toolbar.Visible); Preferences.Save(); } app_window.Resize(width, height - requisition.Height); }
/// <summary>Centers a window relative to its parent.</summary> static void CenterWindow (Window child, Window parent) { if (child == null || parent == null) return; child.Child.Show (); int w, h, winw, winh, x, y, winx, winy; child.GetSize (out w, out h); parent.GetSize (out winw, out winh); parent.GetPosition (out winx, out winy); x = System.Math.Max (0, (winw - w) /2) + winx; y = System.Math.Max (0, (winh - h) /2) + winy; child.Move (x, y); }
/// <summary>Centers a window relative to its parent.</summary> static void CenterWindow (Window child, Window parent) { child.Child.Show (); int w, h, winw, winh, x, y, winx, winy; child.GetSize (out w, out h); parent.GetSize (out winw, out winh); parent.GetPosition (out winx, out winy); x = Math.Max (0, (winw - w) /2) + winx; y = Math.Max (0, (winh - h) /2) + winy; child.Move (x, y); }
public static void Main(string[] args) { Node n = null; if (args.Length == 0){ Console.WriteLine ("Must specify the XML file with the data to load"); return; } try { n = LoadNodes (args [0], "Size", "Foo"); } catch { Console.WriteLine ("Unable to load {0}", args [0]); throw; } Gtk.Application.Init (); MoonlightRuntime.Init (); Gtk.Window w = new Gtk.Window ("Foo"); var v = new Gtk.VBox (false, 0); w.DeleteEvent += delegate { Gtk.Application.Quit (); }; w.SetSizeRequest (width, height); MoonlightHost h = new MoonlightHost (); v.PackStart (h, true, true, 0); var back = new Gtk.Button ("Back"); v.PackStart (back, false, false, 0); w.Add (v); w.ShowAll (); // Make it pretty, skip all levels that are just 1 element while (n.Children.Count == 1) n = n.Children [0]; // Render TreemapRenderer r = new TreemapRenderer (n, ""); r.KeyDown += delegate (object sender, KeyEventArgs e) { if (e.Key == Key.Back) r.Back (); }; back.Clicked += delegate { r.Back (); }; SetSize (r, width, height); h.Application.RootVisual = r; w.ResizeChecked += delegate(object sender, EventArgs e) { int new_width, new_heigth; w.GetSize (out new_width, out new_heigth); SetSize (r, new_width, new_heigth);; }; Gtk.Application.Run (); }
private static void getWindowSize(Gtk.Window win) { win.GetSize(out winHeight, out winWidth); }
private void ObjectToControls() { IgnoreComponentChange = true; checkbuttonEnabled.Active = Notification.Enabled; entryName.Text = Notification.Name; if (Notification is PatternNotification && (Notification as PatternNotification).PatterConfigurable) { LoadPatterns((Notification as PatternNotification).Pattern); } else { table2.Remove(labelPattern); table2.Remove(comboboxPattern); table2.Remove(buttonEditPatterns); if (Notification is DeviceNotification) { table2.NRows -= 1; } } if (Notification is DeviceNotification) { if (((DeviceNotification)Notification).BlinkStickSerial == "" || ((DeviceNotification)Notification).BlinkStickSerial == null) { if (this.DataModel.Devices.Count == 1) { deviceComboboxWidget.SelectBySerial(this.DataModel.Devices[0].Serial); } } else { deviceComboboxWidget.SelectBySerial(((DeviceNotification)Notification).BlinkStickSerial); } spinbuttonLedsFrom.Value = ((DeviceNotification)Notification).LedFirstIndex; spinbuttonLedsTo.Value = ((DeviceNotification)Notification).LedLastIndex; comboboxChannel.Active = ((DeviceNotification)Notification).LedChannel; } else { table2.Remove(labelBlinkStick); table2.Remove(deviceComboboxWidget); table2.Remove(labelLeds); table2.Remove(hboxLedConfiguration); table2.Remove(labelChannel); table2.Remove(hboxChannel); table2.NRows -= 4; } HSeparator hseparator; Type editorType = NotificationRegistry.FindEditorType(Notification.GetType()); object editorWidgetObject = null; if (editorType != null) { editorWidgetObject = Activator.CreateInstance(editorType); } if (editorWidgetObject != null && editorWidgetObject is Widget) { Widget editorWidget = (Widget)editorWidgetObject; hseparator = new HSeparator(); vbox3.PackEnd(hseparator); hseparator.ShowAll(); if (editorWidget is IEditorInterface) { editorInterface = (editorWidget as IEditorInterface); editorInterface.SetNotification(Notification); } vbox3.PackEnd(editorWidget, true, true, 0); editorWidget.SizeAllocated += (o, args) => { int x, y, w, h, myw, myh; ParentForm.GetPosition(out x, out y); ParentForm.GetSize(out w, out h); GetSize(out myw, out myh); this.GdkWindow.Move(x + (w - myw) / 2, y + (h - myh) / 2); }; editorWidget.ShowAll(); } OnDeviceComboboxWidgetDeviceChanged(null, null); hseparator = new HSeparator(); vbox3.PackEnd(hseparator); hseparator.ShowAll(); deviceComboboxWidget.Sensitive = this.ApplicationSettings.AllowModeChange; IgnoreComponentChange = false; }
public static void Main(string[] args) { Node n = null; if (args.Length == 0) { Console.WriteLine("Must specify the XML file with the data to load"); return; } try { n = LoadNodes(args [0], "Size", "Foo"); } catch { Console.WriteLine("Unable to load {0}", args [0]); throw; } Gtk.Application.Init(); MoonlightRuntime.Init(); Gtk.Window w = new Gtk.Window("Foo"); var v = new Gtk.VBox(false, 0); w.DeleteEvent += delegate { Gtk.Application.Quit(); }; w.SetSizeRequest(width, height); MoonlightHost h = new MoonlightHost(); v.PackStart(h, true, true, 0); var back = new Gtk.Button("Back"); v.PackStart(back, false, false, 0); w.Add(v); w.ShowAll(); // Make it pretty, skip all levels that are just 1 element while (n.Children.Count == 1) { n = n.Children [0]; } // Render TreemapRenderer r = new TreemapRenderer(n, ""); r.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.Key == Key.Back) { r.Back(); } }; back.Clicked += delegate { r.Back(); }; SetSize(r, width, height); h.Application.RootVisual = r; w.ResizeChecked += delegate(object sender, EventArgs e) { int new_width, new_heigth; w.GetSize(out new_width, out new_heigth); SetSize(r, new_width, new_heigth);; }; Gtk.Application.Run(); }