增加信息记录分组
This commit is contained in:
parent
1955c433eb
commit
7357c86238
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using SqlSugar;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace PrivateBox.DataContext
|
namespace PrivateBox.DataContext
|
||||||
{
|
{
|
||||||
@ -16,7 +17,12 @@ namespace PrivateBox.DataContext
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密项值
|
/// 加密项值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SqlSugar.SugarColumn(ColumnDataType = "text")]
|
[SugarColumn(ColumnDataType = "text")]
|
||||||
public string? ItemValue { get; set; }
|
public string? ItemValue { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数据分组
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(20)]
|
||||||
|
public string? Group { get; set; } = "未分组";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="textBox1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btOk.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btCancel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
72
PrivateBox/Forms/MainForm.Designer.cs
generated
72
PrivateBox/Forms/MainForm.Designer.cs
generated
@ -29,21 +29,29 @@
|
|||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
toolStripContainer1 = new ToolStripContainer();
|
toolStripContainer1 = new ToolStripContainer();
|
||||||
splitContainer1 = new SplitContainer();
|
splitContainer1 = new SplitContainer();
|
||||||
|
splitContainer3 = new SplitContainer();
|
||||||
|
clb_group = new CheckedListBox();
|
||||||
lbKeyList = new ListBox();
|
lbKeyList = new ListBox();
|
||||||
menuKeyList = new ContextMenuStrip(components);
|
menuKeyList = new ContextMenuStrip(components);
|
||||||
KeyListAddNew = new ToolStripMenuItem();
|
KeyListAddNew = new ToolStripMenuItem();
|
||||||
KeyListRemove = new ToolStripMenuItem();
|
KeyListRemove = new ToolStripMenuItem();
|
||||||
|
KeyListGroup = new ToolStripMenuItem();
|
||||||
splitContainer2 = new SplitContainer();
|
splitContainer2 = new SplitContainer();
|
||||||
toolStrip1 = new ToolStrip();
|
toolStrip1 = new ToolStrip();
|
||||||
btSave = new ToolStripButton();
|
btSave = new ToolStripButton();
|
||||||
btCancel = new ToolStripButton();
|
btCancel = new ToolStripButton();
|
||||||
tbMessage = new RichTextBox();
|
tbMessage = new RichTextBox();
|
||||||
|
toolStripMenuItem1 = new ToolStripSeparator();
|
||||||
toolStripContainer1.ContentPanel.SuspendLayout();
|
toolStripContainer1.ContentPanel.SuspendLayout();
|
||||||
toolStripContainer1.SuspendLayout();
|
toolStripContainer1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||||
splitContainer1.Panel1.SuspendLayout();
|
splitContainer1.Panel1.SuspendLayout();
|
||||||
splitContainer1.Panel2.SuspendLayout();
|
splitContainer1.Panel2.SuspendLayout();
|
||||||
splitContainer1.SuspendLayout();
|
splitContainer1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer3).BeginInit();
|
||||||
|
splitContainer3.Panel1.SuspendLayout();
|
||||||
|
splitContainer3.Panel2.SuspendLayout();
|
||||||
|
splitContainer3.SuspendLayout();
|
||||||
menuKeyList.SuspendLayout();
|
menuKeyList.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
|
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
|
||||||
splitContainer2.Panel1.SuspendLayout();
|
splitContainer2.Panel1.SuspendLayout();
|
||||||
@ -74,7 +82,7 @@
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
splitContainer1.Panel1.Controls.Add(lbKeyList);
|
splitContainer1.Panel1.Controls.Add(splitContainer3);
|
||||||
//
|
//
|
||||||
// splitContainer1.Panel2
|
// splitContainer1.Panel2
|
||||||
//
|
//
|
||||||
@ -83,6 +91,35 @@
|
|||||||
splitContainer1.SplitterDistance = 285;
|
splitContainer1.SplitterDistance = 285;
|
||||||
splitContainer1.TabIndex = 0;
|
splitContainer1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// splitContainer3
|
||||||
|
//
|
||||||
|
splitContainer3.Dock = DockStyle.Fill;
|
||||||
|
splitContainer3.Location = new Point(0,0);
|
||||||
|
splitContainer3.Name = "splitContainer3";
|
||||||
|
splitContainer3.Orientation = Orientation.Horizontal;
|
||||||
|
//
|
||||||
|
// splitContainer3.Panel1
|
||||||
|
//
|
||||||
|
splitContainer3.Panel1.Controls.Add(clb_group);
|
||||||
|
//
|
||||||
|
// splitContainer3.Panel2
|
||||||
|
//
|
||||||
|
splitContainer3.Panel2.Controls.Add(lbKeyList);
|
||||||
|
splitContainer3.Size = new Size(285,379);
|
||||||
|
splitContainer3.SplitterDistance = 117;
|
||||||
|
splitContainer3.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// clb_group
|
||||||
|
//
|
||||||
|
clb_group.Dock = DockStyle.Fill;
|
||||||
|
clb_group.FormattingEnabled = true;
|
||||||
|
clb_group.HorizontalScrollbar = true;
|
||||||
|
clb_group.Items.AddRange(new object[] { "未分组" });
|
||||||
|
clb_group.Location = new Point(0,0);
|
||||||
|
clb_group.Name = "clb_group";
|
||||||
|
clb_group.Size = new Size(285,117);
|
||||||
|
clb_group.TabIndex = 1;
|
||||||
|
//
|
||||||
// lbKeyList
|
// lbKeyList
|
||||||
//
|
//
|
||||||
lbKeyList.ContextMenuStrip = menuKeyList;
|
lbKeyList.ContextMenuStrip = menuKeyList;
|
||||||
@ -91,29 +128,36 @@
|
|||||||
lbKeyList.ItemHeight = 17;
|
lbKeyList.ItemHeight = 17;
|
||||||
lbKeyList.Location = new Point(0,0);
|
lbKeyList.Location = new Point(0,0);
|
||||||
lbKeyList.Name = "lbKeyList";
|
lbKeyList.Name = "lbKeyList";
|
||||||
lbKeyList.Size = new Size(285,379);
|
lbKeyList.Size = new Size(285,258);
|
||||||
lbKeyList.TabIndex = 0;
|
lbKeyList.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// menuKeyList
|
// menuKeyList
|
||||||
//
|
//
|
||||||
menuKeyList.Items.AddRange(new ToolStripItem[] { KeyListAddNew,KeyListRemove });
|
menuKeyList.Items.AddRange(new ToolStripItem[] { KeyListAddNew,KeyListRemove,toolStripMenuItem1,KeyListGroup });
|
||||||
menuKeyList.Name = "menuKeyList";
|
menuKeyList.Name = "menuKeyList";
|
||||||
menuKeyList.Size = new Size(101,48);
|
menuKeyList.Size = new Size(181,98);
|
||||||
//
|
//
|
||||||
// KeyListAddNew
|
// KeyListAddNew
|
||||||
//
|
//
|
||||||
KeyListAddNew.Name = "KeyListAddNew";
|
KeyListAddNew.Name = "KeyListAddNew";
|
||||||
KeyListAddNew.Size = new Size(100,22);
|
KeyListAddNew.Size = new Size(180,22);
|
||||||
KeyListAddNew.Text = "新增";
|
KeyListAddNew.Text = "新增";
|
||||||
KeyListAddNew.Click += KeyListAddNew_Click;
|
KeyListAddNew.Click += KeyListAddNew_Click;
|
||||||
//
|
//
|
||||||
// KeyListRemove
|
// KeyListRemove
|
||||||
//
|
//
|
||||||
KeyListRemove.Name = "KeyListRemove";
|
KeyListRemove.Name = "KeyListRemove";
|
||||||
KeyListRemove.Size = new Size(100,22);
|
KeyListRemove.Size = new Size(180,22);
|
||||||
KeyListRemove.Text = "删除";
|
KeyListRemove.Text = "删除";
|
||||||
KeyListRemove.Click += KeyListRemove_Click;
|
KeyListRemove.Click += KeyListRemove_Click;
|
||||||
//
|
//
|
||||||
|
// KeyListGroup
|
||||||
|
//
|
||||||
|
KeyListGroup.Name = "KeyListGroup";
|
||||||
|
KeyListGroup.Size = new Size(180,22);
|
||||||
|
KeyListGroup.Text = "分组";
|
||||||
|
KeyListGroup.Click += KeyListGroup_Click;
|
||||||
|
//
|
||||||
// splitContainer2
|
// splitContainer2
|
||||||
//
|
//
|
||||||
splitContainer2.Dock = DockStyle.Fill;
|
splitContainer2.Dock = DockStyle.Fill;
|
||||||
@ -172,6 +216,11 @@
|
|||||||
tbMessage.TabIndex = 0;
|
tbMessage.TabIndex = 0;
|
||||||
tbMessage.Text = "tbMessage";
|
tbMessage.Text = "tbMessage";
|
||||||
//
|
//
|
||||||
|
// toolStripMenuItem1
|
||||||
|
//
|
||||||
|
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||||
|
toolStripMenuItem1.Size = new Size(177,6);
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F,17F);
|
AutoScaleDimensions = new SizeF(7F,17F);
|
||||||
@ -179,7 +228,7 @@
|
|||||||
ClientSize = new Size(756,404);
|
ClientSize = new Size(756,404);
|
||||||
Controls.Add(toolStripContainer1);
|
Controls.Add(toolStripContainer1);
|
||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
Text = "密码管理";
|
Text = "凭据管理";
|
||||||
toolStripContainer1.ContentPanel.ResumeLayout(false);
|
toolStripContainer1.ContentPanel.ResumeLayout(false);
|
||||||
toolStripContainer1.ResumeLayout(false);
|
toolStripContainer1.ResumeLayout(false);
|
||||||
toolStripContainer1.PerformLayout();
|
toolStripContainer1.PerformLayout();
|
||||||
@ -187,6 +236,10 @@
|
|||||||
splitContainer1.Panel2.ResumeLayout(false);
|
splitContainer1.Panel2.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
|
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
|
||||||
splitContainer1.ResumeLayout(false);
|
splitContainer1.ResumeLayout(false);
|
||||||
|
splitContainer3.Panel1.ResumeLayout(false);
|
||||||
|
splitContainer3.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer3).EndInit();
|
||||||
|
splitContainer3.ResumeLayout(false);
|
||||||
menuKeyList.ResumeLayout(false);
|
menuKeyList.ResumeLayout(false);
|
||||||
splitContainer2.Panel1.ResumeLayout(false);
|
splitContainer2.Panel1.ResumeLayout(false);
|
||||||
splitContainer2.Panel1.PerformLayout();
|
splitContainer2.Panel1.PerformLayout();
|
||||||
@ -211,5 +264,10 @@
|
|||||||
private ContextMenuStrip menuKeyList;
|
private ContextMenuStrip menuKeyList;
|
||||||
private ToolStripMenuItem KeyListAddNew;
|
private ToolStripMenuItem KeyListAddNew;
|
||||||
private ToolStripMenuItem KeyListRemove;
|
private ToolStripMenuItem KeyListRemove;
|
||||||
|
private CheckedListBox clb_group;
|
||||||
|
private SplitContainer splitContainer3;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem2;
|
||||||
|
private ToolStripMenuItem KeyListGroup;
|
||||||
|
private ToolStripSeparator toolStripMenuItem1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using PrivateBox.DataContext;
|
using PrivateBox.DataContext;
|
||||||
using PrivateBox.Encryption;
|
using PrivateBox.Encryption;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace PrivateBox
|
namespace PrivateBox
|
||||||
{
|
{
|
||||||
@ -10,6 +11,16 @@ namespace PrivateBox
|
|||||||
public DbContext Db { get; init; }
|
public DbContext Db { get; init; }
|
||||||
public string CrytionKey { get; init; }
|
public string CrytionKey { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认分组名
|
||||||
|
/// </summary>
|
||||||
|
private const string _defaultGroupName = "未分组";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 允许刷新Key列表
|
||||||
|
/// </summary>
|
||||||
|
private bool EnableRefreshKeyList = true;
|
||||||
|
|
||||||
public MainForm(IServiceProvider provider) {
|
public MainForm(IServiceProvider provider) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.Encrytion = provider.GetRequiredService<IEncryptionService>();
|
this.Encrytion = provider.GetRequiredService<IEncryptionService>();
|
||||||
@ -17,10 +28,16 @@ namespace PrivateBox
|
|||||||
this.CrytionKey = this.Db.GetCrytionKey();
|
this.CrytionKey = this.Db.GetCrytionKey();
|
||||||
|
|
||||||
this.Load += (s,d) => {
|
this.Load += (s,d) => {
|
||||||
|
RefreshGroupList();
|
||||||
RefreshKeyList();
|
RefreshKeyList();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.lbKeyList.SelectedIndexChanged += LbKeyList_SelectedIndexChanged;
|
this.lbKeyList.SelectedIndexChanged += LbKeyList_SelectedIndexChanged;
|
||||||
|
this.clb_group.ItemCheck += (s,e) => {
|
||||||
|
this.BeginInvoke(new Action(() => {
|
||||||
|
RefreshKeyList();
|
||||||
|
}));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LbKeyList_SelectedIndexChanged(object? sender,EventArgs e) {
|
private void LbKeyList_SelectedIndexChanged(object? sender,EventArgs e) {
|
||||||
@ -38,11 +55,58 @@ namespace PrivateBox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新组
|
||||||
|
/// </summary>
|
||||||
|
private void RefreshGroupList() {
|
||||||
|
var qu = this.Db.Queryable<CrytionItem>()
|
||||||
|
.Where(a => !string.IsNullOrEmpty(a.Group))
|
||||||
|
.Select(a => a.Group)
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
var clbi = this.clb_group.Items;
|
||||||
|
foreach(var i in qu) {
|
||||||
|
if(i == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!clbi.Contains(i)) {
|
||||||
|
clbi.Add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!clbi.Contains(_defaultGroupName)) {
|
||||||
|
clbi.Add(_defaultGroupName);
|
||||||
|
}
|
||||||
|
if(clbi.Count == 1) {
|
||||||
|
this.EnableRefreshKeyList = false;
|
||||||
|
this.clb_group.SetItemChecked(0,true);
|
||||||
|
this.EnableRefreshKeyList = true;
|
||||||
|
}
|
||||||
|
RefreshKeyList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新Key列表
|
||||||
|
/// </summary>
|
||||||
private void RefreshKeyList() {
|
private void RefreshKeyList() {
|
||||||
|
if(!EnableRefreshKeyList) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.lbKeyList.Items.Clear();
|
this.lbKeyList.Items.Clear();
|
||||||
this.tbMessage.Text = "";
|
this.tbMessage.Text = "";
|
||||||
var qu = this.Db.Queryable<CrytionItem>().Select(a => a.ItemName)
|
var groups = this.clb_group.CheckedItems.Cast<string>();
|
||||||
.ToList().OrderBy(a => a);
|
if(groups == null || groups.Count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var qu = this.Db.Queryable<CrytionItem>()
|
||||||
|
.Where(a => groups.Contains(a.Group))
|
||||||
|
.Select(a => a.ItemName)
|
||||||
|
.ToList();
|
||||||
|
if(groups.Contains(_defaultGroupName)) {
|
||||||
|
var qunull = this.Db.Queryable<CrytionItem>()
|
||||||
|
.Where(a => string.IsNullOrEmpty(a.Group))
|
||||||
|
.Select(a => a.ItemName)
|
||||||
|
.ToList();
|
||||||
|
qu = qu.Union(qunull).ToList();
|
||||||
|
}
|
||||||
foreach(var i in qu) {
|
foreach(var i in qu) {
|
||||||
this.lbKeyList.Items.Add(i);
|
this.lbKeyList.Items.Add(i);
|
||||||
}
|
}
|
||||||
@ -94,6 +158,26 @@ namespace PrivateBox
|
|||||||
this.tbMessage.Text = tag.ItemValue;
|
this.tbMessage.Text = tag.ItemValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void KeyListGroup_Click(object sender,EventArgs e) {
|
||||||
|
if(this.lbKeyList.SelectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var sItem = this.lbKeyList.SelectedItem.ToString();
|
||||||
|
var qu = this.Db.Queryable<CrytionItem>().Where(a => a.ItemName == sItem).ToList();
|
||||||
|
if(qu == null || qu.Count == 0) {
|
||||||
|
MessageBox.Show("没有找到项目!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dlg = new InputDlgBox("更新分组",qu.FirstOrDefault().Group);
|
||||||
|
if(dlg.ShowDialog() == DialogResult.OK) {
|
||||||
|
this.Db.Updateable<CrytionItem>()
|
||||||
|
.Where(a => a.ItemName == sItem)
|
||||||
|
.SetColumns(a => a.Group == dlg.Msg)
|
||||||
|
.ExecuteCommand();
|
||||||
|
}
|
||||||
|
RefreshGroupList();
|
||||||
|
}
|
||||||
|
|
||||||
private bool MessageChanged {
|
private bool MessageChanged {
|
||||||
get {
|
get {
|
||||||
var tag = this.tbMessage.Tag as CrytionItem;
|
var tag = this.tbMessage.Tag as CrytionItem;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user