public FFmpegCommandView(FFmpegCommandViewModel viewModel)
        {
            InitializeComponent();
            ViewModel = viewModel;

            this.WhenActivated(d =>
            {
                this.OneWayBind(ViewModel, vm => vm.FFmpegStatus, vm => vm.FFmpegStatusTextBlock.Text).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.FFmpegStatusForeground, vm => vm.FFmpegStatusTextBlock.Foreground).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.CheckFFmpegStatusCommand, vm => vm.FFmpegStatusTextBlock, nameof(FFmpegStatusTextBlock.MouseLeftButtonUp)).DisposeWith(d);

                this.Bind(ViewModel, vm => vm.CutInput, vm => vm.CutInputTextBox.Text).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.CutOutput, vm => vm.CutOutputTextBox.Text).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.CutStartTime, vm => vm.CutStartTimeTextBox.Text).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.CutEndTime, vm => vm.CutEndTimeTextBox.Text).DisposeWith(d);

                this.Bind(ViewModel, vm => vm.ConvertInput, vm => vm.ConvertInputTextBox.Text).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.ConvertOutput, vm => vm.ConvertOutputTextBox.Text).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.IsDelete, vm => vm.IsDeleteToggleSwitch.IsOn).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.IsFlvFixConvert, vm => vm.IsFlvFixConvertToggleSwitch.IsOn).DisposeWith(d);

                this.BindCommand(ViewModel, vm => vm.CutOpenFileCommand, vm => vm.CutInputButton).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.CutSaveFileCommand, vm => vm.CutOutputButton).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.CutCommand, vm => vm.CutButton).DisposeWith(d);

                this.BindCommand(ViewModel, vm => vm.ConvertOpenFileCommand, vm => vm.ConvertInputButton).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.ConvertSaveFileCommand, vm => vm.ConvertOutputButton).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.ConvertCommand, vm => vm.ConvertButton).DisposeWith(d);

                ViewModel.CheckFFmpegStatusCommand
                .Execute()
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(b =>
                {
                    HyperlinkButton.Visibility = b ? Visibility.Collapsed : Visibility.Visible;
                    CutButton.IsEnabled        = b;
                    ConvertButton.IsEnabled    = b;
                }).DisposeWith(d);

                CutInputTextBox.ShowDragOverIconEvent().DisposeWith(d);
                CutOutputTextBox.ShowDragOverIconEvent().DisposeWith(d);
                ConvertInputTextBox.ShowDragOverIconEvent().DisposeWith(d);
                ConvertOutputTextBox.ShowDragOverIconEvent().DisposeWith(d);

                CutInputTextBox.DropPathEvent().DisposeWith(d);
                CutOutputTextBox.DropPathEvent().DisposeWith(d);
                ConvertInputTextBox.DropPathEvent().DisposeWith(d);
                ConvertOutputTextBox.DropPathEvent().DisposeWith(d);
            });
        }
Exemple #2
0
        public MainWindow(
            MainWindowViewModel viewModel,
            LiveRecordListViewModel liveRecordList,
            TaskListViewModel taskList,
            LogViewModel log,
            SettingViewModel settings,
            StreamRecordViewModel streamRecord,
            UserSettingsViewModel userSettings,
            FFmpegCommandViewModel ffmpegCommand)
        {
            InitializeComponent();
            ViewModel = viewModel;

            this.WhenActivated(d =>
            {
                this.BindCommand(ViewModel, vm => vm.ShowWindowCommand, v => v.NotifyIcon, nameof(NotifyIcon.TrayLeftMouseUp)).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.ShowWindowCommand, v => v.ShowMenuItem).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.ExitCommand, v => v.ExitMenuItem).DisposeWith(d);

                this.Bind(ViewModel, vm => vm.Router, v => v.RoutedViewHost.Router).DisposeWith(d);

                Observable.FromEventPattern <NavigationViewSelectionChangedEventArgs>(NavigationView, nameof(NavigationView.SelectionChanged))
                .Subscribe(args =>
                {
                    if (args.EventArgs.IsSettingsSelected)
                    {
                        ViewModel.Router.Navigate.Execute(settings);
                        return;
                    }

                    if (args.EventArgs.SelectedItem is not NavigationViewItem {
                        Tag: string tag
                    })
                    {
                        return;
                    }

                    switch (tag)
                    {
                    case @"1":
                        {
                            ViewModel.Router.Navigate.Execute(liveRecordList);
                            break;
                        }

                    case @"2":
                        {
                            ViewModel.Router.Navigate.Execute(taskList);
                            break;
                        }

                    case @"3":
                        {
                            ViewModel.Router.Navigate.Execute(log);
                            break;
                        }

                    case @"4":
                        {
                            ViewModel.Router.Navigate.Execute(streamRecord);
                            break;
                        }

                    case @"5":
                        {
                            ViewModel.Router.Navigate.Execute(userSettings);
                            break;
                        }

                    case @"6":
                        {
                            ViewModel.Router.Navigate.Execute(ffmpegCommand);
                            break;
                        }
                    }
                }).DisposeWith(d);

                NavigationView.SelectedItem = NavigationView.MenuItems.OfType <NavigationViewItem>().First();

                this.Bind(ViewModel, vm => vm.Config.MainWindowsWidth, v => v.Width).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.Config.MainWindowsHeight, v => v.Height).DisposeWith(d);

                MessageBus.Current.Listen <RoomStatus>()
                .Where(room => room.LiveStatus == LiveStatus.直播)
                .ObserveOnDispatcher()
                .Subscribe(room => NotifyIcon.ShowBalloonTip($@"{room.UserName} 开播了!", room.Title, BalloonIcon.Info)).DisposeWith(d);

                #region CloseReasonHack

                AddCloseReasonHook();

                this.Events().Closing.Subscribe(e =>
                {
                    if (CloseReason == CloseReason.UserClosing)
                    {
                        Hide();
                        e.Cancel = true;
                    }
                }).DisposeWith(d);

                #endregion
            });