Skip to content

Commit

Permalink
1.1.5 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Jul 26, 2022
1 parent ea8d467 commit ba0744f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 39 deletions.
7 changes: 3 additions & 4 deletions Commons/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ private async void ReleaseListBox_SelectionChanged(object sender, SelectionChang
Title = "正在保存更新";

new DirectoryInfo(Define.CACHE_PATH).Create(); //创建文件夹
using FileStream fileStream = new(
Path.Combine(Define.CACHE_PATH, (string)ReleaseListBox.SelectedItem),
FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete);
fileStream.Write(ReleaseBytes, 0, ReleaseBytes.Length);
using (FileStream fileStream = new(Path.Combine(Define.CACHE_PATH, (string)ReleaseListBox.SelectedItem),
FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete))
fileStream.Write(ReleaseBytes, 0, ReleaseBytes.Length);

Title = "正在打开更新";

Expand Down
12 changes: 6 additions & 6 deletions Pages/AppearancePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEven
{
if (Define.MAIN_WINDOW != null)
{
Define.MAIN_WINDOW!.ActiveRightBorder.Opacity = 1 - OpacitySlider.Value / 100; ;
Define.MAIN_WINDOW!.ActiveRightBorder.Opacity = Define.MAIN_WINDOW!.ActiveTopBorder.Opacity = 1 - OpacitySlider.Value / 100;

Properties.Settings.Default.MenuOpacity = OpacitySlider.Value;
Properties.Settings.Default.Save();
Expand Down Expand Up @@ -161,11 +161,11 @@ private void SetButtonContent()
Define.MAIN_WINDOW!.ActiveSettingButton.Content = "设置";
Define.MAIN_WINDOW!.ActiveAboutButton.Content = "关于";

Define.MAIN_WINDOW!.ActiveViewButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveSearchButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveDownloadButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveLuckyButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveSettingButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveViewButton.ToolTip =
Define.MAIN_WINDOW!.ActiveSearchButton.ToolTip =
Define.MAIN_WINDOW!.ActiveDownloadButton.ToolTip =
Define.MAIN_WINDOW!.ActiveLuckyButton.ToolTip =
Define.MAIN_WINDOW!.ActiveSettingButton.ToolTip =
Define.MAIN_WINDOW!.ActiveAboutButton.ToolTip = null;
}
}
Expand Down
43 changes: 14 additions & 29 deletions Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,44 +426,30 @@ private async Task IsKeyWord()
Title = "关键词解析完成";
}

//将URL的参数分离成键值对集合 (待优化)
//将URL的参数分离成键值对集合
private static NameValueCollection GetParamCollection(string queryString)
{
queryString = queryString.Replace("?", string.Empty);
//去掉开头的'?'字符并在末尾添加一个'&'字符标志结束
queryString = queryString.Replace("?", string.Empty) + '&';

//分离所有参数并记录
NameValueCollection paramCollection = new(StringComparer.OrdinalIgnoreCase);
if (!string.IsNullOrWhiteSpace(queryString))
{
for (int i = 0; i < queryString.Length; ++i)
int startIndex = 0, equalIndex = 0;
for (int endIndex = 0; endIndex < queryString.Length; ++endIndex)
{
int startIndex = i, index = -1;
while (i < queryString.Length)
{
if (queryString[i] == '=' && index < 0)
index = i;
else if (queryString[i] == '&')
break;

++i;
}

string key;
string value = null!;
if (index >= 0)
if (queryString[endIndex] == '=')
equalIndex = endIndex;
else if (queryString[endIndex] == '&')
{
key = queryString[startIndex..index];
value = queryString.Substring(index + 1, i - index - 1);
paramCollection[HttpUtility.UrlDecode(queryString[startIndex..equalIndex], Encoding.UTF8)] = HttpUtility.UrlDecode(queryString[(equalIndex + 1)..endIndex], Encoding.UTF8);
startIndex = endIndex + 1;
}
else
{
key = queryString[startIndex..i];
}

paramCollection[HttpUtility.UrlDecode(key, Encoding.UTF8)] = HttpUtility.UrlDecode(value, Encoding.UTF8);
if (i == queryString.Length - 1 && queryString[i] == '&')
paramCollection[key] = string.Empty;
}
}

//返回包含所有被分离的参数的键值对集合
return paramCollection;
}

Expand Down Expand Up @@ -516,7 +502,7 @@ private async Task GetImage(string imageUri)
bitmapImage.BeginInit();
bitmapImage.StreamSource = responseMessage.Content.ReadAsStream();
try { bitmapImage.EndInit(); }
catch (NotSupportedException) { throw new NotSupportedException("文件格式不合法"); }
catch (NotSupportedException) { throw new NotSupportedException("无法显示该结果"); }

CURRENT_IMAGE = bitmapImage;

Expand All @@ -538,7 +524,6 @@ private void SetImage()
Title = "正在读取图片";

ImageBehavior.SetAnimatedSource(ShowImage, CURRENT_IMAGE);

SetControlsEnabled();

Title = "图片读取完成";
Expand Down

0 comments on commit ba0744f

Please sign in to comment.