Пример #1
0
        public static void Init()
        {
            ForegroundManager = new ForegroundManager();
            ScreenSize        = new Size(SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
            FocusManager.Init();
            LoadWindows();
            UpdateScreenCorrection();
            _contextMenu = new ContextMenu();
            var defaultIconStream = Application.GetResourceStream(new Uri("resources/tcc-logo.ico", UriKind.Relative))?.Stream;

            if (defaultIconStream != null)
            {
                DefaultIcon = new Icon(defaultIconStream);
            }
            var connectedIconStream = Application.GetResourceStream(new Uri("resources/tcc-logo-on.ico", UriKind.Relative))?.Stream;

            if (connectedIconStream != null)
            {
                ConnectedIcon = new Icon(connectedIconStream);
            }
            TrayIcon = new NotifyIcon()
            {
                Icon    = DefaultIcon,
                Visible = true
            };
            TrayIcon.MouseDown        += NI_MouseDown;
            TrayIcon.MouseDoubleClick += TrayIcon_MouseDoubleClick;
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            TrayIcon.Text = $"TCC v{v.Major}.{v.Minor}.{v.Build}";

            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Dashboard", Command = new RelayCommand(o => Dashboard.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Settings", Command = new RelayCommand(o => SettingsWindow.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header  = "Close",
                Command = new RelayCommand(o =>
                {
                    _contextMenu.Closed += (_, __) => App.Close();
                    _contextMenu.IsOpen  = false;
                })
            });

            SettingsWindow = new SettingsWindow();

            if (SettingsHolder.UseHotkeys)
            {
                KeyboardHook.Instance.RegisterKeyboardHook();
            }

            SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
            //t = new System.Timers.Timer();
            //t.Interval = 1000;
            //t.Elapsed += (_, __) => PrintDispatcher();
            //t.Start();
        }
Пример #2
0
 public static void HandleGlobalException(object sender, UnhandledExceptionEventArgs e)
 {
     FocusManager.Dispose();
     HandleGlobalExceptionImpl(e);
 }