private static void OnDisableEvent(object sender, EventArgs e) { if (!Composer.IsDisabled()) { Composer.ToggleDisabled(); } }
private void OnDisableEvent(object sender, EventArgs e) { if (!Composer.IsDisabled()) { Composer.ToggleDisabled(); } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDisabled")); }
private static void DisableClicked(object sender, EventArgs e) { if (Composer.IsDisabled()) { m_control.TriggerDisableEvent(); } Composer.ToggleDisabled(); }
private static void ComposerStateChanged(object sender, EventArgs e) { m_tray_icon.Icon = Composer.IsDisabled() ? Properties.Resources.IconDisabled : Composer.IsComposing() ? Properties.Resources.IconActive : Properties.Resources.IconNormal; m_tray_icon.Text = Composer.IsDisabled() ? i18n.Text.DisabledToolTip : String.Format(i18n.Text.TrayToolTip, Settings.ComposeKey.Value.FriendlyName, Settings.GetSequenceCount(), Program.Version); m_disable_item.Checked = Composer.IsDisabled(); }
private static string GetCurrentToolTip() { string ret = i18n.Text.DisabledToolTip; if (!Composer.IsDisabled()) { ret = string.Format(i18n.Text.TrayToolTip, Settings.ComposeKeys.Value.FriendlyName, Settings.SequenceCount, Settings.Version); } if (Updater.HasNewerVersion()) { ret += "\n" + i18n.Text.UpdatesToolTip; } return(ret); }
private static void SysTrayUpdateCallback(object sender, EventArgs e) { m_tray_icon.Icon = GetCurrentIcon(); // XXX: we cannot directly set m_tray_icon.Text because it has an // erroneous 64-character limitation (the underlying framework has // the correct 128-char limitation). So instead we use this hack, // taken from http://stackoverflow.com/a/580264/111461 Type t = typeof(WinForms.NotifyIcon); BindingFlags hidden = BindingFlags.NonPublic | BindingFlags.Instance; t.GetField("text", hidden).SetValue(m_tray_icon, GetCurrentToolTip()); if ((bool)t.GetField("added", hidden).GetValue(m_tray_icon)) { t.GetMethod("UpdateIcon", hidden).Invoke(m_tray_icon, new object[] { true }); } m_disable_item.Checked = Composer.IsDisabled(); }
private System.Drawing.Icon GetCurrentIcon() { return(GetIcon((Composer.IsDisabled() ? 0x1 : 0x0) | (Composer.IsComposing() ? 0x2 : 0x0) | (Updater.HasNewerVersion() ? 0x4 : 0x0))); }
private void OnMenuItemClicked(object parameter) { switch (parameter as MenuCommand?) { case MenuCommand.ShowSequences: if (m_sequencewindow == null) { m_sequencewindow = new SequenceWindow(); WinForms.Integration.ElementHost.EnableModelessKeyboardInterop(m_sequencewindow); } m_sequencewindow.Show(); break; case MenuCommand.ShowOptions: if (m_optionswindow == null) { m_optionswindow = new SettingsWindow(); WinForms.Integration.ElementHost.EnableModelessKeyboardInterop(m_optionswindow); } m_optionswindow.Show(); break; case MenuCommand.About: var about_box = new AboutBox(); about_box.ShowDialog(); break; case MenuCommand.Download: var url = Settings.IsInstalled() ? Updater.Get("Installer") : Updater.Get("Portable"); System.Diagnostics.Process.Start(url); break; case MenuCommand.VisitWebsite: System.Diagnostics.Process.Start("http://wincompose.info/"); break; case MenuCommand.Disable: if (Composer.IsDisabled()) { m_control.TriggerDisableEvent(); } Composer.ToggleDisabled(); SysTrayUpdateCallback(null, new EventArgs()); break; case MenuCommand.Restart: // FIXME: there might be more cleanup to do here; but it’s probably // not worth it, because restarting the app is a hack and whatever // reason the user may have, it’s because of a bug or a limitation // in WinCompose that we need to fix. m_icon.Visible = false; WinForms.Application.Restart(); Environment.Exit(0); break; case MenuCommand.Exit: WinForms.Application.Exit(); break; } }