chore: updated upload interaction, now opens AI file in the pack as defaulttags/0.1.0
| @@ -39,7 +39,7 @@ | |||||
| <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="5" Name="RouteTxtBox" Text="{Binding Route}" Visibility="{Binding RouteBoxVis}"/> | <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="5" Name="RouteTxtBox" Text="{Binding Route}" Visibility="{Binding RouteBoxVis}"/> | ||||
| <Button Grid.Row="3" Grid.Column="6" Name="GetRouteBtn" Content="选择文件夹" Command="{Binding ClickBrowseCommand}" Visibility="{Binding RouteBoxVis}" /> | <Button Grid.Row="3" Grid.Column="6" Name="GetRouteBtn" Content="选择文件夹" Command="{Binding ClickBrowseCommand}" Visibility="{Binding RouteBoxVis}" /> | ||||
| <Button Grid.Row="3" Grid.Column="7" Name="SetBtm" Content="{Binding ConfirmBtnCont}" Command="{Binding ClickConfirmCommand}" Visibility="{Binding RouteBoxVis}"/> | <Button Grid.Row="3" Grid.Column="7" Name="SetBtm" Content="{Binding ConfirmBtnCont}" Command="{Binding ClickConfirmCommand}" Visibility="{Binding RouteBoxVis}"/> | ||||
| <Button Grid.Row="4" Grid.Column="6" Grid.ColumnSpan="2" Name="ReadExsisted" Content="从所选文件夹直接读取" Command="{Binding ClickReadCommand}" Visibility="{Binding NewUserVis}"/> | |||||
| <Button Grid.Row="4" Grid.Column="6" Grid.ColumnSpan="2" Name="ReadExsisted" Content="所选文件夹即为选手包" Command="{Binding ClickReadCommand}" Visibility="{Binding NewUserVis}"/> | |||||
| <Button Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Name="UpdateBtn" Content="{Binding UpdateBtnCont}" Command="{Binding ClickUpdateCommand}" Visibility="{Binding MenuVis}" /> | <Button Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Name="UpdateBtn" Content="{Binding UpdateBtnCont}" Command="{Binding ClickUpdateCommand}" Visibility="{Binding MenuVis}" /> | ||||
| <TextBlock Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" FontSize="10" Text="{Binding UpdateInfo}" Visibility="{Binding UpdateInfoVis}" /> | <TextBlock Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" FontSize="10" Text="{Binding UpdateInfo}" Visibility="{Binding UpdateInfoVis}" /> | ||||
| @@ -88,7 +88,7 @@ | |||||
| <TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="你有已完成的比赛!" Visibility="{Binding MatchFinishedVis}"/> | <TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="你有已完成的比赛!" Visibility="{Binding MatchFinishedVis}"/> | ||||
| <Button Grid.Row="3" Grid.Column="1" Name ="Upload" Content="{Binding UploadBtnCont}" Command="{Binding ClickUploadCommand}" Visibility="{Binding WebVis}"/> | <Button Grid.Row="3" Grid.Column="1" Name ="Upload" Content="{Binding UploadBtnCont}" Command="{Binding ClickUploadCommand}" Visibility="{Binding WebVis}"/> | ||||
| <TextBlock Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding CodeName}" Visibility="{Binding UploadReadyVis}" /> | <TextBlock Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding CodeName}" Visibility="{Binding UploadReadyVis}" /> | ||||
| <Button Grid.Row="3" Grid.Column="2" Name="ReUpload" Content="放弃上传" Command="{Binding ClickReselectCommand}" Visibility="{Binding UploadReadyVis}" /> | |||||
| <Button Grid.Row="3" Grid.Column="2" Name="ReUpload" Content="{Binding AbortOrSelLanguage}" Command="{Binding ClickAboutUploadCommand}" Visibility="{Binding WebVis}" /> | |||||
| <Button Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="2" Content="退出登录" Command="{Binding ClickBackCommand}" Visibility="{Binding WebVis}" /> | <Button Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="2" Content="退出登录" Command="{Binding ClickBackCommand}" Visibility="{Binding WebVis}" /> | ||||
| <StackPanel Grid.Row="5" Grid.Column="1" Grid.RowSpan="3" Grid.ColumnSpan="2"> | <StackPanel Grid.Row="5" Grid.Column="1" Grid.RowSpan="3" Grid.ColumnSpan="2"> | ||||
| <Grid> | <Grid> | ||||
| @@ -31,6 +31,8 @@ using WebConnect; | |||||
| using System.IO.Compression; | using System.IO.Compression; | ||||
| using ICSharpCode.SharpZipLib.Tar; | using ICSharpCode.SharpZipLib.Tar; | ||||
| using ICSharpCode.SharpZipLib.GZip; | using ICSharpCode.SharpZipLib.GZip; | ||||
| using static System.Net.WebRequestMethods; | |||||
| using File = System.IO.File; | |||||
| namespace starter.viewmodel.settings | namespace starter.viewmodel.settings | ||||
| { | { | ||||
| @@ -656,6 +658,7 @@ namespace Downloader | |||||
| //Console.WriteLine(filename + "下载完毕!" + Environment.NewLine); | //Console.WriteLine(filename + "下载完毕!" + Environment.NewLine); | ||||
| updateFile++; | updateFile++; | ||||
| } | } | ||||
| UpdatePlanned = false; | |||||
| } | } | ||||
| catch (CosClientException clientEx) | catch (CosClientException clientEx) | ||||
| { | { | ||||
| @@ -808,6 +811,16 @@ namespace Downloader | |||||
| sw.Write(JsonConvert.SerializeObject(dict)); | sw.Write(JsonConvert.SerializeObject(dict)); | ||||
| Check(); | Check(); | ||||
| Download(); | Download(); | ||||
| if (File.Exists(Data.FilePath + "/THUAI6/AI.cpp")) | |||||
| { | |||||
| FileInfo userCpp = new FileInfo((Data.FilePath + "/THUAI6/AI.cpp").Replace("/", "\\")); | |||||
| userCpp.MoveTo(Data.FilePath + "/THUAI6/win/CAPI/cpp/API/src/AI.cpp", true); | |||||
| } | |||||
| if (File.Exists(Data.FilePath + "/THUAI6/AI.py")) | |||||
| { | |||||
| FileInfo userCpp = new FileInfo((Data.FilePath + "/THUAI6/AI.py").Replace("/", "\\")); | |||||
| userCpp.MoveTo(Data.FilePath + "/THUAI6/win/CAPI/python/PyAPI/AI.cpp", true); | |||||
| } | |||||
| } | } | ||||
| public static void Change_all_hash(string topDir, Dictionary<string, string> jsonDict) // 更改HASH | public static void Change_all_hash(string topDir, Dictionary<string, string> jsonDict) // 更改HASH | ||||
| @@ -887,7 +900,7 @@ namespace Downloader | |||||
| public static int DeleteAll() | public static int DeleteAll() | ||||
| { | { | ||||
| DirectoryInfo di = new DirectoryInfo(Data.FilePath); | |||||
| DirectoryInfo di = new DirectoryInfo(Data.FilePath + "/THUAI6"); | |||||
| //DirectoryInfo player = new DirectoryInfo(System.IO.Path.GetFullPath(System.IO.Path.Combine(Data.FilePath, playerFolder))); | //DirectoryInfo player = new DirectoryInfo(System.IO.Path.GetFullPath(System.IO.Path.Combine(Data.FilePath, playerFolder))); | ||||
| FileInfo[] allfile = di.GetFiles(); | FileInfo[] allfile = di.GetFiles(); | ||||
| try | try | ||||
| @@ -902,10 +915,16 @@ namespace Downloader | |||||
| //} | //} | ||||
| file.Delete(); | file.Delete(); | ||||
| } | } | ||||
| FileInfo userFileCpp = new FileInfo(Data.FilePath + "/THUAI6/win/CAPI/cpp/API/src/AI.cpp"); | |||||
| FileInfo userFilePy = new FileInfo(Data.FilePath + "/THUAI6/win/CAPI/python/PyAPI/AI.py"); | |||||
| userFileCpp.MoveTo(System.IO.Path.Combine(Data.FilePath + "/THUAI6", System.IO.Path.GetFileName(userFileCpp.FullName))); | |||||
| userFilePy.MoveTo(System.IO.Path.Combine(Data.FilePath + "/THUAI6", System.IO.Path.GetFileName(userFilePy.FullName))); | |||||
| foreach (DirectoryInfo subdi in di.GetDirectories()) | foreach (DirectoryInfo subdi in di.GetDirectories()) | ||||
| { | { | ||||
| subdi.Delete(true); | subdi.Delete(true); | ||||
| } | } | ||||
| FileInfo hashFile = new FileInfo(Data.FilePath + "/hash.json"); | |||||
| hashFile.Delete(); | |||||
| } | } | ||||
| catch (UnauthorizedAccessException) | catch (UnauthorizedAccessException) | ||||
| { | { | ||||
| @@ -12,6 +12,7 @@ using System.ComponentModel; | |||||
| using Installer; | using Installer; | ||||
| using static System.Windows.Forms.VisualStyles.VisualStyleElement; | using static System.Windows.Forms.VisualStyles.VisualStyleElement; | ||||
| using System.IO; | using System.IO; | ||||
| using System.Windows.Automation.Provider; | |||||
| namespace starter.viewmodel.settings | namespace starter.viewmodel.settings | ||||
| { | { | ||||
| @@ -250,6 +251,20 @@ namespace starter.viewmodel.settings | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public string AbortOrSelLanguage | |||||
| { | |||||
| get | |||||
| { | |||||
| string ans = ""; | |||||
| if (obj.UploadReady) | |||||
| ans = "放弃上传"; | |||||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||||
| ans = "语言:c++"; | |||||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.python) | |||||
| ans = "语言:python"; | |||||
| return ans; | |||||
| } | |||||
| } | |||||
| public int PlayerNum | public int PlayerNum | ||||
| { | { | ||||
| get | get | ||||
| @@ -504,10 +519,18 @@ namespace starter.viewmodel.settings | |||||
| } | } | ||||
| else if (type == "File") | else if (type == "File") | ||||
| { | { | ||||
| var openFileDialog = new Microsoft.Win32.OpenFileDialog() | |||||
| var openFileDialog = new Microsoft.Win32.OpenFileDialog(); | |||||
| if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||||
| { | |||||
| openFileDialog.InitialDirectory = (Route + "/THUAI6/win/CAPI/cpp/API/src/").Replace("/", "\\"); | |||||
| openFileDialog.Filter = "c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h|python Source File (.py)|*.py"; | |||||
| } | |||||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.python) | |||||
| { | { | ||||
| Filter = "c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h|python Source File (.py)|*.py" | |||||
| }; | |||||
| openFileDialog.InitialDirectory = (Route + "/THUAI6/win/CAPI/python/PyAPI/").Replace("/", "\\"); | |||||
| openFileDialog.Filter = "python Source File (.py)|*.py|c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h"; | |||||
| } | |||||
| var result = openFileDialog.ShowDialog(); | var result = openFileDialog.ShowDialog(); | ||||
| if (result == true) | if (result == true) | ||||
| { | { | ||||
| @@ -658,7 +681,7 @@ namespace starter.viewmodel.settings | |||||
| break; | break; | ||||
| case 0: | case 0: | ||||
| Status = SettingsModel.Status.newUser; | Status = SettingsModel.Status.newUser; | ||||
| MessageBox.Show($"删除成功!player文件夹中的文件已经放在{Downloader.Program.ProgramName}的根目录下", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); | |||||
| MessageBox.Show($"删除成功!player文件夹中的文件已经放在{Downloader.Program.Data.FilePath}/{Downloader.Program.ProgramName}的根目录下", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); | |||||
| break; | break; | ||||
| default: | default: | ||||
| Status = SettingsModel.Status.error; | Status = SettingsModel.Status.error; | ||||
| @@ -833,6 +856,7 @@ namespace starter.viewmodel.settings | |||||
| this.RaisePropertyChanged("UploadBtnCont"); | this.RaisePropertyChanged("UploadBtnCont"); | ||||
| this.RaisePropertyChanged("UploadReadyVis"); | this.RaisePropertyChanged("UploadReadyVis"); | ||||
| this.RaisePropertyChanged("CoverVis"); | this.RaisePropertyChanged("CoverVis"); | ||||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -845,6 +869,7 @@ namespace starter.viewmodel.settings | |||||
| this.RaisePropertyChanged("UploadReadyVis"); | this.RaisePropertyChanged("UploadReadyVis"); | ||||
| this.RaisePropertyChanged("CodeName"); | this.RaisePropertyChanged("CodeName"); | ||||
| this.RaisePropertyChanged("CoverVis"); | this.RaisePropertyChanged("CoverVis"); | ||||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -856,24 +881,38 @@ namespace starter.viewmodel.settings | |||||
| return clickUploadCommand; | return clickUploadCommand; | ||||
| } | } | ||||
| } | } | ||||
| private BaseCommand clickReselectCommand; | |||||
| public BaseCommand ClickReselectCommand | |||||
| private BaseCommand clickAboutUploadCommand; | |||||
| public BaseCommand ClickAboutUploadCommand | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| if (clickReselectCommand == null) | |||||
| if (clickAboutUploadCommand == null) | |||||
| { | { | ||||
| clickReselectCommand = new BaseCommand(new Action<object>(o => | |||||
| clickAboutUploadCommand = new BaseCommand(new Action<object>(o => | |||||
| { | { | ||||
| obj.CodeRoute = ""; | |||||
| obj.UploadReady = false; | |||||
| this.RaisePropertyChanged("UploadBtnCont"); | |||||
| this.RaisePropertyChanged("UploadReadyVis"); | |||||
| this.RaisePropertyChanged("CodeName"); | |||||
| this.RaisePropertyChanged("CoverVis"); | |||||
| if (obj.UploadReady) | |||||
| { | |||||
| obj.CodeRoute = ""; | |||||
| obj.UploadReady = false; | |||||
| this.RaisePropertyChanged("UploadBtnCont"); | |||||
| this.RaisePropertyChanged("UploadReadyVis"); | |||||
| this.RaisePropertyChanged("CodeName"); | |||||
| this.RaisePropertyChanged("CoverVis"); | |||||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||||
| } | |||||
| else | |||||
| { | |||||
| if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||||
| obj.launchLanguage = SettingsModel.LaunchLanguage.python; | |||||
| else | |||||
| obj.launchLanguage = SettingsModel.LaunchLanguage.cpp; | |||||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||||
| this.RaisePropertyChanged("ShiftLanguageBtnCont"); | |||||
| this.RaisePropertyChanged("LaunchBtnCont"); | |||||
| } | |||||
| })); | })); | ||||
| } | } | ||||
| return clickReselectCommand; | |||||
| return clickAboutUploadCommand; | |||||
| } | } | ||||
| } | } | ||||
| private BaseCommand clickExitCommand; | private BaseCommand clickExitCommand; | ||||
| @@ -906,6 +945,7 @@ namespace starter.viewmodel.settings | |||||
| obj.launchLanguage = SettingsModel.LaunchLanguage.cpp; | obj.launchLanguage = SettingsModel.LaunchLanguage.cpp; | ||||
| this.RaisePropertyChanged("ShiftLanguageBtnCont"); | this.RaisePropertyChanged("ShiftLanguageBtnCont"); | ||||
| this.RaisePropertyChanged("LaunchBtnCont"); | this.RaisePropertyChanged("LaunchBtnCont"); | ||||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||||
| })); | })); | ||||
| } | } | ||||
| return clickShiftLanguageCommand; | return clickShiftLanguageCommand; | ||||