### 2020-12-27 dev更新

#### VSoft    V1.0.2012.2702
- *.[修复]修复按热键或鼠标显示主界面,有时无法获得焦点的BUG。
- *.[改进]默认分类支持删除。
This commit is contained in:
如果当时 2020-12-27 22:12:45 +08:00
parent 800c766a67
commit 1954efe3c7
15 changed files with 410 additions and 271 deletions

View File

@ -1,3 +1,3 @@
<root> <root>
<list id="Setting" ShowMainHotKey="1+88" OpenByClick="0" HideAfterRun="1" ShowMainMouseKeyOn="1" ShowMainMouseKey="0" /> <list id="Setting" ShowMainHotKey="1+88" OpenByClick="0" HideAfterRun="1" ShowMainMouseKeyOn="1" ShowMainMouseKey="1" />
</root> </root>

Binary file not shown.

View File

@ -1,4 +1,4 @@
[VSoft] [VSoft]
hwnd=2889742 hwnd=2889742
width=742 width=738
height=572 height=564

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,3 @@
<root> <root>
<list id="LastUpdateTime" Value="2020/12/27 16:55:44" /> <list id="LastUpdateTime" Value="2020/12/27 22:08:33" />
</root> </root>

View File

@ -1,5 +1,11 @@
### 2020-12-27 dev更新 ### 2020-12-27 dev更新
------ ------
#### VSoft V1.0.2012.2702
- *.[修复]修复按热键或鼠标显示主界面有时无法获得焦点的BUG。
- *.[改进]默认分类支持删除。
### 2020-12-27 dev更新
------
#### VSoft V1.0.2012.2701 #### VSoft V1.0.2012.2701
- *.[新增]新增支持通过双击鼠标中键、侧键的方式来显示主界面。 - *.[新增]新增支持通过双击鼠标中键、侧键的方式来显示主界面。
- *.[改进]当多次最小化后,不再显示最小化通知。 - *.[改进]当多次最小化后,不再显示最小化通知。

Binary file not shown.

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2012.2701")] [assembly: AssemblyVersion("1.0.2012.2702")]
[assembly: AssemblyFileVersion("1.0.2012.2701")] [assembly: AssemblyFileVersion("1.0.2012.2702")]

View File

@ -57,6 +57,7 @@ namespace VSoft
mySQL.AddField("Name", TxtName.Text); mySQL.AddField("Name", TxtName.Text);
mySQL.AddField("Des", TxtDes.Text); mySQL.AddField("Des", TxtDes.Text);
mySQL.AddField("editTime", DateTime.Now); mySQL.AddField("editTime", DateTime.Now);
DataProvider mydb = new DataProvider();
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(SQLConnStr) == 1) if (db.ConnDb(SQLConnStr) == 1)
{ {
@ -64,7 +65,19 @@ namespace VSoft
{ {
mySQL.AddField("sortindex", Itrycn_Db.GetColumnCount(db, 0) + 1); mySQL.AddField("sortindex", Itrycn_Db.GetColumnCount(db, 0) + 1);
mySQL.AddField("addTime", DateTime.Now); mySQL.AddField("addTime", DateTime.Now);
db.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL); var ds= db.ReadData(mySQL.GetInsertSQL()+ ";select last_insert_rowid();", mySQL);
if(mydb.HaveData(ds))
{
var ParentId = mydb.GetValue(ds);
RyQuickSQL mySQL2 = new RyQuickSQL(tableName);
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);
}
} }
else else
{ {

View File

@ -248,6 +248,7 @@ namespace VSoft
private void BtnAddColumn_Click(object sender, EventArgs e) private void BtnAddColumn_Click(object sender, EventArgs e)
{ {
FrmAddColumn frm = new FrmAddColumn(); FrmAddColumn frm = new FrmAddColumn();
frm.TopMost = TopMost;
frm.SQLConnStr = SQLConnStr; frm.SQLConnStr = SQLConnStr;
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
@ -278,6 +279,7 @@ namespace VSoft
if (TabList_Column.SelectedItems.Count == 0) { return; } if (TabList_Column.SelectedItems.Count == 0) { return; }
var info = (ColumnInfo)TabList_Column.SelectedItems[0].Tag; var info = (ColumnInfo)TabList_Column.SelectedItems[0].Tag;
FrmAddColumn frm = new FrmAddColumn(); FrmAddColumn frm = new FrmAddColumn();
frm.TopMost = TopMost;
frm.SQLConnStr = SQLConnStr; frm.SQLConnStr = SQLConnStr;
frm.IsAdd = 0; frm.IsAdd = 0;
frm.GetInfo(info.Id); frm.GetInfo(info.Id);
@ -370,7 +372,8 @@ namespace VSoft
FrmAddType frm = new FrmAddType FrmAddType frm = new FrmAddType
{ {
ParentId = id, ParentId = id,
SQLConnStr = SQLConnStr SQLConnStr = SQLConnStr,
TopMost=TopMost
}; };
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
@ -417,7 +420,8 @@ namespace VSoft
FrmAddType frm = new FrmAddType FrmAddType frm = new FrmAddType
{ {
IsAdd = 0, IsAdd = 0,
SQLConnStr = SQLConnStr SQLConnStr = SQLConnStr,
TopMost=TopMost
}; };
frm.GetInfo(info.Id); frm.GetInfo(info.Id);
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
@ -520,7 +524,8 @@ namespace VSoft
FrmAddSoft frm = new FrmAddSoft FrmAddSoft frm = new FrmAddSoft
{ {
SQLConnStr = SQLConnStr, SQLConnStr = SQLConnStr,
ColumnId = ColumnId ColumnId = ColumnId,
TopMost=TopMost
}; };
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
@ -536,7 +541,8 @@ namespace VSoft
{ {
SelectId = info.Id, SelectId = info.Id,
SQLConnStr = SQLConnStr, SQLConnStr = SQLConnStr,
IsAdd = 0 IsAdd = 0,
TopMost=TopMost
}; };
frm.GetInfo(info.Id); frm.GetInfo(info.Id);
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
@ -1106,7 +1112,8 @@ namespace VSoft
FrmAddSoft frm = new FrmAddSoft FrmAddSoft frm = new FrmAddSoft
{ {
SQLConnStr = SQLConnStr, SQLConnStr = SQLConnStr,
ColumnId = ColumnId ColumnId = ColumnId,
TopMost=TopMost
}; };
frm.GetInfo(info.Id); frm.GetInfo(info.Id);
frm.Text = "复制并新增软件"; frm.Text = "复制并新增软件";

View File

@ -141,6 +141,7 @@ namespace VSoft
private void LoadColumn() private void LoadColumn()
{ {
TabList_Column.Items.Clear(); TabList_Column.Items.Clear();
DataProvider mydb = new DataProvider();
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(SQLConnStr) == 1) if (db.ConnDb(SQLConnStr) == 1)
{ {
@ -160,7 +161,20 @@ namespace VSoft
mySQL.AddField("sortindex", 1); mySQL.AddField("sortindex", 1);
mySQL.AddField("parentId", 0); mySQL.AddField("parentId", 0);
mySQL.AddField("addTime", DateTime.Now); mySQL.AddField("addTime", DateTime.Now);
db.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL); 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"); 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++) for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
{ {
@ -182,7 +196,7 @@ namespace VSoft
private void LoadTypeColumn(int id) private void LoadTypeColumn(int id)
{ {
TabList_Type.Items.Clear(); TabList_Type.Items.Clear();
TabList_Type.Items.Add("默认分类").Tag = 0; //TabList_Type.Items.Add("默认分类").Tag = 0;
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(SQLConnStr) == 1) if (db.ConnDb(SQLConnStr) == 1)
{ {
@ -209,6 +223,51 @@ namespace VSoft
LblEmpty.Left =((panelEx1.Width - LblEmpty.Width) / 2); LblEmpty.Left =((panelEx1.Width - LblEmpty.Width) / 2);
Config.Soft_Info.UserDataFolder = ryCommon.RyFiles.GetRealPath(Config.Soft_Info.UserDataFolder); Config.Soft_Info.UserDataFolder = ryCommon.RyFiles.GetRealPath(Config.Soft_Info.UserDataFolder);
VSoft.Prams.Itrycn_Db.CreateTable(); 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();
MessageBox.Show("不支持当前数据库版本,这可能是以下原因导致的:\r\n1.数据库已损坏;'\r\n2.当前数据库是由新版软件创建的(请更新软件后重试)。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
return;
}
}
db.Free();
}
VSoft.Config.Soft_Config.LoadSetting(); VSoft.Config.Soft_Config.LoadSetting();
LoadColumn(); LoadColumn();
//rySearch1.PerformClick(); //rySearch1.PerformClick();
@ -246,6 +305,8 @@ namespace VSoft
break; break;
} }
} }
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetF(IntPtr hWnd); //设置此窗体为活动窗体
/// <summary> /// <summary>
/// 显示或隐藏UI /// 显示或隐藏UI
/// </summary> /// </summary>
@ -257,12 +318,30 @@ namespace VSoft
} }
else else
{ {
ToolStripMenuItem.PerformClick(); this.WindowState = FormWindowState.Normal;
var topmost = this.TopMost;
this.TopMost = true;
this.Show();
//this.TopMost = topmost;
this.BringToFront(); this.BringToFront();
this.Select(); this.Select();
this.Focus(); this.Focus();
RyForm.BringToTop(Handle); //RyForm.BringToTop(Handle);
RyForm.SetActiveWindow(Handle);
//this.TopMost = topmost;
rySearch1.Focus(); 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) protected override void WndProc(ref System.Windows.Forms.Message msg)
@ -340,6 +419,7 @@ namespace VSoft
private void BtnAddColumn_Click(object sender, EventArgs e) private void BtnAddColumn_Click(object sender, EventArgs e)
{ {
FrmAddColumn frm = new FrmAddColumn(); FrmAddColumn frm = new FrmAddColumn();
frm.TopMost = TopMost;
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
@ -362,6 +442,7 @@ namespace VSoft
{ {
if (TabList_Column.SelectedItems.Count == 0) { return; } if (TabList_Column.SelectedItems.Count == 0) { return; }
FrmAddColumn frm = new FrmAddColumn(); FrmAddColumn frm = new FrmAddColumn();
frm.TopMost = TopMost;
frm.IsAdd = 0; frm.IsAdd = 0;
frm.GetInfo(TabList_Column.SelectedItems[0].Tag.ToInt()); frm.GetInfo(TabList_Column.SelectedItems[0].Tag.ToInt());
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
@ -447,6 +528,7 @@ namespace VSoft
} }
var id = TabList_Column.SelectedItems[0].Tag.ToInt(); var id = TabList_Column.SelectedItems[0].Tag.ToInt();
FrmAddType frm = new FrmAddType(); FrmAddType frm = new FrmAddType();
frm.TopMost = TopMost;
frm.ParentId = id; frm.ParentId = id;
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
@ -485,6 +567,7 @@ namespace VSoft
return; return;
} }
FrmAddType frm = new FrmAddType(); FrmAddType frm = new FrmAddType();
frm.TopMost = TopMost;
frm.IsAdd = 0; frm.IsAdd = 0;
frm.GetInfo(id); frm.GetInfo(id);
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
@ -603,6 +686,7 @@ namespace VSoft
return; return;
} }
FrmAddSoft frm = new FrmAddSoft(); FrmAddSoft frm = new FrmAddSoft();
frm.TopMost = TopMost;
frm.ColumnId = ColumnId; frm.ColumnId = ColumnId;
if (frm.ShowDialog() == DialogResult.OK) if (frm.ShowDialog() == DialogResult.OK)
{ {
@ -615,6 +699,7 @@ namespace VSoft
if (IconViewEx1.SelectedItems.Count == 0) { return; } if (IconViewEx1.SelectedItems.Count == 0) { return; }
var info = (SoftInfo)IconViewEx1.SelectedItems[0].Tag; var info = (SoftInfo)IconViewEx1.SelectedItems[0].Tag;
FrmAddSoft frm = new FrmAddSoft(); FrmAddSoft frm = new FrmAddSoft();
frm.TopMost = TopMost;
frm.SelectId = info.Id; frm.SelectId = info.Id;
frm.IsAdd = 0; frm.IsAdd = 0;
frm.GetInfo(info.Id); frm.GetInfo(info.Id);
@ -785,10 +870,15 @@ namespace VSoft
{ {
if (TabList_Column.SelectedItems.Count > 0) if (TabList_Column.SelectedItems.Count > 0)
{ {
ColumnId = TabList_Column.SelectedItems[0].Tag.ToInt(); 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) if(ColumnId<=0)
{ {
MessageBox.Show("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return; return;
@ -906,21 +996,22 @@ namespace VSoft
{ {
#region #region
var info = (SoftInfo)lvi.Tag; 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); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(SQLConnStr) == 1) if (db.ConnDb(SQLConnStr) == 1)
{ {
mySQL.AddField("sortindex", Itrycn_Db.GetSoftCount(db, columnid) + 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); db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + info.Id, mySQL);
if (TabList_Column.SelectedItems.Count > 0) if (TabList_Column.SelectedItems.Count > 0)
{ {
if (TabList_Column.SelectedItems[0].Tag.ToInt() != columnid) if (TabList_Type.SelectedItems.Count > 0 && TabList_Type.SelectedItems[0].Tag.ToInt() > 0 && TabList_Type.SelectedItems[0].Tag.ToInt()!=id)
{
lvi.Remove();
}
else if (TabList_Type.SelectedItems.Count > 0 && TabList_Type.SelectedItems[0].Tag.ToInt() > 0)
{ {
lvi.Remove(); lvi.Remove();
} }
@ -987,10 +1078,7 @@ namespace VSoft
var columnid = item.Tag.ToInt(); var columnid = item.Tag.ToInt();
if (columnid == 0) if (columnid == 0)
{ {
if (TabList_Column.SelectedItems.Count>0) return;
{
columnid = TabList_Column.SelectedItems[0].Tag.ToInt();
}
} }
//获得拖放中的项 //获得拖放中的项
var drag_item = e.Data.GetData(typeof(ListViewItem)); var drag_item = e.Data.GetData(typeof(ListViewItem));
@ -1023,7 +1111,7 @@ namespace VSoft
} }
else if (lvi.ListView == TabList_Type) else if (lvi.ListView == TabList_Type)
{ {
if (lvi.Index == item.Index || item.Index==0 || lvi.Index==0) { return; } if (lvi.Index == item.Index) { return; }
TabList_Type.BeginUpdate(); TabList_Type.BeginUpdate();
TabList_Type.View = View.List; TabList_Type.View = View.List;
TabList_Type.Items.RemoveAt(lvi.Index); TabList_Type.Items.RemoveAt(lvi.Index);
@ -1034,11 +1122,11 @@ namespace VSoft
if (db.ConnDb(SQLConnStr) == 1) if (db.ConnDb(SQLConnStr) == 1)
{ {
db.BeginTransaction(); db.BeginTransaction();
for (int i = 1; i < TabList_Type.Items.Count; i++) for (int i = 0; i < TabList_Type.Items.Count; i++)
{ {
var id = TabList_Type.Items[i].Tag.ToInt(); var id = TabList_Type.Items[i].Tag.ToInt();
RyQuickSQL mySQL = new RyQuickSQL("Columns"); RyQuickSQL mySQL = new RyQuickSQL("Columns");
mySQL.AddField("sortindex", i); mySQL.AddField("sortindex", i+1);
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" +id, mySQL); db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" +id, mySQL);
} }
db.Commit(); db.Commit();
@ -1111,6 +1199,7 @@ namespace VSoft
if (Config.Soft_Info.DonateVisabled) if (Config.Soft_Info.DonateVisabled)
{ {
FrmAbout frm = new FrmAbout(); FrmAbout frm = new FrmAbout();
frm.TopMost = TopMost;
frm.ShowDialog(); frm.ShowDialog();
frm.Dispose(); frm.Dispose();
} }
@ -1124,7 +1213,8 @@ namespace VSoft
{ {
hotkey.Enabled = false; hotkey.Enabled = false;
FrmSetting frm = new FrmSetting(); FrmSetting frm = new FrmSetting();
if(frm.ShowDialog()==DialogResult.OK) frm.TopMost = TopMost;
if (frm.ShowDialog()==DialogResult.OK)
{ {
VSoft.Config.Soft_Config.LoadSetting(); VSoft.Config.Soft_Config.LoadSetting();
hotkey.UnHotKey(); hotkey.UnHotKey();
@ -1209,7 +1299,7 @@ namespace VSoft
TabList_Column.SelectedStartBackColor = Color.LightYellow; TabList_Column.SelectedStartBackColor = Color.LightYellow;
using (var bg = new BackgroundWorker()) using (var bg = new BackgroundWorker())
{ {
bg.DoWork += delegate { System.Threading.Thread.Sleep(500); };//180秒后,3分钟 bg.DoWork += delegate { System.Threading.Thread.Sleep(500); };//0.5
bg.RunWorkerCompleted += delegate { bg.RunWorkerCompleted += delegate {
this.Invoke(new Action(() => this.Invoke(new Action(() =>
{ {
@ -1238,19 +1328,13 @@ namespace VSoft
ColumnId = TabList_Type.SelectedItems[0].Tag.ToInt(); ColumnId = TabList_Type.SelectedItems[0].Tag.ToInt();
} }
if (ColumnId == 0) if (ColumnId == 0)
{
if (TabList_Column.SelectedItems.Count > 0)
{
ColumnId = TabList_Column.SelectedItems[0].Tag.ToInt();
}
}
if (ColumnId == 0)
{ {
MessageBox.Show("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("当前模式下不支持添加软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return; return;
} }
FrmInCMD frm = new FrmInCMD(); FrmInCMD frm = new FrmInCMD();
if(frm.ShowDialog()==DialogResult.OK) frm.TopMost = TopMost;
if (frm.ShowDialog()==DialogResult.OK)
{ {
var info = frm.SelectedInfo; var info = frm.SelectedInfo;
RyQuickSQL mySQL = new RyQuickSQL("Softs"); RyQuickSQL mySQL = new RyQuickSQL("Softs");
@ -1308,16 +1392,8 @@ namespace VSoft
} }
else else
{ {
if (TabList_Type.SelectedItems[0].Index == 0) Menu修改分类.Enabled = true;
{ Menu删除分类.Enabled = true;
Menu修改分类.Enabled = false;
Menu删除分类.Enabled = false;
}
else
{
Menu修改分类.Enabled = true;
Menu删除分类.Enabled = true;
}
} }
} }

View File

@ -36,7 +36,7 @@ namespace VSoft.Prams
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="value"></param> /// <param name="value"></param>
public static void SetSetting(string _SQLConnStr, string name, string value) public static int SetSetting(string _SQLConnStr, string name, string value)
{ {
IDbInterface db = CreateDataProvider(dataType); IDbInterface db = CreateDataProvider(dataType);
if (db.ConnDb(_SQLConnStr) == 1) if (db.ConnDb(_SQLConnStr) == 1)
@ -44,21 +44,24 @@ namespace VSoft.Prams
RyQuickSQL mySQL = new RyQuickSQL("Setting"); RyQuickSQL mySQL = new RyQuickSQL("Setting");
mySQL.AddField("sName", name); mySQL.AddField("sName", name);
mySQL.AddField("sValue", value); mySQL.AddField("sValue", value);
if (db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where sName=@sName", mySQL) == 0) var result = db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where sName=@sName", mySQL);
if (result == 0)
{ {
db.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL); result = db.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL);
} }
return result;
} }
db.Free(); db.Free();
return -1000;
} }
/// <summary> /// <summary>
/// 写入设置 /// 写入设置
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="value"></param> /// <param name="value"></param>
public static void SetSetting(string name, string value) public static int SetSetting(string name, string value)
{ {
SetSetting(SQLConnStr, name, value); return SetSetting(SQLConnStr, name, value);
} }
/// <summary> /// <summary>
/// 读取设置 /// 读取设置
@ -109,6 +112,40 @@ namespace VSoft.Prams
ds.Dispose(); ds.Dispose();
return icount; return icount;
} }
/// <summary>
/// 获取指定栏目的第一个分类id
/// </summary>
/// <param name="db"></param>
/// <param name="ColumnId"></param>
/// <returns></returns>
public static int GetFirstColumnId(IDbInterface db, int ColumnId)
{
var ds = db.ReadData("select id from Columns where parentId=" + ColumnId+ " order by sortindex asc limit 1");
if (ds.Tables[0].Rows.Count == 0)
{ return -1; }
else
{
var icount = ds.Tables[0].Rows[0][0].ToInt();
ds.Dispose();
return icount;
}
}
/// <summary>
/// 获取数据库版本
/// </summary>
/// <returns></returns>
public static int GetDbVer()
{
return GetSetting("dbVer", "1").ToInt();
}
/// <summary>
/// 设置数据库版本
/// </summary>
/// <returns></returns>
public static int SetDbVer(int DbVer)
{
return SetSetting("dbVer", DbVer.ToString());
}
public static void CreateTable(DataProvider.DataProviderType dataType, string ConnStr) public static void CreateTable(DataProvider.DataProviderType dataType, string ConnStr)
{ {
IDbInterface db = CreateDataProvider(dataType); IDbInterface db = CreateDataProvider(dataType);

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2012.2701")] [assembly: AssemblyVersion("1.0.2012.2702")]
[assembly: AssemblyFileVersion("1.0.2012.2701")] [assembly: AssemblyFileVersion("1.0.2012.2702")]

View File

@ -1,98 +1,98 @@
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms; using System.Windows.Forms;
namespace ryControls namespace ryControls
{ {
public class TabList : ListView public class TabList : ListView
{ {
private ColumnHeader columnHeader1; private ColumnHeader columnHeader1;
public TabList() : public TabList() :
base() base()
{ {
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
this.OwnerDraw = true;//用于启用重绘 this.OwnerDraw = true;//用于启用重绘
this.View = View.Tile; this.View = View.Tile;
this.TileSize = new Size(80,28); this.TileSize = new Size(80,28);
this.Scrollable = false; this.Scrollable = false;
this.MultiSelect = false; this.MultiSelect = false;
} }
/// <summary> /// <summary>
/// 图标 /// 图标
/// </summary> /// </summary>
public Image Icon { get; set; } public Image Icon { get; set; }
/// <summary> /// <summary>
/// 重绘图标 /// 重绘图标
/// </summary> /// </summary>
public bool IsDrawIcon { get; set; } public bool IsDrawIcon { get; set; }
/// <summary> /// <summary>
/// 重绘网格线 /// 重绘网格线
/// </summary> /// </summary>
public bool IsDrawGridLines { get; set; } public bool IsDrawGridLines { get; set; }
private int last_selectIndex = 0; private int last_selectIndex = 0;
protected override void OnMouseUp(MouseEventArgs e) protected override void OnMouseUp(MouseEventArgs e)
{ {
var pt = this.PointToClient(e.Location); var pt = this.PointToClient(e.Location);
var item = this.GetItemAt(pt.X, pt.Y); var item = this.GetItemAt(pt.X, pt.Y);
if (item == null) if (item == null)
{ {
if (last_selectIndex < this.Items.Count) if (last_selectIndex < this.Items.Count)
{ {
this.Items[last_selectIndex].Selected = true; this.Items[last_selectIndex].Selected = true;
} }
} }
} }
protected override void OnItemSelectionChanged(ListViewItemSelectionChangedEventArgs e) protected override void OnItemSelectionChanged(ListViewItemSelectionChangedEventArgs e)
{ {
if(e.IsSelected) if(e.IsSelected)
{ {
last_selectIndex = e.ItemIndex; last_selectIndex = e.ItemIndex;
base.OnItemSelectionChanged(e); base.OnItemSelectionChanged(e);
} }
else else
{ {
if ( last_selectIndex < this.Items.Count) if ( last_selectIndex < this.Items.Count)
{ {
//this.Items[last_selectIndex].Selected = true; //this.Items[last_selectIndex].Selected = true;
} }
} }
} }
protected override void OnSelectedIndexChanged(System.EventArgs e) protected override void OnSelectedIndexChanged(System.EventArgs e)
{ {
if(this.SelectedItems.Count>0) if(this.SelectedItems.Count>0)
{ {
base.OnSelectedIndexChanged(e); base.OnSelectedIndexChanged(e);
} }
else else
{ {
} }
} }
protected override void OnDrawItem(DrawListViewItemEventArgs e) protected override void OnDrawItem(DrawListViewItemEventArgs e)
{ {
Rectangle r = e.Bounds; Rectangle r = e.Bounds;
Graphics g = e.Graphics; Graphics g = e.Graphics;
DrawSelectedBackground(e, g, r); DrawSelectedBackground(e, g, r);
//if (IsDrawGridLines) //if (IsDrawGridLines)
//{ //{
// using (Pen pen = new Pen(Color.Gray)) // using (Pen pen = new Pen(Color.Gray))
// { // {
// g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height + 1);//高度加1使横向线条重叠 // g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height + 1);//高度加1使横向线条重叠
// } // }
//} //}
if (!string.IsNullOrEmpty(e.Item.Text)) if (!string.IsNullOrEmpty(e.Item.Text))
{ {
this.DrawText(e, g, r); this.DrawText(e, g, r);
} }
} }
private Color _SelectedStartBackColor = Color.LightSkyBlue; private Color _SelectedStartBackColor = Color.LightSkyBlue;
/// <summary> /// <summary>
/// 选择项的背景开始颜色 /// 选择项的背景开始颜色
@ -143,8 +143,8 @@ namespace ryControls
_SelectedBorderColor = value; _SelectedBorderColor = value;
this.Refresh(); this.Refresh();
} }
} }
private Color _SelectedForeColor = Color.Black; private Color _SelectedForeColor = Color.Black;
/// <summary> /// <summary>
/// 选择项的字体颜色 /// 选择项的字体颜色
/// </summary> /// </summary>
@ -160,120 +160,120 @@ namespace ryControls
_SelectedForeColor = value; _SelectedForeColor = value;
this.Refresh(); this.Refresh();
} }
} }
/// <summary> /// <summary>
/// 重绘选中时背景 /// 重绘选中时背景
/// </summary> /// </summary>
private void DrawSelectedBackground(DrawListViewItemEventArgs e, Graphics g, Rectangle r) private void DrawSelectedBackground(DrawListViewItemEventArgs e, Graphics g, Rectangle r)
{ {
if (e.Item.Selected) if (e.Item.Selected)
{ {
//渐变画刷 //渐变画刷
LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, _SelectedStartBackColor, LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, _SelectedStartBackColor,
_SelectedEndBackColor, LinearGradientMode.Vertical); _SelectedEndBackColor, LinearGradientMode.Vertical);
//填充区域 //填充区域
//Rectangle borderRect = new Rectangle(r, e.Bounds.Y, e.Bounds.Width - 5, e.Bounds.Height - 2); //Rectangle borderRect = new Rectangle(r, e.Bounds.Y, e.Bounds.Width - 5, e.Bounds.Height - 2);
e.Graphics.FillRectangle(brush, r); e.Graphics.FillRectangle(brush, r);
brush.Dispose(); brush.Dispose();
////画边框 ////画边框
Pen pen = new Pen(_SelectedBorderColor); Pen pen = new Pen(_SelectedBorderColor);
Rectangle borderRect = r; Rectangle borderRect = r;
borderRect.Width--; borderRect.Width--;
borderRect.Height--; borderRect.Height--;
e.Graphics.DrawRectangle(pen, borderRect); e.Graphics.DrawRectangle(pen, borderRect);
pen.Dispose(); pen.Dispose();
//using (SolidBrush brush = new SolidBrush(_SelectedBackColor)) //using (SolidBrush brush = new SolidBrush(_SelectedBackColor))
//{ //{
// g.FillRectangle(brush, r); // g.FillRectangle(brush, r);
//} //}
} }
} }
/// <summary> /// <summary>
/// 重绘图标 /// 重绘图标
/// </summary> /// </summary>
private Size DrawIcon(Graphics g, Rectangle r, Image image, Color backColor) private Size DrawIcon(Graphics g, Rectangle r, Image image, Color backColor)
{ {
Rectangle imageBounds = new Rectangle(new Point(r.X+10, r.Y+3), new Size(64,64)); Rectangle imageBounds = new Rectangle(new Point(r.X+10, r.Y+3), new Size(64,64));
if (r.Width > r.Height-20) if (r.Width > r.Height-20)
{ {
imageBounds.Width = r.Height-20; imageBounds.Width = r.Height-20;
imageBounds.Height = r.Height - 20; imageBounds.Height = r.Height - 20;
} }
else else
{ {
imageBounds.Width = r.Width - 20; imageBounds.Width = r.Width - 20;
imageBounds.Height = r.Width - 20; imageBounds.Height = r.Width - 20;
} }
imageBounds.X = r.X + (r.Width - imageBounds.Width) / 2; imageBounds.X = r.X + (r.Width - imageBounds.Width) / 2;
//使图标不会紧贴着每一列的左上角 //使图标不会紧贴着每一列的左上角
//imageBounds.X += 1; //imageBounds.X += 1;
//imageBounds.Y += 1; //imageBounds.Y += 1;
g.DrawImage(image, imageBounds); g.DrawImage(image, imageBounds);
return imageBounds.Size; return imageBounds.Size;
} }
/// <summary> /// <summary>
/// 重绘文本 /// 重绘文本
/// </summary> /// </summary>
private void DrawText(DrawListViewItemEventArgs e, Graphics g, Rectangle r) private void DrawText(DrawListViewItemEventArgs e, Graphics g, Rectangle r)
{ {
TextFormatFlags flags = GetFormatFlags(HorizontalAlignment.Center); TextFormatFlags flags = GetFormatFlags(HorizontalAlignment.Center);
TextRenderer.DrawText( TextRenderer.DrawText(
g, g,
e.Item.Text, e.Item.Text,
e.Item.Font, e.Item.Font,
r, r,
e.Item.Selected?SelectedForeColor: e.Item.ForeColor, e.Item.Selected?SelectedForeColor: e.Item.ForeColor,
flags); flags);
} }
/// <summary> /// <summary>
/// 获取文本对齐 /// 获取文本对齐
/// </summary> /// </summary>
private TextFormatFlags GetFormatFlags( private TextFormatFlags GetFormatFlags(
HorizontalAlignment align) HorizontalAlignment align)
{ {
TextFormatFlags flags = TextFormatFlags flags =
TextFormatFlags.EndEllipsis | TextFormatFlags.EndEllipsis |
TextFormatFlags.VerticalCenter; TextFormatFlags.VerticalCenter;
switch (align) switch (align)
{ {
case HorizontalAlignment.Center: case HorizontalAlignment.Center:
flags |= TextFormatFlags.HorizontalCenter; flags |= TextFormatFlags.HorizontalCenter;
break; break;
case HorizontalAlignment.Right: case HorizontalAlignment.Right:
flags |= TextFormatFlags.Right; flags |= TextFormatFlags.Right;
break; break;
case HorizontalAlignment.Left: case HorizontalAlignment.Left:
flags |= TextFormatFlags.Left; flags |= TextFormatFlags.Left;
break; break;
} }
return flags; return flags;
} }
private void InitializeComponent() private void InitializeComponent()
{ {
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout(); this.SuspendLayout();
// //
// columnHeader1 // columnHeader1
// //
this.columnHeader1.Width = 10; this.columnHeader1.Width = 10;
// //
// IconViewEx // IconViewEx
// //
this.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1}); this.columnHeader1});
this.LabelWrap = false; this.LabelWrap = false;
this.ShowItemToolTips = true; this.ShowItemToolTips = true;
this.TileSize = new System.Drawing.Size(60, 60); this.TileSize = new System.Drawing.Size(60, 60);
this.View = System.Windows.Forms.View.Tile; this.View = System.Windows.Forms.View.Tile;
this.ResumeLayout(false); this.ResumeLayout(false);
} }
} }
} }