private void btnMute_Click(object sender, EventArgs e) { var pid = Process.GetCurrentProcess().Id; bool muted = !(VolumeMixer.GetApplicationMute(pid) ?? false); VolumeMixer.SetApplicationMute(pid, muted); muted = VolumeMixer.GetApplicationMute(pid) ?? false; if (muted) { this.btnMute.BackgroundImage = Properties.Resources.Muted; } else { this.btnMute.BackgroundImage = Properties.Resources.Volume; } Settings.Application_Muted.Value = muted; }
public frmMain() { InitializeComponent(); frmMain.Instance = this; this.Text = Const.ApplicationName; MessageProvider.Instance.SetProvider(this); InitializeTabs(); Helper.SetRegistryFeatureBrowserEmulation(); Helper.PrepareBrowser(frmMain.Instance?.Browser); Action <bool> UpdateLayout = null; UpdateLayout = (x) => { var browser = frmMain.Instance?.Browser; if (this.InvokeRequired) { this.Invoke(UpdateLayout); return; } if (Settings.VerticalMode.Value) { panelBrowser.Dock = DockStyle.Top; if (!Settings.BattleInfoLayout.Value) { browser.Left = panelBrowser.ClientSize.Width / 2 - browser.ClientSize.Width / 2; } else { browser.Left = 0; panelRemain.Padding = new Padding(browser.Width + 4, 0, 0, 0); contentBattle.Invalidate(); } } else { panelBrowser.Dock = DockStyle.Left; browser.Left = 0; panelRemain.Padding = new Padding(0, browser.Height + 4, 0, 0); } if (x) { if (Settings.BattleInfoLayout.Value) { if (CurrentTab == "Battle") { UpdateTab("General"); } if (contentBattle.Parent != null) { contentBattle.Parent.Controls.Remove(contentBattle); } panelRemain.Controls.Add(contentBattle); panelRemain.Visible = true; tabBattle.Visible = false; } else { panelRemain.Controls.Remove(contentBattle); tabBattle.Visible = true; } } }; panelBrowser.Resize += (s, e) => UpdateLayout(false); Translator.Initialize(); DataStorage.Instance.Initialize(); DataStorage.Instance.PropertyEvent(nameof(DataStorage.Initialized), () => { this.contentGeneral.SetHomeport(DataStorage.Instance.Homeport); this.contentFleets.SetHomeport(DataStorage.Instance.Homeport); }); Settings.VerticalMode.PropertyEvent(nameof(Settings.VerticalMode.Value), () => UpdateLayout(true), true); Settings.BattleInfoLayout.PropertyEvent(nameof(Settings.BattleInfoLayout.Value), () => UpdateLayout(true), true); { int x = this.Left, y = this.Top; int w = this.Width, h = this.Height; int state = (int)this.WindowState; if (Settings.Application_X.Value != int.MinValue) { x = Settings.Application_X.Value; } if (Settings.Application_Y.Value != int.MinValue) { y = Settings.Application_Y.Value; } if (Settings.Application_Width.Value != int.MinValue) { w = Settings.Application_Width.Value; } if (Settings.Application_Height.Value != int.MinValue) { h = Settings.Application_Height.Value; } if (Settings.Application_State.Value != int.MinValue) { state = Settings.Application_State.Value; } this.StartPosition = FormStartPosition.Manual; this.WindowState = (FormWindowState)state; this.Location = new Point(x, y); this.Size = new Size(w, h); } this.Move += (s, e) => { Settings.Application_State.Value = (int)this.WindowState; if (this.WindowState != FormWindowState.Maximized) { Settings.Application_X.Value = this.Left; Settings.Application_Y.Value = this.Top; } }; this.Resize += (s, e) => { Settings.Application_State.Value = (int)this.WindowState; if (this.WindowState != FormWindowState.Maximized) { Settings.Application_Width.Value = this.Width; Settings.Application_Height.Value = this.Height; } }; this.FormClosing += (s, e) => { if (DataStorage.Instance?.IsInSortie ?? false) { if (MessageBox.Show("정말로 종료하시겠습니까?", Const.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { e.Cancel = true; } } }; this.FormClosed += (s, e) => Application.Exit(); VolumeMixer.SetApplicationMute( Process.GetCurrentProcess().Id, Settings.Application_Muted.Value ); Settings.AlwaysOnTop.PropertyEvent(nameof(Settings.AlwaysOnTop.Value), () => this.TopMost = Settings.AlwaysOnTop.Value, true); Proxy.Instance.Register(e => { if (!e.Request.PathAndQuery.StartsWith("/kcsapi/")) { return; } var x = e.TryParse(false); if (x == null || !x.IsSuccess) { MessageProvider.Instance.Submit( string.Format( "서버에서 {0} 오류를 전달했습니다.", x?.RawData.api_result ?? -1 ), Const.ApplicationName ); } }); this.Show(); logger = new Logger(); openDB = new OpenDB(); }