Commit 92eae684 authored by tr's avatar tr

1、主界面:增加帮助文档功能

parent c8532694
......@@ -124,7 +124,7 @@ namespace Tools.MyCommon
return true;
}
#region 结束编辑
#region 通用:结束编辑
/// <summary>
/// 基本信息-结束编辑
......@@ -135,10 +135,7 @@ namespace Tools.MyCommon
foreach (DictionaryEntry item in this.BindingContext)
{
bm = (item.Value as WeakReference).Target as BindingManagerBase;
if (bm != null)
{
bm.EndCurrentEdit();
}
bm?.EndCurrentEdit();
}
}
/// <summary>
......@@ -184,7 +181,7 @@ namespace Tools.MyCommon
}
#endregion
#region 数据绑定
#region 通用:数据绑定
/// <summary>
/// 绑定基础信息
......
......@@ -106,6 +106,12 @@
<Compile Include="UI\Popups\wSelectTemplates.Designer.cs">
<DependentUpon>wSelectTemplates.cs</DependentUpon>
</Compile>
<Compile Include="UI\sys\wHelpDocument.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\sys\wHelpDocument.Designer.cs">
<DependentUpon>wHelpDocument.cs</DependentUpon>
</Compile>
<Compile Include="UI\sys\wAboutUS.cs">
<SubType>Form</SubType>
</Compile>
......@@ -302,6 +308,9 @@
<EmbeddedResource Include="UI\sys\wAboutUS.resx">
<DependentUpon>wAboutUS.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\sys\wHelpDocument.resx">
<DependentUpon>wHelpDocument.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\sys\wUploadUpdate.resx">
<DependentUpon>wUploadUpdate.cs</DependentUpon>
</EmbeddedResource>
......
namespace Tools.UI.sys
{
partial class wHelpDocument
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgvDetail = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.btnUpload = new System.Windows.Forms.Button();
this.btnDownload = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgvDetail)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// dgvDetail
//
this.dgvDetail.BackgroundColor = System.Drawing.SystemColors.Window;
this.dgvDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
this.Column4});
this.dgvDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvDetail.Location = new System.Drawing.Point(0, 38);
this.dgvDetail.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dgvDetail.Name = "dgvDetail";
this.dgvDetail.RowTemplate.Height = 23;
this.dgvDetail.Size = new System.Drawing.Size(659, 381);
this.dgvDetail.TabIndex = 1;
//
// Column1
//
this.Column1.DataPropertyName = "dName";
this.Column1.HeaderText = "文件名称";
this.Column1.Name = "Column1";
this.Column1.Width = 210;
//
// Column2
//
this.Column2.DataPropertyName = "dSize";
this.Column2.HeaderText = "文件大小(KB)";
this.Column2.Name = "Column2";
this.Column2.Width = 120;
//
// Column4
//
this.Column4.DataPropertyName = "CreateDate";
this.Column4.HeaderText = "创建日期";
this.Column4.Name = "Column4";
this.Column4.Width = 150;
//
// btnUpload
//
this.btnUpload.BackColor = System.Drawing.SystemColors.Window;
this.btnUpload.Enabled = false;
this.btnUpload.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUpload.Location = new System.Drawing.Point(14, 6);
this.btnUpload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnUpload.Name = "btnUpload";
this.btnUpload.Size = new System.Drawing.Size(87, 27);
this.btnUpload.TabIndex = 0;
this.btnUpload.Text = "上传文件";
this.btnUpload.UseVisualStyleBackColor = false;
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
//
// btnDownload
//
this.btnDownload.BackColor = System.Drawing.SystemColors.Window;
this.btnDownload.Enabled = false;
this.btnDownload.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDownload.Location = new System.Drawing.Point(122, 6);
this.btnDownload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDownload.Name = "btnDownload";
this.btnDownload.Size = new System.Drawing.Size(87, 27);
this.btnDownload.TabIndex = 1;
this.btnDownload.Text = "下载文件";
this.btnDownload.UseVisualStyleBackColor = false;
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(245)))), ((int)(((byte)(255)))));
this.panel1.Controls.Add(this.btnDownload);
this.panel1.Controls.Add(this.btnUpload);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(659, 38);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(245)))), ((int)(((byte)(255)))));
this.panel2.Controls.Add(this.label1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Location = new System.Drawing.Point(0, 419);
this.panel2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(659, 38);
this.panel2.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(101)))), ((int)(((byte)(204)))));
this.label1.Location = new System.Drawing.Point(12, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(231, 17);
this.label1.TabIndex = 0;
this.label1.Text = "*温馨提示:超过50M的文件将被直接忽略";
//
// wHelpDocument
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(659, 457);
this.Controls.Add(this.dgvDetail);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "wHelpDocument";
this.Text = "帮助文档";
this.Load += new System.EventHandler(this.wHelpDocument_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvDetail)).EndInit();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dgvDetail;
private System.Windows.Forms.Button btnUpload;
private System.Windows.Forms.Button btnDownload;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//
using Tools.MyCommon;
using Tools.MyData;
using Tools.MyUtils;
namespace Tools.UI.sys
{
public partial class wHelpDocument : wEditBasic
{
public wHelpDocument()
{
InitializeComponent();
}
private void wHelpDocument_Load(object sender, EventArgs e)
{
//初始化模块表
this.ModuleTableList = new List<TQuery> { new TQuery("FTT_HelpDocument", "SELECT * FROM FTT_HelpDocument ") };
//初始化数据访问对象
this.InitDBHelper(Utils.GetDbLinkString204("FTT_Work"));
//初始化界面
this.InitUI();
//异步装载数据
Task.Run(() => this.InitData());
}
public override void InitUI()
{
//按钮失效
this.ButtonEnabled(false);
//表格初始化
this.dgvDetail.ReadOnly = true;
this.dgvDetail.AllowUserToAddRows = false;
this.dgvDetail.AutoGenerateColumns = false;
this.dgvDetail.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
public override void InitData()
{
this._ds = this._db.GetData(this.ModuleTableList, true);
this.AsyncUI(() => {
this.dgvDetail.DataSource = this._ds.Tables[0].DefaultView;
this.ButtonEnabled(true);
});
}
//事件:上传
private void btnUpload_Click(object sender, EventArgs e)
{
var dlg = new OpenFileDialog() {
CheckFileExists = true,
CheckPathExists = true,
Multiselect = true,
Filter = "所有文件|*.*",
InitialDirectory = Utils.DesktopPath,
};
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (string path in dlg.FileNames)
{
//读取文件
var bytes = File.ReadAllBytes(path);
var KB = bytes.Length / 1024M;
//超过50M直接忽略
if (KB > 50 * 1024)
continue;
//添加文件
var drNew = this._ds.Tables[0].NewRow();
drNew["dName"] = Path.GetFileName(path);
drNew["dSize"] = KB.ToString("0.##");
drNew["dData"] = bytes;
drNew["CreateDate"] = DateTime.Now;
drNew.EndEdit();
this._ds.Tables[0].Rows.Add(drNew);
}
this.Save();
}
}
//事件:下载
private void btnDownload_Click(object sender, EventArgs e)
{
if(this.dgvDetail.SelectedRows.Count == 0)
{
Utils.Tip("请选中要下载的行!");
return;
}
//选择文件夹
var dlg = new FolderBrowserDialog()
{
RootFolder = Environment.SpecialFolder.Desktop,
ShowNewFolderButton = true,
Description = "选择一个文件夹",
};
if (dlg.ShowDialog() == DialogResult.OK)
{
for (int i = 0; i < this.dgvDetail.SelectedRows.Count; i++)
{
var index = this.dgvDetail.SelectedRows[i].Index;
var drNow = this._ds.Tables[0].DefaultView[index];
var fileName = drNow["dName"].ToString();
File.WriteAllBytes($@"{dlg.SelectedPath}\{fileName}", drNow["dData"] as byte[]);
}
Utils.Tip("下载成功!");
}
}
//按钮有效性
private void ButtonEnabled(bool enable)
{
this.btnUpload.Enabled = enable;
this.btnDownload.Enabled = enable;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
......@@ -272,7 +272,7 @@ namespace Tools
/// </summary>
private void Document()
{
this.ShowMessage("帮助文档");
new UI.sys.wHelpDocument().ShowDialog();
}
/// <summary>
/// 帮助:关于我们
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment