Пример #1
0
        public override void EndInit()
        {
            base.EndInit();

            Application.RemoteControl.DisableEvent += OnDisableEvent;
            Application.RemoteControl.ExitEvent    += OnExitEvent;
            Application.RemoteControl.BroadcastDisableEvent();

            WinForms.Application.EnableVisualStyles();
            WinForms.Application.SetCompatibleTextRenderingDefault(false);
            m_icon              = new WinForms.NotifyIcon();
            m_icon.Visible      = true;
            m_icon.Click       += NotifyiconClicked;
            m_icon.DoubleClick += NotifyiconDoubleclicked;

            // Opt-in only, as this feature is a bit controversial
            if (Settings.KeepIconVisible.Value)
            {
                SysTray.AlwaysShow("wincompose[.]exe");
            }

            Composer.Changed += SysTrayUpdateCallback;
            Updater.Changed  += SysTrayUpdateCallback;
            SysTrayUpdateCallback();

            Updater.Changed += UpdaterStateChanged;
            UpdaterStateChanged();
        }
Пример #2
0
        public override void EndInit()
        {
            base.EndInit();

            Application.RemoteControl.DisableEvent += OnDisableEvent;
            Application.RemoteControl.ExitEvent    += OnExitEvent;
            Application.RemoteControl.OpenEvent    += OnOpenEvent;
            Application.RemoteControl.BroadcastDisableEvent();

            TrayMouseDoubleClick += NotifyiconDoubleclicked;

            // Opt-in only, as this feature is a bit controversial
            if (Settings.KeepIconVisible.Value)
            {
                SysTray.AlwaysShow("wincompose[.]exe");
            }

            // This one is a bit safer
            m_cleanup_timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(30)
            };
            m_cleanup_timer.Tick += (o, e) => CleanupNotificationArea();
            m_cleanup_timer.Start();
            CleanupNotificationArea();

            Settings.DisableIcon.ValueChanged += SysTrayUpdateCallback;
            Composer.Changed += SysTrayUpdateCallback;
            Updater.Changed  += SysTrayUpdateCallback;
            SysTrayUpdateCallback();

            Updater.Changed += UpdaterStateChanged;
            UpdaterStateChanged();
        }
Пример #3
0
        private void OnLoaded(object sender, RoutedEventArgs args)
        {
            Application.RemoteControl.DisableEvent += OnDisableEvent;
            Application.RemoteControl.ExitEvent    += OnExitEvent;
            Application.RemoteControl.OpenEvent    += OnOpenEvent;
            Application.RemoteControl.BroadcastDisableEvent();

            TrayMouseDoubleClick += NotifyiconDoubleclicked;

            // Opt-in only, as this feature is a bit controversial
            if (Settings.KeepIconVisible.Value)
            {
                SysTray.AlwaysShow("wincompose[.]exe");
            }

            // This one is a bit safer
            m_cleanup_timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(30)
            };
            m_cleanup_timer.Tick += (o, e) => CleanupNotificationArea();
            m_cleanup_timer.Start();
            CleanupNotificationArea();

            Settings.DisableIcon.ValueChanged += MarkIconDirty;
            Composer.Changed += MarkIconDirty;
            Updater.Changed  += MarkIconDirty;
            MarkIconDirty();

            Updater.Changed += UpdaterStateChanged;
            UpdaterStateChanged();

            CompositionTarget.Rendering += UpdateNotificationIcon;
        }
Пример #4
0
        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,
                    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();
            }
        }