From 9a844c02b9a8ab2c3ce93c6e73f808a55e403123 Mon Sep 17 00:00:00 2001 From: xiang Date: Mon, 28 Oct 2024 21:50:53 +0800 Subject: [PATCH] update --- MainWindow.xaml.cs | 7 ++-- Video.xaml.cs | 80 +++++++++++++++++++++++++++++++++++----------- VideoConcat.csproj | 7 ++++ 3 files changed, 73 insertions(+), 21 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 5f86e7b..d2599f9 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -27,11 +27,12 @@ namespace VideoConcat } private void BtnLogin_Click(object sender, RoutedEventArgs e) - { Video video = new(); - video.Show(); + { + Video video = new(); + video.Show(); if (txtUserName.Text == "admin" && txtPassword.Password == "123456") { - + this.Close(); return; } diff --git a/Video.xaml.cs b/Video.xaml.cs index a266562..044899b 100644 --- a/Video.xaml.cs +++ b/Video.xaml.cs @@ -1,16 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Win32; +using System.IO; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; + namespace VideoConcat { @@ -19,31 +10,33 @@ namespace VideoConcat /// public partial class Video : Window { + public string text = ""; public Video() { InitializeComponent(); + Check_Folder(); + } private async void Button_Click(object sender, RoutedEventArgs e) { + startButton.IsEnabled = false; await Task.Run(() => { - string text = ""; + for (int i = 0; i <= 100; i++) { - Application.Current.Dispatcher.Invoke(() => + System.Windows.Application.Current.Dispatcher.Invoke(() => { processVideoBar.Dispatcher.Invoke(() => { processVideoBar.Value = i; - + }); outputTxt.Dispatcher.Invoke(new Action(() => { - text += "正在生成第" + i + "个视频\r\n"; - outputTxt.Text = text; - scrowText.ScrollToEnd(); + WriteTxt("正在生成第" + i + "个视频"); })); }); System.Threading.Thread.Sleep(50); @@ -56,5 +49,56 @@ namespace VideoConcat });//ProcessVideo.RunTask(processVideoBar, startButton) } + + private void Check_Folder() + { + Boolean hasHead; + Boolean hasTail; + string currentPath = Directory.GetCurrentDirectory(); + DirectoryInfo? parentPathInfo = Directory.GetParent(currentPath); + if (parentPathInfo == null) + { + WriteTxt("获取相关视频文件目录失败!"); + return; + } + WriteTxt(parentPathInfo.FullName); + try + { + + DirectoryInfo dirD = parentPathInfo as DirectoryInfo; + FileSystemInfo[] folders = dirD.GetDirectories();//获取文件夹下所有文件和文件夹 + //对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作 + + foreach (FileSystemInfo folder in folders) + { + WriteTxt($"{folder.Name}"); + + if (folder.Name == "head") + { + hasHead = true; + } + if (folder.Name == "tail") + { + hasTail = true; + } + } + //if (hasHead) + //{ + // WriteTxt("存在head文件夹"); + //} + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return; + } + } + + private void WriteTxt(string str) + { + text += str + "\r\n"; + outputTxt.Text = text; + scrowText.ScrollToEnd(); + } } } diff --git a/VideoConcat.csproj b/VideoConcat.csproj index 82b6fb7..06f2158 100644 --- a/VideoConcat.csproj +++ b/VideoConcat.csproj @@ -10,7 +10,14 @@ + + + + Never + + +