diff --git a/installer/Installer/Common.cs b/installer/Installer/Common.cs
index 6fe5377..fc3a554 100644
--- a/installer/Installer/Common.cs
+++ b/installer/Installer/Common.cs
@@ -1,6 +1,8 @@
using System.ComponentModel;
using System;
using System.Windows.Input;
+using System.Globalization;
+using System.Windows.Data;
namespace starter.viewmodel.common
{
@@ -66,4 +68,34 @@ namespace starter.viewmodel.common
}
}
}
+
+ public class RadioConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null || parameter == null)
+ {
+ return false;
+ }
+ string checkvalue = value.ToString();
+ string targetvalue = parameter.ToString();
+ bool r = checkvalue.Equals(targetvalue);
+ return r;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null || parameter == null)
+ {
+ return null;
+ }
+
+ if ((bool)value)
+ {
+ return parameter.ToString();
+ }
+ return null;
+ }
+ }
+
}
diff --git a/installer/Installer/MainWindow.xaml b/installer/Installer/MainWindow.xaml
index cb43e6d..993efaa 100644
--- a/installer/Installer/MainWindow.xaml
+++ b/installer/Installer/MainWindow.xaml
@@ -3,9 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:Installer"
+ xmlns:local="clr-namespace:Installer" xmlns:c="clr-namespace:starter.viewmodel.common"
mc:Ignorable="d"
Title="Installer" Window.SizeToContent="WidthAndHeight">
+
+
+
@@ -34,14 +37,14 @@
-
-
+
+
-
+
-
+
@@ -50,27 +53,40 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
@@ -79,11 +95,18 @@
- 玩家1
- 玩家2
- 玩家3
- 玩家4
+ 玩家1
+ 玩家2
+ 玩家3
+ 玩家4
+
+
+
+
+
+
+
diff --git a/installer/Installer/Model.cs b/installer/Installer/Model.cs
index 7b9e332..371bd97 100644
--- a/installer/Installer/Model.cs
+++ b/installer/Installer/Model.cs
@@ -49,6 +49,7 @@ namespace starter.viewmodel.settings
Password = "";
updates = "";
CodeRoute = "";
+ PlayerNum = "nSelect";
UploadReady = false;
LoginFailed = false;
}
@@ -166,7 +167,9 @@ namespace starter.viewmodel.settings
default:
return -8;
}
- return await web.UploadFiles(client, CodeRoute, Language, "player_1");
+ if (PlayerNum.Equals("nSelect"))
+ return -9;
+ return await web.UploadFiles(client, CodeRoute, Language, PlayerNum);
}
///
/// Route of files
@@ -394,8 +397,8 @@ namespace Downloader
.Build(); // 创建 CosXmlConfig 对象
// 永久密钥访问凭证
- string secretId = "***"; //"云 API 密钥 SecretId";
- string secretKey = "***"; //"云 API 密钥 SecretKey";
+ string secretId = "***"; //"云 API 密钥 SecretId";
+ string secretKey = "***"; //"云 API 密钥 SecretKey";
long durationSecond = 1000; // 每次请求签名有效时长,单位为秒
QCloudCredentialProvider cosCredentialProvider = new DefaultQCloudCredentialProvider(
@@ -1119,7 +1122,8 @@ namespace WebConnect
using FileStream fs = new FileStream(tarfile, FileMode.Open, FileAccess.Read);
using StreamReader sr = new StreamReader(fs);
content = sr.ReadToEnd();
- using (var response = await client.GetAsync($"https://api.eesast.com/static/player?team_id={await GetTeamId()}"))
+ string targetUrl = $"https://api.eesast.com/static/player?team_id={await GetTeamId()}";
+ using (var response = await client.GetAsync(targetUrl))
{
switch (response.StatusCode)
{
@@ -1343,7 +1347,7 @@ namespace WebConnect
// ""query"": ""query MyQuery {{contest_team_member(where: {{user_id: {{_eq: \""{Downloader.UserInfo._id}\""}}}}) {{ team_id }}}}"",
// ""variables"": {{}},
// }}", null, "application/json");
- var content = new StringContent("{\"query\":\"query MyQuery {\\r\\n contest_team_member(where: {user_id: {_eq: \\\""+Downloader.UserInfo._id+"\\\"}}) {\\r\\n team_id\\r\\n }\\r\\n}\",\"variables\":{}}", null, "application/json");
+ var content = new StringContent("{\"query\":\"query MyQuery {\\r\\n contest_team_member(where: {user_id: {_eq: \\\"" + Downloader.UserInfo._id + "\\\"}}) {\\r\\n team_id\\r\\n }\\r\\n}\",\"variables\":{}}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
diff --git a/installer/Installer/ViewModel.cs b/installer/Installer/ViewModel.cs
index d7cd29d..b776fa8 100644
--- a/installer/Installer/ViewModel.cs
+++ b/installer/Installer/ViewModel.cs
@@ -6,8 +6,7 @@ using System.Windows.Forms;
using Downloader;
using MessageBox = System.Windows.MessageBox;
using System.Configuration;
-using WebConnect;
-using System.Net.Http;
+using System.Drawing.Design;
namespace starter.viewmodel.settings
{
@@ -135,6 +134,46 @@ namespace starter.viewmodel.settings
}
}
}
+ public int PlayerNum
+ {
+ get
+ {
+ int ans;
+ if (obj.PlayerNum.Equals("player_1"))
+ ans = 1;
+ else if (obj.PlayerNum.Equals("player_2"))
+ ans = 2;
+ else if (obj.PlayerNum.Equals("player_3"))
+ ans = 3;
+ else if (obj.PlayerNum.Equals("player_4"))
+ ans = 4;
+ else
+ ans = 0;
+ return ans;
+ }
+ set
+ {
+ switch (value)
+ {
+ case 1:
+ obj.PlayerNum = "player_1";
+ break;
+ case 2:
+ obj.PlayerNum = "player_2";
+ break;
+ case 3:
+ obj.PlayerNum = "player_3";
+ break;
+ case 4:
+ obj.PlayerNum = "player_4";
+ break;
+ default:
+ obj.PlayerNum = "nSelect";
+ break;
+ }
+ this.RaisePropertyChanged("PlayerNum");
+ }
+ }
public string Route
{
@@ -242,7 +281,7 @@ namespace starter.viewmodel.settings
{
get
{
- return obj.UpdatePlanned ? "Update" : "Check Updates";
+ return obj.UpdatePlanned ? "更新" : "检查更新";
}
}
public string UpdateInfo
@@ -448,7 +487,9 @@ namespace starter.viewmodel.settings
}
else
{
+ obj.LoginFailed = false;
Status = SettingsModel.Status.web;
+ this.RaisePropertyChanged("CoverVis");
}
this.RaisePropertyChanged("LoginFailVis");
}));
@@ -530,38 +571,46 @@ namespace starter.viewmodel.settings
{
if (obj.UploadReady)
{
- switch (await obj.Upload())
+ if (obj.PlayerNum.Equals("nSelect"))
{
- case -1:
- MessageBox.Show("Token失效!", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
- break;
- case -2:
- MessageBox.Show("目标路径不存在!", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
- break;
- case -3:
- MessageBox.Show("服务器错误", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
- break;
- case -4:
- MessageBox.Show("您未登录或登录失效", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
- Status = SettingsModel.Status.login;
- break;
- case -5:
- MessageBox.Show("您未报名THUAI!", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
- break;
- case -6:
- MessageBox.Show("读取文件失败,请确认文件是否被占用", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
- break;
- case -7:
- MessageBox.Show("网络错误,请检查你的网络", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
- break;
- case -8:
- MessageBox.Show("不是c++或python源文件", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
- break;
+ MessageBox.Show("您还没有选择要上传的玩家身份", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ }
+ else
+ {
+ switch (await obj.Upload())
+ {
+ case -1:
+ MessageBox.Show("Token失效!", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
+ break;
+ case -2:
+ MessageBox.Show("目标路径不存在!", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ break;
+ case -3:
+ MessageBox.Show("服务器错误", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
+ break;
+ case -4:
+ MessageBox.Show("您未登录或登录失效", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ Status = SettingsModel.Status.login;
+ break;
+ case -5:
+ MessageBox.Show("您未报名THUAI!", "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
+ break;
+ case -6:
+ MessageBox.Show("读取文件失败,请确认文件是否被占用", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ break;
+ case -7:
+ MessageBox.Show("网络错误,请检查你的网络", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ break;
+ case -8:
+ MessageBox.Show("不是c++或python源文件", "", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
+ break;
+ }
+ obj.CodeRoute = "";
+ obj.UploadReady = false;
+ this.RaisePropertyChanged("UploadBtnCont");
+ this.RaisePropertyChanged("UploadReadyVis");
+ this.RaisePropertyChanged("CoverVis");
}
- obj.CodeRoute = "";
- obj.UploadReady = false;
- this.RaisePropertyChanged("UploadBtnCont");
- this.RaisePropertyChanged("UploadReadyVis");
}
else
{
@@ -572,6 +621,7 @@ namespace starter.viewmodel.settings
this.RaisePropertyChanged("UploadBtnCont");
this.RaisePropertyChanged("UploadReadyVis");
this.RaisePropertyChanged("CodeName");
+ this.RaisePropertyChanged("CoverVis");
}
else
{
@@ -583,6 +633,26 @@ namespace starter.viewmodel.settings
return clickUploadCommand;
}
}
+ private BaseCommand clickReselectCommand;
+ public BaseCommand ClickReselectCommand
+ {
+ get
+ {
+ if (clickReselectCommand == null)
+ {
+ clickReselectCommand = new BaseCommand(new Action