This commit is contained in:
xiang 2024-10-28 21:50:53 +08:00
parent 8220e07fe6
commit 9a844c02b9
3 changed files with 73 additions and 21 deletions

View File

@ -27,8 +27,9 @@ namespace VideoConcat
} }
private void BtnLogin_Click(object sender, RoutedEventArgs e) 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") if (txtUserName.Text == "admin" && txtPassword.Password == "123456")
{ {

View File

@ -1,16 +1,7 @@
using System; using Microsoft.Win32;
using System.Collections.Generic; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; 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 namespace VideoConcat
{ {
@ -19,20 +10,24 @@ namespace VideoConcat
/// </summary> /// </summary>
public partial class Video : Window public partial class Video : Window
{ {
public string text = "";
public Video() public Video()
{ {
InitializeComponent(); InitializeComponent();
Check_Folder();
} }
private async void Button_Click(object sender, RoutedEventArgs e) private async void Button_Click(object sender, RoutedEventArgs e)
{ {
startButton.IsEnabled = false; startButton.IsEnabled = false;
await Task.Run(() => await Task.Run(() =>
{ {
string text = "";
for (int i = 0; i <= 100; i++) for (int i = 0; i <= 100; i++)
{ {
Application.Current.Dispatcher.Invoke(() => System.Windows.Application.Current.Dispatcher.Invoke(() =>
{ {
processVideoBar.Dispatcher.Invoke(() => processVideoBar.Dispatcher.Invoke(() =>
{ {
@ -41,9 +36,7 @@ namespace VideoConcat
}); });
outputTxt.Dispatcher.Invoke(new Action(() => outputTxt.Dispatcher.Invoke(new Action(() =>
{ {
text += "正在生成第" + i + "个视频\r\n"; WriteTxt("正在生成第" + i + "个视频");
outputTxt.Text = text;
scrowText.ScrollToEnd();
})); }));
}); });
System.Threading.Thread.Sleep(50); System.Threading.Thread.Sleep(50);
@ -56,5 +49,56 @@ namespace VideoConcat
});//ProcessVideo.RunTask(processVideoBar, startButton) });//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();
}
} }
} }

View File

@ -10,7 +10,14 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.4" /> <PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="WPFDevelopers" Version="0.0.0.1" /> <PackageReference Include="WPFDevelopers" Version="0.0.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</ApplicationDefinition>
</ItemGroup>
</Project> </Project>