### rycUpdate V1.0.2506.0401 - *.[修复]修复文件替换失败,不会失败提示的BUG。 ### RaUI V4.0.2508.1601 - *.[新增]ChromeTabControl控件支持设置SizeMode属性。 - *.[新增]HotkeyTextBox新增支持传入热键文本进行自动转换。 - *.[新增]ryQuickSQL类新增GetJsonData方法。 - *.[新增]ryQuickSQL类新增DateToTimeStamp属性,导出时自动将时间类型转为时间戳。 - *.[新增]自动更新模块新增支持版本类型,区分正式版和测试版。 - *.[改进]HotkeyTextBox控件渲染方式改成全画布渲染。 - *.[改进]TextBoxEx2开启多行模式后,空文本改成在第一行显示。 - *.[修复]修复截图功能某些情况下会报错的BUG。 - *.[修复]修复HotkeyValue类处理多功能键文本时转换错误的BUG。 - *.[修复]修复RyComboBox控件在某些情况下边框会丢失的BUG。 - *.[修复]修复Hosts类针对删除hosts规则处理出错的BUG。 - *.[修复]修复当升级文件Url无法访问时,升级模块会无限期等待的BUG。
216 lines
6.8 KiB
C#
216 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
namespace LiveUpdate
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public partial class FrmUpdate : Form
|
|
{
|
|
private readonly ClsLiveUpdate myLiveUpdate;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="_myLiveUpdate"></param>
|
|
public FrmUpdate(ClsLiveUpdate _myLiveUpdate)
|
|
{
|
|
InitializeComponent();
|
|
myLiveUpdate = _myLiveUpdate;
|
|
}
|
|
/// <summary>
|
|
/// 提示文本
|
|
/// </summary>
|
|
[Description("提示文本")]
|
|
public string Capion
|
|
{
|
|
get { return label1.Text; }
|
|
set { label1.Text = value; }
|
|
}
|
|
/// <summary>
|
|
/// 更新日期
|
|
/// </summary>
|
|
[Description("更新日期")]
|
|
public string UpdateDate
|
|
{
|
|
get { return label3.Text; }
|
|
set { label3.Text = value; }
|
|
}
|
|
/// <summary>
|
|
/// 更新版本
|
|
/// </summary>
|
|
[Description("更新版本")]
|
|
public string UpdateVer
|
|
{
|
|
get { return label5.Text; }
|
|
set { label5.Text = value; }
|
|
}
|
|
/// <summary>
|
|
/// 更新描述
|
|
/// </summary>
|
|
[Description("更新描述")]
|
|
public string UpdateDes
|
|
{
|
|
get { return labelTx1.Text; }
|
|
set { labelTx1.Text = value; }
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Str"></param>
|
|
/// <param name="defValue"></param>
|
|
/// <returns></returns>
|
|
public string ConvertDateStr(string Str, string defValue)
|
|
{
|
|
try
|
|
{
|
|
return Convert.ToDateTime(Str).ToString("yyyy-MM-dd");
|
|
}
|
|
catch
|
|
{
|
|
return defValue;
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
public void SetUpdateInfo(UpdateInfo e)
|
|
{
|
|
if (e.UpdateType == "soft")
|
|
{
|
|
Capion = "发现软件存在更新的版本,升级到最新版本,可以体验新功能和更完善的软件。";
|
|
}
|
|
else
|
|
{
|
|
Capion = "发现更新的数据库,升级到最新版数据库,可以获取更全的显示内容。";
|
|
}
|
|
UpdateDate = ConvertDateStr(e.UpdateDate, "未知");
|
|
UpdateVer = e.UpdateVer+(e.VersionType.Length==0?"":" "+e.VersionType);
|
|
if (e.UpdateDes_Url != "" && e.UpdateDes_Url.IndexOf("http", StringComparison.OrdinalIgnoreCase) == 0)
|
|
{
|
|
extendedWebBrowser1.Visible = true;
|
|
labelTx1.Visible = false;
|
|
extendedWebBrowser1.Navigate(e.UpdateDes_Url.Replace("<%rd%>",DateTime.Now.ToString("yyyyMMddHHmmss")));
|
|
}
|
|
else
|
|
{
|
|
extendedWebBrowser1.Visible = false ;
|
|
labelTx1.Visible = true;
|
|
UpdateDes = e.UpdateDes;
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Description("设置多长时间后进行下次更新")]
|
|
public int UpdateAfterTime
|
|
{
|
|
get
|
|
{
|
|
switch (comboBox1.SelectedIndex)
|
|
{
|
|
case 0:
|
|
return 0;
|
|
case 1:
|
|
return 1;
|
|
case 2:
|
|
return 7;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool canClose = false;
|
|
private void BtnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("确定要不升级吗?不升级的话无法获得更好的体验?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
|
{
|
|
return;
|
|
}
|
|
ryCommon.Storage MyXml = new ryCommon.Storage();
|
|
MyXml.LoadFromFile(myLiveUpdate.SettingPath);
|
|
MyXml.SelectNode2("id", "UpdateAfterTime");
|
|
MyXml.SetAttrValue("Value", UpdateAfterTime.ToString());
|
|
MyXml.SaveToFile(myLiveUpdate.SettingPath);
|
|
canClose = true;
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="hWnd"></param>
|
|
/// <returns></returns>
|
|
[DllImport("user32.dll")]
|
|
public static extern bool SetForegroundWindow(int hWnd);
|
|
private void FrmUpdate_Load(object sender, EventArgs e)
|
|
{
|
|
this.MinimumSize = Size;
|
|
comboBox1.SelectedIndex = 0;
|
|
ryCommon.RyForm.RemoveXButton(this.Handle);
|
|
ryCommon.RyForm.BringToTop(this.Handle);
|
|
}
|
|
|
|
private void BtnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
btnUpdate.Enabled = false;
|
|
btnCancel.Enabled = false;
|
|
frmStartUpdate frm = new frmStartUpdate();
|
|
ryCommon.RyFiles.DeleteFile(Application.StartupPath + "\\Update",false);
|
|
Directory.CreateDirectory(Application.StartupPath + "\\Update");
|
|
this.Hide();
|
|
frm.MyLiveUpdate = myLiveUpdate;
|
|
frm.OnAppExit += Frm_OnAppExit;
|
|
frm.ShowDialog(this);
|
|
if (frm.DialogResult == DialogResult.OK)
|
|
{
|
|
canClose = true;
|
|
Application.Exit();
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
btnUpdate.Enabled = true;
|
|
btnCancel.Enabled = true;
|
|
this.Show();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("升级发生错误,升级失败。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public event LiveUpdate.OnAppExit OnAppExit;
|
|
private void Frm_OnAppExit(object sender, EventArgs e)
|
|
{
|
|
OnAppExit?.Invoke(sender, e);
|
|
}
|
|
|
|
private void FrmUpdate_Resize(object sender, EventArgs e)
|
|
{
|
|
//labelTx1.Width = panelEx1.Width - labelTx1.Left- 1;
|
|
panelEx1.Refresh();
|
|
}
|
|
|
|
private void FrmUpdate_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if(!canClose) { e.Cancel = true; }
|
|
}
|
|
}
|
|
}
|