/// <summary> /// Returns a <see cref="WindowSizeInfo"/> for the specified <see cref="WindowSize"/>, or <c>null</c> if the /// specified <see cref="WindowSize"/> is <c>null</c>. /// </summary> /// <param name="windowSize">A <see cref="WindowSize"/>.</param> /// <returns>A <see cref="WindowSizeInfo"/> for the specified <see cref="WindowSize"/>, or <c>null</c> if the /// specified <see cref="WindowSize"/> is <c>null</c>.</returns> public static WindowSizeInfo FromWindowSize(WindowSize windowSize) { if (windowSize == null) { return null; } return windowSize.ToWindowSizeInfo(); }
public DBSettingForm(string strTitle, bool bIsModal, UserInfo objUserInfo, WindowSize objWindowSize = null, Flag objFlag = null) : base(strTitle, bIsModal, objUserInfo, objWindowSize, objFlag) { InitializeComponent(); this.Text = strTitle; }
/// <summary cref="Packet.ToString(StringOutputType)" /> public override string ToString(StringOutputType outputFormat) { var buffer = new StringBuilder(); string color = ""; string colorEscape = ""; if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored) { color = Color; colorEscape = AnsiEscapeSequences.Reset; } if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored) { // build flagstring string flags = "{"; if (Urg) { flags += "urg[0x" + System.Convert.ToString(UrgentPointer, 16) + "]|"; } if (Ack) { flags += "ack[" + AcknowledgmentNumber + " (0x" + System.Convert.ToString(AcknowledgmentNumber, 16) + ")]|"; } if (Psh) { flags += "psh|"; } if (Rst) { flags += "rst|"; } if (Syn) { flags += "syn[0x" + System.Convert.ToString(SequenceNumber, 16) + "," + SequenceNumber + "]|"; } flags = flags.TrimEnd('|'); flags += "}"; // build the output string buffer.AppendFormat("{0}[TCPPacket: SourcePort={2}, DestinationPort={3}, Flags={4}]{1}", color, colorEscape, SourcePort, DestinationPort, flags); } if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored) { // collect the properties and their value Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add("source port", SourcePort.ToString()); properties.Add("destination port", DestinationPort.ToString()); properties.Add("sequence number", SequenceNumber.ToString() + " (0x" + SequenceNumber.ToString("x") + ")"); properties.Add("acknowledgement number", AcknowledgmentNumber.ToString() + " (0x" + AcknowledgmentNumber.ToString("x") + ")"); // TODO: Implement a HeaderLength property for TCPPacket //properties.Add("header length", HeaderLength.ToString()); properties.Add("flags", "(0x" + AllFlags.ToString("x") + ")"); string flags = Convert.ToString(AllFlags, 2).PadLeft(8, '0'); properties.Add("", flags[0] + "... .... = [" + flags[0] + "] congestion window reduced"); properties.Add(" ", "." + flags[1] + ".. .... = [" + flags[1] + "] ECN - echo"); properties.Add(" ", ".." + flags[2] + ". .... = [" + flags[2] + "] urgent"); properties.Add(" ", "..." + flags[3] + " .... = [" + flags[3] + "] acknowledgement"); properties.Add(" ", ".... " + flags[4] + "... = [" + flags[4] + "] push"); properties.Add(" ", ".... ." + flags[5] + ".. = [" + flags[5] + "] reset"); properties.Add(" ", ".... .." + flags[6] + ". = [" + flags[6] + "] syn"); properties.Add(" ", ".... ..." + flags[7] + " = [" + flags[7] + "] fin"); properties.Add("window size", WindowSize.ToString()); properties.Add("checksum", "0x" + Checksum.ToString() + " [" + (ValidChecksum ? "valid" : "invalid") + "]"); properties.Add("options", "0x" + BitConverter.ToString(Options).Replace("-", "").PadLeft(12, '0')); var parsedOptions = OptionsCollection; if (parsedOptions != null) { for (int i = 0; i < parsedOptions.Count; i++) { properties.Add("option" + (i + 1).ToString(), parsedOptions[i].ToString()); } } // calculate the padding needed to right-justify the property names int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys)); // build the output string buffer.AppendLine("TCP: ******* TCP - \"Transmission Control Protocol\" - offset=? length=" + TotalPacketLength); buffer.AppendLine("TCP:"); foreach (var property in properties) { if (property.Key.Trim() != "") { buffer.AppendLine("TCP: " + property.Key.PadLeft(padLength) + " = " + property.Value); } else { buffer.AppendLine("TCP: " + property.Key.PadLeft(padLength) + " " + property.Value); } } buffer.AppendLine("TCP:"); } // append the base class output buffer.Append(base.ToString(outputFormat)); return(buffer.ToString()); }
public void Resize(WindowSize windowSize) { Resized?.Invoke(windowSize); }
/* * private void PopulateScreens() * { * settings.Screens = Screen.AllScreens.Select(s => * { * string friendlyName = s.DeviceName; * if (settings.ScreenFriendlyName) * { * try * { * string friendlyNameStr = s.DeviceFriendlyName(); * if (!String.IsNullOrEmpty(friendlyNameStr)) * { * friendlyName = friendlyNameStr; * } * } * catch { } * } * return new ScreenInfo(s.DeviceName, friendlyName); * }).ToList(); * * if (string.IsNullOrWhiteSpace(settings.Screen) && settings.Screens.Count > 0) * { * settings.Screen = settings.Screens[0].DeviceName; * } * Logger.Instance.LogMessage(TracingLevel.INFO, $"Populated {settings.Screens.Count} screens"); * }*/ private async Task MoveApplication() { if (String.IsNullOrWhiteSpace(settings.Screen)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Screen not specified."); await Connection.ShowAlert(); return; } if (settings.AppSpecific && String.IsNullOrWhiteSpace(settings.ApplicationName)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Application not specified."); await Connection.ShowAlert(); return; } if (String.IsNullOrWhiteSpace(settings.XPosition) || String.IsNullOrWhiteSpace(settings.YPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"X or Y position not specified."); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.XPosition, out int xPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid X position: {settings.XPosition}"); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.YPosition, out int yPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid Y position: {settings.YPosition}"); await Connection.ShowAlert(); return; } WindowSize windowSize = null; WindowResize windowResize = WindowResize.NoResize; if (settings.ResizeWindow) { windowResize = WindowResize.ResizeWindow; if (String.IsNullOrWhiteSpace(settings.Height) || String.IsNullOrWhiteSpace(settings.Width)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Height or Width position not specified."); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.Height, out int height)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid height: {settings.Height}"); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.Width, out int width)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid width: {settings.Width}"); await Connection.ShowAlert(); return; } windowSize = new WindowSize(height, width); } else if (settings.MaximizeWindow) { windowResize = WindowResize.Maximize; } else if (settings.MinimizeWindow) { windowResize = WindowResize.Minimize; } else if (settings.OnlyTopmost) { windowResize = WindowResize.OnlyTopmost; } Screen screen = MonitorManager.Instance.GetScreenFromUniqueValue(settings.Screen); if (screen == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"Could not find screen {settings.Screen}"); await Connection.ShowAlert(); return; } var processCount = WindowPosition.MoveProcess(new MoveProcessSettings() { AppSpecific = settings.AppSpecific, Name = settings.ApplicationName, DestinationScreen = screen, Position = new System.Drawing.Point(xPosition, yPosition), WindowResize = windowResize, WindowSize = windowSize, MakeTopmost = settings.TopmostWindow, LocationFilter = settings.ShouldFilterLocation ? settings.LocationFilter : null, TitleFilter = settings.ShouldFilterTitle ? settings.TitleFilter : null }); if (processCount > 0) { tmrRetryProcess.Stop(); } else if (processCount == 0 && !tmrRetryProcess.Enabled) { if (!Int32.TryParse(settings.RetryAttempts, out retryAttempts)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid RetryAttempts: {settings.RetryAttempts}"); return; } tmrRetryProcess.Start(); } }
/// <summary> /// Sets all of the options from an instance of the <see cref="TimerOptionsInfo"/> class. /// </summary> /// <param name="info">A <see cref="TimerOptionsInfo"/>.</param> public void Set(TimerOptionsInfo info) { if (info == null) { throw new ArgumentNullException("info"); } this.title = info.Title; this.alwaysOnTop = info.AlwaysOnTop; this.promptOnExit = info.PromptOnExit; this.doNotKeepComputerAwake = info.DoNotKeepComputerAwake; this.showTimeElapsed = info.ShowTimeElapsed; this.loopTimer = info.LoopTimer; this.popUpWhenExpired = info.PopUpWhenExpired; this.closeWhenExpired = info.CloseWhenExpired; this.shutDownWhenExpired = info.ShutDownWhenExpired; this.color = Color.FromIdentifier(info.ColorIdentifier); this.sound = Sound.FromIdentifier(info.SoundIdentifier); this.loopSound = info.LoopSound; this.windowSize = WindowSize.FromWindowSizeInfo(info.WindowSize); }
private unsafe void MedianFiltering(WindowSize windowSize) { lock (LockObject) { button1.BeginInvoke(new Action(() => { button1.Enabled = false; })); GC.Collect(); Bitmap bitmap = new Bitmap(Bitmap); BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat); int bytesPerPixel = Bitmap.GetPixelFormatSize(bitmap.PixelFormat) / 8; int heightInPixels = bitmapData.Height; int widthInBytes = bitmapData.Width * bytesPerPixel; byte* ptrFirstPixel = (byte*)bitmapData.Scan0; double progress = 0.0; List<Color> c = new List<Color>((bitmapData.Width - (Convert.ToInt32(windowSize) / 2) * 2) * (bitmapData.Height - (Convert.ToInt32(windowSize) / 2) * 2)); for (int i = 0; i < heightInPixels - Convert.ToInt32(windowSize) + 1; i++) { byte* currentLine = ptrFirstPixel + (i * bitmapData.Stride); for (int j = 0; j < widthInBytes - Convert.ToInt32(windowSize) * bytesPerPixel + bytesPerPixel; j = j + bytesPerPixel) { List<Color> colors = new List<Color>(9); for (int k = 0; k < Convert.ToInt32(windowSize); k++) { byte* currentWindowLine = currentLine + (k * bitmapData.Stride); for (int l = j; l < j + Convert.ToInt32(windowSize) * bytesPerPixel; l = l + bytesPerPixel) { colors.Add(Color.FromArgb(currentWindowLine[l + 2], currentWindowLine[l + 1], currentWindowLine[l])); } } colors.Sort((Color left, Color right) => { int leftBrightness = (left.R + left.G + left.B) / 3; int rightBrightness = (right.R + right.G + right.B) / 3; return leftBrightness.CompareTo(rightBrightness); }); c.Add(colors[colors.Count / 2]); } Interlocked.Exchange(ref progress, progress + (1.0 / (heightInPixels - Convert.ToInt32(windowSize) + 1)) * 0.5); progressBar1.BeginInvoke(new Action(() => { progressBar1.Value = Convert.ToInt32(100.0 * progress); })); } Parallel.For(Convert.ToInt32(windowSize) / 2, heightInPixels - Convert.ToInt32(windowSize) / 2, i => { byte* currentLine = ptrFirstPixel + (i * bitmapData.Stride); for (int j = bytesPerPixel * (Convert.ToInt32(windowSize) / 2); j < widthInBytes - bytesPerPixel * (Convert.ToInt32(windowSize) / 2); j = j + bytesPerPixel) { currentLine[j] = c[(bitmapData.Width - (Convert.ToInt32(windowSize) / 2) * 2) * (i - Convert.ToInt32(windowSize) / 2) + (j - bytesPerPixel * (Convert.ToInt32(windowSize) / 2)) / bytesPerPixel].B; currentLine[j + 1] = c[(bitmapData.Width - (Convert.ToInt32(windowSize) / 2) * 2) * (i - Convert.ToInt32(windowSize) / 2) + (j - bytesPerPixel * (Convert.ToInt32(windowSize) / 2)) / bytesPerPixel].G; currentLine[j + 2] = c[(bitmapData.Width - (Convert.ToInt32(windowSize) / 2) * 2) * (i - Convert.ToInt32(windowSize) / 2) + (j - bytesPerPixel * (Convert.ToInt32(windowSize) / 2)) / bytesPerPixel].R; } Interlocked.Exchange(ref progress, progress + (1.0 / (heightInPixels - Convert.ToInt32(windowSize) / 2)) * 0.5); progressBar1.BeginInvoke(new Action(() => { progressBar1.Value = Convert.ToInt32(100.0 * progress); })); }); progressBar1.BeginInvoke(new Action(() => { progressBar1.Value = 100; })); bitmap.UnlockBits(bitmapData); pictureBox1.Image = bitmap; button1.BeginInvoke(new Action(() => { button1.Enabled = true; })); } }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.promptOnExit = options.promptOnExit; this.doNotKeepComputerAwake = options.doNotKeepComputerAwake; this.showTimeElapsed = options.showTimeElapsed; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.shutDownWhenExpired = options.shutDownWhenExpired; this.theme = options.theme; this.sound = options.sound; this.loopSound = options.loopSound; this.windowTitleMode = options.windowTitleMode; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); this.OnPropertyChanged( "Title", "AlwaysOnTop", "PromptOnExit", "DoNotKeepComputerAwake", "ShowTimeElapsed", "LoopTimer", "PopUpWhenExpired", "CloseWhenExpired", "ShutDownWhenExpired", "Theme", "Sound", "LoopSound", "WindowTitleMode", "WindowSize"); }
/// <summary> /// Return a configured RemoteWebDriver of the given browser type with default settings. /// </summary> /// <param name="browser"></param> /// <param name="platformType"></param> /// <param name="windowSize"></param> /// <param name="headless"></param> /// <param name="windowCustomSize"></param> /// <returns></returns> public IWebDriver GetWebDriver(Browser browser, PlatformType platformType = PlatformType.Any, WindowSize windowSize = WindowSize.Hd, bool headless = false, Size windowCustomSize = new Size()) { if (headless && !(browser == Browser.Chrome || browser == Browser.Edge || browser == Browser.Firefox)) { Exception ex = new ArgumentException($"Headless mode is not currently supported for {browser}."); Logger.Fatal("Invalid WebDriver Configuration requested.", ex); throw ex; } switch (browser) { case Browser.Firefox: return(GetWebDriver(DriverOptionsFactory.GetRemoteDriverOptions <FirefoxOptions>(platformType, headless), windowSize, windowCustomSize)); case Browser.Chrome: return(GetWebDriver(DriverOptionsFactory.GetRemoteDriverOptions <ChromeOptions>(platformType, headless), windowSize, windowCustomSize)); case Browser.InternetExplorer: return(GetWebDriver(DriverOptionsFactory.GetRemoteDriverOptions <InternetExplorerOptions>(platformType, headless), windowSize, windowCustomSize)); case Browser.Edge: return(GetWebDriver(DriverOptionsFactory.GetRemoteDriverOptions <EdgeOptions>(platformType, headless), windowSize, windowCustomSize)); case Browser.Safari: return(GetWebDriver(DriverOptionsFactory.GetRemoteDriverOptions <SafariOptions>(platformType, headless), windowSize, windowCustomSize)); default: Exception ex = new PlatformNotSupportedException($"{browser} is not currently supported."); Logger.Fatal("Invalid WebDriver Configuration requested.", ex); throw ex; } }
/// <summary> /// Sets all of the options from an instance of the <see cref="TimerOptionsInfo"/> class. /// </summary> /// <param name="info">A <see cref="TimerOptionsInfo"/>.</param> public void Set(TimerOptionsInfo info) { if (info == null) { throw new ArgumentNullException("info"); } this.title = info.Title; this.alwaysOnTop = info.AlwaysOnTop; this.loopTimer = info.LoopTimer; this.popUpWhenExpired = info.PopUpWhenExpired; this.closeWhenExpired = info.CloseWhenExpired; this.color = Color.FromIdentifier(info.ColorIdentifier); this.sound = Sound.FromIdentifier(info.SoundIdentifier); this.loopSound = info.LoopSound; this.windowSize = WindowSize.FromWindowSizeInfo(info.WindowSize); }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.color = options.color; this.sound = options.sound; this.loopSound = options.loopSound; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); }
/// <summary> /// Set the required value for the WindowSize Enum /// </summary> /// <param name="windowSize"></param> /// <returns></returns> public WebDriverConfigurationBuilder WithWindowSize(WindowSize windowSize) { this.windowSize = windowSize; return(this); }
public static IWebDriver GetLocalWebDriver(ChromeOptions options, WindowSize windowSize = WindowSize.Hd) { IWebDriver driver = new ChromeDriver(DriverPath, options); return(SetWindowSize(driver, windowSize)); }
public void WindowSizeEnumHaveSizeReturnsCorrectValue(WindowSize windowSize, bool shouldHaveSize) { windowSize.HasDefinedSize().Should().Be(shouldHaveSize); }
//Set appnum to 100+ for study plates instead of regular apps public static GameObject NewWindow(Vector3 position, Quaternion rotation, WindowSize size, Color colour, int id, bool showFace, int appNum) { GameObject newWindow = GameObject.CreatePrimitive(PrimitiveType.Cube); newWindow.transform.position = position; newWindow.transform.rotation = rotation; newWindow.name = "window" + id.ToString(); Vector3 dimensions = Vector3.zero; switch (size) { case WindowSize.Small: dimensions = Window.WindowSizeSmall; break; case WindowSize.Medium: dimensions = Window.WindowSizeMed; break; case WindowSize.Large: dimensions = Window.WindowSizeLarge; break; } newWindow.transform.localScale = dimensions; //Add this script and set id newWindow.AddComponent("Window"); Window data = newWindow.GetComponent <Window>(); data.WindowId = id; data.cuboid = newWindow; data.homeSize = size; //Add textured face to the cube if (showFace) { GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); data.face = quad; quad.transform.parent = newWindow.transform; quad.transform.localScale = new Vector3(0.95f, 0.95f, 1); //new Vector2(dimensions.x, dimensions.y); quad.transform.localPosition = new Vector3(0, 0, -0.75f); quad.transform.localRotation = Quaternion.identity; Texture2D face; face = apps[appNum]; quad.renderer.material.mainTexture = face; //quad.renderer.material.shader = Shader.Find("Self-Illumin/Diffuse"); quad.renderer.material.shader = Shader.Find("Diffuse"); //quad.renderer.material.shader = Shader.Find("Custom/IllumOnTop"); //quad.renderer.material.shader = Shader. newWindow.renderer.material.color = StatusNormalColour; } else { newWindow.renderer.material.color = colour; } newWindow.renderer.material.shader = Shader.Find("Diffuse"); //newWindow.renderer.material.shader = Shader.Find("Self-Illumin/Diffuse"); //newWindow.renderer.material.shader = Shader.Find("Custom/IllumOnTop"); data.state = Window.WindowState.Static; //Add collider //newWindow.AddComponent<BoxCollider>(); newWindow.AddComponent <BoxCollider>(); return(newWindow); }
/// <summary> /// This is called when the vis manager is reset. /// </summary> public void Reset() { channel = Defaults.channel; windowSize = Defaults.windowSize; windowType = Defaults.windowType; m_bUseAudioListener = Defaults.useAudioListener; displaySpectrumDebug = Defaults.displaySpectrumDebug; displayDataGroupDebug = Defaults.displayDataGroupDebug; displayControllerDebug = Defaults.displayControllerDebug; debugSpectrumBarWidth = Defaults.debugSpectrumBarWidth; debugSpectrumBarHeight = Defaults.debugSpectrumBarHeight; debugRawAudioBarHeight = Defaults.debugRawAudioBarHeight; debugDataGroupBarWidth = Defaults.debugDataGroupBarWidth; debugDataGroupBarHeight = Defaults.debugDataGroupBarHeight; debugControllerBarWidth = Defaults.debugControllerBarWidth; debugControllerBarHeight = Defaults.debugControllerBarHeight; debugSeparation = Defaults.debugSeparation; debugTexture = null; }
/// <summary> /// Sets the window size to use when converting /// </summary> /// <param name="size"></param> public void SetWindowSize(WindowSize size) { switch (size) { case WindowSize.SVGA: SetDefaultArgument("--window-size", 800 + "," + 600); break; case WindowSize.WSVGA: SetDefaultArgument("--window-size", 1024 + "," + 600); break; case WindowSize.XGA: SetDefaultArgument("--window-size", 1024 + "," + 768); break; case WindowSize.XGAPLUS: SetDefaultArgument("--window-size", 1152 + "," + 864); break; case WindowSize.WXGA_5_3: SetDefaultArgument("--window-size", 1280 + "," + 768); break; case WindowSize.WXGA_16_10: SetDefaultArgument("--window-size", 1280 + "," + 800); break; case WindowSize.SXGA: SetDefaultArgument("--window-size", 1280 + "," + 1024); break; case WindowSize.HD_1360_768: SetDefaultArgument("--window-size", 1360 + "," + 768); break; case WindowSize.HD_1366_768: SetDefaultArgument("--window-size", 1366 + "," + 768); break; case WindowSize.OTHER_1536_864: SetDefaultArgument("--window-size", 1536 + "," + 864); break; case WindowSize.HD_PLUS: SetDefaultArgument("--window-size", 1600 + "," + 900); break; case WindowSize.WSXGA_PLUS: SetDefaultArgument("--window-size", 1680 + "," + 1050); break; case WindowSize.FHD: SetDefaultArgument("--window-size", 1920 + "," + 1080); break; case WindowSize.WUXGA: SetDefaultArgument("--window-size", 1920 + "," + 1200); break; case WindowSize.OTHER_2560_1070: SetDefaultArgument("--window-size", 2560 + "," + 1070); break; case WindowSize.WQHD: SetDefaultArgument("--window-size", 2560 + "," + 1440); break; case WindowSize.OTHER_3440_1440: SetDefaultArgument("--window-size", 3440 + "," + 1440); break; case WindowSize._4K_UHD: SetDefaultArgument("--window-size", 3840 + "," + 2160); break; default: throw new ArgumentOutOfRangeException(nameof(size), size, null); } }
/// <summary> /// Sets all of the options from an instance of the <see cref="TimerOptionsInfo"/> class. /// </summary> /// <param name="info">A <see cref="TimerOptionsInfo"/>.</param> public void Set(TimerOptionsInfo info) { if (info == null) { throw new ArgumentNullException("info"); } this.title = info.Title; this.alwaysOnTop = info.AlwaysOnTop; this.promptOnExit = info.PromptOnExit; this.doNotKeepComputerAwake = info.DoNotKeepComputerAwake; this.showTimeElapsed = info.ShowTimeElapsed; this.loopTimer = info.LoopTimer; this.popUpWhenExpired = info.PopUpWhenExpired; this.closeWhenExpired = info.CloseWhenExpired; this.shutDownWhenExpired = info.ShutDownWhenExpired; this.theme = Theme.FromIdentifier(info.ThemeIdentifier); this.sound = Sound.FromIdentifier(info.SoundIdentifier); this.loopSound = info.LoopSound; this.windowTitleMode = info.WindowTitleMode; this.windowSize = WindowSize.FromWindowSizeInfo(info.WindowSize); this.OnPropertyChanged( "Title", "AlwaysOnTop", "PromptOnExit", "DoNotKeepComputerAwake", "ShowTimeElapsed", "LoopTimer", "PopUpWhenExpired", "CloseWhenExpired", "ShutDownWhenExpired", "Theme", "Sound", "LoopSound", "WindowTitleMode", "WindowSize"); }
/// <summary> /// ActionBar上的启动按钮被按下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LaunchBtn_MouseDown(object sender, MouseButtonEventArgs e) { if (games.SelectedItem == null) { UI.MessageBox.QuickShow("不选择一个版本怎么玩啊 >_<\n当然也可以下一个", (MainWindow)Window.GetWindow(this), "请选择版本"); return; } TaskbarIconManager.Toast("启动游戏中..", "启动器将自动隐藏,你可以点击任务栏图标打开"); this.WindowState = WindowState.Minimized; var ver = (KMCCC.Launcher.Version)games.SelectedItem; LaunchOptions options = new LaunchOptions(); options.Mode = LaunchMode.MCLauncher; // 正版验证 if (Config.GetConfig().users[0].type == "online") { options.Authenticator = new YggdrasilLogin(Config.GetConfig().users[0].name, Config.GetConfig().users[0].pass, true); } else { options.Authenticator = new OfflineAuthenticator(Config.GetConfig().users[0].name); } // 自动选择Java string AutoSelectJavaJre() { if (Config.GetConfig().users[0].java.jre_path == null || Config.GetConfig().users[0].java.jre_path == "") { // 取64位Java列表 if (OSHelper.IsWindows64Bit) { List <JavaInfo> tankDayBitJavas = new List <JavaInfo>(); // 64Bit JavaJres, Don't talk the tank day foreach (JavaInfo javaInfo in OSHelper.GetJavaList()) { if (javaInfo.Bit == 64) // Is Bit is tank day, bye, i'm going to jail { tankDayBitJavas.Add(javaInfo); } } if (tankDayBitJavas.Count != 0) { ConfigModel cfModel = Config.GetConfig(); cfModel.users[0].java.jre_path = tankDayBitJavas[0].JavaW; Config.SaveConfig(cfModel); return(tankDayBitJavas[0].JavaW); } } if (OSHelper.GetJavaList().Count != 0) { ConfigModel cfModel = Config.GetConfig(); cfModel.users[0].java.jre_path = OSHelper.GetJavaList()[0].JavaW; Config.SaveConfig(cfModel); return(OSHelper.GetJavaList()[0].JavaW); } return(""); } else { return(Config.GetConfig().users[0].java.jre_path); } } // Java if (Config.GetConfig().users[0].java != null) { if (!Config.GetConfig().users[0].java.is_auto_memory) { options.MaxMemory = Config.GetConfig().users[0].java.max_memory; } else { if (Config.GetConfig().users[0].java.is_auto_memory) { // 自动分配内存大小 ulong AutoCalcJavaMaxMemory(string JavaWPath) { ulong giveMemory = 0; JavaInfo ji = new JavaInfo() { JavaW = JavaWPath }; ulong deviceMemory = KMCCC.Tools.SystemTools.GetTotalMemory(); deviceMemory = deviceMemory / 1024; // B -> KB deviceMemory = deviceMemory / 1024; // KB -> M if (ji.Bit != 64) { // 非64位 if (deviceMemory <= 512) { giveMemory = 128; } else if (deviceMemory <= 1024) { giveMemory = 256; } else if (deviceMemory <= 2048) { giveMemory = 512; } else { giveMemory = 1024; } } else { // 64位 if (deviceMemory <= 2048) { giveMemory = 512; } else if (deviceMemory <= 4096) { giveMemory = 2048; } else if (deviceMemory <= 8192) { giveMemory = 4096; } else if (deviceMemory <= 16384) { giveMemory = 8192; } else { giveMemory = 8192; } } return(giveMemory); } if (AutoSelectJavaJre() == "") { UI.MessageBox.QuickShow("您,请去安装Java\nJava不安装你都想和MC玩?\nJava下载地址: http://www.java.com", this); return; } else { options.MaxMemory = (int)AutoCalcJavaMaxMemory(AutoSelectJavaJre()); } } } if (Config.GetConfig().users[0].java.min_memory != 0) { options.MinMemory = Config.GetConfig().users[0].java.min_memory; } App.Core.JavaPath = AutoSelectJavaJre(); } // 判断系统是否64位然后判断Java是否64位,如果Java是32位则提示更换64位 if (Helper.OSHelper.IsWindows64Bit) { if (Config.GetConfig().users[0].javas != null) { Helper.JavaInfo ji = new Helper.JavaInfo(); ji.JavaW = App.Core.JavaPath; if (ji.Bit != 64) { int thisJavaInJavasIndex = 0; for (int i = 0; i < Config.GetConfig().users[0].javas.Length; i++) { if (Config.GetConfig().users[0].javas[i].javaw_path == App.Core.JavaPath) { thisJavaInJavasIndex = i; break; } } if (Config.GetConfig().users[0].javas[thisJavaInJavasIndex].is_no_tip_update_32bit == true) { return; } UI.MessageBox mb = new UI.MessageBox(this); mb.Title = "为了更流畅的游戏"; mb.Message = "我们检测到您的Java是32位的,但是您的系统是64位的\n而64位的Java性能更好,更适合进行游戏\n我们建议您在「设置」内更换或者在「下载Java」内下载"; mb.LeftButtonText = "我知道了,不要再提醒我了"; mb.RightButtonText = "我现在就换"; bool userWantChangeJava = false; mb.LeftButtonClick += (arg) => { ConfigModel m = Config.GetConfig(); m.users[0].javas[thisJavaInJavasIndex].is_no_tip_update_32bit = true; Config.SaveConfig(m); }; mb.RightButtonClick += (arg) => { userWantChangeJava = true; }; mb.ShowDialog(); if (userWantChangeJava) { return; } } } } options.Version = ver; options.VersionType = "AquaL"; // 自动进入服务器 if (Config.GetConfig().users[0].auto_join_server != null && Config.GetConfig().users[0].auto_join_server.address != null) { ServerInfo si = new ServerInfo(); si.Address = Config.GetConfig().users[0].auto_join_server.address; if (Config.GetConfig().users[0].auto_join_server.port != 0) { si.Port = (ushort)Config.GetConfig().users[0].auto_join_server.port; } options.Server = si; } // 设置窗口大小 if (Config.GetConfig().users[0].custom_minecraft_window_size != null) { if (Config.GetConfig().users[0].custom_minecraft_window_size.width != 0 && Config.GetConfig().users[0].custom_minecraft_window_size.height != 0) { WindowSize ws = new WindowSize(); if (Config.GetConfig().users[0].custom_minecraft_window_size.width < 0 && Config.GetConfig().users[0].custom_minecraft_window_size.height < 0) { ws.FullScreen = true; } else { ws.Height = (ushort)Config.GetConfig().users[0].custom_minecraft_window_size.height; ws.Width = (ushort)Config.GetConfig().users[0].custom_minecraft_window_size.width; } options.Size = ws; } } var result = App.Core.Launch(options); if (!result.Success) { switch (result.ErrorType) { case ErrorType.NoJAVA: UI.MessageBox.QuickShow("你系统的Java有异常,建议去重新下载最新版本安装", this, "Java 错误"); break; case ErrorType.AuthenticationFailed: UI.MessageBox.QuickShow("Minecraft正版验证失败!请检查你的账号密码", this, "验证失败"); break; case ErrorType.UncompressingFailed: UI.MessageBox mb = new UI.MessageBox(this); mb.Message = "游戏运行库文件异常,请确定是不是已经开了一个游戏。\n如果确定不是则可以试试重新下载"; mb.Title = "运行库异常"; mb.LeftButtonText = "重新下载运行库"; mb.LeftButtonClick += (args) => { mb.Close(); try { AquaL.Helper.LibrariesDownloadHelper.AutoDownloadLibraries(((KMCCC.Launcher.Version)games.SelectedItem).Id, Model.Download.Api.UsingApi); LaunchBtn_MouseDown(null, null); return; } catch { UI.MessageBox.QuickShow("版本信息获取失败!请确认已选择正确的核心版本", this); } }; mb.RightButtonText = "关闭"; mb.ShowDialog(); break; default: string writeData = "KMCCC报错信息: " + result.ErrorMessage; writeData = writeData + "\nUnix时间: " + (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; if (result.Exception != null) { writeData = writeData + "\n异常信息: " + result.Exception.Message + "\n调用堆栈: " + result.Exception.StackTrace; } try { FileStream logFs = new FileStream("aqual.log", FileMode.Create); StreamWriter logSw = new StreamWriter(logFs); logSw.Write(writeData); logSw.Flush(); logSw.Close(); logFs.Close(); UI.MessageBox.QuickShow("启动失败!请将游戏目录下的 aqual.log 文件发送给 [email protected] 尝试获得帮助! ", this, "启动错误"); } catch (Exception) { UI.MessageBox.QuickShow("启动失败!请将此窗口截图发送至 [email protected] 来寻求帮助\n" + result.ErrorMessage + "\n" + (result.Exception != null ? result.Exception.StackTrace : ""), this, "启动错误"); } break; } this.Visibility = Visibility.Visible; } }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.promptOnExit = options.promptOnExit; this.doNotKeepComputerAwake = options.doNotKeepComputerAwake; this.showTimeElapsed = options.showTimeElapsed; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.shutDownWhenExpired = options.shutDownWhenExpired; this.color = options.color; this.sound = options.sound; this.loopSound = options.loopSound; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); }
internal void UpdateWindowGuide(Vector2 size) { WindowSize.UpdateSize(size); }
/// <summary> /// Initializes a new instance of the <see cref="TimerOptions"/> class. /// </summary> public TimerOptions() { this.title = string.Empty; this.alwaysOnTop = false; this.promptOnExit = true; this.doNotKeepComputerAwake = false; this.showTimeElapsed = false; this.loopTimer = false; this.popUpWhenExpired = true; this.closeWhenExpired = false; this.shutDownWhenExpired = false; this.color = Color.DefaultColor; this.sound = Sound.DefaultSound; this.loopSound = false; this.windowSize = new WindowSize( new Rect(double.PositiveInfinity, double.PositiveInfinity, 350, 150), WindowState.Normal, WindowState.Normal, false /* isFullScreen */); }
private void WindowEventHub_Resized(WindowSize obj) { FullScreenMode = obj.InnerWidth <= 575; HandleCollapsedState(); this.Flush(); }