提交rbac
提交设置右键错位的bug
This commit is contained in:
87
DH.RBAC/UserControls/AccountControl.Designer.cs
generated
Normal file
87
DH.RBAC/UserControls/AccountControl.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
||||
namespace DH.RBAC.UserControls
|
||||
{
|
||||
partial class AccountControl
|
||||
{
|
||||
/// <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.userAvatar = new Sunny.UI.UIAvatar();
|
||||
this.lblUserName = new Sunny.UI.UILabel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// userAvatar
|
||||
//
|
||||
this.userAvatar.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.userAvatar.FillColor = System.Drawing.Color.Transparent;
|
||||
this.userAvatar.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.userAvatar.ForeColor = System.Drawing.Color.White;
|
||||
this.userAvatar.Location = new System.Drawing.Point(0, 0);
|
||||
this.userAvatar.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.userAvatar.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.userAvatar.Name = "userAvatar";
|
||||
this.userAvatar.Size = new System.Drawing.Size(55, 60);
|
||||
this.userAvatar.Style = Sunny.UI.UIStyle.Custom;
|
||||
this.userAvatar.TabIndex = 2;
|
||||
this.userAvatar.Click += new System.EventHandler(this.userAvatar_Click);
|
||||
this.userAvatar.MouseEnter += new System.EventHandler(this.lblUserName_MouseEnter);
|
||||
this.userAvatar.MouseLeave += new System.EventHandler(this.userAvatar_Leave);
|
||||
//
|
||||
// lblUserName
|
||||
//
|
||||
this.lblUserName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lblUserName.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.lblUserName.ForeColor = System.Drawing.Color.White;
|
||||
this.lblUserName.Location = new System.Drawing.Point(55, 0);
|
||||
this.lblUserName.Name = "lblUserName";
|
||||
this.lblUserName.Size = new System.Drawing.Size(122, 60);
|
||||
this.lblUserName.Style = Sunny.UI.UIStyle.Custom;
|
||||
this.lblUserName.TabIndex = 4;
|
||||
this.lblUserName.Text = "Admin";
|
||||
this.lblUserName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.lblUserName.Click += new System.EventHandler(this.userAvatar_Click);
|
||||
this.lblUserName.MouseEnter += new System.EventHandler(this.lblUserName_MouseEnter);
|
||||
this.lblUserName.MouseLeave += new System.EventHandler(this.userAvatar_Leave);
|
||||
//
|
||||
// AccountControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Gray;
|
||||
this.Controls.Add(this.lblUserName);
|
||||
this.Controls.Add(this.userAvatar);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "AccountControl";
|
||||
this.Size = new System.Drawing.Size(177, 60);
|
||||
this.Load += new System.EventHandler(this.AccountControl_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Sunny.UI.UIAvatar userAvatar;
|
||||
private Sunny.UI.UILabel lblUserName;
|
||||
}
|
||||
}
|
75
DH.RBAC/UserControls/AccountControl.cs
Normal file
75
DH.RBAC/UserControls/AccountControl.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using DH.RBAC.Common;
|
||||
using DH.RBAC.UserControls.Menus;
|
||||
using PopupTool;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DH.RBAC.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户自定义控件,弹出层显示
|
||||
/// </summary>
|
||||
public partial class AccountControl : UserControl
|
||||
{
|
||||
public AccountControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面加载时,显示信息
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void AccountControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
lblUserName.Text = GlobalConfig.CurrentUser.NickName;
|
||||
if (GlobalConfig.Avatar != null)
|
||||
{
|
||||
userAvatar.Icon = Sunny.UI.UIAvatar.UIIcon.Image;
|
||||
userAvatar.Image = GlobalConfig.Avatar;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标放上去改变颜色
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void lblUserName_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
userAvatar.BackColor = Color.FromArgb(176, 176, 176);
|
||||
lblUserName.BackColor = Color.FromArgb(176, 176, 176);
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标离开时,颜色改回来
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void userAvatar_Leave(object sender, EventArgs e)
|
||||
{
|
||||
userAvatar.BackColor = Color.Gray;
|
||||
lblUserName.BackColor = Color.Gray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 点下去后显示弹出层
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void userAvatar_Click(object sender, EventArgs e)
|
||||
{
|
||||
UserMenuPanel uc = new UserMenuPanel();
|
||||
Popup pop = new Popup(uc);
|
||||
pop.Show(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
120
DH.RBAC/UserControls/AccountControl.resx
Normal file
120
DH.RBAC/UserControls/AccountControl.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
121
DH.RBAC/UserControls/Menus/UserMenuPanel.cs
Normal file
121
DH.RBAC/UserControls/Menus/UserMenuPanel.cs
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
using DH.RBAC;
|
||||
using DH.RBAC.Utility.Other;
|
||||
using Sunny.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.RBAC.UserControls.Menus
|
||||
{
|
||||
public class UserMenuPanel : UIPanel
|
||||
{
|
||||
public UserMenuPanel()
|
||||
{
|
||||
UISymbolLabel lblAccountManage = new UISymbolLabel();
|
||||
lblAccountManage.ForeColor = Color.FromArgb(153, 153, 153);
|
||||
|
||||
lblAccountManage.Location = new Point(7, 7);
|
||||
lblAccountManage.MinimumSize = new Size(1, 1);
|
||||
lblAccountManage.Padding = new System.Windows.Forms.Padding(32, 0, 0, 0);
|
||||
lblAccountManage.Size = new Size(122, 44);
|
||||
lblAccountManage.Style = UIStyle.Custom;
|
||||
lblAccountManage.StyleCustomMode = true;
|
||||
lblAccountManage.Symbol = 61508;
|
||||
lblAccountManage.SymbolColor = Color.FromArgb(153, 153, 153);
|
||||
lblAccountManage.SymbolSize = 28;
|
||||
lblAccountManage.Text = "账户管理";
|
||||
lblAccountManage.Click += new EventHandler(this.lblAccountManage_Click);
|
||||
lblAccountManage.MouseEnter += new EventHandler(this.uiSymbolLabel1_MouseEnter);
|
||||
lblAccountManage.MouseLeave += new EventHandler(this.uiSymbolLabel1_MouseLeave);
|
||||
|
||||
|
||||
UISymbolLabel lblExit = new UISymbolLabel();
|
||||
lblExit.ForeColor = Color.FromArgb(153, 153, 153);
|
||||
|
||||
lblExit.Location = new Point(6, 62);
|
||||
lblExit.Padding = new System.Windows.Forms.Padding(32, 0, 0, 0);
|
||||
lblExit.Size = new Size(122, 44);
|
||||
lblExit.Style = UIStyle.Custom;
|
||||
lblExit.StyleCustomMode = true;
|
||||
lblExit.Symbol = 61584;
|
||||
lblExit.SymbolColor = Color.FromArgb(153, 153, 153);
|
||||
lblExit.SymbolSize = 28;
|
||||
lblExit.TabIndex = 15;
|
||||
lblExit.Text = "安全退出";
|
||||
lblExit.Click += new EventHandler(this.lblExit_Click);
|
||||
lblExit.MouseEnter += new EventHandler(this.uiSymbolLabel1_MouseEnter);
|
||||
lblExit.MouseLeave += new EventHandler(this.uiSymbolLabel1_MouseLeave);
|
||||
|
||||
this.Style = UIStyle.Custom;
|
||||
this.StyleCustomMode = true;
|
||||
this.Size = new Size(134, 114);
|
||||
this.BackColor = Color.White;
|
||||
this.FillColor = Color.White;
|
||||
this.RectColor = Color.Silver;
|
||||
this.Controls.Add(lblExit);
|
||||
this.Controls.Add(lblAccountManage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 账户管理点击事件处理
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void lblAccountManage_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormHelper.ShowSubForm(new AccountForm());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标进入按钮后,改变颜色
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void uiSymbolLabel1_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
UISymbolLabel label = sender as UISymbolLabel;
|
||||
label.BackColor = Color.FromArgb(244, 244, 244);
|
||||
label.ForeColor = Color.FromArgb(181, 181, 181);
|
||||
label.SymbolColor = Color.FromArgb(181, 181, 181);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标离开按钮后,颜色改回来
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void uiSymbolLabel1_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
UISymbolLabel label = sender as UISymbolLabel;
|
||||
label.BackColor = Color.Transparent;
|
||||
label.ForeColor = Color.FromArgb(153, 153, 153);
|
||||
label.SymbolColor = Color.FromArgb(153, 153, 153);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 安全退出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void lblExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
//自己关闭,重新打开自己
|
||||
new Thread(() =>
|
||||
{
|
||||
string fileName = Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(fileName);
|
||||
new Process { StartInfo = processStartInfo }.Start();
|
||||
}).Start();
|
||||
Thread.Sleep(100);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
120
DH.RBAC/UserControls/Menus/UserMenuPanel.resx
Normal file
120
DH.RBAC/UserControls/Menus/UserMenuPanel.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
69
DH.RBAC/UserControls/ProgressForm.Designer.cs
generated
Normal file
69
DH.RBAC/UserControls/ProgressForm.Designer.cs
generated
Normal file
@ -0,0 +1,69 @@
|
||||
namespace DH.RBAC.UserControls
|
||||
{
|
||||
partial class ProgressForm
|
||||
{
|
||||
/// <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.uiProcessBar1 = new Sunny.UI.UIProcessBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// uiProcessBar1
|
||||
//
|
||||
this.uiProcessBar1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.uiProcessBar1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.uiProcessBar1.Location = new System.Drawing.Point(0, 0);
|
||||
this.uiProcessBar1.MinimumSize = new System.Drawing.Size(70, 3);
|
||||
this.uiProcessBar1.Name = "uiProcessBar1";
|
||||
this.uiProcessBar1.Size = new System.Drawing.Size(704, 41);
|
||||
this.uiProcessBar1.TabIndex = 0;
|
||||
this.uiProcessBar1.Text = "uiProcessBar1";
|
||||
//
|
||||
// ProgressForm
|
||||
//
|
||||
this.AllowShowTitle = false;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 27F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(704, 41);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.uiProcessBar1);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Movable = false;
|
||||
this.Name = "ProgressForm";
|
||||
this.Padding = new System.Windows.Forms.Padding(0);
|
||||
this.ShowTitle = false;
|
||||
this.Text = "下载进度";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Sunny.UI.UIProcessBar uiProcessBar1;
|
||||
}
|
||||
}
|
132
DH.RBAC/UserControls/ProgressForm.cs
Normal file
132
DH.RBAC/UserControls/ProgressForm.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using Sunny.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DH.RBAC.Utility.Other;
|
||||
namespace DH.RBAC.UserControls
|
||||
{
|
||||
public partial class ProgressForm : UIForm
|
||||
{
|
||||
public delegate void EndEventHandler(object sender);
|
||||
public event EndEventHandler EndHandler;
|
||||
|
||||
|
||||
public delegate void ErrorEventHandler(object sender, Exception ex);
|
||||
public event ErrorEventHandler ErrorHandler;
|
||||
public ProgressForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
CloseForm = new CloseFormDelegate(() =>
|
||||
{
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
|
||||
public void SetValue(int value)
|
||||
{
|
||||
uiProcessBar1.InvokeProgressValue(value);
|
||||
}
|
||||
|
||||
public delegate void CloseFormDelegate();
|
||||
public CloseFormDelegate CloseForm;
|
||||
|
||||
public string FileName { get; internal set; }
|
||||
|
||||
public void Download(string method, string url, Dictionary<string, string> parms)
|
||||
{
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
HttpWebRequest request = null;
|
||||
//如果是发送HTTPS请求
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.ProtocolVersion = HttpVersion.Version10;
|
||||
}
|
||||
else
|
||||
{
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
}
|
||||
|
||||
//request.CookieContainer = m_Cookie;
|
||||
request.Method = method;
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
|
||||
// 设置参数
|
||||
|
||||
//如果需要POST数据
|
||||
if (!(parms == null || parms.Count == 0))
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (string key in parms.Keys)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
buffer.AppendFormat("&{0}={1}", key, parms[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.AppendFormat("{0}={1}", key, parms[key]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(buffer.ToString());
|
||||
using (Stream stream1 = request.GetRequestStream())
|
||||
{
|
||||
stream1.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
//发送请求并获取相应回应数据
|
||||
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
||||
//直到request.GetResponse()程序才开始向目标网页发送Post请求
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
|
||||
long totalLenght = response.ContentLength;
|
||||
//StartHandler?.Invoke(this, totalLenght);
|
||||
|
||||
long current = 0;
|
||||
//创建写入流
|
||||
FileStream pFileStream = new FileStream(FileName, FileMode.OpenOrCreate);
|
||||
byte[] bArr = new byte[10240];
|
||||
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
||||
while (size > 0)
|
||||
{
|
||||
current += size;
|
||||
uiProcessBar1.InvokeProgressValue((int)((current * 1.0 / totalLenght) * 100));
|
||||
pFileStream.Write(bArr, 0, size);
|
||||
size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
||||
}
|
||||
responseStream.Close();
|
||||
pFileStream.Close();
|
||||
this.Invoke(CloseForm, null);
|
||||
EndHandler?.Invoke(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Invoke(CloseForm, null);
|
||||
ErrorHandler?.Invoke(this, ex);
|
||||
}
|
||||
});
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
}
|
120
DH.RBAC/UserControls/ProgressForm.resx
Normal file
120
DH.RBAC/UserControls/ProgressForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
Reference in New Issue
Block a user