From 460f2f12783e39cb97da12ae514ee3123f8ccb1e Mon Sep 17 00:00:00 2001 From: xiangbing Date: Fri, 29 Nov 2024 17:44:16 +0800 Subject: [PATCH 01/34] Create README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4abb60f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# WPF 视频拼接程序 From b8cf1e9ce986b4d1e107b9c48016d0d40ede8c64 Mon Sep 17 00:00:00 2001 From: xiangbing Date: Tue, 17 Dec 2024 13:43:26 +0800 Subject: [PATCH 02/34] v1.* --- MainWindow.xaml.cs | 13 -- Task.cs | 35 ---- Video.xaml | 37 ----- Video.xaml.cs | 390 --------------------------------------------- VideoConcat.csproj | 1 + 5 files changed, 1 insertion(+), 475 deletions(-) delete mode 100644 Task.cs delete mode 100644 Video.xaml delete mode 100644 Video.xaml.cs diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 4a935fe..acf90d5 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -28,19 +28,6 @@ namespace VideoConcat private void BtnLogin_Click(object sender, RoutedEventArgs e) { - - if (txtUserName.Text == "admin" && txtPassword.Password == "&o4Fwag3xYUf") - { - Video video = new(); - video.Show(); - - this.Close(); - return; - } - - MessageBox.Show("用户名或者密码错误!"); - txtUserName.Clear(); - txtPassword.Clear(); } } } diff --git a/Task.cs b/Task.cs deleted file mode 100644 index a3b0f17..0000000 --- a/Task.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace VideoConcat -{ - - public static class ProcessVideo - { - public static void RunTask(System.Windows.Controls.ProgressBar progressBar, System.Windows.Controls.Button btn) - { - for (int i = 0; i <= 100; i++) - { - Application.Current.Dispatcher.Invoke(() => - { - progressBar.Dispatcher.Invoke(() => - { - progressBar.Value = i; - - }); - }); - System.Threading.Thread.Sleep(50); - } - btn.Dispatcher.Invoke(() => - { - btn.IsEnabled = true; - }); - - } - } - -} diff --git a/Video.xaml b/Video.xaml deleted file mode 100644 index 12155af..0000000 --- a/Video.xaml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - + diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index 2321cfc..828b896 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -1,64 +1,101 @@ -using System.Windows; -using VideoConcat.Common.Api.Base; -using VideoConcat.Common.Tools; +using System.Globalization; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; +using VideoConcat.Models; +using RadioButton = System.Windows.Controls.RadioButton; namespace VideoConcat.Views { /// - /// Interaction logic for MainWindow.xaml + /// MainWindow.xaml 的交互逻辑 /// public partial class MainWindow : Window { + + public MainWindow() { InitializeComponent(); - Username.Text = Config.GetSettingString("userName"); - Password.Password = Config.GetSettingString("password"); - ckbRemember.IsChecked = Config.GetSettingString("isRemember") == "true"; + this.DataContext = new MainWindowModel(); + // 窗口加载完成后执行 + Loaded += MainView_Loaded; } - private void BtnExit_Click(object sender, RoutedEventArgs e) + public void MainView_Loaded(object sender, RoutedEventArgs e) { - Close(); + // 1. 为目标Grid创建列定义 + SetupGridColumns(mainGrid); + + // 2. 实例化已有视图(或获取已存在的视图实例) + var existingView = new VideoWindow(); // 这里是已有视图的实例 + + // 3. 将视图添加到指定列中(例如第1列,索引为1) + AddViewToColumn(mainGrid, existingView); } - private async void BtnLogin_Click(object sender, RoutedEventArgs e) + /// + /// 为Grid设置列定义 + /// + private void SetupGridColumns(Grid grid) + { + // 清空现有列(可选) + grid.Children.Clear(); + } + + + /// + /// 将视图添加到Grid的指定列 + /// + /// 目标Grid + /// 要添加的视图(UserControl/FrameworkElement) + /// 列索引(从0开始) + private void AddViewToColumn(Grid grid, FrameworkElement view) { - string _userName = Username.Text; - bool _isChecked = Convert.ToBoolean(ckbRemember.IsChecked); - string _password = Password.Password; + // 将视图添加到Grid的子元素中 + grid.Children.Add(view); + } - if (string.IsNullOrEmpty(_userName) || string.IsNullOrEmpty(_password)) + private void Border_MouseDown(object sender, MouseButtonEventArgs e) + { + + if (e.ChangedButton == MouseButton.Left) { - Username.Clear(); - Password.Clear(); - WPFDevelopers.Controls.MessageBox.Show("请输入用户名或者密码!"); - return; + this.DragMove(); } - ApiResponse res = await SystemApi.LoginAsync(_userName, _password); - if (res.Code != 0) + } + + + private void RadioButton_Checked(object sender, RoutedEventArgs e) + { + if (sender is RadioButton radioButton) { - WPFDevelopers.Controls.MessageBox.Show(res.Msg); - } - else - { - if (_isChecked) + if (radioButton.Name == "extract") { - Config.UpdateSettingString("userName", _userName); - Config.UpdateSettingString("password", _password); - Config.UpdateSettingString("isRemember", "true"); + SetupGridColumns(mainGrid); + // 2. 实例化已有视图(或获取已存在的视图实例) + var existingView = new ExtractWindow(); // 这里是已有视图的实例 + + // 3. 将视图添加到指定列中(例如第1列,索引为1) + AddViewToColumn(mainGrid, existingView); } - else + + if (radioButton.Name == "video") { - Config.UpdateSettingString("userName", ""); - Config.UpdateSettingString("password", ""); - Config.UpdateSettingString("isRemember", "false"); + // 1. 为目标Grid创建列定义 + SetupGridColumns(mainGrid); + + // 2. 实例化已有视图(或获取已存在的视图实例) + var existingView = new VideoWindow(); // 这里是已有视图的实例 + + // 3. 将视图添加到指定列中(例如第1列,索引为1) + AddViewToColumn(mainGrid, existingView); } - new Video().Show(); - Close(); } } } + } diff --git a/Views/Video.xaml b/Views/VideoWindow.xaml similarity index 94% rename from Views/Video.xaml rename to Views/VideoWindow.xaml index 96ea3a1..f87f752 100644 --- a/Views/Video.xaml +++ b/Views/VideoWindow.xaml @@ -1,4 +1,4 @@ - - + Height="800" Width="1000"> + @@ -18,18 +18,18 @@ - + - +