private static void KeyboardThread() { // Since the Composer uses a DispatcherTimer, we need to be the ones // initialising that class from our STA thread. Composer.Init(); if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.WinCE) { CheckHook(must_reinstall: true); // Create a timer to regularly check our hook m_check_timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5) }; m_check_timer.Tick += (o, e) => CheckHook(must_reinstall: true); m_check_timer.Start(); } Dispatcher.Run(); Composer.Fini(); }
static void Main() { // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); KeyboardHook.Init(); Updater.Init(); Settings.StartWatchConfigFile(); try { var app = new Application(); var icon = new SysTrayIcon(); app.Exit += (o, e) => icon.Dispose(); app.Run(); } finally { Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); Updater.Fini(); } }
static void Main() { Composer.Init(); Settings.LoadConfig(); Settings.LoadSequences(); KeyboardHook.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); m_control = new RemoteControl(); m_control.DisableEvent += OnDisableEvent; m_control.ExitEvent += OnExitEvent; m_control.TriggerDisableEvent(); m_tray_icon = new WinForms.NotifyIcon { Visible = true, Icon = Properties.Resources.IconNormal, ContextMenu = new WinForms.ContextMenu(new[] { new WinForms.MenuItem("WinCompose") { Enabled = false }, new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.ShowSequences, ShowSequencesClicked), new WinForms.MenuItem(i18n.Text.ShowOptions, ShowOptionsClicked), /* Keep a reference on this entry */ m_disable_item = new WinForms.MenuItem(i18n.Text.Disable, DisableClicked), new WinForms.MenuItem(i18n.Text.About, AboutClicked), new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.Restart, RestartClicked), new WinForms.MenuItem(i18n.Text.Exit, OnExitEvent), }) }; m_tray_icon.DoubleClick += NotifyiconDoubleclicked; Composer.Changed += ComposerStateChanged; WinForms.Application.Run(); m_tray_icon.Dispose(); } finally { Composer.Changed -= ComposerStateChanged; m_control.DisableEvent -= OnDisableEvent; m_control.ExitEvent -= OnExitEvent; Settings.StopWatchConfigFile(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); } }
static void Main(string[] args) { // Some commandline flags just trigger a message broadcast var command_flags = new Dictionary <string, MenuCommand>() { { "-sequences", MenuCommand.ShowSequences }, { "-settings", MenuCommand.ShowOptions }, }; foreach (var arg in args) { if (command_flags.TryGetValue(arg, out var cmd)) { NativeMethods.PostMessage(HWND.BROADCAST, WM_WINCOMPOSE.OPEN, (int)cmd, 0); return; } } // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); Metadata.LoadDB(); KeyboardHook.Init(); Updater.Init(); Settings.StartWatchConfigFile(); try { var app = new Application(); var icon = new SysTrayIcon(); app.Exit += (o, e) => icon.Dispose(); app.Run(); } finally { Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Metadata.SaveDB(); Composer.Fini(); Updater.Fini(); } }
static void Main() { // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); Updater.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); // Must call this after SetCompatibleTextRenderingDefault() // because it uses a WinForms timer which seems to open a // hidden window. The reason we use a WinForms timer is so that // the hook is installed from the main thread. KeyboardHook.Init(); using (SysTrayIcon icon = new SysTrayIcon()) { WinForms.Application.Run(); } } finally { Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); Updater.Fini(); } }
static void Main() { // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); KeyboardHook.Init(); Updater.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); m_control = new RemoteControl(); m_control.DisableEvent += OnDisableEvent; m_control.DisableEvent += SysTrayUpdateCallback; m_control.ExitEvent += OnExitEvent; m_control.TriggerDisableEvent(); m_tray_icon = new WinForms.NotifyIcon { Visible = true, //Icon = GetCurrentIcon(), //Text = GetCurrentToolTip(), ContextMenu = new WinForms.ContextMenu(new[] { new TitleMenuItem(), new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.ShowSequences, ShowSequencesClicked), new WinForms.MenuItem(i18n.Text.ShowOptions, ShowOptionsClicked), m_help_item = /* Keep a reference on this entry */ new WinForms.MenuItem(i18n.Text.Help, new[] { new WinForms.MenuItem(i18n.Text.About, AboutClicked), new WinForms.MenuItem(i18n.Text.VisitWebsite, delegate(object o, EventArgs e) { System.Diagnostics.Process.Start("http://wincompose.info/"); }), m_download_item = /* Keep a reference on this entry */ new WinForms.MenuItem("", DownloadClicked) { Visible = false }, }), new WinForms.MenuItem("-"), m_disable_item = /* Keep a reference on this entry */ new WinForms.MenuItem(i18n.Text.Disable, DisableClicked), new WinForms.MenuItem(i18n.Text.Restart, RestartClicked), new WinForms.MenuItem(i18n.Text.Exit, OnExitEvent), }) }; m_tray_icon.DoubleClick += NotifyiconDoubleclicked; Composer.Changed += SysTrayUpdateCallback; Updater.Changed += SysTrayUpdateCallback; SysTrayUpdateCallback(null, new EventArgs()); Updater.Changed += UpdaterStateChanged; UpdaterStateChanged(null, new EventArgs()); WinForms.Application.Run(); m_tray_icon.Dispose(); } finally { Composer.Changed -= SysTrayUpdateCallback; Updater.Changed -= SysTrayUpdateCallback; Updater.Changed -= UpdaterStateChanged; m_control.DisableEvent -= OnDisableEvent; m_control.ExitEvent -= OnExitEvent; Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); Updater.Fini(); } }