예제 #1
0
        public MainWindow()
        {
            Instance = this;

            FFmpegService.FFmpegDownloader += () =>
            {
                if (_downloader == null)
                {
                    _downloader         = new FFmpegDownloaderWindow();
                    _downloader.Closed += (Sender, Args) => _downloader = null;
                }

                _downloader.ShowAndFocus();
            };

            InitializeComponent();

            if (DataContext is MainViewModel vm)
            {
                vm.Init(!App.CmdOptions.NoPersist, true, !App.CmdOptions.Reset, !App.CmdOptions.NoHotkeys);

                var listener = new HotkeyListener();

                listener.HotkeyReceived += Id => vm.HotKeyManager.ProcessHotkey(Id);

                ServiceProvider.Get <HotKeyManager>().HotkeyPressed += Service =>
                {
                    switch (Service)
                    {
                    case ServiceName.OpenImageEditor:
                        new ImageEditorWindow().ShowAndFocus();
                        break;

                    case ServiceName.ShowMainWindow:
                        this.ShowAndFocus();
                        break;
                    }
                };

                Loaded += (Sender, Args) =>
                {
                    RepositionWindowIfOutside();

                    vm.ViewLoaded();
                };
            }

            if (App.CmdOptions.Tray || ServiceProvider.Get <Settings>().Tray.MinToTrayOnStartup)
            {
                Hide();
            }

            Closing += (Sender, Args) =>
            {
                if (!TryExit())
                {
                    Args.Cancel = true;
                }
            };
        }
예제 #2
0
        public MainWindow()
        {
            Instance = this;

            FFmpegService.FFmpegDownloader += () =>
            {
                if (_downloader == null)
                {
                    _downloader         = new FFmpegDownloaderWindow();
                    _downloader.Closed += (Sender, Args) => _downloader = null;
                }

                _downloader.ShowAndFocus();
            };

            InitializeComponent();

            if (DataContext is MainViewModel vm)
            {
                vm.Init(!App.CmdOptions.NoPersist, true, !App.CmdOptions.Reset, !App.CmdOptions.NoHotkeys);

                // Register for Windows Messages
                ComponentDispatcher.ThreadPreprocessMessage += (ref MSG Message, ref bool Handled) =>
                {
                    const int wmHotkey = 786;

                    if (Message.message == wmHotkey)
                    {
                        var id = Message.wParam.ToInt32();

                        vm.HotKeyManager.ProcessHotkey(id);
                    }
                };

                Loaded += (Sender, Args) =>
                {
                    RepositionWindowIfOutside();

                    vm.ViewLoaded();
                };
            }

            if (App.CmdOptions.Tray || ServiceProvider.Get <Settings>().UI.MinToTrayOnStartup)
            {
                Hide();
            }

            Closing += (Sender, Args) =>
            {
                if (!TryExit())
                {
                    Args.Cancel = true;
                }
            };
        }
예제 #3
0
        public MainWindow()
        {
            Instance = this;

            FFmpegService.FFmpegDownloader += () =>
            {
                if (_downloader == null)
                {
                    _downloader         = new FFmpegDownloaderWindow();
                    _downloader.Closed += (Sender, Args) => _downloader = null;
                }

                _downloader.ShowAndFocus();
            };

            InitializeComponent();

            var mainModel = ServiceProvider.Get <MainModel>();

            mainModel.Init(!App.CmdOptions.NoPersist, !App.CmdOptions.Reset);

            var hotkeySetup = ServiceProvider.Get <HotkeySetup>();

            hotkeySetup.Setup();

            ServiceProvider.Get <TimerModel>().Init();

            Loaded += (Sender, Args) =>
            {
                RepositionWindowIfOutside();

                WebCamWindow.Instance.SetupWebcamPreview();

                hotkeySetup.ShowUnregistered();

                mainModel.ViewLoaded();
            };

            if (App.CmdOptions.Tray || ServiceProvider.Get <Settings>().Tray.MinToTrayOnStartup)
            {
                Hide();
            }

            Closing += (Sender, Args) =>
            {
                if (!TryExit())
                {
                    Args.Cancel = true;
                }
            };
        }
예제 #4
0
 void FFmpegDownload(object Sender, RoutedEventArgs E)
 {
     FFmpegDownloaderWindow.ShowInstance();
 }
예제 #5
0
 public void ShowDownloader()
 {
     FFmpegDownloaderWindow.ShowInstance();
 }