diff --git a/.vs/UniversalGUI/v15/.suo b/.vs/UniversalGUI/v15/.suo new file mode 100644 index 0000000..70773b4 Binary files /dev/null and b/.vs/UniversalGUI/v15/.suo differ diff --git a/.vs/UniversalGUI/v15/Server/sqlite3/db.lock b/.vs/UniversalGUI/v15/Server/sqlite3/db.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide new file mode 100644 index 0000000..e78f063 Binary files /dev/null and b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-shm b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-shm new file mode 100644 index 0000000..ddb2c32 Binary files /dev/null and b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-wal b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-wal new file mode 100644 index 0000000..34a85b7 Binary files /dev/null and b/.vs/UniversalGUI/v15/Server/sqlite3/storage.ide-wal differ diff --git a/README.md b/README.md index 25fcd1f..af50545 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,17 @@   假设你有一个多核心的CPU(现在谁还用单核!),同时,你有一批`图片(或者是别的什么东西)`需要`转换为xx格式`,但是这个转换器是一个命令行程序,一次只能处理一张图片,并且它**不支持多核**,怎么办? -  也许你会说:“我多开几个,让它占满CPU时间,不就得了?” - -  但是,如果这需要转换的文件非常小,很快就能转换完成,并且这一批文件数量非常多,那么你岂不是要手忙脚乱地输一大堆命令? -   你也许会使用`XnConvert`之类的带GUI的集成转换器,解决了手动输命令的问题。再多开几个,也似乎能解决CPU利用的问题,但是——   若是`XnConvert`的其中一个实例已经转换完了所有你分配给这个实例的文件,然而其他的实例还没完成任务,那么就不能最大化地利用CPU时间了! -  再这么下去,最后也许会出现“只有一个实例在运行,其他实例都完成了分配的任务”这种蛋疼的局面,于是又回到了“一核有难x核围观”的状态。 +  再这么下去,最后也许会出现“仅一个实例未完成,其他实例都完成了分配的任务”这种蛋疼的局面,于是又回到了“一核有难x核围观”的状态。   所以——   来试试我的**Universal GUI**! -* 这个程序的初衷是为了解决多核利用的问题,不过嘛。。。我想了想,就把它做成了一个还算友好的,通用的`GUI外壳`。 +* 也许你已经猜出来了,我写这程序的初衷是为了解决多核利用问题,不过我不满足于此,就把它做成了一个还算友好的,通用的`GUI外壳`。 * 顾名思义,这是**通用**的GUI外壳,当然不止适配下边举例的LibWebP,也可用于Lame、NeroAAC、LibPNG等命令行程序。其实,也不仅用于文件转换。 @@ -29,17 +25,15 @@ Usage: cwebp [-preset <...>] [options] in_file [-o out_file] ``` -  我们发现了什么? - -* 参数大致分为三个部分:`选项(可选,不指定则使用默认选项)`、`输入文件(必填)`、`输出文件(可选,不指定则输出为同文件名)`。 +  可见,参数大致分为三个部分:选项(可选,不指定则使用默认选项)、输入文件(必填)、输出文件(可选,不指定则输出为同文件名)。 -  因此,我们用三个标记来表示这三个部分。分别是:`{UserParameters}`、`{InputFile}`、`{OutputFile}`。 +  在这里,需要用三个标记来表示这三个部分。分别是:`{UserParameters}`、`{InputFile}`和`{OutputFile}`。 -  所以,我们在`Universal GUI`的`参数模板`中填入:`{UserParameters} {InputFile} -o {OutputFile}`。请留意在标记之间按需添加空格。 +  所以,我们在`Universal GUI`的`Argument templet`中填入:`{UserParameters} {InputFile} -o {OutputFile}`。请留意在标记之间按需添加空格。 -  接着,我们在`Universal GUI`的`用户参数`中填入所需的参数,这些文本将会替换`{UserParameters}`标记。当然,你也可以直接在`参数模板`中直接填入所需参数,不使用`{UserParameters}`标记(这可以适配一些对于输入文件有一些选项,对输出文件又有一些选项,并且这些选项在参数中不连续的程序)。 +  接着在`Universal GUI`的`User arguments`中填入所需的参数,这些文本将会替换`{UserParameters}`标记。当然,你也可以直接在`参数模板`中直接填入所需参数,不使用`{UserParameters}`标记(这可以适配一些对于输入文件有一些选项,对输出文件又有一些选项,并且这些选项在参数中不连续的程序)。 -  不过,`这个程序的初衷`难道被我忘掉了?当然不。我们可以在`Thread number`这个Combo Box中选择线程数,这将同时运行多个源程序,并进行**异步调度**(多高大上),以弥补源程序不支持多核心带来的不便。 +  不过,`这程序的初衷`难道被我忘掉了?当然不。我们可以在`Thread number`这个Combo Box中选择线程数,这将同时运行多个源程序,并进行**异步调度**(多高大上),以弥补源程序不支持多核带来的不便。   其他的就没啥可说了。添加文件到列表中,给输出文件指定新的拓展名以及添加后缀……凡所应有,无所不有。Enjoy it! @@ -51,17 +45,17 @@ Usage: cwebp [-preset <...>] [options] in_file [-o out_file] * 测试平台:`i3-2310m 2核心 4逻辑处理器(超线程)`、`2G DDR3 1333 内存`。 -|-------------|未使用多线程|UniversalGUI-4线程| -|-------------|------------|------------------| -|所用时间 | 1min29s| 39s| -|平均CPU利用率| 26.1%| 98.4%| +|------------------|所用时间|平均CPU利用率| +|------------------|--------|-------------| +|未使用多线程 | 1min29s| 26.1%| +|UniversalGUI-4线程| 39s| 98.4%| ### Todo * 添加语言切换功能,毕竟不是人人都能看懂英文。 -* 添加暂停功能,用挂起进程实现(可能有点困难,容易出现进程死锁)(已放弃)。 +* 添加暂停功能,用挂起进程实现(可能有点麻烦,易出现进程死锁)(已放弃)。 ### Bugs -* Combo Box只有“收起”时才能看到Pressed效果。 \ No newline at end of file +* Combo Box只有“收起”时才能看到Pressed效果。 diff --git a/UniversalGUI/App.xaml b/UniversalGUI/App.xaml index a7644b4..52b8aa9 100644 --- a/UniversalGUI/App.xaml +++ b/UniversalGUI/App.xaml @@ -2,8 +2,255 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:UniversalGUI" + xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" StartupUri="MainWindow.xaml"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UniversalGUI/IniManager.cs b/UniversalGUI/IniManager.cs index 4bcd01f..d3d1ae3 100644 --- a/UniversalGUI/IniManager.cs +++ b/UniversalGUI/IniManager.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Runtime.InteropServices; using System.Text; @@ -20,12 +21,12 @@ public class IniManager /// [DllImport("kernel32")] private static extern int GetPrivateProfileString( - string lpAppName, - string lpKeyName, - string lpDefault, - StringBuilder lpReturnedString, - int nSize, - string lpFileName); + string section, + string key, + string value, + StringBuilder cache, + int cacheSize, + string path); /// /// Write value @@ -37,35 +38,81 @@ private static extern int GetPrivateProfileString( /// 0:error 1:success [DllImport("kernel32")] private static extern long WritePrivateProfileString( - string mpAppName, - string mpKeyName, - string mpDefault, - string mpFileName); + string section, + string key, + string value, + string path); #endregion + public string IniFile { get; private set; } + + /// + /// IniManager constructor + /// + /// Ini file's full path(Use full path!) + public IniManager(string path) + { + IniFile = path; + } + + /// + /// Read key + /// + /// Section name + /// Key name + /// Read value + public string Read(string section, string key) + { + StringBuilder strBuilder = new StringBuilder(1024); + GetPrivateProfileString(section, key, "", strBuilder, 1024, IniFile); + return strBuilder.ToString(); + } + + /// + /// Write key + /// + /// Section name + /// Key name + /// Write value + public void Write(string section, string key, string value) + { + WritePrivateProfileString(section, key, value, IniFile); + } + /// - /// Read + /// Write key /// /// Section name /// Key name - /// 读取值 - public static string Read(string section, string key, string path) + /// Write value + public void Write(string section, string key, double value) { - StringBuilder stringBuilder = new StringBuilder(1024); //定义一个最大长度为1024的可变字符串 - GetPrivateProfileString(section, key, "", stringBuilder, 1024, path); //读取INI文件 - return stringBuilder.ToString(); //返回键值 + string strValue = Convert.ToString(value); + Write(section, key, strValue); } /// - /// Write + /// Write key /// /// Section name /// Key name /// Write value - /// File full path - public static void Write(string section, string key, string value, string path) + public void Write(string section, string key, object value) { - WritePrivateProfileString(section, key, value, path); + string strValue = Convert.ToString(value); + Write(section, key, strValue); + } + + /// + /// Write key + /// + /// Section name + /// Key name + /// Write value + public void Write(string section, string key, bool value) + { + string strValue = Convert.ToString(value); + Write(section, key, strValue); } /// @@ -73,33 +120,36 @@ public static void Write(string section, string key, string value, string path) /// /// Section name /// Key name - /// File full path - public static void DeleteKey(string section, string key, string path) + public void Delete(string section, string key) { - WritePrivateProfileString(section, key, null, path); //写入 + WritePrivateProfileString(section, key, null, IniFile); } /// /// Delete section /// /// Section name - /// File full path - public static void DeleteSection(string section, string path) + /// Key name + public void Delete(string section) { - WritePrivateProfileString(section, null, null, path); //写入 + WritePrivateProfileString(section, null, null, IniFile); } /// /// Creat file /// - /// File full path - public static void CreatFile(string path) + public void CreatFile() { - if (!File.Exists(path)) + string iniFilePath = Path.GetDirectoryName(IniFile); + if (Directory.Exists(iniFilePath)) { - FileStream fs = File.Create(path); + var fs = File.Create(IniFile); fs.Close(); } + else + { + Directory.CreateDirectory(iniFilePath); + CreatFile(); + } } -} - +} \ No newline at end of file diff --git a/UniversalGUI/MainWindow.xaml b/UniversalGUI/MainWindow.xaml index bb6521f..5b5c1e6 100644 --- a/UniversalGUI/MainWindow.xaml +++ b/UniversalGUI/MainWindow.xaml @@ -4,274 +4,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:UniversalGUI" - xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" x:Class="UniversalGUI.MainWindow" + xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" + x:Class="UniversalGUI.MainWindow" mc:Ignorable="d" - Title="Universal GUI" Height="500" Width="700" MinWidth="550" MinHeight="425" Closing="SaveIniConfig"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //Core function + //Core public partial class MainWindow : Window { - private string DefaultTitle; - - private string IniFile = Environment.CurrentDirectory + "\\UniversalGUI.ini"; - - Config config = new Config(); - - public MainWindow() - { - InitializeComponent(); - - DefaultTitle = Title; - ImputIniConfig(); - StartMonitorAsync(); - } - - public void Tetete() //Method for text - { - Console.WriteLine(config.FilesSum); - //MessageBox.Show(myw.ParametersTemplet.Text); - - //var jfiodsjf = Dispatcher.Invoke(() => ParametersTemplet.Text); - } + private Config config = new Config(); public async void StartTaskAsync() { //Change UI - MainGrid.IsEnabled = false; + this.IsEnabled = false; StartTaskButton.IsEnabled = false; StartTaskButton.Content = "Running"; - TaskProgressBar.Visibility = Visibility.Visible; + SetProgress(0); //Collect config on UI SumConfig(); - bool settingRight = CheckConfig(); - int filesNum = config.FilesList.Count; + bool settingLegal = CheckConfig(); - //Run on backgrount thread,avoid UI have been lock + //Run on background thread await Task.Run(() => { - if (settingRight == true) + if (settingLegal == true) { - SetProgress(0); Task[] tasks = new Task[config.ThreadNumber]; for (int i = 0; i < tasks.Length; i++) { @@ -74,8 +50,8 @@ await Task.Run(() => }); //Change UI - MainGrid.IsEnabled = true; - if (settingRight == true) + this.IsEnabled = true; + if (settingLegal == true) { StartTaskButton.Content = "Finished"; SetProgress(1); @@ -89,14 +65,14 @@ await Task.Run(() => StartTaskButton.IsEnabled = true; StartTaskButton.Content = "Start"; TaskProgressBar.Visibility = Visibility.Hidden; - SetProgress(); //Clear progress + SetProgress(); //擦屁股 } - private async Task NewThreadAsync() + public async Task NewThreadAsync() { while (config.FilesList.Count > 0) { - string args = SumArgs( + string sumAppArgs = SumAppArgs( argsTemplet: config.ArgsTemplet, inputFile: config.FilesList.First.Value, //链表中第一个文件 userArgs: config.UserArgs, @@ -108,85 +84,19 @@ await Task.Run(() => { NewProcess( appPath: config.AppPath, - args: args, + appArgs: sumAppArgs, windowStyle: config.WindowStyle, priority: config.Priority); }); - SetProgress(((double)config.FilesSum - config.FilesList.Count) / config.FilesSum); - - } - } - - private void NewProcess(string appPath, string args, int windowStyle, int priority) - { - var process = new Process(); - process.StartInfo.FileName = appPath; - process.StartInfo.Arguments = args; - switch (windowStyle) - { - case 0: - process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - break; - case 1: - process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; - break; - case 2: - process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; - break; - case 3: - process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; - break; - default: - break; - } - process.Start(); - switch (priority) - { - case 1: - process.PriorityClass = ProcessPriorityClass.Idle; - break; - case 2: - process.PriorityClass = ProcessPriorityClass.BelowNormal; - break; - case 3: - process.PriorityClass = ProcessPriorityClass.Normal; - break; - case 4: - process.PriorityClass = ProcessPriorityClass.AboveNormal; - break; - case 5: - process.PriorityClass = ProcessPriorityClass.High; - break; - case 6: - process.PriorityClass = ProcessPriorityClass.RealTime; - break; - } - process.WaitForExit(); - } - - private void SumConfig() - { - config = new Config(); //直接new一个,省的整天重置这重置那的 - Dispatcher.Invoke(() => - { - foreach (var item in FilesList.Items) + config.CompletedFileNum++; + Dispatcher.Invoke(() => { - config.FilesList.AddLast(Convert.ToString(item)); //把文件添加到链表底部 - } - config.FilesSum = config.FilesList.Count; - config.AppPath = AppPath.Text; - config.ArgsTemplet = ArgsTemplet.Text; - config.UserArgs = UserArgs.Text; - config.OutputSuffix = OutputSuffix.Text; - config.OutputExtension = OutputExtension.Text; - config.OutputFloder = OutputFloder.Text; - config.Priority = Convert.ToInt32(Priority.SelectedValue); - config.ThreadNumber = Convert.ToInt32(ThreadNumber.SelectedValue); - config.WindowStyle = Convert.ToInt32(CUIWindowStyle.SelectedValue); - }); + SetProgress((double)config.CompletedFileNum / config.FilesSum); + }); + } } - private string SumArgs(string argsTemplet, string inputFile, string userArgs, string outputSuffix, string outputExtension, string outputFloder) + private string SumAppArgs(string argsTemplet, string inputFile, string userArgs, string outputSuffix, string outputExtension, string outputFloder) { //去前后引号 inputFile = new Regex("[(^\")(\"$)]").Replace(inputFile, ""); @@ -262,88 +172,142 @@ private string SumArgs(string argsTemplet, string inputFile, string userArgs, st return arguments; } - private void ImputIniConfig() + private void NewProcess(string appPath, string appArgs, uint windowStyle, uint priority) { - if (File.Exists(IniFile)) + var process = new Process(); + process.StartInfo.FileName = appPath; + process.StartInfo.Arguments = appArgs; + switch (windowStyle) { - AppPath.Text = IniManager.Read("Command", "AppPath", IniFile); - ArgsTemplet.Text = IniManager.Read("Command", "ArgsTemplet", IniFile); - UserArgs.Text = IniManager.Read("Command", "UserArgs", IniFile); - OutputExtension.Text = IniManager.Read("Output", "Extension", IniFile); - OutputSuffix.Text = IniManager.Read("Output", "Suffix", IniFile); - OutputFloder.Text = IniManager.Read("Output", "Floder", IniFile); - Priority.SelectedValue = IniManager.Read("Process", "Priority", IniFile); - ThreadNumber.SelectedValue = IniManager.Read("Process", "ThreadNumber", IniFile); - CUIWindowStyle.SelectedValue = IniManager.Read("Process", "WindowStyle", IniFile); + case 1: + process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + break; + case 2: + process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; + break; + case 3: + process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; + break; + case 4: + process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; + break; + default: + break; } + process.Start(); + switch (priority) + { + case 1: + process.PriorityClass = ProcessPriorityClass.Idle; + break; + case 2: + process.PriorityClass = ProcessPriorityClass.BelowNormal; + break; + case 3: + process.PriorityClass = ProcessPriorityClass.Normal; + break; + case 4: + process.PriorityClass = ProcessPriorityClass.AboveNormal; + break; + case 5: + process.PriorityClass = ProcessPriorityClass.High; + break; + case 6: + process.PriorityClass = ProcessPriorityClass.RealTime; + break; + } + process.WaitForExit(); + } + + private void SumConfig() + { + config = new Config(); //直接new一个,省的整天重置这重置那的 + Dispatcher.Invoke(() => + { + foreach (var item in FilesList.Items) + { + config.FilesList.AddLast(Convert.ToString(item)); //把文件添加到链表底部 + } + config.FilesSum = FilesList.Items.Count; + config.AppPath = AppPath.Text; + config.ArgsTemplet = ArgsTemplet.Text; + config.UserArgs = UserArgs.Text; + config.OutputSuffix = OutputSuffix.Text; + config.OutputExtension = OutputExtension.Text; + config.OutputFloder = OutputFloder.Text; + config.Priority = Convert.ToUInt32(Priority.SelectedValue); + config.ThreadNumber = Convert.ToUInt32(ThreadNumber.SelectedValue); + config.WindowStyle = Convert.ToUInt32(CUIWindowStyle.SelectedValue); + }); + } + } + + //Start and Exit + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + + DefaultTitle = this.Title; + + IniConfigManager = new IniManager(GetIniConfigFile()); + ImputIniConfig(IniConfigManager); } - private void SaveIniConfig() + private void MainWindow_Loaded(object sender, RoutedEventArgs e) { - IniManager.CreatFile(IniFile); - IniManager.Write("Command", "AppPath", AppPath.Text, IniFile); - IniManager.Write("Command", "ArgsTemplet", ArgsTemplet.Text, IniFile); - IniManager.Write("Command", "UserArgs", UserArgs.Text, IniFile); - IniManager.Write("Output", "Extension", OutputExtension.Text, IniFile); - IniManager.Write("Output", "Suffix", OutputSuffix.Text, IniFile); - IniManager.Write("Output", "Floder", OutputFloder.Text, IniFile); - IniManager.Write("Process", "Priority", Convert.ToString(Priority.SelectedValue), IniFile); - IniManager.Write("Process", "ThreadNumber", Convert.ToString(ThreadNumber.SelectedValue), IniFile); - IniManager.Write("Process", "WindowStyle", Convert.ToString(CUIWindowStyle.SelectedValue), IniFile); + StartMonitorAsync(); + } + + private void MainWindow_WindowClosing(object sender, System.ComponentModel.CancelEventArgs e) + { + SaveIniConfig(IniConfigManager); } } //About UI public partial class MainWindow : Window { - private void SaveIniConfig(object sender, System.ComponentModel.CancelEventArgs e) => SaveIniConfig(); + private string DefaultTitle; private void StartTaskAsync(object sender, RoutedEventArgs e) => StartTaskAsync(); private void SetProgress(double multiple = -2) { - Dispatcher.Invoke(() => + if (multiple == -2) //重置 { - //重置 - if (multiple == -2) - { - SetTitleSuffix(); - TaskProgressBar.Value = 0; - TaskProgressBar.Foreground = new SolidColorBrush(Colors.DimGray); - //TaskProgressBar.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF06B025")); - } - - //错误警告 - if (multiple == -1) - { - SetTitleSuffix("Error"); - TaskProgressBar.Foreground = new SolidColorBrush(Colors.Red); - TaskProgressBar.Value = 100; - } - - //修改 - if (multiple >= 0 && multiple <= 1) - { - double percent = Math.Round(multiple * 100); - SetTitleSuffix(percent + "%"); - TaskProgressBar.Value = percent; - } - }); + SetTitleSuffix(); + TaskProgressBar.Value = 0; + TaskProgressBar.Foreground = new SolidColorBrush(Colors.DimGray); + TaskProgressBar.Visibility = Visibility.Hidden; + } + else if (multiple == -1) //错误警告 + { + SetTitleSuffix("Error"); + TaskProgressBar.Foreground = new SolidColorBrush(Colors.Red); + TaskProgressBar.Value = 100; + TaskProgressBar.Visibility = Visibility.Visible; + } + else if (multiple >= 0 && multiple <= 1) //修改 + { + double percent = Math.Round(multiple * 100); + SetTitleSuffix(percent + "%"); + TaskProgressBar.Value = percent; + TaskProgressBar.Visibility = Visibility.Visible; + } } private void SetTitleSuffix(string suffix = "") { - Dispatcher.Invoke(() => + if (suffix == "") { - if (suffix != "") - { - Title = DefaultTitle + " [" + suffix + "]"; - } - else - { - Title = DefaultTitle; - } - }); + Title = DefaultTitle; + } + else + { + Title = DefaultTitle + " [" + suffix + "]"; + } } private async void StartMonitorAsync() @@ -409,30 +373,38 @@ private bool CheckConfig() { if (FilesList.Items.Count == 0) { - MessageBox.Show(@"Please add file into fileslist.", "Error"); + MessageBox.Show("Please add file into fileslist.", "Error"); return false; } - if (AppPath.Text == "") + else if (AppPath.Text == "") { - MessageBox.Show(@"Please input command application's path.", "Error"); + MessageBox.Show("Please input command application's path.", "Error"); return false; } - if (ArgsTemplet.Text == "") + else if (ArgsTemplet.Text == "") { - MessageBox.Show(@"Please input parameters' templet.", "Error"); + MessageBox.Show("Please input arguments' templet.", "Error"); return false; } - if (OutputFloder.Text == "" && OutputExtension.Text == "" && OutputSuffix.Text == "") + else if (OutputFloder.Text == "" && OutputExtension.Text == "" && OutputSuffix.Text == "") { - MessageBox.Show(@"If you want to output into source floder,in output extension and suffix, you need to fill in at least one.", "Error"); + MessageBox.Show("If you want to output into source floder,in output extension and suffix, you need to fill in at least one.", "Error"); return false; } + else if (CustomThreadNumberItem.IsSelected == true) + { + if (Convert.ToInt32(CustomThreadNumberItem.Tag) == 0 || CustomThreadNumberTextBox.Text == "") + { + MessageBox.Show("Thread number is illegal.", "Error"); + return false; + } + } return true; } private void AddFilesListItems(object sender, RoutedEventArgs e) { - var openFileDialog = new OpenFileDialog() + var openFileDialog = new Microsoft.Win32.OpenFileDialog() { DereferenceLinks = true, Multiselect = true, @@ -482,6 +454,19 @@ private void FilesList_Drop(object sender, DragEventArgs e) } } + private void SwitchApplicationPath(object sender, RoutedEventArgs e) + { + var openFileDialog = new Microsoft.Win32.OpenFileDialog() + { + Filter = "Executable program (*.exe)|*.exe|Dynamic link library (*.dll)|*.dll", + DereferenceLinks = true, + }; + if (openFileDialog.ShowDialog() == true) + { + AppPath.Text = openFileDialog.FileName; + } + } + private void ApplicationPath_PreviewDragOver(object sender, DragEventArgs e) { e.Effects = DragDropEffects.Copy; @@ -494,34 +479,190 @@ private void ApplicationPath_PreviewDrop(object sender, DragEventArgs e) AppPath.Text = dropFiles[0]; } - private void SwitchApplicationPath(object sender, RoutedEventArgs e) + private void SwitchOutputFloder(object sender, RoutedEventArgs e) { - var openFileDialog = new OpenFileDialog() + var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - Filter = "Executable program (*.exe)|*.exe|Dynamic link library (*.dll)|*.dll", - DereferenceLinks = true, - }; - if (openFileDialog.ShowDialog() == true) + OutputFloder.Text = folderBrowserDialog.SelectedPath; + } + } + + private void OutputFloder_PreviewDragOver(object sender, DragEventArgs e) + { + e.Effects = DragDropEffects.Copy; + e.Handled = true; + } + + private void OutputFloder_PreviewDrop(object sender, DragEventArgs e) + { + string[] dropFloders = (string[])e.Data.GetData(DataFormats.FileDrop); + OutputFloder.Text = dropFloders[0]; + } + + private void OutputExtension_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + OutputExtension.Focus(); + e.Handled = true; + } + + private void OutputExtension_GotFocus(object sender, RoutedEventArgs e) + { + OutputExtension.SelectAll(); + } + + private void OutputSuffix_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + OutputSuffix.Focus(); + e.Handled = true; + } + + private void OutputSuffix_GotFocus(object sender, RoutedEventArgs e) + { + OutputSuffix.SelectAll(); + } + + private void CustomThreadNumberTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) + { + uint threadNumber = 0; + try { - AppPath.Text = openFileDialog.FileName; + threadNumber = Convert.ToUInt32(CustomThreadNumberTextBox.Text); + } + catch (FormatException) + { + CustomThreadNumberTextBox.Clear(); + } + catch (OverflowException) + { + CustomThreadNumberTextBox.Clear(); + } + finally + { + CustomThreadNumber(threadNumber); + CustomThreadNumberTextBox.Focus(); } } - private void SwitchOutputFloder(object sender, RoutedEventArgs e) + private void CustomThreadNumber(uint threadNumber, bool updateTextBox = false) { - var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); - if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + CustomThreadNumberItem.Tag = threadNumber; + if (threadNumber > 8) { - OutputFloder.Text = folderBrowserDialog.SelectedPath; + ThreadNumber.SelectedValue = threadNumber; + } + if (updateTextBox == true) + { + CustomThreadNumberTextBox.Text = threadNumber.ToString(); + } + } + } + + //About Ini Config + public partial class MainWindow : Window + { + private string IniConfigFileName = "Config.ini"; + + private string IniConfigFileVersion = "0.7.7.2"; + + private IniManager IniConfigManager; + + private string GetIniConfigFile() + { + string iniConfigFilePath; + if (File.Exists(Environment.CurrentDirectory + "\\Portable") == true) + { + iniConfigFilePath = Environment.CurrentDirectory; + } + else + { + iniConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\UniversalGUI"; + } + string IniConfigFile = Path.Combine(iniConfigFilePath, IniConfigFileName); + return IniConfigFile; + } + + private void ImputIniConfig(IniManager ini) + { + if (File.Exists(ini.IniFile) && File.ReadAllBytes(ini.IniFile).Length != 0) + { + if (ini.Read("Versions", "ConfigFile") == IniConfigFileVersion) + { + try + { + string windowWidth = ini.Read("Window", "Width"); + this.Width = Convert.ToDouble(windowWidth); + string windowHeight = ini.Read("Window", "Height"); + this.Height = Convert.ToDouble(windowHeight); + AppPath.Text = ini.Read("Command", "AppPath"); + ArgsTemplet.Text = ini.Read("Command", "ArgsTemplet"); + UserArgs.Text = ini.Read("Command", "UserArgs"); + OutputExtension.Text = ini.Read("Output", "Extension"); + OutputSuffix.Text = ini.Read("Output", "Suffix"); + OutputFloder.Text = ini.Read("Output", "Floder"); + Priority.SelectedValue = ini.Read("Process", "Priority"); + uint threadNumber = Convert.ToUInt32(ini.Read("Process", "ThreadNumber")); + if (threadNumber > 8) + { + CustomThreadNumber(threadNumber, updateTextBox: true); + } + ThreadNumber.SelectedValue = threadNumber; + CUIWindowStyle.SelectedValue = ini.Read("Process", "WindowStyle"); + } + catch(Exception e) + { + MessageBox.Show("There is a mistake in the configfile's format:" + "\n\n" + e.TargetSite + "\n\n" + e.Message, "Error"); + } + } + else + { + MessageBox.Show("Existing configFile's version is not supported.So you will use built-in config", "Hint"); + } + } + } + + private void SaveIniConfig(IniManager ini) + { + if (File.Exists(ini.IniFile)) + { + if (ini.Read("Versions", "ConfigFile") == IniConfigFileVersion || File.ReadAllBytes(ini.IniFile).Length == 0) + { + ini.Write("Versions", "ConfigFile", IniConfigFileVersion); + ini.Write("Window", "Width", this.Width); + ini.Write("Window", "Height", this.Height); + ini.Write("Command", "AppPath", AppPath.Text); + ini.Write("Command", "ArgsTemplet", ArgsTemplet.Text); + ini.Write("Command", "UserArgs", UserArgs.Text); + ini.Write("Output", "Extension", OutputExtension.Text); + ini.Write("Output", "Suffix", OutputSuffix.Text); + ini.Write("Output", "Floder", OutputFloder.Text); + ini.Write("Process", "Priority", Priority.SelectedValue); + ini.Write("Process", "ThreadNumber", ThreadNumber.SelectedValue); + ini.Write("Process", "WindowStyle", CUIWindowStyle.SelectedValue); + } + else + { + var result = MessageBox.Show("Existing configFile's version is not supported.Want you delete it and creat a new one?", "Hint", MessageBoxButton.YesNo); + if (result == MessageBoxResult.Yes) + { + ini.CreatFile(); + SaveIniConfig(ini); + } + } + } + else + { + ini.CreatFile(); + SaveIniConfig(ini); } } } - //Save config public class Config { public LinkedList FilesList = new LinkedList(); - public int FilesSum; + public int FilesSum = 0; + public int CompletedFileNum = 0; public string AppPath; public string ArgsTemplet; @@ -530,8 +671,8 @@ public class Config public string OutputExtension; public string OutputFloder; - public int Priority; - public int ThreadNumber; - public int WindowStyle; + public uint Priority; + public uint ThreadNumber; + public uint WindowStyle; } } diff --git a/UniversalGUI/Properties/AssemblyInfo.cs b/UniversalGUI/Properties/AssemblyInfo.cs index 1046f71..6283e7b 100644 --- a/UniversalGUI/Properties/AssemblyInfo.cs +++ b/UniversalGUI/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.7.5.2")] -[assembly: AssemblyFileVersion("0.7.5.2")] +[assembly: AssemblyVersion("0.7.7.2")] +[assembly: AssemblyFileVersion("0.7.7.2")] diff --git a/UniversalGUI/UniversalGUI.csproj b/UniversalGUI/UniversalGUI.csproj index d608948..683a47d 100644 --- a/UniversalGUI/UniversalGUI.csproj +++ b/UniversalGUI/UniversalGUI.csproj @@ -40,13 +40,13 @@ + - 4.0 diff --git a/UniversalGUI/obj/Debug/App.g.i.cs b/UniversalGUI/obj/Debug/App.g.i.cs index 7e1f592..0574cd4 100644 --- a/UniversalGUI/obj/Debug/App.g.i.cs +++ b/UniversalGUI/obj/Debug/App.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "833D2432012EC1578EAB2C034FE69229514E6121" +#pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00B8DBEDD6EB204FF31B7CE6287971F8DB2879FF" //------------------------------------------------------------------------------ // // 此代码由工具生成。 @@ -9,6 +9,7 @@ // //------------------------------------------------------------------------------ +using Microsoft.Windows.Themes; using System; using System.Diagnostics; using System.Windows; @@ -40,16 +41,29 @@ namespace UniversalGUI { /// public partial class App : System.Windows.Application { + private bool _contentLoaded; + /// /// InitializeComponent /// [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { + if (_contentLoaded) { + return; + } + _contentLoaded = true; - #line 5 "..\..\App.xaml" + #line 6 "..\..\App.xaml" this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative); + #line default + #line hidden + System.Uri resourceLocater = new System.Uri("/UniversalGUI;component/app.xaml", System.UriKind.Relative); + + #line 1 "..\..\App.xaml" + System.Windows.Application.LoadComponent(this, resourceLocater); + #line default #line hidden } diff --git a/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 0d18c11..37f512c 100644 Binary files a/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 79ce350..3fb8232 100644 Binary files a/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/UniversalGUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/UniversalGUI/obj/Debug/MainWindow.g.i.cs b/UniversalGUI/obj/Debug/MainWindow.g.i.cs index c1f8d76..cf301db 100644 --- a/UniversalGUI/obj/Debug/MainWindow.g.i.cs +++ b/UniversalGUI/obj/Debug/MainWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "EA5343B09D9ECA68E3D33DF9175DBAF15CA2ED63" +#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "BBAED14E502BC1C38DCAC50E1AEDEFBFA79A701A" //------------------------------------------------------------------------------ // // 此代码由工具生成。 @@ -42,15 +42,7 @@ namespace UniversalGUI { public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { - #line 271 "..\..\MainWindow.xaml" - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - internal System.Windows.Controls.Grid MainGrid; - - #line default - #line hidden - - - #line 272 "..\..\MainWindow.xaml" + #line 12 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.Button StartTaskButton; @@ -58,7 +50,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 273 "..\..\MainWindow.xaml" + #line 13 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ProgressBar TaskProgressBar; @@ -66,7 +58,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ListBox FilesList; @@ -74,7 +66,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox AppPath; @@ -82,7 +74,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 291 "..\..\MainWindow.xaml" + #line 31 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox ArgsTemplet; @@ -90,7 +82,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 294 "..\..\MainWindow.xaml" + #line 34 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox UserArgs; @@ -98,7 +90,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 300 "..\..\MainWindow.xaml" + #line 40 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputExtension; @@ -106,7 +98,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 303 "..\..\MainWindow.xaml" + #line 43 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputSuffix; @@ -114,7 +106,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 306 "..\..\MainWindow.xaml" + #line 46 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputFloder; @@ -122,7 +114,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 315 "..\..\MainWindow.xaml" + #line 55 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox Priority; @@ -130,7 +122,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 326 "..\..\MainWindow.xaml" + #line 65 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox ThreadNumber; @@ -138,7 +130,23 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 338 "..\..\MainWindow.xaml" + #line 74 "..\..\MainWindow.xaml" + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] + internal System.Windows.Controls.ComboBoxItem CustomThreadNumberItem; + + #line default + #line hidden + + + #line 75 "..\..\MainWindow.xaml" + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] + internal System.Windows.Controls.TextBox CustomThreadNumberTextBox; + + #line default + #line hidden + + + #line 80 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox CUIWindowStyle; @@ -146,7 +154,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 346 "..\..\MainWindow.xaml" + #line 88 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.GroupBox Monitor; @@ -154,7 +162,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 349 "..\..\MainWindow.xaml" + #line 91 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBlock MonitorForCPU; @@ -162,7 +170,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 352 "..\..\MainWindow.xaml" + #line 94 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBlock MonitorForMem; @@ -201,128 +209,179 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object { case 1: - #line 9 "..\..\MainWindow.xaml" - ((UniversalGUI.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.SaveIniConfig); + #line 10 "..\..\MainWindow.xaml" + ((UniversalGUI.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.MainWindow_WindowClosing); + + #line default + #line hidden + + #line 10 "..\..\MainWindow.xaml" + ((UniversalGUI.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_Loaded); #line default #line hidden return; case 2: - this.MainGrid = ((System.Windows.Controls.Grid)(target)); - return; - case 3: this.StartTaskButton = ((System.Windows.Controls.Button)(target)); - #line 272 "..\..\MainWindow.xaml" + #line 12 "..\..\MainWindow.xaml" this.StartTaskButton.Click += new System.Windows.RoutedEventHandler(this.StartTaskAsync); #line default #line hidden return; - case 4: + case 3: this.TaskProgressBar = ((System.Windows.Controls.ProgressBar)(target)); return; - case 5: + case 4: this.FilesList = ((System.Windows.Controls.ListBox)(target)); - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" this.FilesList.Drop += new System.Windows.DragEventHandler(this.FilesList_Drop); #line default #line hidden - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" this.FilesList.DragOver += new System.Windows.DragEventHandler(this.FilesList_DragOver); #line default #line hidden return; - case 6: + case 5: - #line 278 "..\..\MainWindow.xaml" + #line 18 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddFilesListItems); #line default #line hidden return; - case 7: + case 6: - #line 279 "..\..\MainWindow.xaml" + #line 19 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.RemoveFilesListItems); #line default #line hidden return; - case 8: + case 7: - #line 280 "..\..\MainWindow.xaml" + #line 20 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.EmptyFilesList); #line default #line hidden return; - case 9: + case 8: this.AppPath = ((System.Windows.Controls.TextBox)(target)); - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" this.AppPath.PreviewDragOver += new System.Windows.DragEventHandler(this.ApplicationPath_PreviewDragOver); #line default #line hidden - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" this.AppPath.PreviewDrop += new System.Windows.DragEventHandler(this.ApplicationPath_PreviewDrop); #line default #line hidden return; - case 10: + case 9: - #line 288 "..\..\MainWindow.xaml" + #line 28 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SwitchApplicationPath); #line default #line hidden return; - case 11: + case 10: this.ArgsTemplet = ((System.Windows.Controls.TextBox)(target)); return; - case 12: + case 11: this.UserArgs = ((System.Windows.Controls.TextBox)(target)); return; - case 13: + case 12: this.OutputExtension = ((System.Windows.Controls.TextBox)(target)); + + #line 40 "..\..\MainWindow.xaml" + this.OutputExtension.GotFocus += new System.Windows.RoutedEventHandler(this.OutputExtension_GotFocus); + + #line default + #line hidden + + #line 40 "..\..\MainWindow.xaml" + this.OutputExtension.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OutputExtension_PreviewMouseDown); + + #line default + #line hidden return; - case 14: + case 13: this.OutputSuffix = ((System.Windows.Controls.TextBox)(target)); + + #line 43 "..\..\MainWindow.xaml" + this.OutputSuffix.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OutputSuffix_PreviewMouseDown); + + #line default + #line hidden + + #line 43 "..\..\MainWindow.xaml" + this.OutputSuffix.GotFocus += new System.Windows.RoutedEventHandler(this.OutputSuffix_GotFocus); + + #line default + #line hidden return; - case 15: + case 14: this.OutputFloder = ((System.Windows.Controls.TextBox)(target)); + + #line 46 "..\..\MainWindow.xaml" + this.OutputFloder.PreviewDragOver += new System.Windows.DragEventHandler(this.OutputFloder_PreviewDragOver); + + #line default + #line hidden + + #line 46 "..\..\MainWindow.xaml" + this.OutputFloder.PreviewDrop += new System.Windows.DragEventHandler(this.OutputFloder_PreviewDrop); + + #line default + #line hidden return; - case 16: + case 15: - #line 307 "..\..\MainWindow.xaml" + #line 47 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SwitchOutputFloder); #line default #line hidden return; - case 17: + case 16: this.Priority = ((System.Windows.Controls.ComboBox)(target)); return; - case 18: + case 17: this.ThreadNumber = ((System.Windows.Controls.ComboBox)(target)); return; + case 18: + this.CustomThreadNumberItem = ((System.Windows.Controls.ComboBoxItem)(target)); + return; case 19: - this.CUIWindowStyle = ((System.Windows.Controls.ComboBox)(target)); + this.CustomThreadNumberTextBox = ((System.Windows.Controls.TextBox)(target)); + + #line 75 "..\..\MainWindow.xaml" + this.CustomThreadNumberTextBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CustomThreadNumberTextBox_TextChanged); + + #line default + #line hidden return; case 20: - this.Monitor = ((System.Windows.Controls.GroupBox)(target)); + this.CUIWindowStyle = ((System.Windows.Controls.ComboBox)(target)); return; case 21: - this.MonitorForCPU = ((System.Windows.Controls.TextBlock)(target)); + this.Monitor = ((System.Windows.Controls.GroupBox)(target)); return; case 22: + this.MonitorForCPU = ((System.Windows.Controls.TextBlock)(target)); + return; + case 23: this.MonitorForMem = ((System.Windows.Controls.TextBlock)(target)); return; } diff --git a/UniversalGUI/obj/Debug/UniversalGUI_MarkupCompile.i.cache b/UniversalGUI/obj/Debug/UniversalGUI_MarkupCompile.i.cache deleted file mode 100644 index c7beef2..0000000 --- a/UniversalGUI/obj/Debug/UniversalGUI_MarkupCompile.i.cache +++ /dev/null @@ -1,20 +0,0 @@ -UniversalGUI - - -winexe -C# -.cs -E:\Code\VisualStudio\CSharp\UniversalGUI\UniversalGUI\obj\Debug\ -UniversalGUI -none -false -DEBUG;TRACE -E:\Code\VisualStudio\CSharp\UniversalGUI\UniversalGUI\App.xaml -11151548125 - -10611411010 -16483770892 -MainWindow.xaml; - -False - diff --git a/UniversalGUI/obj/Release/App.g.i.cs b/UniversalGUI/obj/Release/App.g.i.cs index 7e1f592..0574cd4 100644 --- a/UniversalGUI/obj/Release/App.g.i.cs +++ b/UniversalGUI/obj/Release/App.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "833D2432012EC1578EAB2C034FE69229514E6121" +#pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00B8DBEDD6EB204FF31B7CE6287971F8DB2879FF" //------------------------------------------------------------------------------ // // 此代码由工具生成。 @@ -9,6 +9,7 @@ // //------------------------------------------------------------------------------ +using Microsoft.Windows.Themes; using System; using System.Diagnostics; using System.Windows; @@ -40,16 +41,29 @@ namespace UniversalGUI { /// public partial class App : System.Windows.Application { + private bool _contentLoaded; + /// /// InitializeComponent /// [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { + if (_contentLoaded) { + return; + } + _contentLoaded = true; - #line 5 "..\..\App.xaml" + #line 6 "..\..\App.xaml" this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative); + #line default + #line hidden + System.Uri resourceLocater = new System.Uri("/UniversalGUI;component/app.xaml", System.UriKind.Relative); + + #line 1 "..\..\App.xaml" + System.Windows.Application.LoadComponent(this, resourceLocater); + #line default #line hidden } diff --git a/UniversalGUI/obj/Release/MainWindow.g.i.cs b/UniversalGUI/obj/Release/MainWindow.g.i.cs index c1f8d76..cf301db 100644 --- a/UniversalGUI/obj/Release/MainWindow.g.i.cs +++ b/UniversalGUI/obj/Release/MainWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "EA5343B09D9ECA68E3D33DF9175DBAF15CA2ED63" +#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "BBAED14E502BC1C38DCAC50E1AEDEFBFA79A701A" //------------------------------------------------------------------------------ // // 此代码由工具生成。 @@ -42,15 +42,7 @@ namespace UniversalGUI { public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { - #line 271 "..\..\MainWindow.xaml" - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - internal System.Windows.Controls.Grid MainGrid; - - #line default - #line hidden - - - #line 272 "..\..\MainWindow.xaml" + #line 12 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.Button StartTaskButton; @@ -58,7 +50,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 273 "..\..\MainWindow.xaml" + #line 13 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ProgressBar TaskProgressBar; @@ -66,7 +58,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ListBox FilesList; @@ -74,7 +66,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox AppPath; @@ -82,7 +74,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 291 "..\..\MainWindow.xaml" + #line 31 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox ArgsTemplet; @@ -90,7 +82,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 294 "..\..\MainWindow.xaml" + #line 34 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox UserArgs; @@ -98,7 +90,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 300 "..\..\MainWindow.xaml" + #line 40 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputExtension; @@ -106,7 +98,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 303 "..\..\MainWindow.xaml" + #line 43 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputSuffix; @@ -114,7 +106,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 306 "..\..\MainWindow.xaml" + #line 46 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBox OutputFloder; @@ -122,7 +114,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 315 "..\..\MainWindow.xaml" + #line 55 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox Priority; @@ -130,7 +122,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 326 "..\..\MainWindow.xaml" + #line 65 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox ThreadNumber; @@ -138,7 +130,23 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 338 "..\..\MainWindow.xaml" + #line 74 "..\..\MainWindow.xaml" + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] + internal System.Windows.Controls.ComboBoxItem CustomThreadNumberItem; + + #line default + #line hidden + + + #line 75 "..\..\MainWindow.xaml" + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] + internal System.Windows.Controls.TextBox CustomThreadNumberTextBox; + + #line default + #line hidden + + + #line 80 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.ComboBox CUIWindowStyle; @@ -146,7 +154,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 346 "..\..\MainWindow.xaml" + #line 88 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.GroupBox Monitor; @@ -154,7 +162,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 349 "..\..\MainWindow.xaml" + #line 91 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBlock MonitorForCPU; @@ -162,7 +170,7 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I #line hidden - #line 352 "..\..\MainWindow.xaml" + #line 94 "..\..\MainWindow.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.TextBlock MonitorForMem; @@ -201,128 +209,179 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object { case 1: - #line 9 "..\..\MainWindow.xaml" - ((UniversalGUI.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.SaveIniConfig); + #line 10 "..\..\MainWindow.xaml" + ((UniversalGUI.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.MainWindow_WindowClosing); + + #line default + #line hidden + + #line 10 "..\..\MainWindow.xaml" + ((UniversalGUI.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_Loaded); #line default #line hidden return; case 2: - this.MainGrid = ((System.Windows.Controls.Grid)(target)); - return; - case 3: this.StartTaskButton = ((System.Windows.Controls.Button)(target)); - #line 272 "..\..\MainWindow.xaml" + #line 12 "..\..\MainWindow.xaml" this.StartTaskButton.Click += new System.Windows.RoutedEventHandler(this.StartTaskAsync); #line default #line hidden return; - case 4: + case 3: this.TaskProgressBar = ((System.Windows.Controls.ProgressBar)(target)); return; - case 5: + case 4: this.FilesList = ((System.Windows.Controls.ListBox)(target)); - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" this.FilesList.Drop += new System.Windows.DragEventHandler(this.FilesList_Drop); #line default #line hidden - #line 276 "..\..\MainWindow.xaml" + #line 16 "..\..\MainWindow.xaml" this.FilesList.DragOver += new System.Windows.DragEventHandler(this.FilesList_DragOver); #line default #line hidden return; - case 6: + case 5: - #line 278 "..\..\MainWindow.xaml" + #line 18 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddFilesListItems); #line default #line hidden return; - case 7: + case 6: - #line 279 "..\..\MainWindow.xaml" + #line 19 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.RemoveFilesListItems); #line default #line hidden return; - case 8: + case 7: - #line 280 "..\..\MainWindow.xaml" + #line 20 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.EmptyFilesList); #line default #line hidden return; - case 9: + case 8: this.AppPath = ((System.Windows.Controls.TextBox)(target)); - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" this.AppPath.PreviewDragOver += new System.Windows.DragEventHandler(this.ApplicationPath_PreviewDragOver); #line default #line hidden - #line 287 "..\..\MainWindow.xaml" + #line 27 "..\..\MainWindow.xaml" this.AppPath.PreviewDrop += new System.Windows.DragEventHandler(this.ApplicationPath_PreviewDrop); #line default #line hidden return; - case 10: + case 9: - #line 288 "..\..\MainWindow.xaml" + #line 28 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SwitchApplicationPath); #line default #line hidden return; - case 11: + case 10: this.ArgsTemplet = ((System.Windows.Controls.TextBox)(target)); return; - case 12: + case 11: this.UserArgs = ((System.Windows.Controls.TextBox)(target)); return; - case 13: + case 12: this.OutputExtension = ((System.Windows.Controls.TextBox)(target)); + + #line 40 "..\..\MainWindow.xaml" + this.OutputExtension.GotFocus += new System.Windows.RoutedEventHandler(this.OutputExtension_GotFocus); + + #line default + #line hidden + + #line 40 "..\..\MainWindow.xaml" + this.OutputExtension.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OutputExtension_PreviewMouseDown); + + #line default + #line hidden return; - case 14: + case 13: this.OutputSuffix = ((System.Windows.Controls.TextBox)(target)); + + #line 43 "..\..\MainWindow.xaml" + this.OutputSuffix.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OutputSuffix_PreviewMouseDown); + + #line default + #line hidden + + #line 43 "..\..\MainWindow.xaml" + this.OutputSuffix.GotFocus += new System.Windows.RoutedEventHandler(this.OutputSuffix_GotFocus); + + #line default + #line hidden return; - case 15: + case 14: this.OutputFloder = ((System.Windows.Controls.TextBox)(target)); + + #line 46 "..\..\MainWindow.xaml" + this.OutputFloder.PreviewDragOver += new System.Windows.DragEventHandler(this.OutputFloder_PreviewDragOver); + + #line default + #line hidden + + #line 46 "..\..\MainWindow.xaml" + this.OutputFloder.PreviewDrop += new System.Windows.DragEventHandler(this.OutputFloder_PreviewDrop); + + #line default + #line hidden return; - case 16: + case 15: - #line 307 "..\..\MainWindow.xaml" + #line 47 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SwitchOutputFloder); #line default #line hidden return; - case 17: + case 16: this.Priority = ((System.Windows.Controls.ComboBox)(target)); return; - case 18: + case 17: this.ThreadNumber = ((System.Windows.Controls.ComboBox)(target)); return; + case 18: + this.CustomThreadNumberItem = ((System.Windows.Controls.ComboBoxItem)(target)); + return; case 19: - this.CUIWindowStyle = ((System.Windows.Controls.ComboBox)(target)); + this.CustomThreadNumberTextBox = ((System.Windows.Controls.TextBox)(target)); + + #line 75 "..\..\MainWindow.xaml" + this.CustomThreadNumberTextBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CustomThreadNumberTextBox_TextChanged); + + #line default + #line hidden return; case 20: - this.Monitor = ((System.Windows.Controls.GroupBox)(target)); + this.CUIWindowStyle = ((System.Windows.Controls.ComboBox)(target)); return; case 21: - this.MonitorForCPU = ((System.Windows.Controls.TextBlock)(target)); + this.Monitor = ((System.Windows.Controls.GroupBox)(target)); return; case 22: + this.MonitorForCPU = ((System.Windows.Controls.TextBlock)(target)); + return; + case 23: this.MonitorForMem = ((System.Windows.Controls.TextBlock)(target)); return; }