private void ShowHiddenWindow(int?width, int?height, int?top, int?left, System.Windows.Forms.FormWindowState windowState) { HiddenWindow = new HiddenForm(); HiddenWindow.Load += HiddenWindow_Load; HiddenWindow.Activated += HiddenWindow_Activated; if (left.HasValue || top.HasValue) { HiddenWindow.StartPosition = System.Windows.Forms.FormStartPosition.Manual; } if (top.HasValue) { HiddenWindow.Top = top.Value; } if (left.HasValue) { HiddenWindow.Left = left.Value; } if (width.HasValue) { HiddenWindow.Width = width.Value; } if (height.HasValue) { HiddenWindow.Height = height.Value; } HiddenWindow.WindowState = windowState; HiddenWindow.Show(); System.Windows.Threading.Dispatcher.Run(); }
protected override void OnSizeChanged( EventArgs e ) { base.OnSizeChanged( e ); if ( mWindowState != this.WindowState ) { if ( WindowStateChanged != null ) { WindowStateChanged.Invoke( this, new EventArgs() ); } } mWindowState = this.WindowState; }
public static void MinimizeApplicationForm() { if (ApplicationForm == null) { return; } if (ApplicationForm.WindowState != System.Windows.Forms.FormWindowState.Minimized) { appstate = ApplicationForm.WindowState; ApplicationForm.WindowState = System.Windows.Forms.FormWindowState.Minimized; } }
public void Update(System.Drawing.Point location, System.Windows.Forms.FormWindowState state) { if (state != System.Windows.Forms.FormWindowState.Minimized) { State = state; } if (state != System.Windows.Forms.FormWindowState.Normal) { return; } Location = location; return; }
public void Update(System.Drawing.Size size, System.Windows.Forms.FormWindowState state) { if (state != System.Windows.Forms.FormWindowState.Minimized) { State = state; } if (state != System.Windows.Forms.FormWindowState.Normal) { return; } Size = size; return; }
private void popup_mode() { saved_state = this.WindowState; saved_topMost = this.TopMost; this.WindowState = System.Windows.Forms.FormWindowState.Normal; this.TopMost = true; saved_width = this.Width; saved_height = this.Height; saved_opacity = this.Opacity; saved_style = this.FormBorderStyle; this.Width = 800; this.Height = 300; this.Opacity = 0.90; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20)); }
private void popup_mode() { saved_state = this.WindowState; saved_topMost = this.TopMost; this.WindowState = System.Windows.Forms.FormWindowState.Normal; this.TopMost = true; saved_width = this.Width; saved_height = this.Height; saved_opacity = this.Opacity; saved_style = this.FormBorderStyle; this.Width = 800; this.Height = 300; this.Opacity = 0.90; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20)); }
/// <summary> /// 程序已经被启动显示当前主窗口 /// </summary> /// <param name="eventArgs"></param> protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) { // Subsequent launches base.OnStartupNextInstance(eventArgs); if (WPFApplication != null) { System.Windows.WindowState windowState = WPFApplication.MainWindow.WindowState; WPFApplication.MainWindow.WindowState = System.Windows.WindowState.Minimized; WPFApplication.MainWindow.Show(); WPFApplication.MainWindow.Activate(); WPFApplication.MainWindow.Focus(); WPFApplication.MainWindow.WindowState = windowState; } else if (this.ApplicationContext.MainForm != null) { System.Windows.Forms.FormWindowState formWindowState = this.ApplicationContext.MainForm.WindowState; this.ApplicationContext.MainForm.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.ApplicationContext.MainForm.Show(); this.ApplicationContext.MainForm.Activate(); this.ApplicationContext.MainForm.Focus(); this.ApplicationContext.MainForm.WindowState = formWindowState; } }
/// <summary> /// Enters fake full-screen mode. This method is thread-safe. /// </summary> /// <param name="resolution">The screen resolution to enter fake fullscreen mode in.</param> /// <returns>Whether the operation succeeded.</returns> public bool GoFakeFullScreen(DisplayResolution resolution) { bool succeeded = true; try { DisplayDevice.Default.ChangeResolution(resolution); } catch (GraphicsModeException) { succeeded = false; } if (!this.InFakeFullScreen && succeeded) { this.oldBorderStyle = this.FakeFullScreenForm.GetFormBorderStyle(); this.FakeFullScreenForm.SetFormBorderStyle(System.Windows.Forms.FormBorderStyle.None); this.oldWindowState = this.FakeFullScreenForm.GetWindowState(); this.FakeFullScreenForm.SetWindowState(System.Windows.Forms.FormWindowState.Maximized); this.FakeFullScreenForm.BringToFrontSafe(); this.InFakeFullScreen = true; } return succeeded; }
/// <summary> /// Метод сохранения формы в конфиг /// </summary> /// <param name="FormName">Имя формы</param> /// <param name="StartPos">Позиция при создании формы</param> /// <param name="Location">Последнее местоположение</param> /// <param name="Size">Размер формы</param> /// <param name="WinState">Состояние окна(мин, макс, хайд)</param> public void SaveResizedForm(string FormName, System.Windows.Forms.FormStartPosition StartPos, System.Drawing.Point Location, System.Drawing.Size Size, System.Windows.Forms.FormWindowState WinState) { if ((_settings as IFormsSettingsForSettings) == null) { return; } if ((_settings as IFormsSettingsForSettings).Forms == null) { (_settings as IFormsSettingsForSettings).Forms = new FormsSettings(); } FormProperties fSettings = (_settings as IFormsSettingsForSettings).Forms.FindFormByName(FormName); bool add = false; if (fSettings == null) { fSettings = new FormProperties(); add = true; } fSettings.FormName = FormName; fSettings.StartPosition = StartPos; fSettings.FormLocation = Location; fSettings.FormSize = Size; fSettings.FormState = WinState; if (add) { (_settings as IFormsSettingsForSettings).Forms.Add(fSettings); } Save(); }
private static PInvoke.ShowWindowCommand WindowStateToSW(System.Windows.Forms.FormWindowState state) => (PInvoke.ShowWindowCommand)state;
public void Save(System.Windows.Forms.Form form) { if (form.WindowState == System.Windows.Forms.FormWindowState.Normal) { Width = form.Width; Height = form.Height; Left = form.Left; Top = form.Top; } state = form.WindowState; }
static void Main(string[] args) { // required by DirectPlay Voice System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; // depending on the command line arguments, we launch a client or a server if (args.Length == 2 && args[0] == "-s") { // launch standalone server int port = int.Parse(args[1]); using (IServer server = new DXServer()) { server.Start((VoiceServerMode)Settings.Default.VoiceServerMode, port); } } else { // configure ZunTzu to handle .ztb, .ztg and .zts files installFileAssociations(); // parse command line parameters or URL parameters string fileToOpen = parseParameters(args); // launch client System.Windows.Forms.Application.EnableVisualStyles(); #if !DEBUG try { #endif // retrieve user settings DisplayProperties displayProperties; displayProperties.TextureQuality = (TextureQualityType)Settings.Default.DisplayTextureFormat; displayProperties.MapsAndCountersDetailLevel = (DetailLevelType)Settings.Default.DisplayMapAndCounterDetail; displayProperties.WaitForVerticalBlank = Settings.Default.DisplayWaitForVerticalBlank; displayProperties.PreferredFullscreenMode = Settings.Default.DisplayPreferedFullscreenMode; displayProperties.DiceModelsDetailLevel = (ModelDetailType)Settings.Default.DisplayDiceModelComplexity; displayProperties.GameAspectRatio = (Settings.Default.DisplayWidescreen ? AspectRatioType.SixteenToTen : AspectRatioType.FourToThree); AudioProperties audioProperties; audioProperties.MuteAll = Settings.Default.VoiceMuteAll; audioProperties.MuteSoundEffects = Settings.Default.AudioDisableSoundEffects; audioProperties.MuteRecording = Settings.Default.VoiceMuteRecording; audioProperties.MutePlayback = Settings.Default.VoiceMutePlayback; audioProperties.UseVoiceActivation = true; audioProperties.AdjustActivationThresholdAutomatically = false; audioProperties.ActivationThreshold = Settings.Default.VoiceActivationThreshold; audioProperties.ActivateEchoSuppression = Settings.Default.VoiceEchoSuppression; audioProperties.UseAutomaticJitterControl = Settings.Default.VoiceAutomaticJitterControl; audioProperties.JitterControl = Settings.Default.VoiceJitterBuffer; audioProperties.DisableAutomaticGainControl = true; audioProperties.DisableAutoconfiguration = Settings.Default.VoiceDisableAudioMixerAutoconfig; audioProperties.MicrophoneInputLevel = Settings.Default.VoiceMicrophoneInputLevel; Size windowSize = Settings.Default.DisplayWindowSize; System.Windows.Forms.FormWindowState windowState = (Settings.Default.DisplayMaximizeWindow ? System.Windows.Forms.FormWindowState.Maximized : System.Windows.Forms.FormWindowState.Normal); string playerFirstName = Settings.Default.PlayerFirstName; string playerLastName = Settings.Default.PlayerLastName; Guid playerGuid = Settings.Default.PlayerId; if (playerGuid == Guid.Empty) { // assign a unique persistent id to this player do { playerGuid = Guid.NewGuid(); } while(playerGuid == Guid.Empty); Settings.Default.PlayerId = playerGuid; Settings.Default.Save(); } if (Settings.Default.Language != "") { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(Settings.Default.Language); } // initialize mainForm, model, view, controller using (MainForm mainForm = new MainForm(windowSize, windowState)) { IModel model = new Model(mainForm, audioProperties, playerFirstName, playerLastName, playerGuid); IView view = new View(model, mainForm, displayProperties); IController controller = new Controller(model, mainForm, view); IPrecisionTimer precisionTimer = new PrecisionTimer(); model.OpenGameBox(model.GameLibrary.DefaultGameBox); model.CurrentGameBox.OpenBuiltInScenario(model.CurrentGameBox.StartupScenarioFileName); view.ResetGraphicsElements(); if (controller.AutosaveAvailable && System.Windows.Forms.MessageBox.Show( Resources.AutosaveDialogText, Resources.AutosaveDialogCaption, System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { mainForm.Show(); controller.ExecuteCommand("restoreautosave"); } else { mainForm.Show(); if (fileToOpen != null) { controller.ExecuteCommand("open " + fileToOpen); } else { view.Prompter.AddTextToHistory(0xFF00FFFF, Resources.Welcome); } } // While the form is still valid, render and process messages long currentTimeInMicroseconds = precisionTimer.NowInMicroseconds; while (mainForm.Created) { view.Render(currentTimeInMicroseconds); currentTimeInMicroseconds = precisionTimer.NowInMicroseconds; model.AnimationManager.Animate(currentTimeInMicroseconds); controller.DoEvents(currentTimeInMicroseconds); } } #if !DEBUG } catch (Exception e) { // display error message, invite to send a report try { string version = "unknown"; if (ApplicationDeployment.IsNetworkDeployed) { version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); } string reportContent = e.ToString(); // Direct3D drivers? if (reportContent.Contains("-2146232832") && reportContent.Contains("Microsoft.DirectX.Direct3D.Manager.GetDeviceCaps")) { System.Windows.Forms.MessageBox.Show( "Graphics card doesn't meet ZunTzu's minimum requirements. Are the drivers installed?", "Can't start ZunTzu", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { ErrorForm errorForm = new ErrorForm( "version " + version + "\r\n" + "os " + Environment.OSVersion.VersionString + "\r\n" + "framework " + Environment.Version.ToString() + "\r\n" + "cpu count " + Environment.ProcessorCount.ToString() + "\r\n" + reportContent); errorForm.ShowDialog(); if (errorForm.DialogResult == System.Windows.Forms.DialogResult.OK) { // send an error report to www.zuntzu.com HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://www.zuntzu.com/forum/reportcrash.php"); request.UserAgent = "ZunTzu"; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; Encoding encoding = Encoding.GetEncoding(1252); byte[] reportData = encoding.GetBytes("message=" + HttpUtility.UrlEncode( "version " + version + "\r\n" + "os " + Environment.OSVersion.VersionString + "\r\n" + "framework " + Environment.Version.ToString() + "\r\n" + "cpu count " + Environment.ProcessorCount.ToString() + "\r\n" + "[code]" + reportContent + "[/code]", encoding)); request.ContentLength = reportData.Length; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(reportData, 0, reportData.Length); } request.Timeout = 20000; WebResponse response = request.GetResponse(); } } } catch (Exception) { } } #endif } }