upgrade ProgressUpdater to .net6

This commit is contained in:
2022-06-09 08:41:47 +02:00
parent 50347d6ae6
commit 83b0ca22cd
22 changed files with 942 additions and 1061 deletions

View File

@@ -1,18 +1,19 @@
using DevComponents.DotNetBar;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;
namespace SM64_ROM_Manager.ProgressUpdater
{
public partial class PasteFromDocument : OfficeForm
public partial class PasteFromDocument : RadForm
{
private Settings settings;
@@ -22,15 +23,14 @@ namespace SM64_ROM_Manager.ProgressUpdater
{
this.settings = settings;
InitializeComponent();
UpdateAmbientColors();
}
private void ButtonX_Paste_Click(object sender, EventArgs e)
{
BaseItem selectedItem = null;
foreach (BaseItem item in itemPanel1.Items)
RadListDataItem selectedItem = null;
foreach (RadListDataItem item in RadListControl_Paragraph.Items)
{
if (selectedItem == null && item is CheckBoxItem && ((CheckBoxItem)item).Checked)
if (selectedItem == null && item is RadCheckedListDataItem && ((RadCheckedListDataItem)item).Checked)
selectedItem = item;
}
@@ -44,7 +44,7 @@ namespace SM64_ROM_Manager.ProgressUpdater
private async void textBoxX1_TextChanged(object sender, EventArgs e)
{
var url = textBoxX1.Text.Trim();
var url = radTextBoxControl1.Text.Trim();
settings.UpcommingVersionsDownloadURL = url;
if (!string.IsNullOrEmpty(url))
await GetNewItems(url);
@@ -55,42 +55,39 @@ namespace SM64_ROM_Manager.ProgressUpdater
var mdDocStr = await DownloadString(url);
if (!string.IsNullOrEmpty(mdDocStr))
{
itemPanel1.SuspendLayout();
itemPanel1.Items.Clear();
RadListControl_Paragraph.BeginUpdate();
RadListControl_Paragraph.Items.Clear();
foreach (var kvp in MarkdownHelper.SplitToVersions(mdDocStr))
{
var item = new CheckBoxItem
var item = new RadListDataItem
{
Text = kvp.Key,
Tag = kvp.Value,
CheckBoxStyle = eCheckBoxStyle.RadioButton
Tag = kvp.Value
};
item.DoubleClick += ButtonX_Paste_Click;
itemPanel1.Items.Add(item);
RadListControl_Paragraph.Items.Add(item);
}
itemPanel1.ResumeLayout();
itemPanel1.Refresh();
RadListControl_Paragraph.EndUpdate();
RadListControl_Paragraph.Refresh();
if (itemPanel1.Items.Count != 0)
((CheckBoxItem)itemPanel1.Items[0]).Checked = true;
if (RadListControl_Paragraph.Items.Any())
((RadCheckedListDataItem)RadListControl_Paragraph.Items[0]).Checked = true;
}
}
private static async Task<string> DownloadString(string url)
{
var wc = new WebClient();
var res = await wc.DownloadStringTaskAsync(url);
var wc = new HttpClient();
var res = await wc.GetStringAsync(url);
wc.Dispose();
return res;
}
private void PasteFromDocument_Load(object sender, EventArgs e)
{
textBoxX1.Text = settings.UpcommingVersionsDownloadURL;
radTextBoxControl1.Text = settings.UpcommingVersionsDownloadURL;
}
}
}