public static void ResizeWindows(WindowSizes ws) { var screen = ScreenHelper.GetCurrentScreenSize(Application.Current.MainWindow); double w, h; if (ws == WindowSizes.Normal) { w = 1000; h = 540; } else { w = 1152; h = 648; } if (screen.Width < w || screen.Height < h) { MainWindow.ErrorDialog("Current monitor does not have the needed resolution for large mode"); return; } Application.Current.MainWindow.Width = w; Application.Current.MainWindow.Height = h; foreach (var window in _childs) { window.Width = w; window.Height = h; } }
public static IWebDriver SetWindowSize(IWebDriver driver, WindowSizes windowSize) { Point size; switch (windowSize) { case WindowSizes.Unchanged: return(driver); case WindowSizes.Maximize: driver.Manage().Window.Maximize(); return(driver); case WindowSizes.Proprietary: driver.Manage().Window.Position = Point.Empty; try { string[] coords = Environment.GetEnvironmentVariable("RESOLUTION").Split(','); size = new Point(int.Parse(coords[0]), int.Parse(coords[1])); driver.Manage().Window.Size = new Size(size); return(driver); } catch { driver.Manage().Window.Maximize(); return(driver); } default: return(driver); } }
public static void Save() { try { Directory.CreateDirectory(SettingsDir); var ms = new MemoryStream(); var xw = new XmlTextWriter(ms, Encoding.UTF8); xw.Formatting = Formatting.Indented; xw.WriteStartDocument(); xw.WriteStartElement("settings"); xw.WriteElementString("BackgroundColor", BackgroundColor.ToArgb().ToString()); xw.WriteElementString("Email", Email); xw.WriteElementString("Delay", ((int)Delay.TotalMilliseconds).ToString()); xw.WriteElementString("active_skin", ActiveSkin?.Path ?? ""); xw.WriteElementString("active_dev_path", GetActiveController()?.DevicePath ?? ""); xw.WriteStartElement("skin_settings"); foreach (var skin in Skins) { xw.WriteStartElement("skin"); xw.WriteAttributeString("skin_path", skin.Path); if (WindowSizes.ContainsKey(skin)) { var sz = WindowSizes[skin]; xw.WriteAttributeString("window_size", $"{sz.Width}x{sz.Height}"); } xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteStartElement("arduino_mapping"); foreach (var mapEntry in ArduinoMapping) { xw.WriteStartElement("map"); xw.WriteAttributeString("port", mapEntry.Key); xw.WriteAttributeString("type", mapEntry.Value.ToString()); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndElement(); // settings xw.WriteEndDocument(); xw.Flush(); xw.Close(); File.WriteAllBytes(SettingsFile, ms.ToArray()); ms.Dispose(); } catch (IOException exc) { MessageBox.Show("IO Error while saving: " + exc); } catch (XmlException exc) { MessageBox.Show("XML Error while saving: " + exc); } catch (Exception exc) { MessageBox.Show("Unknown Error while saving: " + exc); } }
public static IWebDriver GetLocalWebDriver(EdgeOptions options, WindowSizes windowSize = WindowSizes.Maximize) { if (!Platform.CurrentPlatform.IsPlatformType(PlatformType.WinNT)) { throw new PlatformNotSupportedException("Microsoft Edge is only available on Microsoft Windows."); } IWebDriver driver = new EdgeDriver(options); return(SetWindowSize(driver, windowSize)); }
/// <summary> /// Window Size /// </summary> /// <param name="type"></param> /// <param name="frm"></param> public void WindowSize(WindowSizes type, Form frm, string ini) { if (!string.IsNullOrEmpty(frm.Name)) { if (type == WindowSizes.Loading) { frm.Left = IniFileHelper.ReadIniInt(ini, frm.Name, "Left", frm.Left); frm.Top = IniFileHelper.ReadIniInt(ini, frm.Name, "Top", frm.Top); frm.Width = IniFileHelper.ReadIniInt(ini, frm.Name, "Width", frm.Width); frm.Height = IniFileHelper.ReadIniInt(ini, frm.Name, "Height", frm.Height); } else { IniFileHelper.WriteIni(ini, frm.Name, "Left", frm.Left.ToString()); IniFileHelper.WriteIni(ini, frm.Name, "Top", frm.Top.ToString()); IniFileHelper.WriteIni(ini, frm.Name, "Width", frm.Width.ToString()); IniFileHelper.WriteIni(ini, frm.Name, "Height", frm.Height.ToString()); } } }
public static IWebDriver GetLocalWebDriver(FirefoxOptions options, WindowSizes windowSize = WindowSizes.Maximize) { IWebDriver driver = new FirefoxDriver(DriverPath, options); return(SetWindowSize(driver, windowSize)); }
public static void ResizeWindows(WindowSizes ws) { var screen = ScreenHelper.GetCurrentScreenSize(Application.Current.MainWindow); double w, h; if (ws == WindowSizes.Normal) { w = 960; h = 540; } else { w = 1152; h = 648; } if (screen.Width < w || screen.Height < h) { MainWindow.ErrorDialog("Current monitor does not have the needed resolution for large mode"); return; } Application.Current.MainWindow.Width = w; Application.Current.MainWindow.Height = h; foreach (var window in _childs) { window.Width = w; window.Height = h; } }