------ #### VSoft V1.0.2312.0401 - *.[改进]升级到.NET 4.6.2。 - *.[改进]双击列表时优先隐藏界面(当开启开关时)。
1843 lines
77 KiB
C#
1843 lines
77 KiB
C#
using ryCommon;
|
||
using ryCommonDb;
|
||
using ryControls;
|
||
using SysFuns;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Windows.Forms;
|
||
using VSoft.Config;
|
||
using VSoft.Prams;
|
||
using VSoft.Skins;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
|
||
|
||
namespace VSoft
|
||
{
|
||
public partial class FrmVSoft : SKinForm
|
||
{
|
||
readonly string[] prog_args;
|
||
readonly string SQLConnStr = Itrycn_Db.SQLConnStr;
|
||
readonly MouseHook mouse = new MouseHook();
|
||
public FrmVSoft(string[] args)
|
||
{
|
||
InitializeComponent();
|
||
prog_args = args;
|
||
//配置软件信息
|
||
notifyIcon1.Text = Config.Soft_Info.Soft_Title;
|
||
Text = Config.Soft_Info.Soft_Title + " V" + RySoft.GetVersionStr(Application.ExecutablePath);
|
||
#if TEST
|
||
Text +=" V内部测试版";
|
||
#endif
|
||
if (!Config.Soft_Info.ShowTray) { notifyIcon1.Visible = false; }
|
||
#if DY
|
||
捐助ToolStripMenuItem.Text = "关于";
|
||
#else
|
||
if (!Config.Soft_Info.DonateVisabled) { 捐助ToolStripMenuItem.Text = "关于"; } else { 捐助ToolStripMenuItem.Text = "捐助/关于"; }
|
||
#endif
|
||
if (Config.Soft_Info.Soft_Url.Length == 0) { 打开官网ToolStripMenuItem.PerformClick(); }
|
||
|
||
notifyIcon1.Icon = Icon;
|
||
var backcolor = SystemColors.Control;
|
||
TabList_Column.BackColor = backcolor;
|
||
TabList_Type.BackColor = backcolor;
|
||
//pictureBox1.BackColor = backcolor;
|
||
PnlLeft.BackColor = backcolor;
|
||
|
||
}
|
||
private readonly System.Windows.Forms.ToolTip lvTp = new System.Windows.Forms.ToolTip();
|
||
private void FrmVSoft_FormClosed(object sender, FormClosedEventArgs e)
|
||
{
|
||
mouse.Stop();
|
||
}
|
||
DateTime dt_lastMouse = DateTime.Now;
|
||
int clickcount = 1;
|
||
private void Mouse_OnMouseActivity(object sender, MouseEventArgs e)
|
||
{
|
||
if (!Soft_Config.ShowMainMouseKeyOn) { return; }
|
||
var button = MouseButtons.Middle;
|
||
if(Soft_Config.ShowMainMouseKey==1)
|
||
{
|
||
button = MouseButtons.XButton1;
|
||
}
|
||
else if (Soft_Config.ShowMainMouseKey == 2)
|
||
{
|
||
button = MouseButtons.XButton2;
|
||
}
|
||
if (e.Button== button)
|
||
{
|
||
//ryCommon.RyFiles.WriteAllText(Application.StartupPath+"\\1.txt",e.Button.ToString(),Encoding.UTF8);
|
||
if(Math.Abs((dt_lastMouse-DateTime.Now).TotalMilliseconds)<500)
|
||
{
|
||
clickcount++;
|
||
if (clickcount == 2)
|
||
{
|
||
ShowOrHideUI();
|
||
}
|
||
clickcount = 1;
|
||
}
|
||
else
|
||
{
|
||
clickcount = 1;
|
||
}
|
||
dt_lastMouse = DateTime.Now;
|
||
}
|
||
// Msg.ShowMsg(e.Button.ToString());
|
||
// e.Button == MouseButtons.Middle;
|
||
}
|
||
|
||
private bool IsProcUse = false;
|
||
private void LoadDb()
|
||
{
|
||
LoadDb(false);
|
||
}
|
||
|
||
readonly Dictionary<string, Image> dictCacheImg = new Dictionary<string, Image>();
|
||
private void LoadDb(bool isSearch)
|
||
{
|
||
IconViewEx1.Items.Clear();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var id = GetCurColumnId();
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("SearchText", "%" + rySearch1.Text + "%");
|
||
var sql = "select * from Softs where (Name like @SearchText or Path like @SearchText or Des like @SearchText or PinYin like @SearchText)";
|
||
if (isSearch)
|
||
{
|
||
IsProcUse = true;
|
||
TabList_Column.SelectedItems.Clear();
|
||
TabList_Type.Items.Clear();
|
||
TabList_Type.Items.Add("默认分类").Tag = 0;
|
||
IsProcUse = false;
|
||
}
|
||
else
|
||
{
|
||
if (id > 0)
|
||
{
|
||
sql += " and ColumnId=" + id;
|
||
}
|
||
else { sql += " and ColumnId<=0"; }
|
||
}
|
||
DataSet ds = db.ReadData(sql + " order by sortindex asc,AddTime desc", mySQL);
|
||
IconViewEx1.BeginUpdate();
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[i];
|
||
SoftInfo info = new SoftInfo
|
||
{
|
||
Id = row["id"].ToInt(),
|
||
SoftType = row["SoftType"].ToInt(),
|
||
ColumnId = row["ColumnId"].ToInt(),
|
||
Name = row["Name"].ToString(),
|
||
Path = row["Path"].ToString(),
|
||
RunPram = row["RunPram"].ToString(),
|
||
SetJson = row["SetJson"].ToString(),
|
||
StartPath = row["StartPath"].ToString(),
|
||
IconPath = row["IconPath"].ToString()
|
||
};
|
||
string img_path;
|
||
if (info.IconPath.Length == 0)
|
||
{
|
||
img_path = info.TruePath;
|
||
}
|
||
else
|
||
{
|
||
img_path = RyFiles.GetRealPath(info.IconPath);
|
||
}
|
||
if(dictCacheImg.ContainsKey(img_path))
|
||
{
|
||
info.Image = dictCacheImg[img_path];
|
||
}
|
||
else
|
||
{
|
||
info.Image = API.GetImg(img_path, 128);
|
||
dictCacheImg.Add(img_path, info.Image);
|
||
}
|
||
Application.DoEvents();
|
||
IconViewEx1.Items.Add(info.Name).Tag = info ;
|
||
}
|
||
IconViewEx1.EndUpdate();
|
||
db.Free();
|
||
if(IconViewEx1.Items.Count==0)
|
||
{
|
||
LblEmpty.Visible = true;
|
||
}
|
||
else { LblEmpty.Visible = false; }
|
||
}
|
||
db.Free();
|
||
}
|
||
private void LoadColumn()
|
||
{
|
||
TabList_Column.Items.Clear();
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
TabList_Column.BeginUpdate();
|
||
DataSet ds = db.ReadData("select * from Columns where parentId=0 order by sortindex asc");
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[i];
|
||
TabList_Column.Items.Add(row["Name"].ToString()).Tag = row["id"].ToInt();
|
||
}
|
||
if(ds.Tables[0].Rows.Count==0)
|
||
{
|
||
#region 如果没有栏目,则创建一个栏目
|
||
RyQuickSQL mySQL = new RyQuickSQL("Columns");
|
||
mySQL.AddField("Name", "默认栏目");
|
||
mySQL.AddField("editTime", DateTime.Now);
|
||
mySQL.AddField("sortindex", 1);
|
||
mySQL.AddField("parentId", 0);
|
||
mySQL.AddField("addTime", DateTime.Now);
|
||
var ds_c = db.ReadData(mySQL.GetInsertSQL() + ";select last_insert_rowid();", mySQL);
|
||
if (mydb.HaveData(ds_c))
|
||
{
|
||
var ParentId = mydb.GetValue(ds_c);
|
||
RyQuickSQL mySQL2 = new RyQuickSQL("Columns");
|
||
mySQL2.AddField("Name", "默认分类");
|
||
mySQL2.AddField("Des", "");
|
||
mySQL2.AddField("editTime", DateTime.Now);
|
||
mySQL2.AddField("sortindex", Itrycn_Db.GetColumnCount(db, ParentId) + 1);
|
||
mySQL2.AddField("parentId", ParentId);
|
||
mySQL2.AddField("addTime", DateTime.Now);
|
||
db.ExecuteNonQuery(mySQL2.GetInsertSQL(), mySQL2);
|
||
}
|
||
ds_c.Dispose();
|
||
DataSet ds2 = db.ReadData("select * from Columns where parentId=0 order by sortindex asc");
|
||
for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds2.Tables[0].Rows[i];
|
||
TabList_Column.Items.Add(row["Name"].ToString()).Tag = row["id"].ToInt();
|
||
}
|
||
ds2.Dispose();
|
||
#endregion
|
||
}
|
||
ds.Dispose();
|
||
TabList_Column.EndUpdate();
|
||
db.Free();
|
||
}
|
||
if(TabList_Column.Items.Count>0)
|
||
{
|
||
TabList_Column.Items[0].Selected = true;
|
||
}
|
||
}
|
||
private void LoadTypeColumn(int id)
|
||
{
|
||
TabList_Type.Items.Clear();
|
||
//TabList_Type.Items.Add("默认分类").Tag = 0;
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Columns where parentId="+ id + " order by sortindex asc");
|
||
TabList_Type.BeginUpdate();
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[i];
|
||
TabList_Type.Items.Add(row["Name"].ToString()).Tag = row["id"].ToInt();
|
||
}
|
||
ds.Dispose();
|
||
TabList_Type.EndUpdate();
|
||
db.Free();
|
||
}
|
||
if (TabList_Type.Items.Count > 0)
|
||
{
|
||
TabList_Type.Items[0].Selected = true;
|
||
}
|
||
}
|
||
int hot_index = 0;
|
||
/// <summary>
|
||
/// 注册热键
|
||
/// </summary>
|
||
private void RegisterHotkey()
|
||
{
|
||
hotkey.UnHotKey();
|
||
IDbInterface db2 = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db2.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var index = 100;
|
||
HotkeyValue hot = new HotkeyValue(Soft_Config.ShowMainHotKey);
|
||
hotkey.RegHotKey(100, hot.Modifiers_Int, hot.KeyCode);
|
||
var ds_type = db2.ReadData("select * from Columns where Hotkey<>''");
|
||
if (ds_type.HaveData())
|
||
{
|
||
for (int i = 0; i < ds_type.Tables[0].Rows.Count; i++)
|
||
{
|
||
index++;
|
||
var item = ds_type.GetRow(i);
|
||
hot.LoadHotKeyStr(item["HotKey"].ToString());
|
||
hotkey.RegHotKey(index, "type_" + item["id"].ToInt(), hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
ds_type.Dispose();
|
||
var ds = db2.ReadData("select * from Softs where Hotkey<>''");
|
||
if (ds.HaveData())
|
||
{
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
index++;
|
||
var item = ds.GetRow(i);
|
||
hot.LoadHotKeyStr(item["HotKey"].ToString());
|
||
hotkey.RegHotKey(index, "soft_" + item["id"].ToInt(), hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
ds.Dispose();
|
||
hot_index = index;
|
||
}
|
||
db2.Free();
|
||
}
|
||
SysFuns.WinHotReg hotkey;
|
||
private void FrmVSoft_Load(object sender, EventArgs e)
|
||
{
|
||
//IconViewEx1.SetInterval(100, 100);
|
||
Config.Soft_Config.MainForm = this;
|
||
MinimumSize = new Size(400, 200);
|
||
LblEmpty.Left =((panelEx1.Width - LblEmpty.Width) / 2);
|
||
Config.Soft_Info.UserDataFolder = ryCommon.RyFiles.GetRealPath(Config.Soft_Info.UserDataFolder);
|
||
Itrycn_Db.SQLConnStr = Soft_Info.UserDataFolder + "\\Softs.dat|";
|
||
Itrycn_Db.SQLConnStr_Logs = Soft_Info.UserDataFolder + "\\logs.dat|";
|
||
VSoft.Prams.Itrycn_Db.CreateTable();
|
||
var dbver = Itrycn_Db.GetDbVer();
|
||
if (dbver == 2) //当前要求的数据库
|
||
{
|
||
|
||
}
|
||
else //不是符合的数据库
|
||
{
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
if (dbver == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Columns where parentId=0 order by sortindex asc");
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[i];
|
||
#region 新建一个默认分类
|
||
RyQuickSQL mySQL2 = new RyQuickSQL("Columns");
|
||
mySQL2.AddField("Name", "默认分类");
|
||
mySQL2.AddField("Des", "");
|
||
mySQL2.AddField("editTime", DateTime.Now);
|
||
mySQL2.AddField("sortindex", Itrycn_Db.GetColumnCount(db, row["id"].ToInt()) + 1);
|
||
mySQL2.AddField("parentId", row["id"].ToInt());
|
||
mySQL2.AddField("addTime", DateTime.Now);
|
||
var ds_id = db.ReadData(mySQL2.GetInsertSQL() + ";select last_insert_rowid();", mySQL2);
|
||
var type_id = mydb.GetValue(ds_id);
|
||
#endregion
|
||
RyQuickSQL mySQL3 = new RyQuickSQL("Softs");
|
||
mySQL3.AddField("ColumnId", type_id);//将直属分类修改为默认分类
|
||
db.ExecuteNonQuery(mySQL3.GetUpdateSQL()+ " where ColumnId="+ row["id"].ToInt(), mySQL3);
|
||
}
|
||
ds.Dispose();
|
||
Itrycn_Db.SetDbVer(2);
|
||
}
|
||
else
|
||
{
|
||
db.Free();
|
||
Msg.ShowMsg("不支持当前数据库版本,这可能是以下原因导致的:\r\n1.数据库已损坏;'\r\n2.当前数据库是由新版软件创建的(请更新软件后重试)。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
Application.Exit();
|
||
return;
|
||
}
|
||
}
|
||
db.Free();
|
||
}
|
||
VSoft.Config.Soft_Config.LoadSetting();
|
||
LoadColumn();
|
||
//rySearch1.PerformClick();
|
||
//if(RySoft.IsAdministrator())
|
||
//{
|
||
// Msg.ShowMsg("管理员模式下启动本软件,可能会导致无法拖放图标到本软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
//}
|
||
hotkey = new SysFuns.WinHotReg(Handle);
|
||
hotkey.OnHotkey += Hotkey_OnHotkey;
|
||
RegisterHotkey();
|
||
#region 加载图标缓存
|
||
IDbInterface db2 = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db2.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db2.ReadData("select * from Softs");
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[i];
|
||
var IconPath = row["IconPath"].ToString();
|
||
var TruePath = RyFiles.GetRealPath(row["Path"].ToString());
|
||
string img_path;
|
||
Image image;
|
||
if (IconPath.Length == 0)
|
||
{
|
||
img_path = TruePath;
|
||
}
|
||
else
|
||
{
|
||
img_path = RyFiles.GetRealPath(IconPath);
|
||
}
|
||
if (!dictCacheImg.ContainsKey(img_path))
|
||
{
|
||
image = API.GetImg(img_path, 128);
|
||
dictCacheImg.Add(img_path, image);
|
||
}
|
||
}
|
||
}
|
||
db2.Free();
|
||
#endregion
|
||
ryCommon.RyRegedit.RegRoot = Microsoft.Win32.RegistryHive.CurrentUser;
|
||
//如果开机启动没有启动
|
||
if(!ryCommon.RyRegedit.IsAutoRun(Soft_Info.Soft_Id, "\"" + Application.ExecutablePath.Replace("/", "\\") + "\" " + Soft_Info.Soft_Pram))
|
||
{
|
||
switch (Msg.ShowMsg("您暂未设置开机启动,下次开机后软件将无法自动运行。\r\n设置过程中可能会遇到安全软件提示,请选择允许。\r\n\r\n是否要设置开机启动?", "开机启动", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2))
|
||
{
|
||
case DialogResult.Yes:
|
||
ryCommon.RyRegedit.SetAutoRun(true, Soft_Info.Soft_Id, "\"" + Application.ExecutablePath.Replace("/", "\\") + "\" " + Soft_Info.Soft_Pram);
|
||
break;
|
||
}
|
||
}
|
||
ShowInCenter(null);
|
||
#if DY
|
||
#else
|
||
LiveUpdate.RyUpdate update = new LiveUpdate.RyUpdate(Soft_Info.Update_Url);
|
||
update.CheckUpdate();
|
||
#endif
|
||
mouse.OnMouseActivity += Mouse_OnMouseActivity;
|
||
mouse.Start();
|
||
}
|
||
|
||
private void Hotkey_OnHotkey(int HotKeyID)
|
||
{
|
||
switch (HotKeyID)
|
||
{
|
||
case 100:
|
||
ShowOrHideUI();
|
||
break;
|
||
default:
|
||
var ids=hotkey.GetTag(HotKeyID);
|
||
if(ids.IndexOfEx("type_")==0)
|
||
{
|
||
#region 软件热键
|
||
var id = ids.Substring(5).ToInt();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
//var sql = "select * from Columns where id=" + id;
|
||
DataSet ds = db.ReadData("select * from Columns where id=" + id);
|
||
if (ds.HaveData())
|
||
{
|
||
DataRow row = ds.GetFirstRowData();
|
||
var parentId=row["parentId"].ToInt();
|
||
if(parentId>0)
|
||
{
|
||
for (int i = 0; i < TabList_Column.Items.Count; i++)
|
||
{
|
||
if (TabList_Column.Items[i].Tag.ToInt()==parentId)
|
||
{
|
||
TabList_Column.Items[i].Selected = true;
|
||
for (int m = 0; m < TabList_Type.Items.Count; m++)
|
||
{
|
||
if (TabList_Type.Items[m].Tag.ToInt() == row["id"].ToInt())
|
||
{
|
||
TabList_Type.Items[m].Selected = true;
|
||
ShowOrHideUI(true);
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
db.Free();
|
||
}
|
||
db.Free();
|
||
#endregion
|
||
}
|
||
else if (ids.IndexOfEx("soft_") == 0)
|
||
{
|
||
#region 软件热键
|
||
var id = ids.Substring(5).ToInt();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
//var sql = "select * from Softs where id=" + id;
|
||
DataSet ds = db.ReadData("select * from Softs where id=" + id);
|
||
if (ds.HaveData())
|
||
{
|
||
DataRow row = ds.GetFirstRowData();
|
||
SoftInfo info = new SoftInfo
|
||
{
|
||
Id = row["id"].ToInt(),
|
||
SoftType = row["SoftType"].ToInt(),
|
||
ColumnId = row["ColumnId"].ToInt(),
|
||
Name = row["Name"].ToString(),
|
||
Path = row["Path"].ToString(),
|
||
RunPram = row["RunPram"].ToString(),
|
||
SetJson = row["SetJson"].ToString(),
|
||
StartPath = row["StartPath"].ToString(),
|
||
IconPath = row["IconPath"].ToString()
|
||
};
|
||
VSoft.Prams.Run.Open(info, false);
|
||
}
|
||
db.Free();
|
||
}
|
||
db.Free();
|
||
#endregion
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
|
||
public static extern bool SetF(IntPtr hWnd); //设置此窗体为活动窗体
|
||
/// <summary>
|
||
/// 显示或隐藏UI
|
||
/// </summary>
|
||
private void ShowOrHideUI(bool ForceShow=false)
|
||
{
|
||
if (this.Visible && RyForm.GetActiveWindow() == Handle && !ForceShow)
|
||
{
|
||
this.Hide();
|
||
}
|
||
else
|
||
{
|
||
this.WindowState = FormWindowState.Normal;
|
||
var topmost = this.TopMost;
|
||
this.TopMost = true;
|
||
this.Show();
|
||
//this.TopMost = topmost;
|
||
this.BringToFront();
|
||
this.Select();
|
||
this.Focus();
|
||
//RyForm.BringToTop(Handle);
|
||
RyForm.SetActiveWindow(Handle);
|
||
//this.TopMost = topmost;
|
||
rySearch1.Focus();
|
||
using (var bg = new BackgroundWorker())
|
||
{
|
||
bg.DoWork += delegate { System.Threading.Thread.Sleep(100); };//1秒后
|
||
bg.RunWorkerCompleted += delegate {
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.TopMost = topmost;
|
||
SetF(Handle);
|
||
}));
|
||
}; // 线程执行完成后会执行 RunWorkerCompleted 事伯的代码块
|
||
bg.RunWorkerAsync();
|
||
}
|
||
}
|
||
}
|
||
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);
|
||
rySearch1.Focus();
|
||
}
|
||
#endregion
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
break;
|
||
default:
|
||
base.WndProc(ref msg);//调用基类函数处理非自定义消息。
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void RySearch1_OnSearch(object sender, EventArgs e)
|
||
{
|
||
if(rySearch1.Text.Length==0)
|
||
{
|
||
Msg.ShowMsg("请输入内容。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
|
||
}
|
||
LoadDb(true);
|
||
}
|
||
#region 对栏目标签进行操作
|
||
/// <summary>
|
||
/// 将栏目列表中的第几个栏目修改
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <param name="index"></param>
|
||
private void SetColumnRow(int id, int index)
|
||
{
|
||
#region 重新载入数据
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Columns where id=" + id);
|
||
if (mydb.HaveData(ds))
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[0];
|
||
var item = TabList_Column.Items[index];
|
||
item.Text = row["Name"].ToString();
|
||
}
|
||
db.Free();
|
||
}
|
||
#endregion
|
||
}
|
||
private void BtnAddColumn_Click(object sender, EventArgs e)
|
||
{
|
||
FrmAddColumn frm = new FrmAddColumn
|
||
{
|
||
TopMost = TopMost
|
||
};
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Columns where parentId=0 order by sortindex desc limit 1");
|
||
TabList_Column.BeginUpdate();
|
||
if (ds.Tables[0].Rows.Count > 0)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[0];
|
||
TabList_Column.Items.Add(row["Name"].ToString()).Tag = row["id"].ToInt();
|
||
}
|
||
TabList_Column.EndUpdate();
|
||
db.Free();
|
||
}
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
private void 修改栏目ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0) { return; }
|
||
FrmAddColumn frm = new FrmAddColumn
|
||
{
|
||
TopMost = TopMost,
|
||
IsAdd = 0
|
||
};
|
||
frm.GetInfo(TabList_Column.SelectedItems[0].Tag.ToInt());
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
SetColumnRow(TabList_Column.SelectedItems[0].Tag.ToInt(), TabList_Column.SelectedItems[0].Index);
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
|
||
private void 删除栏目ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0) { return; }
|
||
if (Msg.ShowMsg("确定要删除选定项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
if (TabList_Column.Items.Count ==1) {
|
||
Msg.ShowMsg("请至少保留一个栏目。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var column_id = TabList_Column.SelectedItems[0].Tag.ToInt();
|
||
var ds = db.ReadData("select count(*) from Columns where parentId=" + column_id);
|
||
if (mydb.HaveData(ds))
|
||
{
|
||
if (mydb.GetValue(ds) > 0)
|
||
{
|
||
ds.Dispose();
|
||
Msg.ShowMsg("当前栏目下还有分类,请先移除再删除栏目。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
db.Free();
|
||
return;
|
||
}
|
||
}
|
||
ds.Dispose();
|
||
db.DelById("Columns", column_id.ToString());
|
||
TabList_Column.SelectedItems[0].Remove();
|
||
db.BeginTransaction();
|
||
for (int i = 1; i < TabList_Column.Items.Count; i++)
|
||
{
|
||
var id = TabList_Column.Items[i].Tag.ToInt();
|
||
RyQuickSQL mySQL = new RyQuickSQL("Columns");
|
||
mySQL.AddField("sortindex", i);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + id, mySQL);
|
||
}
|
||
db.Commit();
|
||
}
|
||
db.Free();
|
||
}
|
||
#endregion
|
||
#region 对分类标签进行操作
|
||
/// <summary>
|
||
///将分类列表中的第几个分类进行修改
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <param name="index"></param>
|
||
private void SetTypeRow(int id, int index)
|
||
{
|
||
#region 重新载入数据
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Columns where id=" + id);
|
||
if (mydb.HaveData(ds))
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[0];
|
||
var item = TabList_Type.Items[index];
|
||
item.Text = row["Name"].ToString();
|
||
}
|
||
db.Free();
|
||
}
|
||
#endregion
|
||
}
|
||
private void 新增分类ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0)
|
||
{
|
||
Msg.ShowMsg("请先选择一个栏目。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
var id = TabList_Column.SelectedItems[0].Tag.ToInt();
|
||
FrmAddType frm = new FrmAddType
|
||
{
|
||
TopMost = TopMost,
|
||
ParentId = id
|
||
};
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
hot_index++;
|
||
HotkeyValue hot = new HotkeyValue(frm.hotkeyTextBox1.HotKey);
|
||
hotkey.RegHotKey(hot_index,"type_"+frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
DataSet ds = db.ReadData("select * from Columns where parentId=" + id + " order by sortindex desc limit 1");
|
||
TabList_Type.BeginUpdate();
|
||
if(ds.Tables[0].Rows.Count>0)
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[0];
|
||
TabList_Type.Items.Add(row["Name"].ToString()).Tag = row["id"].ToInt();
|
||
}
|
||
ds.Dispose();
|
||
TabList_Type.EndUpdate();
|
||
db.Free();
|
||
}
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
|
||
private void Menu修改分类_Click(object sender, EventArgs e)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0)
|
||
{
|
||
Msg.ShowMsg("请先选择一个栏目。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
if (TabList_Type.SelectedItems.Count == 0)
|
||
{
|
||
Msg.ShowMsg("请先选择一个分类。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
var id = TabList_Type.SelectedItems[0].Tag.ToInt();
|
||
if (id == 0) {
|
||
Msg.ShowMsg("默认分类不支持修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
FrmAddType frm = new FrmAddType
|
||
{
|
||
TopMost = TopMost,
|
||
IsAdd = 0
|
||
};
|
||
frm.GetInfo(id);
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
SetTypeRow(id, TabList_Type.SelectedItems[0].Index);
|
||
HotkeyValue hot = new HotkeyValue(frm.hotkeyTextBox1.HotKey);
|
||
var index = hotkey.GetHotId("type_" + frm.Op_Id);
|
||
if (index >= 0)
|
||
{
|
||
hotkey.UnHotKey(index);
|
||
if (frm.hotkeyTextBox1.HaveHotKey)
|
||
{
|
||
hotkey.RegHotKey(index, "type_" + frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (frm.hotkeyTextBox1.HaveHotKey)
|
||
{
|
||
hot_index++;
|
||
hotkey.RegHotKey(hot_index, "type_" + frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
|
||
private void Menu删除分类_Click(object sender, EventArgs e)
|
||
{
|
||
if (TabList_Type.SelectedItems.Count == 0) { return; }
|
||
if (Msg.ShowMsg("确定要删除选定项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
if (TabList_Type.SelectedItems.Count == 0) { return; }
|
||
var column_id = TabList_Type.SelectedItems[0].Tag.ToInt();
|
||
if (column_id == 0) {
|
||
Msg.ShowMsg("默认分类不支持删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var ds = db.ReadData("select count(*) from Softs where ColumnId=" + column_id);
|
||
if (mydb.HaveData(ds))
|
||
{
|
||
if (mydb.GetValue(ds) > 0)
|
||
{
|
||
ds.Dispose();
|
||
Msg.ShowMsg("当前分类下还有软件,请先移除再删除分类。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
db.Free();
|
||
return;
|
||
}
|
||
}
|
||
ds.Dispose();
|
||
var index = hotkey.GetHotId("type_" + column_id);
|
||
if (index >= 0)
|
||
{
|
||
hotkey.UnHotKey(index);
|
||
}
|
||
db.DelById("Columns", column_id.ToString());
|
||
TabList_Type.SelectedItems[0].Remove();
|
||
db.BeginTransaction();
|
||
for (int i = 0; i < TabList_Type.Items.Count; i++)
|
||
{
|
||
var id = TabList_Type.Items[i].Tag.ToInt();
|
||
RyQuickSQL mySQL = new RyQuickSQL("Columns");
|
||
mySQL.AddField("sortindex", i);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + id, mySQL);
|
||
}
|
||
db.Commit();
|
||
}
|
||
db.Free();
|
||
}
|
||
#endregion
|
||
#region 对软件列表进行操作
|
||
private void SetSoftRow(int id, int index)
|
||
{
|
||
#region 重新载入数据
|
||
DataProvider mydb = new DataProvider();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
DataSet ds = db.ReadData("select * from Softs where id=" + id);
|
||
if (mydb.HaveData(ds))
|
||
{
|
||
DataRow row = ds.Tables[0].Rows[0];
|
||
var item = IconViewEx1.Items[index];
|
||
SoftInfo info = (SoftInfo)item.Tag;
|
||
info.Id = row["id"].ToInt();
|
||
info.Name = row["Name"].ToString();
|
||
info.Path = row["Path"].ToString();
|
||
info.RunPram = row["RunPram"].ToString();
|
||
info.SetJson = row["SetJson"].ToString();
|
||
info.StartPath = row["StartPath"].ToString();
|
||
info.IconPath = row["IconPath"].ToString();
|
||
info.SoftType = row["SoftType"].ToInt();
|
||
if (info.IconPath.Length == 0)
|
||
{
|
||
info.Image = API.GetImg(info.TruePath, 128);
|
||
}
|
||
else
|
||
{
|
||
info.Image = API.GetImg(RyFiles.GetRealPath(row["IconPath"].ToString()), 128);
|
||
}
|
||
item.Text = row["Name"].ToString();
|
||
}
|
||
db.Free();
|
||
}
|
||
#endregion
|
||
}
|
||
/// <summary>
|
||
/// 获取当前页面所属的分类或栏目ID
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private int GetCurColumnId()
|
||
{
|
||
var ColumnId = 0;
|
||
if (TabList_Type.SelectedItems.Count > 0)
|
||
{
|
||
ColumnId = TabList_Type.SelectedItems[0].Tag.ToInt();
|
||
}
|
||
if (ColumnId == 0)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count > 0)
|
||
{
|
||
ColumnId = TabList_Column.SelectedItems[0].Tag.ToInt();
|
||
}
|
||
}
|
||
return ColumnId;
|
||
}
|
||
private void 新增软件ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var ColumnId = GetCurColumnId();
|
||
if (ColumnId == 0)
|
||
{
|
||
Msg.ShowMsg("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
FrmAddSoft frm = new FrmAddSoft
|
||
{
|
||
TopMost = TopMost,
|
||
ColumnId = ColumnId
|
||
};
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
hot_index++;
|
||
HotkeyValue hot = new HotkeyValue(frm.hotkeyTextBox1.HotKey);
|
||
hotkey.RegHotKey(hot_index, "soft_" + frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
LoadDb();
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
private void 修改软件ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
var info = (SoftInfo)IconViewEx1.SelectedItems[0].Tag;
|
||
FrmAddSoft frm = new FrmAddSoft
|
||
{
|
||
TopMost = TopMost,
|
||
SelectId = info.Id,
|
||
IsAdd = 0
|
||
};
|
||
frm.GetInfo(info.Id);
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
HotkeyValue hot = new HotkeyValue(frm.hotkeyTextBox1.HotKey);
|
||
var index = hotkey.GetHotId("soft_" + frm.Op_Id);
|
||
if (index >= 0)
|
||
{
|
||
hotkey.UnHotKey(index);
|
||
if (frm.hotkeyTextBox1.HaveHotKey)
|
||
{
|
||
hotkey.RegHotKey(index, "soft_" + frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (frm.hotkeyTextBox1.HaveHotKey)
|
||
{
|
||
hot_index++;
|
||
hotkey.RegHotKey(hot_index, "soft_" + frm.Op_Id, hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
}
|
||
SetSoftRow(info.Id, IconViewEx1.SelectedItems[0].Index);
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
private void 从列表删除该软件ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
if (Msg.ShowMsg("确定要删除选定项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
for (int i = IconViewEx1.SelectedItems.Count - 1; i >= 0; i--)
|
||
{
|
||
var info = (SoftInfo)IconViewEx1.SelectedItems[i].Tag;
|
||
if(info.IconPath.Length>0 && info.IconPath.StartsWith("<app>\\UserDb\\SoftLogos", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
RyFiles.DeleteFile(RyFiles.GetRealPath(info.IconPath));
|
||
}
|
||
var index = hotkey.GetHotId("soft_" + info.Id);
|
||
if (index >= 0)
|
||
{
|
||
hotkey.UnHotKey(index);
|
||
}
|
||
db.DelById("Softs", info.Id.ToString());
|
||
IconViewEx1.SelectedItems[i].Remove();
|
||
if (IconViewEx1.Items.Count == 0)
|
||
{
|
||
LblEmpty.Visible = true;
|
||
}
|
||
else { LblEmpty.Visible = false; }
|
||
}
|
||
ReSortSoftByList(db);
|
||
}
|
||
db.Free();
|
||
}
|
||
private void 以管理员方式启动ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
RunByListSelected(true);
|
||
}
|
||
private void 打开软件所在位置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
var info = (SoftInfo)IconViewEx1.SelectedItems[0].Tag;
|
||
if (System.IO.File.Exists(info.TruePath) || System.IO.Directory.Exists(info.TruePath))
|
||
{
|
||
RyFiles.OpenFolderGotoFile(info.TruePath);
|
||
}
|
||
else
|
||
{
|
||
Msg.ShowMsg("没有找到文件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
private void RunByListSelected(bool RunasAdmin)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
var info = (SoftInfo)IconViewEx1.SelectedItems[0].Tag;
|
||
if (VSoft.Config.Soft_Config.HideAfterRun)
|
||
{
|
||
this.Hide();
|
||
}
|
||
Thread th = new Thread(Start);
|
||
th.Start();
|
||
void Start()
|
||
{
|
||
var result = VSoft.Prams.Run.Open(info, RunasAdmin);
|
||
if (result > 36 && VSoft.Config.Soft_Config.HideAfterRun) {
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.Hide();
|
||
}));
|
||
}
|
||
else
|
||
{
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.Show();
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
private void IconViewEx1_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
RunByListSelected(false);
|
||
}
|
||
else if (e.KeyCode == Keys.Up)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
var item = IconViewEx1.SelectedItems[0];
|
||
if(item.Position.Y== IconViewEx1.Items[0].Position.Y)
|
||
{
|
||
IconViewEx1.SelectedItems.Clear();
|
||
if (TabList_Column.SelectedItems.Count == 0)
|
||
{
|
||
TabList_Column.Items[0].Selected = true;
|
||
}
|
||
TabList_Column.Focus();
|
||
var color = TabList_Column.SelectedStartBackColor;
|
||
TabList_Column.SelectedStartBackColor = Color.LightYellow;
|
||
using (var bg = new BackgroundWorker())
|
||
{
|
||
bg.DoWork += delegate { System.Threading.Thread.Sleep(500); };//180秒后,3分钟
|
||
bg.RunWorkerCompleted += delegate {
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
TabList_Column.SelectedStartBackColor = color;
|
||
}));
|
||
}; // 线程执行完成后会执行 RunWorkerCompleted 事伯的代码块
|
||
bg.RunWorkerAsync();
|
||
}
|
||
}
|
||
}
|
||
else if (e.KeyCode == Keys.Left)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0) { return; }
|
||
var item = IconViewEx1.SelectedItems[0];
|
||
if (item.Index==0 || item.Position.X== IconViewEx1.Items[0].Position.X)
|
||
{
|
||
IconViewEx1.SelectedItems.Clear();
|
||
if (TabList_Type.SelectedItems.Count == 0)
|
||
{
|
||
TabList_Type.Items[0].Selected = true;
|
||
}
|
||
TabList_Type.Focus();
|
||
var color = TabList_Type.SelectedStartBackColor;
|
||
TabList_Type.SelectedStartBackColor = Color.LightYellow;
|
||
using (var bg = new BackgroundWorker())
|
||
{
|
||
bg.DoWork += delegate { System.Threading.Thread.Sleep(500); };//180秒后,3分钟
|
||
bg.RunWorkerCompleted += delegate {
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
TabList_Type.SelectedStartBackColor = color;
|
||
}));
|
||
}; // 线程执行完成后会执行 RunWorkerCompleted 事伯的代码块
|
||
bg.RunWorkerAsync();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
private void IconViewEx1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
if (Soft_Config.OpenByClick) { return; }
|
||
RunByListSelected(false);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 软件列表拖放
|
||
private void IconViewEx1_ItemDrag(object sender, ItemDragEventArgs e)
|
||
{
|
||
this.DoDragDrop(e.Item, DragDropEffects.Move);
|
||
}
|
||
|
||
private void IconViewEx1_DragEnter(object sender, DragEventArgs e)
|
||
{
|
||
ListViewItem lvi = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
|
||
if (lvi != null)
|
||
{
|
||
if (lvi.ListView != IconViewEx1)
|
||
{
|
||
e.Effect = DragDropEffects.None;
|
||
return;
|
||
}
|
||
}
|
||
e.Effect = DragDropEffects.Move;
|
||
}
|
||
private void IconViewEx1_DragDrop(object sender, DragEventArgs e)
|
||
{
|
||
var filedrop = e.Data.GetData(DataFormats.FileDrop);
|
||
if (filedrop != null)
|
||
{
|
||
#region 拖放文件到软件列表
|
||
var ColumnId = 0;
|
||
if (TabList_Type.SelectedItems.Count > 0)
|
||
{
|
||
ColumnId = TabList_Type.SelectedItems[0].Tag.ToInt();
|
||
}
|
||
if (ColumnId == 0)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count > 0)
|
||
{
|
||
IDbInterface db2 = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db2.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
ColumnId = Itrycn_Db.GetFirstColumnId(db2, TabList_Column.SelectedItems[0].Tag.ToInt());
|
||
}
|
||
db2.Free();
|
||
}
|
||
}
|
||
if(ColumnId<=0)
|
||
{
|
||
Msg.ShowMsg("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
IDbInterface db3 = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db3.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var filelist = (string[])filedrop;
|
||
for (int f = 0; f < filelist.Length; f++)
|
||
{
|
||
var path = filelist[f];
|
||
var pram = "";
|
||
var StartPath = "";
|
||
var des = "";
|
||
var icon = "";
|
||
var name = System.IO.Path.GetFileNameWithoutExtension(path);
|
||
if (System.IO.Path.GetExtension(path).ToLower() == ".lnk")
|
||
{
|
||
var shortcut = API.ReadShortcut(path);
|
||
path = shortcut.TargetPath;
|
||
pram = shortcut.Arguments;
|
||
StartPath = shortcut.WorkDir;
|
||
if(shortcut.IconLocation!= path)
|
||
{
|
||
icon = shortcut.IconLocation;
|
||
}
|
||
des = shortcut.Description;
|
||
}
|
||
else
|
||
{
|
||
path = RyFiles.GetRelativePath(path);
|
||
}
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("Name", name);
|
||
mySQL.AddField("CmdId", "");
|
||
mySQL.AddField("Path", path);
|
||
mySQL.AddField("RunPram", pram);
|
||
mySQL.AddField("StartPath", StartPath);//起始路径
|
||
mySQL.AddField("IconPath", icon);//图标路径
|
||
Json json = new Json("");
|
||
json.Add("RunAsAdmin", false);
|
||
mySQL.AddField("SetJson", json.Text);//设置
|
||
mySQL.AddField("Des", des);//备注
|
||
mySQL.AddField("Pinyin", ryCommon.PinYin.Convert(name) + "\r\n" + ryCommon.PinYin.ConvertFirstPY(name));
|
||
mySQL.AddField("editTime", DateTime.Now);
|
||
mySQL.AddField("SoftType", 0);//0表示运行文件,1表示执行快速命令,2表示执行脚本
|
||
mySQL.AddField("ClickCount", 0);//点击量
|
||
mySQL.AddField("ColumnId", ColumnId);
|
||
mySQL.AddField("sortindex", Itrycn_Db.GetSoftCount(db3, ColumnId) + 1);
|
||
mySQL.AddField("addTime", DateTime.Now);
|
||
var ds = db3.ReadData(mySQL.GetInsertSQL() + ";select last_insert_rowid();", mySQL);
|
||
SoftInfo info = new SoftInfo
|
||
{
|
||
Id = ds.Tables[0].Rows[0][0].ToInt(),
|
||
SoftType = 0,
|
||
ColumnId = ColumnId,
|
||
Name = name,
|
||
Path = path,
|
||
RunPram = pram,
|
||
SetJson = json.Text,
|
||
StartPath = StartPath,
|
||
IconPath = ""
|
||
};
|
||
string img_path = info.TruePath;
|
||
if (dictCacheImg.ContainsKey(img_path))
|
||
{
|
||
info.Image = dictCacheImg[img_path];
|
||
}
|
||
else
|
||
{
|
||
info.Image = API.GetImg(img_path, 128);
|
||
dictCacheImg.Add(img_path, info.Image);
|
||
}
|
||
IconViewEx1.Items.Add(info.Name).Tag = info;
|
||
}
|
||
}
|
||
db3.Free();
|
||
return;
|
||
#endregion
|
||
}
|
||
Point pt;
|
||
pt = ((IconViewEx)(sender)).PointToClient(new Point(e.X, e.Y));
|
||
var to_item = IconViewEx1.GetItemAt(pt.X, pt.Y);
|
||
IconViewEx1.InsertionMark.Index = -1;
|
||
TabList_Type.InsertionMark.Index = -1;
|
||
TabList_Column.InsertionMark.Index = -1;
|
||
if (to_item == null) { return; }
|
||
//获得拖放中的项
|
||
ListViewItem lvi = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
|
||
if (lvi == null) { return; }
|
||
if (lvi.ListView!=IconViewEx1) { return; }
|
||
if (lvi.Index == to_item.Index) { return; }
|
||
IconViewEx1.BeginUpdate();
|
||
IconViewEx1.View = View.List;
|
||
IconViewEx1.Items.RemoveAt(lvi.Index);
|
||
IconViewEx1.Items.Insert(to_item.Index, lvi);
|
||
IconViewEx1.View = View.Tile;
|
||
IconViewEx1.EndUpdate();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
ReSortSoftByList(db);
|
||
}
|
||
db.Free();
|
||
}
|
||
private void IconViewEx1_DragOver(object sender, DragEventArgs e)
|
||
{
|
||
if (sender is IconViewEx list)
|
||
{
|
||
var filedrop = e.Data.GetData(DataFormats.FileDrop);
|
||
if (filedrop != null)
|
||
{
|
||
list.InsertionMark.Index = -1;
|
||
return;
|
||
}
|
||
var lvi = e.Data.GetData(typeof(ListViewItem));
|
||
if (lvi == null)
|
||
{
|
||
list.InsertionMark.Index = -1;
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
var lvi2 = (ListViewItem)lvi;
|
||
if (lvi2.ListView != IconViewEx1)
|
||
{
|
||
list.InsertionMark.Index = -1;
|
||
return;
|
||
}
|
||
}
|
||
var pt = list.PointToClient(new Point(e.X, e.Y));
|
||
int targetIndex = list.InsertionMark.NearestIndex(pt);
|
||
if (targetIndex > -1)
|
||
{
|
||
// Determine whether the mouse pointer is to the left or
|
||
// the right of the midpoint of the closest item and set
|
||
// the InsertionMark.AppearsAfterItem property accordingly.
|
||
Rectangle itemBounds = list.GetItemRect(targetIndex);
|
||
if (pt.X > itemBounds.Left + (itemBounds.Width / 2))
|
||
{
|
||
list.InsertionMark.AppearsAfterItem = true;
|
||
}
|
||
else
|
||
{
|
||
list.InsertionMark.AppearsAfterItem = false;
|
||
}
|
||
}
|
||
list.InsertionMark.Index = targetIndex;
|
||
list.InsertionMark.Color = Color.Black; ;
|
||
//item = list.GetItemAt(pt.X, pt.Y);
|
||
}
|
||
else if (sender is TabList list2)
|
||
{
|
||
var pt = list2.PointToClient(new Point(e.X, e.Y));
|
||
int targetIndex = list2.InsertionMark.NearestIndex(pt);
|
||
if (targetIndex > -1)
|
||
{
|
||
// Rectangle itemBounds = list2.GetItemRect(targetIndex);
|
||
list2.InsertionMark.AppearsAfterItem = false;
|
||
}
|
||
list2.InsertionMark.Index = targetIndex;
|
||
list2.InsertionMark.Color = Color.Black; ;
|
||
}
|
||
}
|
||
#endregion
|
||
#region 栏目拖放
|
||
private void TabList_Column_DragEnter(object sender, DragEventArgs e)
|
||
{
|
||
//判定是否现在拖动的数据是LISTVIEW项
|
||
ListViewItem lvi = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
|
||
if (lvi != null)
|
||
{
|
||
e.Effect = DragDropEffects.Move;
|
||
}
|
||
}
|
||
private void TabList_Column_DragDrop(object sender, DragEventArgs e)
|
||
{
|
||
Point pt;
|
||
IconViewEx1.InsertionMark.Index = -1;
|
||
TabList_Type.InsertionMark.Index = -1;
|
||
TabList_Column.InsertionMark.Index = -1;
|
||
pt = ((TabList)(sender)).PointToClient(new Point(e.X, e.Y));
|
||
var item = TabList_Column.GetItemAt(pt.X, pt.Y);
|
||
if (item == null) { return; }
|
||
var columnid = item.Tag.ToInt();
|
||
//获得拖放中的项
|
||
var drag_item = e.Data.GetData(typeof(ListViewItem));
|
||
if (drag_item == null) { return; }
|
||
ListViewItem lvi = (ListViewItem)drag_item;
|
||
if (lvi.ListView == IconViewEx1)
|
||
{
|
||
#region 从软件列表里拖放
|
||
var info = (SoftInfo)lvi.Tag;
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
var id = Itrycn_Db.GetFirstColumnId(db, columnid);
|
||
if(id<=0)
|
||
{
|
||
return;
|
||
}
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("ColumnId", id);
|
||
mySQL.AddField("editTime", DateTime.Now);
|
||
mySQL.AddField("sortindex", Itrycn_Db.GetSoftCount(db, id) + 1);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + info.Id, mySQL);
|
||
if (TabList_Column.SelectedItems.Count > 0)
|
||
{
|
||
if (TabList_Type.SelectedItems.Count > 0 && TabList_Type.SelectedItems[0].Tag.ToInt() > 0 && TabList_Type.SelectedItems[0].Tag.ToInt()!=id)
|
||
{
|
||
lvi.Remove();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
lvi.Remove();
|
||
}
|
||
ReSortSoftByList(db);
|
||
}
|
||
db.Free();
|
||
#endregion
|
||
}
|
||
else if (lvi.ListView == TabList_Column)
|
||
{
|
||
if (lvi.Index == item.Index) { return; }
|
||
TabList_Column.BeginUpdate();
|
||
TabList_Column.View = View.List;
|
||
TabList_Column.Items.RemoveAt(lvi.Index);
|
||
TabList_Column.Items.Insert(item.Index, lvi);
|
||
TabList_Column.View = View.Tile;
|
||
TabList_Column.EndUpdate();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
db.BeginTransaction();
|
||
for (int i = 0; i < TabList_Column.Items.Count; i++)
|
||
{
|
||
var id = TabList_Column.Items[i].Tag.ToInt();
|
||
RyQuickSQL mySQL = new RyQuickSQL("Columns");
|
||
mySQL.AddField("sortindex", i + 1);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + id, mySQL);
|
||
}
|
||
db.Commit();
|
||
}
|
||
db.Free();
|
||
}
|
||
}
|
||
private void TabList_Column_ItemDrag(object sender, ItemDragEventArgs e)
|
||
{
|
||
this.DoDragDrop(e.Item, DragDropEffects.Move);
|
||
}
|
||
#endregion
|
||
#region 分类拖放
|
||
private void TabList_Type_DragEnter(object sender, DragEventArgs e)
|
||
{
|
||
//判定是否现在拖动的数据是LISTVIEW项
|
||
ListViewItem lvi = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
|
||
if (lvi != null)
|
||
{
|
||
e.Effect = DragDropEffects.Move;
|
||
}
|
||
}
|
||
|
||
private void TabList_Type_DragDrop(object sender, DragEventArgs e)
|
||
{
|
||
Point pt;
|
||
IconViewEx1.InsertionMark.Index = -1;
|
||
TabList_Type.InsertionMark.Index = -1;
|
||
TabList_Column.InsertionMark.Index = -1;
|
||
pt = ((TabList)(sender)).PointToClient(new Point(e.X, e.Y));
|
||
var item = TabList_Type.GetItemAt(pt.X, pt.Y);
|
||
if (item == null) { return; }
|
||
var columnid = item.Tag.ToInt();
|
||
if (columnid == 0)
|
||
{
|
||
return;
|
||
}
|
||
//获得拖放中的项
|
||
var drag_item = e.Data.GetData(typeof(ListViewItem));
|
||
if (drag_item == null) { return; }
|
||
ListViewItem lvi = (ListViewItem)drag_item;
|
||
if (lvi.ListView == IconViewEx1)
|
||
{
|
||
#region 来源自软件列表
|
||
var info = (SoftInfo)lvi.Tag;
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("ColumnId", columnid);
|
||
mySQL.AddField("editTime", DateTime.Now);
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
mySQL.AddField("sortindex", Itrycn_Db.GetSoftCount(db, columnid) + 1);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + info.Id, mySQL);
|
||
if (TabList_Type.SelectedItems.Count > 0)
|
||
{
|
||
if (TabList_Type.SelectedItems[0].Tag.ToInt() != columnid)
|
||
{
|
||
lvi.Remove();
|
||
}
|
||
}
|
||
else { lvi.Remove(); }
|
||
ReSortSoftByList(db);
|
||
}
|
||
db.Free();
|
||
#endregion
|
||
}
|
||
else if (lvi.ListView == TabList_Type)
|
||
{
|
||
if (lvi.Index == item.Index) { return; }
|
||
TabList_Type.BeginUpdate();
|
||
TabList_Type.View = View.List;
|
||
TabList_Type.Items.RemoveAt(lvi.Index);
|
||
TabList_Type.Items.Insert(item.Index, lvi);
|
||
TabList_Type.View = View.Tile;
|
||
TabList_Type.EndUpdate();
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
db.BeginTransaction();
|
||
for (int i = 0; i < TabList_Type.Items.Count; i++)
|
||
{
|
||
var id = TabList_Type.Items[i].Tag.ToInt();
|
||
RyQuickSQL mySQL = new RyQuickSQL("Columns");
|
||
mySQL.AddField("sortindex", i+1);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" +id, mySQL);
|
||
}
|
||
db.Commit();
|
||
}
|
||
db.Free();
|
||
}
|
||
}
|
||
private void TabList_Type_ItemDrag(object sender, ItemDragEventArgs e)
|
||
{
|
||
this.DoDragDrop(e.Item, DragDropEffects.Move);
|
||
}
|
||
#endregion
|
||
private void TabList_Type_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if (IsProcUse) { return; }
|
||
LoadDb();
|
||
}
|
||
private void TabList_Column_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
||
{
|
||
if (IsProcUse) { return; }
|
||
if (TabList_Column.SelectedItems.Count > 0)
|
||
{
|
||
LoadTypeColumn(TabList_Column.SelectedItems[0].Tag.ToInt());
|
||
}
|
||
else
|
||
{
|
||
LoadTypeColumn(-1);
|
||
}
|
||
//LoadDb();
|
||
}
|
||
/// <summary>
|
||
/// 将当前列表中的软件在数据库中排序
|
||
/// </summary>
|
||
/// <param name="db"></param>
|
||
private void ReSortSoftByList(IDbInterface db)
|
||
{
|
||
db.BeginTransaction();
|
||
for (int i = 0; i < IconViewEx1.Items.Count; i++)
|
||
{
|
||
var info = (SoftInfo)IconViewEx1.Items[i].Tag;
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("sortindex", i + 1);
|
||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + info.Id, mySQL);
|
||
}
|
||
db.Commit();
|
||
}
|
||
|
||
|
||
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 打开官网ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
ryCommon.RyFiles.OpenUrl(Config.Soft_Info.Soft_Url);
|
||
}
|
||
|
||
private void 捐助ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
#if DY
|
||
Msg.ShowMsg(Config.Soft_Info.AboutText.Replace("#softname#", Config.Soft_Info.Soft_Title).Replace("#ver#", "V" + RySoft.VersionStr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
#else
|
||
if (Config.Soft_Info.DonateVisabled)
|
||
{
|
||
FrmAbout frm = new FrmAbout();
|
||
frm.TopMost = TopMost;
|
||
frm.ShowDialog();
|
||
frm.Dispose();
|
||
}
|
||
else
|
||
{
|
||
Msg.ShowMsg(Config.Soft_Info.AboutText.Replace("#softname#", Config.Soft_Info.Soft_Title).Replace("#ver#", "V" + RySoft.VersionStr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
#endif
|
||
}
|
||
private void ShowSetting(bool ShowInScreenCenter)
|
||
{
|
||
hotkey.Enabled = false;
|
||
FrmSetting frm = new FrmSetting
|
||
{
|
||
TopMost = TopMost
|
||
};
|
||
if (!ShowInScreenCenter)
|
||
{
|
||
frm.ShowInCenter(this);
|
||
}
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
VSoft.Config.Soft_Config.LoadSetting();
|
||
hotkey.UnHotKey(100);
|
||
HotkeyValue hot = new HotkeyValue(Soft_Config.ShowMainHotKey);
|
||
hotkey.RegHotKey(100, hot.Modifiers_Int, hot.KeyCode);
|
||
}
|
||
frm.Dispose();
|
||
hotkey.Enabled = true;
|
||
}
|
||
private void 设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
ShowSetting(true);
|
||
}
|
||
int hideCount = 0;
|
||
private void FrmVSoft_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
if (Soft_Info.ShowTray && Soft_Config.HideByCloseBtn && e.CloseReason == CloseReason.UserClosing)
|
||
{
|
||
e.Cancel = true;
|
||
this.Hide();
|
||
hideCount++;
|
||
if (hideCount <= 2)
|
||
{
|
||
notifyIcon1.ShowBalloonTip(3000, Soft_Info.Soft_Title, "软件已经最小化到此处,请右击托盘图标进行关闭。", ToolTipIcon.Info);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void TabList_Column_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if(e.KeyCode==Keys.Down)
|
||
{
|
||
if(IconViewEx1.Items.Count>0)
|
||
{
|
||
if(IconViewEx1.SelectedItems.Count==0)
|
||
{
|
||
IconViewEx1.Items[0].Selected = true ;
|
||
}
|
||
IconViewEx1.Focus();
|
||
}
|
||
}
|
||
else if (e.KeyCode == Keys.Up)
|
||
{
|
||
rySearch1.Focus();
|
||
}
|
||
}
|
||
|
||
private void TabList_Type_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Right)
|
||
{
|
||
if (IconViewEx1.Items.Count > 0)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0)
|
||
{
|
||
IconViewEx1.Items[0].Selected = true;
|
||
}
|
||
IconViewEx1.Focus();
|
||
}
|
||
}
|
||
}
|
||
|
||
private void RySearch1_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Down)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0)
|
||
{
|
||
if (IconViewEx1.Items.Count > 0)
|
||
{
|
||
if (IconViewEx1.SelectedItems.Count == 0)
|
||
{
|
||
IconViewEx1.Items[0].Selected = true;
|
||
}
|
||
IconViewEx1.Focus();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
TabList_Column.Items[0].Selected = true;
|
||
}
|
||
}
|
||
TabList_Column.Focus();
|
||
var color = TabList_Column.SelectedStartBackColor;
|
||
TabList_Column.SelectedStartBackColor = Color.LightYellow;
|
||
using (var bg = new BackgroundWorker())
|
||
{
|
||
bg.DoWork += delegate { System.Threading.Thread.Sleep(500); };//0.5秒
|
||
bg.RunWorkerCompleted += delegate {
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
TabList_Column.SelectedStartBackColor = color;
|
||
}));
|
||
}; // 线程执行完成后会执行 RunWorkerCompleted 事伯的代码块
|
||
bg.RunWorkerAsync();
|
||
}
|
||
}
|
||
}
|
||
|
||
private void IconViewEx1_MouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
if (!Soft_Config.OpenByClick) { return; }
|
||
RunByListSelected(false);
|
||
}
|
||
}
|
||
|
||
private void 新增内置功能ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var ColumnId = 0;
|
||
if (TabList_Type.SelectedItems.Count > 0)
|
||
{
|
||
ColumnId = TabList_Type.SelectedItems[0].Tag.ToInt();
|
||
}
|
||
if (ColumnId == 0)
|
||
{
|
||
Msg.ShowMsg("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
FrmInCMD frm = new FrmInCMD
|
||
{
|
||
TopMost = TopMost
|
||
};
|
||
frm.ShowInCenter(this);
|
||
if (frm.ShowDialog()==DialogResult.OK)
|
||
{
|
||
var info = frm.SelectedInfo;
|
||
RyQuickSQL mySQL = new RyQuickSQL("Softs");
|
||
mySQL.AddField("Name", info.Name);
|
||
mySQL.AddField("SoftType",1);//0表示运行文件,1表示执行内置命令,2表示执行脚本
|
||
mySQL.AddField("Path",frm.SQLConnStr);
|
||
if (info.CmdId.Length > 0)
|
||
{ mySQL.AddField("RunPram","cmdid="+ info.CmdId); }
|
||
else
|
||
{
|
||
mySQL.AddField("RunPram","id="+ info.Id);
|
||
}
|
||
mySQL.AddField("StartPath","");//起始路径
|
||
mySQL.AddField("IconPath", info.IconPath.Length>0? info.IconPath: info.Path);//图标路径
|
||
mySQL.AddField("SetJson","");//设置
|
||
mySQL.AddField("Des", info.Des);//备注
|
||
mySQL.AddField("Pinyin", ryCommon.PinYin.Convert(info.Name) + "\r\n" + ryCommon.PinYin.ConvertFirstPY(info.Name));
|
||
mySQL.AddField("editTime", DateTime.Now);
|
||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||
if (db.ConnDb(SQLConnStr) == 1)
|
||
{
|
||
mySQL.AddField("ClickCount", 0);//点击量
|
||
mySQL.AddField("ColumnId", ColumnId);
|
||
mySQL.AddField("sortindex", Itrycn_Db.GetSoftCount(db, ColumnId) + 1);
|
||
mySQL.AddField("addTime", DateTime.Now);
|
||
db.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL);
|
||
LoadDb();
|
||
}
|
||
db.Free();
|
||
}
|
||
frm.Dispose();
|
||
}
|
||
|
||
private void FrmVSoft_ResizeEnd(object sender, EventArgs e)
|
||
{
|
||
if (Width > 200 && Height > 200)
|
||
{
|
||
ryCommon.Ini ini = new Ini(VSoft.Config.Soft_Info.UserDataFolder + "\\Win.dat");
|
||
ini.WriteIni(VSoft.Config.Soft_Info.Soft_Id, "width", Width);
|
||
ini.WriteIni(VSoft.Config.Soft_Info.Soft_Id, "height", Height);
|
||
}
|
||
}
|
||
|
||
private void 添加栏目ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
BtnAddColumn.PerformClick();
|
||
}
|
||
|
||
private void MenuTabType_Opening(object sender, CancelEventArgs e)
|
||
{
|
||
if(TabList_Type.SelectedItems.Count==0)
|
||
{
|
||
Menu修改分类.Enabled = false;
|
||
Menu删除分类.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
Menu修改分类.Enabled = true;
|
||
Menu删除分类.Enabled = true;
|
||
}
|
||
}
|
||
|
||
private void MenuTabColumn_Opening(object sender, CancelEventArgs e)
|
||
{
|
||
if (TabList_Column.SelectedItems.Count == 0)
|
||
{
|
||
修改栏目ToolStripMenuItem.Enabled = false;
|
||
删除栏目ToolStripMenuItem.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
修改栏目ToolStripMenuItem.Enabled = true;
|
||
删除栏目ToolStripMenuItem.Enabled = true;
|
||
}
|
||
}
|
||
|
||
private void MenuList_Opening(object sender, CancelEventArgs e)
|
||
{
|
||
bool isSelected = IconViewEx1.SelectedItems.Count>0;
|
||
以管理员方式启动ToolStripMenuItem.Enabled = isSelected;
|
||
修改软件ToolStripMenuItem.Enabled = isSelected;
|
||
从列表删除该软件ToolStripMenuItem.Enabled = isSelected;
|
||
打开软件所在位置ToolStripMenuItem.Enabled = isSelected;
|
||
}
|
||
|
||
private void IconViewEx1_Resize(object sender, EventArgs e)
|
||
{
|
||
//LblEmpty.Left = (IconViewEx1.Width - LblEmpty.Width) / 2 + IconViewEx1.Left;
|
||
}
|
||
|
||
private void FrmVSoft_Resize(object sender, EventArgs e)
|
||
{
|
||
LblEmpty.Left =((panelEx1.Width - LblEmpty.Width) / 2);
|
||
|
||
}
|
||
|
||
private void PanelEx1_Resize(object sender, EventArgs e)
|
||
{
|
||
// LblEmpty.Left = panelEx1.Left + ((panelEx1.Width - LblEmpty.Width) / 2);
|
||
}
|
||
|
||
private void LblSetting_Click(object sender, EventArgs e)
|
||
{
|
||
ShowSetting(false);
|
||
}
|
||
|
||
private void FrmVSoft_Shown(object sender, EventArgs e)
|
||
{
|
||
ryCommon.Ini ini = new ryCommon.Ini(Soft_Info.UserDataFolder + "\\Win.dat");
|
||
ini.WriteIni(Soft_Info.Soft_Id, "hwnd",Handle.ToInt32());
|
||
if (prog_args!=null && prog_args.Length>=1 && prog_args[0]=="q")
|
||
{
|
||
this.Hide();
|
||
}
|
||
}
|
||
private ListViewItem currentItem = new ListViewItem();
|
||
private void IconViewEx1_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
ListViewItem lvi = IconViewEx1.GetItemAt(e.X, e.Y);
|
||
if (lvi != null && lvi != currentItem)
|
||
{
|
||
currentItem = lvi;
|
||
if (lvi.Text.Length > 10)
|
||
{
|
||
lvTp.Show(lvi.Text, IconViewEx1, e.Location);
|
||
}
|
||
else
|
||
{
|
||
lvTp.Hide(IconViewEx1);
|
||
}
|
||
}
|
||
else if (lvi == null)
|
||
{
|
||
lvTp.Hide(IconViewEx1);
|
||
}
|
||
currentItem = lvi;
|
||
}
|
||
}
|
||
}
|