Exemplo n.º 1
0
        public OtherParamsView()
        {
            InitializeComponent();
            Refresh();
            cbStartOnLogon.SelectionChanged += (o, e) =>
            {
                _manager.Settings.RunOnUserLogon = cbStartOnLogon.Selected;
                _manager.SaveSettings();
            };

            cbRightSideHover.SelectionChanged += (o, e) =>
            {
                UISettings.Current.MouseRightSideHoverEvent = cbRightSideHover.Selected;
                UISettings.Save();
                RightSideHoverForm.Initialize();
            };

            btRestart.Click  += (o, e) => Utils.RestartApp();
            btShutdown.Click += (o, e) => Application.Current.Shutdown();
        }
Exemplo n.º 2
0
        public App()
        {
            Exit += (o, e) => Core?.Dispose();

            System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            System.Windows.Forms.Application.ThreadException += (o, e) =>
            {
                HandleUnhandledException(e.Exception);
            };

            AppDomain.CurrentDomain.UnhandledException += (o, e) =>
            {
                HandleUnhandledException(e.ExceptionObject as Exception);
            };

            DispatcherUnhandledException += (o, e) =>
            {
                HandleUnhandledException(e.Exception);
            };

            ShutdownMode = ShutdownMode.OnExplicitShutdown;

            try
            {
                Core = new LazuriteCore();

                //Crutch: after this actions first window runs faster
                JournalLightWindow.Show("Lazurite запущен...", WarnType.Info);
                JournalLightWindow.CloseWindow();

                Core.WarningHandler.OnWrite += (o, e) =>
                {
                    var args = (WarningEventArgs)e;
                    JournalManager.Set(args.Message, args.Value, args.Exception);
                };

                Core.Initialize();
                Core.Server.StartAsync(null);
                Singleton.Add(Core);
                NotifyIconManager.Initialize();
                DuplicatedProcessesListener.Found += (o, e) => NotifyIconManager.ShowMainWindow();
                DuplicatedProcessesListener.Start();
                RightSideHoverForm.Initialize();
            }
            catch (Exception e)
            {
                if (Core != null)
                {
                    Core.WarningHandler.Fatal("Во время инициализации приложения возникла ошибка", e);
                }
                else
                {
                    throw e;
                }
            }

            var ci = new CultureInfo("ru-RU");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
        }