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() { // 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(); } }
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(); 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, ContextMenu = new WinForms.ContextMenu(new[] { new CustomMenuItem { Enabled = false, Text = "WinCompose", Scale = 1.05f, Bold = true, Gradient = true, MenuIcon = GetIcon(0), }, 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 CustomMenuItem() { Text = i18n.Text.Help }, 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; m_help_item.MenuItems.AddRange(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 }, }); SysTray.AlwaysShow("wincompose[.]exe"); 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(); } }