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); } }
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; }
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(); }
/// <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); }
public ModernDialog(string title, Window owner) : base(title) { this.WidthRequest = 350; this.HeightRequest = 180; this.ShowMinimize = false; this.WindowPosition = WindowPosition.None; this.KeepAbove = true; this.Modal = true; _response = ResponseType.None; if (owner != null) { int root_x, root_y; owner.GetPosition(out root_x, out root_y); this.Move(root_x + (owner.WidthRequest / 2) - (this.WidthRequest / 2), root_y + (owner.HeightRequest / 2) - (this.HeightRequest / 2)); } this.text = new global::Gtk.TextView(); this.text.WrapMode = Gtk.WrapMode.Word; this.text.CanFocus = true; this.text.Editable = false; this.text.WidthRequest = (int)(this.WidthRequest * 0.8); this.GridMain.Add(this.text); global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.text])); w2.X = 50; w2.Y = 70; this.btn1 = new Button(); this.btn1.Clicked += btn1_Clicked; this.btn1.WidthRequest = 100; this.btn1.HeightRequest = 30; this.GridMain.Add(this.btn1); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn1])); w2.X = 75; w2.Y = 120; this.btn2 = new Button(); this.btn2.Clicked += btn2_Clicked; this.btn2.WidthRequest = 100; this.btn2.HeightRequest = 30; this.GridMain.Add(this.btn2); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn2])); w2.X = 175; w2.Y = 120; this.ShowObjects(); }
public Loupe(PhotoImageView view) : base("Loupe") { this.view = view; Decorated = false; Gtk.Window win = (Gtk.Window)view.Toplevel; win.GetPosition(out old_win_pos.X, out old_win_pos.Y); win.ConfigureEvent += HandleToplevelConfigure; TransientFor = win; DestroyWithParent = true; BuildUI(); }
static void HandleMouseMove(object sender, MouseEventArgs e) { if (!can_dragging) { return; } int x = 0, y = 0; window.GetPosition(out x, out y); System.Windows.Point p = e.GetPosition(sender as UIElement); window.BeginMoveDrag(1, (int)p.X + x, (int)p.Y + y, 0); can_dragging = false; }
public static void CenterToParentWindow(this Window child, Window parent) { int width1; int height1; child.GetSize(out width1, out height1); int width2; int height2; parent.GetSize(out width2, out height2); int root_x; int root_y; parent.GetPosition(out root_x, out root_y); int x = Math.Max(0, (width2 - width1) / 2) + root_x; int y = Math.Max(0, (height2 - height1) / 2) + root_y; child.Move(x, y); }
/// <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); }
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); }); }
/// <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 ConfigWindow(Window owner) : base("config") { this.WidthRequest = 500; this.HeightRequest = 300; this.ShowMinimize = false; this.Modal = true; this.WindowPosition = Gtk.WindowPosition.None; int root_x, root_y; owner.GetPosition(out root_x, out root_y); this.Move(root_x + (owner.WidthRequest / 2) - (this.WidthRequest / 2), root_y + (owner.HeightRequest / 2) - (this.HeightRequest / 2)); this.lblPort = new global::Gtk.Label(); this.lblPort.LabelProp = "Server Port:"; this.GridMain.Add(this.lblPort); global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.lblPort])); w2.X = 40; w2.Y = 62; this.txtPort = new global::Gtk.Entry(); this.txtPort.WidthRequest = 100; this.GridMain.Add(this.txtPort); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.txtPort])); w2.X = 110; w2.Y = 60; this.cbStartup = new CheckButton(); this.cbStartup.Label = "Start the web server when the PC starts up"; this.GridMain.Add(this.cbStartup); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.cbStartup])); w2.X = 40; w2.Y = 85; this.cbMinimize = new CheckButton(); this.cbMinimize.Label = "Minimize on startup"; this.GridMain.Add(this.cbMinimize); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.cbMinimize])); w2.X = 40; w2.Y = 105; this.swNetworkCards = new ScrolledWindow(); this.swNetworkCards.WidthRequest = 400; this.swNetworkCards.HeightRequest = 100; this.swNetworkCards.ShadowType = ((global::Gtk.ShadowType)(1)); this.GridMain.Add(this.swNetworkCards); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.swNetworkCards])); w2.X = 40; w2.Y = 130; this.tNetworkCards = new Table(6, 2, false); this.tNetworkCards.RowSpacing = (6); this.tNetworkCards.ColumnSpacing = (6); global::Gtk.Viewport w1 = new global::Gtk.Viewport(); w1.ShadowType = ((global::Gtk.ShadowType)(0)); w1.Add(tNetworkCards); this.swNetworkCards.Add(w1); _lstNetworkCards = new List<NetworkCard>(); List<string> ids = Globals.ReadEnvironmentVariables(Globals.V_NetworkID); IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); NetworkInterface[] netInterfaces = NetworkInterface.GetAllNetworkInterfaces(); uint i = 0; foreach (NetworkInterface adapter in netInterfaces) { var ipProps = adapter.GetIPProperties(); foreach (var ip in ipProps.UnicastAddresses) { if (ip.Address.AddressFamily == AddressFamily.InterNetwork) { CheckButton cbNetworkCard = new CheckButton(); cbNetworkCard.Active = ids.Contains(adapter.Id); cbNetworkCard.Label = String.Format("{0} - {1}", adapter.Name, ip.Address.ToString()); this.tNetworkCards.Add(cbNetworkCard); tNetworkCards.Add(cbNetworkCard); global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.tNetworkCards[cbNetworkCard])); w3.TopAttach = i++; w3.YOptions = ((global::Gtk.AttachOptions)(4)); NetworkCard networkCard = new NetworkCard(); networkCard.ID = adapter.Id; networkCard.NetworkName = adapter.Name; networkCard.IPAddress = ip.Address.ToString(); networkCard.CheckBox = cbNetworkCard; _lstNetworkCards.Add(networkCard); } } } this.btnApply = new Button(); this.btnApply.Clicked += btnApply_Clicked; this.btnApply.Label = "Apply"; this.btnApply.WidthRequest = 100; this.GridMain.Add(this.btnApply); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.btnApply])); w2.X = 150; w2.Y = 240; this.btnCancel = new Button(); this.btnCancel.Clicked += btnCancel_Clicked; this.btnCancel.Label = "Cancel"; this.btnCancel.WidthRequest = 100; this.GridMain.Add(this.btnCancel); w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.btnCancel])); w2.X = 250; w2.Y = 240; //Apply settings txtPort.Text = Globals.ReadEnvironmentVariable<int>(Globals.V_WebServerPort).ToString(); cbStartup.Active = Globals.ReadEnvironmentVariable<bool>(Globals.V_WebServerAutoStart); cbMinimize.Active = Globals.ReadEnvironmentVariable<bool>(Globals.V_WebServerHide); this.ShowObjects(); }
/// <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); }
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; }