RaUI/Source/Itrycn_Project2/FrmStart.cs
鑫Intel 6bc527a8a2 ### 2020-12-27 dev更新
------

#### ryControls    V2.1.2012.2701
- *.[改进]IconViewEx控件选中背景颜色支持渐变。
- *.[改进]支持设置IconViewEx控件选中字体颜色。
2020-12-27 17:03:04 +08:00

148 lines
5.8 KiB
C#

using Itrycn_Project;
using ryCommon;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Itrycn_Project2
{
public partial class FrmStart : Form
{
string[] prog_args;
public FrmStart(string[] args)
{
InitializeComponent();
prog_args = args;
//配置软件信息
notifyIcon1.Text = Soft_Info.Soft_Title;
Text = Soft_Info.Soft_Title + " V" + RySoft.VersionStr;
if (!Soft_Info.ShowTray) { notifyIcon1.Visible = false; }
if (!Soft_Info.DonateVisabled) { ToolStripMenuItem.Text = "关于"; }
if (Soft_Info.Soft_Url.Length == 0) { ToolStripMenuItem.PerformClick(); }
notifyIcon1.Icon = Icon;
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
var topmost = this.TopMost;
this.TopMost = true;
this.Show();
this.TopMost = topmost;
}
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FrmStart_Shown(object sender, EventArgs e)
{
ryCommon.Ini ini = new Ini(Soft_Info.UserDataFolder + "\\Win.dat");
ini.WriteIni(Soft_Info.Soft_Id, "hwnd", Handle.ToInt32());
if (prog_args.Length >= 1)
{
//如果是自启动,并且开启了右下角托盘图标,则隐藏自身。
if (prog_args[0] == Soft_Info.Soft_Pram && Soft_Info.ShowTray)
this.Hide();
}
}
private void FrmStart_FormClosing(object sender, FormClosingEventArgs e)
{
if (Soft_Info.ShowTray && Soft_Config.HideByCloseBtn && e.CloseReason== CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide();
notifyIcon1.ShowBalloonTip(3000, Soft_Info.Soft_Title, "软件已经最小化到此处,请右击托盘图标进行关闭。", ToolTipIcon.Info);
return;
}
if (!Soft_Config.IsCanCloseForm)
{
e.Cancel = true;
MessageBox.Show("当前还有操作正在运行,请稍后关闭软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
protected override void WndProc(ref System.Windows.Forms.Message msg)
{
switch (msg.Msg)
{
case 17189: //处理消息
{
#region
switch (msg.WParam.ToInt32())
{
case 100://
#region
if ((int)msg.LParam.ToInt32() == 100)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Top = (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2;
this.Left = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2;
//RyForm.SetActiveWindow(Handle);
RyForm.BringToTop(Handle);
ToolStripMenuItem.PerformClick();
this.BringToFront();
this.Select();
this.Focus();
RyForm.BringToTop(Handle);
}
#endregion
break;
}
#endregion
}
break;
default:
base.WndProc(ref msg);//调用基类函数处理非自定义消息。
break;
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Soft_Info.DonateVisabled)
{
FrmAbout frm = new FrmAbout();
frm.ShowDialog();
frm.Dispose();
}
else
{
MessageBox.Show(Soft_Info.AboutText.Replace("#softname#", Soft_Info.Soft_Title).Replace("#ver#", "V" + RySoft.VersionStr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ryCommon.RyFiles.OpenUrl(Soft_Info.Soft_Url);
}
private void FrmStart_Load(object sender, EventArgs e)
{
RyFiles.AddDropDrag(tabPage1.Handle);
Itrycn_Project.Itrycn_Db.CreateTable();
LiveUpdate.RyUpdate update = new LiveUpdate.RyUpdate(Soft_Info.Update_Url);
update.CheckUpdate();
var dbver = Itrycn_Db.GetDbVer();
if(dbver==1) //初始版本,并是当前要求的数据库
{
}
else
{
MessageBox.Show("不支持当前数据库版本,这可能是以下原因导致的:\r\n1.数据库已损坏;'\r\n2.当前数据库是由新版软件创建的(请更新软件后重试)。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
return;
}
}
}
}