init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Main.main2
|
||||
{
|
||||
public partial class TreeNodeCustom : UserControl
|
||||
{
|
||||
public TreeNodeCustom()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnDesktop_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//Button button = sender as Button;
|
||||
//if (button != null)
|
||||
//{
|
||||
// if (defaultButton != null)
|
||||
// defaultButton.BackgroundImage = Resources.left_default;
|
||||
// button.BackgroundImage = Resources.left_select;
|
||||
//}
|
||||
//this.Cursor = Cursors.Hand;
|
||||
|
||||
//if (defaultButton != button)
|
||||
//{
|
||||
// if (hoverEvent != null)
|
||||
// {
|
||||
// this.hoverEvent(defaultButton, button);
|
||||
// }
|
||||
// defaultButton = button;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Lskj.Main.main2
|
||||
{
|
||||
partial class TreeNodeCustom
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnTreeNode = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnTreeNode
|
||||
//
|
||||
this.btnTreeNode.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnTreeNode.BackgroundImage = global::Lskj.Main.Properties.Resources.node_default;
|
||||
this.btnTreeNode.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.btnTreeNode.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btnTreeNode.FlatAppearance.BorderSize = 0;
|
||||
this.btnTreeNode.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnTreeNode.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnTreeNode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnTreeNode.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnTreeNode.ForeColor = System.Drawing.Color.White;
|
||||
this.btnTreeNode.Location = new System.Drawing.Point(0, 0);
|
||||
this.btnTreeNode.Name = "btnTreeNode";
|
||||
this.btnTreeNode.Padding = new System.Windows.Forms.Padding(10, 0, 3, 3);
|
||||
this.btnTreeNode.Size = new System.Drawing.Size(130, 31);
|
||||
this.btnTreeNode.TabIndex = 9;
|
||||
this.btnTreeNode.Text = "我的桌面";
|
||||
this.btnTreeNode.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnTreeNode.UseVisualStyleBackColor = false;
|
||||
this.btnTreeNode.MouseMove += new System.Windows.Forms.MouseEventHandler(this.btnDesktop_MouseMove);
|
||||
//
|
||||
// TreeNodeCustom
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.btnTreeNode);
|
||||
this.Name = "TreeNodeCustom";
|
||||
this.Size = new System.Drawing.Size(130, 31);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public System.Windows.Forms.Button btnTreeNode;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,407 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Lskj.Main.Properties;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.Main.main2
|
||||
{
|
||||
/// <summary>
|
||||
/// description: 自定义树
|
||||
/// author: gyc
|
||||
/// date: 2017-03-16
|
||||
/// </summary>
|
||||
public partial class TreeViewCustom : UserControl
|
||||
{
|
||||
#region 公有属性
|
||||
/// <summary>
|
||||
/// 父节点字段
|
||||
/// </summary>
|
||||
public string ParentField;
|
||||
/// <summary>
|
||||
/// 显示节点文本字段
|
||||
/// </summary>
|
||||
public string TextField;
|
||||
/// <summary>
|
||||
/// 父节点关联子节点位数
|
||||
/// </summary>
|
||||
public int ParentKeyLength;
|
||||
|
||||
public delegate void ButtonClickEventHandler(Button after);
|
||||
#endregion
|
||||
|
||||
#region 私有属性
|
||||
/// <summary>
|
||||
/// 上次显示节点
|
||||
/// </summary>
|
||||
private string lastTreeNode;
|
||||
/// <summary>
|
||||
/// 上次显示按钮ID
|
||||
/// </summary>
|
||||
private string lastMenuId;
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
private DataTable dataSource;
|
||||
private ButtonClickEventHandler clickEvent;
|
||||
/// <summary>
|
||||
/// 缓存菜单,按照节点缓存
|
||||
/// </summary>
|
||||
private Dictionary<string, List<TreeNodeCustom>> dicTreeNodes = new Dictionary<string, List<TreeNodeCustom>>();
|
||||
/// <summary>
|
||||
/// 缓存所有按钮
|
||||
/// </summary>
|
||||
private Dictionary<string, Button> dicButtons = new Dictionary<string, Button>();
|
||||
#endregion
|
||||
|
||||
#region Api
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
|
||||
|
||||
private const int WM_SETREDRAW = 11;
|
||||
|
||||
/// <summary>
|
||||
/// 停止界面重绘
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public static void SuspendDrawing(Control parent)
|
||||
{
|
||||
SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始绘制
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public static void ResumeDrawing(Control parent)
|
||||
{
|
||||
SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
|
||||
parent.Refresh();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public TreeViewCustom()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == 0x0014) return;
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
/// <summary>
|
||||
/// 注册设置事件
|
||||
/// </summary>
|
||||
/// <param name="hoverEvent"></param>
|
||||
public void SetClickEvent(ButtonClickEventHandler clickEvent)
|
||||
{
|
||||
this.clickEvent = clickEvent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 检查是否包含父节点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<TreeNodeCustom> getParentNodes(string parent)
|
||||
{
|
||||
string parentKey = parent.Length == ParentKeyLength ? parent : parent.Substring(0, parent.Length - ParentKeyLength);
|
||||
List<TreeNodeCustom> treeNodeList = new List<TreeNodeCustom>();
|
||||
|
||||
if (dicTreeNodes == null)
|
||||
dicTreeNodes = new Dictionary<string, List<TreeNodeCustom>>();
|
||||
|
||||
if (dicTreeNodes.ContainsKey(parentKey))
|
||||
{
|
||||
treeNodeList = dicTreeNodes[parentKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
dicTreeNodes.Add(parentKey, treeNodeList);
|
||||
}
|
||||
return treeNodeList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载菜单
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void SetDataSource(DataTable dtTable)
|
||||
{
|
||||
int index = 1;
|
||||
this.dataSource = dtTable;
|
||||
if (dataSource == null || dataSource.Rows.Count == 0) return;
|
||||
|
||||
// 获取根节点
|
||||
DataRow[] rootRows = dataSource.Rows.Cast<DataRow>().Where(x => (x[ParentField] + "").Length == ParentKeyLength || (x[ParentField] + "").Length == ParentKeyLength * 2).ToArray();
|
||||
foreach (DataRow item in dataSource.Rows)
|
||||
{
|
||||
int length = (item[ParentField] + "").Length;
|
||||
TreeNodeCustom treeNode = new TreeNodeCustom();
|
||||
treeNode.Dock = DockStyle.Top;
|
||||
treeNode.Tag = item[ParentField] + "";
|
||||
treeNode.TabIndex = index;
|
||||
|
||||
if (length == ParentKeyLength)
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = Resources.node_default;
|
||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 12);
|
||||
}
|
||||
else if (length / ParentKeyLength == 2)
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = Resources.node2_default;
|
||||
treeNode.btnTreeNode.Padding = new Padding(20, 1, 3, 3);
|
||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 11);
|
||||
}
|
||||
else
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = Resources.node3_default;
|
||||
treeNode.btnTreeNode.Padding = new Padding(30, 1, 3, 3);
|
||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 10);
|
||||
}
|
||||
|
||||
treeNode.btnTreeNode.Name = index + "";
|
||||
treeNode.btnTreeNode.Text = item[TextField] + "";
|
||||
treeNode.btnTreeNode.Tag = item;
|
||||
treeNode.btnTreeNode.Click += new EventHandler(btnTreeNode_Click);
|
||||
treeNode.btnTreeNode.MouseMove += new MouseEventHandler(btnTreeNode_MouseMove);
|
||||
treeNode.btnTreeNode.MouseLeave += new EventHandler(btnTreeNode_MouseLeave);
|
||||
|
||||
plTreeView.Controls.Add(treeNode);
|
||||
dicButtons.Add(index + "", treeNode.btnTreeNode);
|
||||
|
||||
List<TreeNodeCustom> parentNodes = getParentNodes(item[ParentField] + "");
|
||||
parentNodes.Add(treeNode);
|
||||
// 隐藏需要放在添加后,否则出现顺序错乱
|
||||
treeNode.Visible = length == ParentKeyLength;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 树节点点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnTreeNode_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SuspendDrawing(plTreeView);
|
||||
TreeNodeCustom treeNode = (sender as Button).Parent as TreeNodeCustom;
|
||||
if (treeNode != null)
|
||||
{
|
||||
string nodeValue = treeNode.Tag + "";
|
||||
if (lastTreeNode == null)
|
||||
{
|
||||
lastTreeNode = nodeValue;
|
||||
}
|
||||
if (nodeValue.Length == ParentKeyLength)
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = dicTreeNodes[nodeValue][0].Visible ? Resources.node_default : Resources.node_select;
|
||||
}
|
||||
if (nodeValue.Length == ParentKeyLength * 2)
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = dicTreeNodes[nodeValue][0].Visible ? Resources.node2_default : Resources.node2_select;
|
||||
}
|
||||
// 末节点
|
||||
if (nodeValue.Length == ParentKeyLength * 3)
|
||||
{
|
||||
treeNode.btnTreeNode.BackgroundImage = Resources.node3_select;
|
||||
if (!string.IsNullOrEmpty(lastMenuId) && lastMenuId != treeNode.btnTreeNode.Name)
|
||||
{
|
||||
dicButtons[lastMenuId].BackgroundImage = Resources.node3_default;
|
||||
}
|
||||
lastMenuId = treeNode.btnTreeNode.Name;
|
||||
}
|
||||
|
||||
|
||||
List<TreeNodeCustom> treeNodes = new List<TreeNodeCustom>();
|
||||
// 展开当前点击节点
|
||||
if (dicTreeNodes.ContainsKey(nodeValue))
|
||||
{
|
||||
treeNodes = dicTreeNodes[nodeValue];
|
||||
foreach (TreeNodeCustom node in treeNodes)
|
||||
{
|
||||
string menuKey = node.Tag + "";
|
||||
if (menuKey.Length == ParentKeyLength) continue;
|
||||
node.Visible = !node.Visible;
|
||||
Application.DoEvents();// 处理当前消息队列中的所有windows消息
|
||||
}
|
||||
}
|
||||
// 点击根节点隐藏所有子节点
|
||||
if (nodeValue.Length == ParentKeyLength && !dicTreeNodes[nodeValue][0].Visible)
|
||||
{
|
||||
treeNodes = getChildNodes(nodeValue);
|
||||
foreach (TreeNodeCustom node in treeNodes)
|
||||
{
|
||||
node.Visible = false;
|
||||
//Application.DoEvents();// 处理当前消息队列中的所有windows消息
|
||||
}
|
||||
}
|
||||
// 点击末节点
|
||||
if (nodeValue.Length == ParentKeyLength * 3)
|
||||
{
|
||||
if (clickEvent != null)
|
||||
{
|
||||
this.clickEvent(treeNode.btnTreeNode);
|
||||
}
|
||||
}
|
||||
lastTreeNode = nodeValue;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
ResumeDrawing(plTreeView);
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标移动
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnTreeNode_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Button button = sender as Button;
|
||||
if (button != null)
|
||||
{
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
||||
string treeNodeTag = treeNode.Tag + "";
|
||||
if (treeNodeTag.Length == ParentKeyLength)
|
||||
{
|
||||
// 根节点
|
||||
//bool isOpen = false;
|
||||
//List<TreeNodeCustom> nodes = getChildNodes(treeNodeTag);
|
||||
//foreach (TreeNodeCustom item in nodes)
|
||||
//{
|
||||
// if (item.Visible)
|
||||
// {
|
||||
// isOpen = true;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
//if (!isOpen)
|
||||
//{
|
||||
// button.BackgroundImage = Resources.node_move;
|
||||
//}
|
||||
}
|
||||
else if (treeNodeTag.Length == ParentKeyLength * 2)
|
||||
{
|
||||
// 第一级节点
|
||||
if (dicTreeNodes.ContainsKey(treeNodeTag) && dicTreeNodes[treeNodeTag].Count > 0)
|
||||
{
|
||||
button.BackgroundImage = dicTreeNodes[treeNodeTag][0].Visible ? Resources.node2_select : Resources.node2_move;
|
||||
}
|
||||
else
|
||||
{
|
||||
button.BackgroundImage = Resources.node2_move;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 末节点
|
||||
if (button.Name != lastMenuId)
|
||||
{
|
||||
button.BackgroundImage = Resources.node3_move;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标离开
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnTreeNode_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Button button = sender as Button;
|
||||
if (button != null)
|
||||
{
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
||||
string treeNodeTag = treeNode.Tag + "";
|
||||
if (treeNodeTag.Length == ParentKeyLength)
|
||||
{
|
||||
// 根节点
|
||||
//bool isOpen = false;
|
||||
//List<TreeNodeCustom> nodes = getChildNodes(treeNodeTag);
|
||||
//foreach (TreeNodeCustom item in nodes)
|
||||
//{
|
||||
// if (item.Visible)
|
||||
// {
|
||||
// isOpen = true;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
//if (!isOpen)
|
||||
//{
|
||||
// button.BackgroundImage = Resources.node_move;
|
||||
//}
|
||||
}
|
||||
else if (treeNodeTag.Length == ParentKeyLength * 2)
|
||||
{
|
||||
// 第一级节点
|
||||
if (dicTreeNodes.ContainsKey(treeNodeTag) && dicTreeNodes[treeNodeTag].Count > 0)
|
||||
{
|
||||
button.BackgroundImage = dicTreeNodes[treeNodeTag][0].Visible ? Resources.node2_select : Resources.node2_default;
|
||||
}
|
||||
else
|
||||
{
|
||||
button.BackgroundImage = Resources.node2_default;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 末节点
|
||||
if (button.Name != lastMenuId)
|
||||
{
|
||||
button.BackgroundImage = Resources.node3_default;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取子节点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<TreeNodeCustom> getChildNodes(string nodeValue)
|
||||
{
|
||||
List<TreeNodeCustom> treeNodes = new List<TreeNodeCustom>();
|
||||
|
||||
// 获取第3个节点之后的节点
|
||||
DataRow[] rowChilds = dataSource.Rows.Cast<DataRow>().Where(x => (x[ParentField] + "").Length == nodeValue.Length * 2 && (x[ParentField] + "").Substring(0, nodeValue.Length) == nodeValue).ToArray();
|
||||
|
||||
foreach (DataRow item in rowChilds)
|
||||
{
|
||||
if (dicTreeNodes.ContainsKey(item[ParentField] + ""))
|
||||
{
|
||||
List<TreeNodeCustom> nodeChilds = dicTreeNodes[item[ParentField] + ""];
|
||||
foreach (TreeNodeCustom node in nodeChilds)
|
||||
{
|
||||
treeNodes.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return treeNodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
namespace Lskj.Main.main2
|
||||
{
|
||||
partial class TreeViewCustom
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.plTreeView = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// plTreeView
|
||||
//
|
||||
this.plTreeView.AutoScroll = true;
|
||||
this.plTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(87)))), ((int)(((byte)(167)))));
|
||||
this.plTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.plTreeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.plTreeView.Name = "plTreeView";
|
||||
this.plTreeView.Size = new System.Drawing.Size(140, 452);
|
||||
this.plTreeView.TabIndex = 0;
|
||||
//
|
||||
// TreeViewCustom
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.plTreeView);
|
||||
this.Name = "TreeViewCustom";
|
||||
this.Size = new System.Drawing.Size(140, 452);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel plTreeView;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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