Compare commits
4 Commits
aacefa24f8
...
43ae774164
| Author | SHA1 | Date | |
|---|---|---|---|
| 43ae774164 | |||
| 326fccf8fe | |||
| 5042f2c8c2 | |||
| 57ff1ea406 |
@@ -328,6 +328,7 @@ namespace Lskj.Business
|
|||||||
Instance.EnableSpecialInfoProcess = item.Table.Columns.Contains("EnableSpecialInfoProcess") && !string.IsNullOrEmpty(item["EnableSpecialInfoProcess"] + "") ? "1".Equals(item["EnableSpecialInfoProcess"] + "") : false;
|
Instance.EnableSpecialInfoProcess = item.Table.Columns.Contains("EnableSpecialInfoProcess") && !string.IsNullOrEmpty(item["EnableSpecialInfoProcess"] + "") ? "1".Equals(item["EnableSpecialInfoProcess"] + "") : false;
|
||||||
Instance.SourceFilteringMobile = item.Table.Columns.Contains("SourceFilteringMobile") && !string.IsNullOrEmpty(item["SourceFilteringMobile"] + "") ? "1".Equals(item["SourceFilteringMobile"] + "") : false;
|
Instance.SourceFilteringMobile = item.Table.Columns.Contains("SourceFilteringMobile") && !string.IsNullOrEmpty(item["SourceFilteringMobile"] + "") ? "1".Equals(item["SourceFilteringMobile"] + "") : false;
|
||||||
Instance.LoginUsername = item.Table.Columns.Contains("LoginUsername") && !string.IsNullOrEmpty(item["LoginUsername"] + "") ? item["LoginUsername"] + "" : "";
|
Instance.LoginUsername = item.Table.Columns.Contains("LoginUsername") && !string.IsNullOrEmpty(item["LoginUsername"] + "") ? item["LoginUsername"] + "" : "";
|
||||||
|
Instance.MainLeftShowMode = item.Table.Columns.Contains("MainLeftShowMode") && !string.IsNullOrEmpty(item["MainLeftShowMode"] + "") ? item["MainLeftShowMode"] + "" : "";
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 高拍仪AccessKey
|
/// 高拍仪AccessKey
|
||||||
@@ -1144,6 +1145,10 @@ namespace Lskj.Business
|
|||||||
///登录界面,用户名显示字段
|
///登录界面,用户名显示字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LoginUsername;
|
public string LoginUsername;
|
||||||
|
/// <summary>
|
||||||
|
/// 主界面左侧树展示模式
|
||||||
|
/// </summary>
|
||||||
|
public string MainLeftShowMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ namespace Lskj.Main.Control
|
|||||||
/// 缓存分组控件
|
/// 缓存分组控件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<string, Panel> _groupItems = new Dictionary<string, Panel>();
|
private Dictionary<string, Panel> _groupItems = new Dictionary<string, Panel>();
|
||||||
|
private TreeView _leftGroupTreeView;
|
||||||
|
private ImageList _leftGroupTreeIcons;
|
||||||
|
private Panel _leftGroupSeparator;
|
||||||
|
private const string LeftGroupTreeNodeTypeMenu = "menu";
|
||||||
|
private const string LeftGroupTreeNodeTypeGroup = "group";
|
||||||
|
private const int GroupControlTopPadding = 8;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存右上菜单控件
|
/// 缓存右上菜单控件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -301,7 +307,7 @@ namespace Lskj.Main.Control
|
|||||||
if (HiddenAccountSet && (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4))
|
if (HiddenAccountSet && (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4))
|
||||||
{
|
{
|
||||||
pl_top_right.Width = pl_top_right.Width - this.label1.Left - this.label1.Width;
|
pl_top_right.Width = pl_top_right.Width - this.label1.Left - this.label1.Width;
|
||||||
this.lblMenuTitle.Location= new Point(this.button3.Left , this.lblMenuTitle.Top);
|
this.lblMenuTitle.Location = new Point(this.button3.Left, this.lblMenuTitle.Top);
|
||||||
}
|
}
|
||||||
if (SystemInfo.Instance.HideSkin)
|
if (SystemInfo.Instance.HideSkin)
|
||||||
{
|
{
|
||||||
@@ -332,7 +338,10 @@ namespace Lskj.Main.Control
|
|||||||
{
|
{
|
||||||
this.SetMenus();
|
this.SetMenus();
|
||||||
this.SetSearchMenus();
|
this.SetSearchMenus();
|
||||||
this.tv_left.Visible = false;
|
if (!CanUseLeftGroupTreeMenu())
|
||||||
|
{
|
||||||
|
this.tv_left.Visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4)
|
if (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4)
|
||||||
{
|
{
|
||||||
@@ -671,6 +680,385 @@ namespace Lskj.Main.Control
|
|||||||
|
|
||||||
return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
|
return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DataTable CreateLeftGroupTreeTable()
|
||||||
|
{
|
||||||
|
DataTable table = new DataTable();
|
||||||
|
table.Columns.Add("nodekey");
|
||||||
|
table.Columns.Add("parentkey");
|
||||||
|
table.Columns.Add("nodetext");
|
||||||
|
table.Columns.Add("nodetype");
|
||||||
|
table.Columns.Add("menustruct");
|
||||||
|
table.Columns.Add("groupkey");
|
||||||
|
table.Columns.Add("sortno", typeof(int));
|
||||||
|
table.Columns.Add("iconindex", typeof(int));
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddLeftGroupTreeNode(DataTable table, string nodeKey, string nodeText, string nodeType, string menuStruct, string groupKey)
|
||||||
|
{
|
||||||
|
if (table == null || string.IsNullOrWhiteSpace(nodeKey)) return;
|
||||||
|
if (table.Rows.Cast<DataRow>().Any(n => (n["nodekey"] + "").Equals(nodeKey))) return;
|
||||||
|
|
||||||
|
DataRow row = table.NewRow();
|
||||||
|
row["nodekey"] = nodeKey;
|
||||||
|
row["parentkey"] = nodeType.Equals(LeftGroupTreeNodeTypeGroup) ? menuStruct : string.Empty;
|
||||||
|
row["nodetext"] = nodeText;
|
||||||
|
row["nodetype"] = nodeType;
|
||||||
|
row["menustruct"] = menuStruct;
|
||||||
|
row["groupkey"] = groupKey;
|
||||||
|
row["sortno"] = table.Rows.Count + 1;
|
||||||
|
row["iconindex"] = table.Rows.Count;
|
||||||
|
table.Rows.Add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetGroupTreeKey(string menuStruct, int groupIndex)
|
||||||
|
{
|
||||||
|
return string.Format("{0}|{1:00}", menuStruct, groupIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetLeftGroupTreeDefaultNode(DataTable treeTable, string defaultParentMenu)
|
||||||
|
{
|
||||||
|
if (treeTable == null || treeTable.Rows.Count == 0) return string.Empty;
|
||||||
|
|
||||||
|
DataRow defaultParentRow = treeTable.Rows.Cast<DataRow>()
|
||||||
|
.FirstOrDefault(n => (n["nodetype"] + "").Equals(LeftGroupTreeNodeTypeMenu) && (n["menustruct"] + "").Equals(defaultParentMenu));
|
||||||
|
if (defaultParentRow != null)
|
||||||
|
{
|
||||||
|
return defaultParentRow["nodekey"] + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
DataRow firstParentRow = treeTable.Rows.Cast<DataRow>()
|
||||||
|
.FirstOrDefault(n => (n["nodetype"] + "").Equals(LeftGroupTreeNodeTypeMenu));
|
||||||
|
if (firstParentRow != null) return firstParentRow["nodekey"] + "";
|
||||||
|
|
||||||
|
return treeTable.Rows[0]["nodekey"] + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetGroupCaptionText(string groupCaption)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(groupCaption)) return string.Empty;
|
||||||
|
return groupCaption.Length > 2 ? groupCaption.Remove(0, 2) : groupCaption;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TreeView GetLeftGroupTreeView()
|
||||||
|
{
|
||||||
|
if (_leftGroupTreeView != null) return _leftGroupTreeView;
|
||||||
|
|
||||||
|
_leftGroupTreeView = new TreeView
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Fill,
|
||||||
|
BorderStyle = BorderStyle.None,
|
||||||
|
BackColor = Color.FromArgb(250, 253, 255),
|
||||||
|
DrawMode = TreeViewDrawMode.Normal,
|
||||||
|
Font = new Font("微软雅黑", 10F),
|
||||||
|
ForeColor = Color.FromArgb(38, 73, 98),
|
||||||
|
HideSelection = false,
|
||||||
|
Indent = 20,
|
||||||
|
ImageList = GetLeftGroupTreeIcons(),
|
||||||
|
ItemHeight = 29,
|
||||||
|
LineColor = Color.FromArgb(198, 214, 226),
|
||||||
|
ShowLines = false,
|
||||||
|
ShowPlusMinus = false,
|
||||||
|
ShowRootLines = false
|
||||||
|
};
|
||||||
|
_leftGroupTreeView.NodeMouseClick += OnLeftGroupTreeViewNodeMouseClick;
|
||||||
|
|
||||||
|
return _leftGroupTreeView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Panel GetLeftGroupSeparator()
|
||||||
|
{
|
||||||
|
if (_leftGroupSeparator != null) return _leftGroupSeparator;
|
||||||
|
|
||||||
|
_leftGroupSeparator = new Panel
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Left,
|
||||||
|
Width = 2,
|
||||||
|
BackColor = Color.FromArgb(198, 214, 226),
|
||||||
|
Margin = Padding.Empty
|
||||||
|
};
|
||||||
|
return _leftGroupSeparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetLeftGroupSeparatorVisible(bool visible)
|
||||||
|
{
|
||||||
|
Panel separator = GetLeftGroupSeparator();
|
||||||
|
this.FirstMain.SuspendLayout();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.FirstMain.Controls.Contains(separator))
|
||||||
|
{
|
||||||
|
this.FirstMain.Controls.Add(separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.FirstMain.Controls.SetChildIndex(this.pl_center_main, 0);
|
||||||
|
this.FirstMain.Controls.SetChildIndex(separator, 1);
|
||||||
|
this.FirstMain.Controls.SetChildIndex(this.pl_center_left, 2);
|
||||||
|
separator.Visible = visible;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this.FirstMain.ResumeLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanUseLeftGroupTreeMenu()
|
||||||
|
{
|
||||||
|
return "1".Equals((SystemInfo.Instance.MainLeftShowMode + "").Trim()) && this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetLeftMenuBarPanel()
|
||||||
|
{
|
||||||
|
SetLeftGroupSeparatorVisible(false);
|
||||||
|
this.pl_center_left.Padding = new Padding(4);
|
||||||
|
this.pl_center_left.BackColor = Color.FromArgb(10, 87, 167);
|
||||||
|
if (_leftGroupTreeView != null && this.pl_center_left.Controls.Contains(_leftGroupTreeView))
|
||||||
|
{
|
||||||
|
this.pl_center_left.Controls.Remove(_leftGroupTreeView);
|
||||||
|
}
|
||||||
|
if (this.pl_center_left.Controls.Contains(this.tv_left))
|
||||||
|
{
|
||||||
|
this.tv_left.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImageList GetLeftGroupTreeIcons()
|
||||||
|
{
|
||||||
|
if (_leftGroupTreeIcons != null) return _leftGroupTreeIcons;
|
||||||
|
|
||||||
|
_leftGroupTreeIcons = new ImageList();
|
||||||
|
_leftGroupTreeIcons.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
|
_leftGroupTreeIcons.ImageSize = new Size(18, 18);
|
||||||
|
|
||||||
|
string iconPath = PubUtil.MainTreeviewImagePath;
|
||||||
|
if (Directory.Exists(iconPath))
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(iconPath, "*.png").OrderBy(n => n).ToArray();
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
using (Image image = ImageHelper.ReadImage(file))
|
||||||
|
{
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
_leftGroupTreeIcons.Images.Add(new Bitmap(image));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_leftGroupTreeIcons.Images.Count == 0)
|
||||||
|
{
|
||||||
|
_leftGroupTreeIcons.Images.Add(new Bitmap(18, 18));
|
||||||
|
}
|
||||||
|
return _leftGroupTreeIcons;
|
||||||
|
}
|
||||||
|
private void BindLeftGroupTreeView(DataTable treeTable, string defaultNode)
|
||||||
|
{
|
||||||
|
TreeView treeView = GetLeftGroupTreeView();
|
||||||
|
treeView.BeginUpdate();
|
||||||
|
treeView.Nodes.Clear();
|
||||||
|
|
||||||
|
Dictionary<string, TreeNode> nodeMap = new Dictionary<string, TreeNode>();
|
||||||
|
List<DataRow> rows = treeTable.Rows.Cast<DataRow>()
|
||||||
|
.OrderBy(n => Convert.ToInt32(n["sortno"]))
|
||||||
|
.ToList();
|
||||||
|
int iconCount = GetLeftGroupTreeIcons().Images.Count;
|
||||||
|
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
TreeNode node = new TreeNode(row["nodetext"] + "");
|
||||||
|
int iconIndex = 0;
|
||||||
|
int.TryParse(row["iconindex"] + "", out iconIndex);
|
||||||
|
iconIndex = Math.Abs(iconIndex) % iconCount;
|
||||||
|
node.ImageIndex = iconIndex;
|
||||||
|
node.SelectedImageIndex = iconIndex;
|
||||||
|
node.Name = row["nodekey"] + "";
|
||||||
|
node.Tag = row;
|
||||||
|
nodeMap[node.Name] = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
string nodeKey = row["nodekey"] + "";
|
||||||
|
string parentKey = row["parentkey"] + "";
|
||||||
|
TreeNode node = nodeMap[nodeKey];
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(parentKey) && nodeMap.ContainsKey(parentKey))
|
||||||
|
{
|
||||||
|
nodeMap[parentKey].Nodes.Add(node);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
treeView.Nodes.Add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
treeView.CollapseAll();
|
||||||
|
FocusLeftGroupTreeNode(defaultNode);
|
||||||
|
treeView.EndUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FocusLeftGroupTreeNode(string nodeKey)
|
||||||
|
{
|
||||||
|
if (_leftGroupTreeView == null || string.IsNullOrEmpty(nodeKey)) return;
|
||||||
|
|
||||||
|
TreeNode node = FindLeftGroupTreeNode(_leftGroupTreeView.Nodes, nodeKey);
|
||||||
|
if (node == null) return;
|
||||||
|
|
||||||
|
_leftGroupTreeView.SelectedNode = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TreeNode FindLeftGroupTreeNode(TreeNodeCollection nodes, string nodeKey)
|
||||||
|
{
|
||||||
|
foreach (TreeNode node in nodes)
|
||||||
|
{
|
||||||
|
if (node.Name.Equals(nodeKey)) return node;
|
||||||
|
|
||||||
|
TreeNode childNode = FindLeftGroupTreeNode(node.Nodes, nodeKey);
|
||||||
|
if (childNode != null) return childNode;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLeftGroupTreeViewNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TreeView treeView = sender as TreeView;
|
||||||
|
if (treeView == null || e.Node == null || e.Button != MouseButtons.Left) return;
|
||||||
|
|
||||||
|
treeView.SelectedNode = e.Node;
|
||||||
|
if (e.Node.Nodes.Count > 0)
|
||||||
|
{
|
||||||
|
e.Node.Toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
OnLeftGroupTreeRowClick(e.Node.Tag as DataRow);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||||
|
MessageUtil.Show(Message, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BindLeftGroupTreeMenu(DataTable treeTable, string defaultParentMenu)
|
||||||
|
{
|
||||||
|
if (treeTable == null || treeTable.Rows.Count == 0) return;
|
||||||
|
|
||||||
|
string expandNode = GetLeftGroupTreeDefaultNode(treeTable, defaultParentMenu);
|
||||||
|
this.pl_center_left.Controls.Clear();
|
||||||
|
this.pl_center_left.Padding = Padding.Empty;
|
||||||
|
this.pl_center_left.BackColor = Color.FromArgb(250, 253, 255);
|
||||||
|
this.pl_center_main.Padding = Padding.Empty;
|
||||||
|
this.pl_center_main.BackColor = Color.FromArgb(240, 240, 240);
|
||||||
|
SetLeftGroupSeparatorVisible(true);
|
||||||
|
TreeView treeView = GetLeftGroupTreeView();
|
||||||
|
this.pl_center_left.Controls.Add(treeView);
|
||||||
|
BindLeftGroupTreeView(treeTable, expandNode);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(expandNode))
|
||||||
|
{
|
||||||
|
DataRow expandRow = treeTable.Rows.Cast<DataRow>().FirstOrDefault(n => (n["nodekey"] + "").Equals(expandNode));
|
||||||
|
if (expandRow != null)
|
||||||
|
{
|
||||||
|
OnLeftGroupTreeRowClick(expandRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowGroupMenuPanel(string menuStruct, string groupKey)
|
||||||
|
{
|
||||||
|
if (!_groupItems.ContainsKey(menuStruct)) return;
|
||||||
|
|
||||||
|
Panel groupPanel = _groupItems[menuStruct];
|
||||||
|
groupPanel.SuspendLayout();
|
||||||
|
foreach (System.Windows.Forms.Control control in groupPanel.Controls)
|
||||||
|
{
|
||||||
|
GroupControl groupControl = control as GroupControl;
|
||||||
|
if (groupControl == null) continue;
|
||||||
|
groupControl.Visible = string.IsNullOrEmpty(groupKey) || (groupControl.Name + "").Equals(groupKey);
|
||||||
|
}
|
||||||
|
NormalizeGroupPanelSpacing(groupPanel);
|
||||||
|
groupPanel.ResumeLayout(true);
|
||||||
|
groupPanel.AutoScrollPosition = Point.Empty;
|
||||||
|
|
||||||
|
this.allMenuPanel.Controls.Clear();
|
||||||
|
this.allMenuPanel.Controls.Add(groupPanel);
|
||||||
|
groupPanel.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NormalizeGroupPanelSpacing(Panel groupPanel)
|
||||||
|
{
|
||||||
|
if (groupPanel == null) return;
|
||||||
|
|
||||||
|
List<GroupControl> groupControls = groupPanel.Controls.OfType<GroupControl>().ToList();
|
||||||
|
int topPadding = groupControls.Count > 1 ? GroupControlTopPadding : 0;
|
||||||
|
foreach (GroupControl groupControl in groupControls)
|
||||||
|
{
|
||||||
|
groupControl.Padding = new Padding(0, topPadding, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowShortcutPanels(string menuStruct)
|
||||||
|
{
|
||||||
|
if (!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu) || SystemInfo.Instance.HideGallerys)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pl_center_main_bottom_right_main.Controls.Clear();
|
||||||
|
this.pl_center_main_bottom_left_main.Controls.Clear();
|
||||||
|
if (this.topLayoutPanelDic.ContainsKey(menuStruct))
|
||||||
|
{
|
||||||
|
TableLayoutPanel tableLayoutPanel = this.topLayoutPanelDic[menuStruct];
|
||||||
|
this.pl_center_main_bottom_right_main.Controls.Add(tableLayoutPanel);
|
||||||
|
string labelCaption = tableLayoutPanel.Tag + "";
|
||||||
|
this.lblShortcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblShortcutset.Tag + "";
|
||||||
|
}
|
||||||
|
if (this.botLayoutPanelDic.ContainsKey(menuStruct))
|
||||||
|
{
|
||||||
|
TableLayoutPanel tableLayoutPanel = this.botLayoutPanelDic[menuStruct];
|
||||||
|
this.pl_center_main_bottom_left_main.Controls.Add(tableLayoutPanel);
|
||||||
|
string labelCaption = tableLayoutPanel.Tag + "";
|
||||||
|
this.lblReportcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblReportcutset.Tag + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLeftGroupTreeMenuClick(Button button)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DataRow row = button == null ? null : button.Tag as DataRow;
|
||||||
|
if (row == null) return;
|
||||||
|
|
||||||
|
OnLeftGroupTreeRowClick(row);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||||
|
MessageUtil.Show(Message, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLeftGroupTreeRowClick(DataRow row)
|
||||||
|
{
|
||||||
|
if (row == null) return;
|
||||||
|
|
||||||
|
string menuStruct = row["menustruct"] + "";
|
||||||
|
string nodeType = row["nodetype"] + "";
|
||||||
|
string groupKey = nodeType.Equals(LeftGroupTreeNodeTypeGroup) ? row["groupkey"] + "" : string.Empty;
|
||||||
|
ShowGroupMenuPanel(menuStruct, groupKey);
|
||||||
|
ShowShortcutPanels(menuStruct);
|
||||||
|
|
||||||
|
if (SystemInfo.Instance.DesktopFormat && this.tabMain.SelectedTabPage == this.xtpDesktop)
|
||||||
|
{
|
||||||
|
this.webBrowser.Hide();
|
||||||
|
this.webBrowser.SendToBack();
|
||||||
|
this.tabMain.SelectedTabPage = this.xtpFirst;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:设置左侧菜单</para>
|
/// <para>说明:设置左侧菜单</para>
|
||||||
/// <para>创建人:龚宇超</para>
|
/// <para>创建人:龚宇超</para>
|
||||||
@@ -683,6 +1071,7 @@ namespace Lskj.Main.Control
|
|||||||
private void SetMenus()
|
private void SetMenus()
|
||||||
{
|
{
|
||||||
this._menus.Clear();
|
this._menus.Clear();
|
||||||
|
this._firstMenuBar = null;
|
||||||
var groupMenus = this._allMenus.AsEnumerable().Where(n => n.Table.Columns.Contains("groupcaption") && !string.IsNullOrEmpty(n["groupcaption"] + ""));
|
var groupMenus = this._allMenus.AsEnumerable().Where(n => n.Table.Columns.Contains("groupcaption") && !string.IsNullOrEmpty(n["groupcaption"] + ""));
|
||||||
if (groupMenus.Count() == 0 && this._allMenus.Columns.Contains("groupcaption"))
|
if (groupMenus.Count() == 0 && this._allMenus.Columns.Contains("groupcaption"))
|
||||||
{
|
{
|
||||||
@@ -714,6 +1103,12 @@ namespace Lskj.Main.Control
|
|||||||
List<DataRow> rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToList();
|
List<DataRow> rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToList();
|
||||||
if (rows != null && rows.Count > 0)
|
if (rows != null && rows.Count > 0)
|
||||||
{
|
{
|
||||||
|
bool useLeftGroupTreeMenu = CanUseLeftGroupTreeMenu();
|
||||||
|
if (!useLeftGroupTreeMenu)
|
||||||
|
{
|
||||||
|
ResetLeftMenuBarPanel();
|
||||||
|
}
|
||||||
|
DataTable leftGroupTreeTable = useLeftGroupTreeMenu ? CreateLeftGroupTreeTable() : null;
|
||||||
int buttonTop = Convert.ToInt32(0.05 * DpiY); // 按钮上边距
|
int buttonTop = Convert.ToInt32(0.05 * DpiY); // 按钮上边距
|
||||||
int menuLeft = Convert.ToInt32(0.05 * DpiY), menuTop = Convert.ToInt32(0.05 * DpiY); // 模块距离左边距,模块距离顶部边距
|
int menuLeft = Convert.ToInt32(0.05 * DpiY), menuTop = Convert.ToInt32(0.05 * DpiY); // 模块距离左边距,模块距离顶部边距
|
||||||
int menuWidthOld = Convert.ToInt32(1.14 * DpiX), menuHeightOld = Convert.ToInt32(1.32 * DpiY); // 旧模块宽度,模块高度
|
int menuWidthOld = Convert.ToInt32(1.14 * DpiX), menuHeightOld = Convert.ToInt32(1.32 * DpiY); // 旧模块宽度,模块高度
|
||||||
@@ -923,7 +1318,6 @@ namespace Lskj.Main.Control
|
|||||||
// 加载左侧菜单
|
// 加载左侧菜单
|
||||||
if (menuStruct.Length == 2)
|
if (menuStruct.Length == 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
DataTable childs = rows.Cast<DataRow>().Where(x => (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
|
DataTable childs = rows.Cast<DataRow>().Where(x => (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
|
||||||
if (childs != null && childs.Rows.Count > 1)
|
if (childs != null && childs.Rows.Count > 1)
|
||||||
{
|
{
|
||||||
@@ -931,33 +1325,40 @@ namespace Lskj.Main.Control
|
|||||||
defaultParentMenu = menuStruct;
|
defaultParentMenu = menuStruct;
|
||||||
// menuLeft = 5; menuTop = 5;
|
// menuLeft = 5; menuTop = 5;
|
||||||
menuLeft = Convert.ToInt32(0.05 * DpiX); menuTop = Convert.ToInt32(0.05 * DpiY);
|
menuLeft = Convert.ToInt32(0.05 * DpiX); menuTop = Convert.ToInt32(0.05 * DpiY);
|
||||||
MenuBar button = new MenuBar();
|
if (useLeftGroupTreeMenu)
|
||||||
button.Size = new Size(Convert.ToInt32(1.52 * DpiX), Convert.ToInt32(0.46 * DpiX));
|
{
|
||||||
button.Location = new Point(2, buttonTop);
|
AddLeftGroupTreeNode(leftGroupTreeTable, menuStruct, item["menucaption"] + "", LeftGroupTreeNodeTypeMenu, menuStruct, string.Empty);
|
||||||
button.BackColor = System.Drawing.Color.Transparent;
|
}
|
||||||
button.GetButton().Text = item["menucaption"] + "";
|
else
|
||||||
button.GetButton().Tag = item;
|
{
|
||||||
|
MenuBar button = new MenuBar();
|
||||||
|
button.Size = new Size(Convert.ToInt32(1.52 * DpiX), Convert.ToInt32(0.46 * DpiX));
|
||||||
|
button.Location = new Point(2, buttonTop);
|
||||||
|
button.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
button.GetButton().Text = item["menucaption"] + "";
|
||||||
|
button.GetButton().Tag = item;
|
||||||
|
|
||||||
if (SystemInfo.Instance.MenuBarWidth > 0)
|
if (SystemInfo.Instance.MenuBarWidth > 0)
|
||||||
{
|
{
|
||||||
button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
|
button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
|
||||||
button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
|
button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_firstMenuBar == null)
|
if (_firstMenuBar == null)
|
||||||
{
|
{
|
||||||
_firstMenuBar = button;
|
_firstMenuBar = button;
|
||||||
|
}
|
||||||
|
// 注册事件
|
||||||
|
button.SetHoverEvent(hoverEvent, (MenuEventType)SystemInfo.Instance.MemuEventType);
|
||||||
|
// 44
|
||||||
|
buttonTop += Convert.ToInt32(0.45 * DpiY);
|
||||||
|
if (menuStruct == defaultParentMenu)
|
||||||
|
{
|
||||||
|
button.SetDefaultSelectMenu(button);
|
||||||
|
button.SetButtonState(MenuButtonState.selectState);
|
||||||
|
}
|
||||||
|
pl_center_left.Controls.Add(button);
|
||||||
}
|
}
|
||||||
// 注册事件
|
|
||||||
button.SetHoverEvent(hoverEvent, (MenuEventType)SystemInfo.Instance.MemuEventType);
|
|
||||||
// 44
|
|
||||||
buttonTop += Convert.ToInt32(0.45 * DpiY);
|
|
||||||
if (menuStruct == defaultParentMenu)
|
|
||||||
{
|
|
||||||
button.SetDefaultSelectMenu(button);
|
|
||||||
button.SetButtonState(MenuButtonState.selectState);
|
|
||||||
}
|
|
||||||
pl_center_left.Controls.Add(button);
|
|
||||||
|
|
||||||
|
|
||||||
// 缓存控件
|
// 缓存控件
|
||||||
@@ -1091,23 +1492,34 @@ namespace Lskj.Main.Control
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
IEnumerable<IGrouping<int, DataRow>> groupByDataRows = groupDataRows.GroupBy(n => Convert.ToInt32((n["groupcaption"] + "").Substring(0, 2))).OrderByDescending(n => n.Key);
|
IEnumerable<IGrouping<int, DataRow>> groupByDataRows = groupDataRows.GroupBy(n => Convert.ToInt32((n["groupcaption"] + "").Substring(0, 2))).OrderByDescending(n => n.Key);
|
||||||
|
int groupByDataRowCount = groupByDataRows.Count();
|
||||||
Panel groupPanel = new Panel();
|
Panel groupPanel = new Panel();
|
||||||
groupPanel.AutoScroll = true;
|
groupPanel.AutoScroll = true;
|
||||||
groupPanel.Dock = DockStyle.Fill;
|
groupPanel.Dock = DockStyle.Fill;
|
||||||
int groupControlIndex = 0;
|
int groupControlIndex = 0;
|
||||||
foreach (IGrouping<int, DataRow> groupByDataRow in groupByDataRows)
|
foreach (IGrouping<int, DataRow> groupByDataRow in groupByDataRows)
|
||||||
{
|
{
|
||||||
|
string groupTreeKey = GetGroupTreeKey(menuStruct, groupByDataRow.Key);
|
||||||
|
string groupTreeCaption = GetGroupCaptionText(groupByDataRow.First()["groupcaption"] + "");
|
||||||
|
if (string.IsNullOrWhiteSpace(groupTreeCaption) || (groupByDataRowCount == 1 && groupTreeCaption.Equals("默认分组")))
|
||||||
|
{
|
||||||
|
groupTreeCaption = item["menucaption"] + "";
|
||||||
|
}
|
||||||
|
if (useLeftGroupTreeMenu && groupByDataRowCount > 1)
|
||||||
|
{
|
||||||
|
string leftGroupTreeGroupKey = menuStruct + groupByDataRow.Key.ToString("00");
|
||||||
|
AddLeftGroupTreeNode(leftGroupTreeTable, leftGroupTreeGroupKey, groupTreeCaption, LeftGroupTreeNodeTypeGroup, menuStruct, groupTreeKey);
|
||||||
|
}
|
||||||
int nowRowCount = 1;//当前行数
|
int nowRowCount = 1;//当前行数
|
||||||
int minMenuRow = this._allMenus.Columns.Contains("menuRow") ? groupByDataRow.Min(n => Convert.ToInt32(n["menuRow"])) : 1;
|
int minMenuRow = this._allMenus.Columns.Contains("menuRow") ? groupByDataRow.Min(n => Convert.ToInt32(n["menuRow"])) : 1;
|
||||||
int menuGroupLeft = Convert.ToInt32(0.05 * DpiY);
|
int menuGroupLeft = Convert.ToInt32(0.05 * DpiY);
|
||||||
int menuGroupTop = 0; // 模块距离左边距,模块距离顶部边距
|
int menuGroupTop = 0; // 模块距离左边距,模块距离顶部边距
|
||||||
GroupControl groupControl = new GroupControl();
|
GroupControl groupControl = new GroupControl();
|
||||||
|
groupControl.Name = groupTreeKey;
|
||||||
|
groupControl.Tag = groupTreeCaption;
|
||||||
groupControl.TipsLabel.ForeColor = Color.DimGray;
|
groupControl.TipsLabel.ForeColor = Color.DimGray;
|
||||||
groupControl.Dock = DockStyle.Top;
|
groupControl.Dock = DockStyle.Top;
|
||||||
if (groupControlIndex == groupByDataRows.Count() - 1 && !isShowGrallyInTop)
|
groupControl.Padding = new Padding(0, GroupControlTopPadding, 0, 0);
|
||||||
{
|
|
||||||
groupControl.Padding = new Padding(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
groupPanel.Controls.Add(groupControl);
|
groupPanel.Controls.Add(groupControl);
|
||||||
List<DataRow> groupOrderDataRow = groupByDataRow.ToList();
|
List<DataRow> groupOrderDataRow = groupByDataRow.ToList();
|
||||||
if (this._allMenus.Columns.Contains("menuRow"))
|
if (this._allMenus.Columns.Contains("menuRow"))
|
||||||
@@ -1231,12 +1643,13 @@ namespace Lskj.Main.Control
|
|||||||
}
|
}
|
||||||
groupControlIndex += 1;
|
groupControlIndex += 1;
|
||||||
groupControl.TipsText = $"{groupControl.TipsText}({count})";
|
groupControl.TipsText = $"{groupControl.TipsText}({count})";
|
||||||
groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + 16);
|
groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + GroupControlTopPadding);
|
||||||
}
|
}
|
||||||
if (groupPanel.Controls.Count == 1)
|
if (groupPanel.Controls.Count == 1)
|
||||||
{
|
{
|
||||||
(groupPanel.Controls[0] as GroupControl).TipsVisable = false;
|
(groupPanel.Controls[0] as GroupControl).TipsVisable = false;
|
||||||
}
|
}
|
||||||
|
NormalizeGroupPanelSpacing(groupPanel);
|
||||||
if (!_groupItems.ContainsKey(menuStruct))
|
if (!_groupItems.ContainsKey(menuStruct))
|
||||||
{
|
{
|
||||||
_groupItems.Add(menuStruct, groupPanel);
|
_groupItems.Add(menuStruct, groupPanel);
|
||||||
@@ -1331,6 +1744,10 @@ namespace Lskj.Main.Control
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (useLeftGroupTreeMenu)
|
||||||
|
{
|
||||||
|
BindLeftGroupTreeMenu(leftGroupTreeTable, defaultParentMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1599,9 +2016,27 @@ namespace Lskj.Main.Control
|
|||||||
private void InitLeftMenu()
|
private void InitLeftMenu()
|
||||||
{
|
{
|
||||||
DataTable dtLvTree = MainImpl.GetLeftTreeView();
|
DataTable dtLvTree = MainImpl.GetLeftTreeView();
|
||||||
|
if (!pl_center_left.Controls.Contains(tv_left))
|
||||||
|
{
|
||||||
|
pl_center_left.Controls.Clear();
|
||||||
|
pl_center_left.Padding = new Padding(4);
|
||||||
|
pl_center_left.BackColor = Color.FromArgb(10, 87, 167);
|
||||||
|
pl_center_main.Padding = Padding.Empty;
|
||||||
|
pl_center_main.BackColor = Color.FromArgb(240, 240, 240);
|
||||||
|
SetLeftGroupSeparatorVisible(false);
|
||||||
|
pl_center_left.Controls.Add(tv_left);
|
||||||
|
}
|
||||||
|
tv_left.Dock = DockStyle.Fill;
|
||||||
|
tv_left.Visible = true;
|
||||||
tv_left.ParentField = "speciesno";
|
tv_left.ParentField = "speciesno";
|
||||||
tv_left.ParentKeyLength = 2;
|
tv_left.ParentKeyLength = 2;
|
||||||
tv_left.TextField = "speciesname";
|
tv_left.TextField = "speciesname";
|
||||||
|
tv_left.RaiseClickEventOnAllNodes = false;
|
||||||
|
tv_left.ExpandAllNodes = false;
|
||||||
|
tv_left.AllowNodeCollapse = true;
|
||||||
|
tv_left.SwitchOnMouseMove = false;
|
||||||
|
tv_left.UseMenuBarTextStyle = false;
|
||||||
|
tv_left.UseGroupTreeImageStyle = false;
|
||||||
tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
|
tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
|
||||||
tv_left.SetDataSource(dtLvTree);
|
tv_left.SetDataSource(dtLvTree);
|
||||||
}
|
}
|
||||||
@@ -2484,6 +2919,13 @@ namespace Lskj.Main.Control
|
|||||||
if (this._groupItems.ContainsKey(item_after["menustruct"] + ""))
|
if (this._groupItems.ContainsKey(item_after["menustruct"] + ""))
|
||||||
{
|
{
|
||||||
Panel groupPanel = this._groupItems[item_after["menustruct"] + ""];
|
Panel groupPanel = this._groupItems[item_after["menustruct"] + ""];
|
||||||
|
foreach (System.Windows.Forms.Control control in groupPanel.Controls)
|
||||||
|
{
|
||||||
|
GroupControl groupControl = control as GroupControl;
|
||||||
|
if (groupControl != null) groupControl.Visible = true;
|
||||||
|
}
|
||||||
|
NormalizeGroupPanelSpacing(groupPanel);
|
||||||
|
groupPanel.AutoScrollPosition = Point.Empty;
|
||||||
groupPanel.Visible = true;
|
groupPanel.Visible = true;
|
||||||
allMenuPanel.Controls.Add(groupPanel);
|
allMenuPanel.Controls.Add(groupPanel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Lskj.Main.Control
|
|||||||
{
|
{
|
||||||
public partial class TreeViewCustom : UserControl
|
public partial class TreeViewCustom : UserControl
|
||||||
{
|
{
|
||||||
#region 公有属性
|
#region 公有属性
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 父节点字段
|
/// 父节点字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -43,6 +43,30 @@ namespace Lskj.Main.Control
|
|||||||
/// 左侧菜单事件注册
|
/// 左侧菜单事件注册
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ButtonClickEventHandler OnButtonClickEvent;
|
public ButtonClickEventHandler OnButtonClickEvent;
|
||||||
|
/// <summary>
|
||||||
|
/// 所有节点点击时都触发回调,默认保持原来的末级节点触发逻辑。
|
||||||
|
/// </summary>
|
||||||
|
public bool RaiseClickEventOnAllNodes;
|
||||||
|
/// <summary>
|
||||||
|
/// 默认显示所有节点。
|
||||||
|
/// </summary>
|
||||||
|
public bool ExpandAllNodes;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许点击节点时展开/折叠子节点。
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowNodeCollapse = true;
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标滑过节点时是否触发点击回调。
|
||||||
|
/// </summary>
|
||||||
|
public bool SwitchOnMouseMove;
|
||||||
|
/// <summary>
|
||||||
|
/// 使用旧版左侧菜单文字大小。
|
||||||
|
/// </summary>
|
||||||
|
public bool UseMenuBarTextStyle;
|
||||||
|
/// <summary>
|
||||||
|
/// 使用分组左侧菜单专用图片样式。
|
||||||
|
/// </summary>
|
||||||
|
public bool UseGroupTreeImageStyle;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 私有属性
|
#region 私有属性
|
||||||
@@ -65,6 +89,14 @@ namespace Lskj.Main.Control
|
|||||||
/// 缓存所有按钮
|
/// 缓存所有按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<string, Button> _dicButtons = new Dictionary<string, Button>();
|
private Dictionary<string, Button> _dicButtons = new Dictionary<string, Button>();
|
||||||
|
/// <summary>
|
||||||
|
/// 记录节点自身是否应显示,避免 Control.Visible 受父控件可见性影响。
|
||||||
|
/// </summary>
|
||||||
|
private HashSet<string> _visibleNodeValues = new HashSet<string>();
|
||||||
|
/// <summary>
|
||||||
|
/// 默认展开节点。
|
||||||
|
/// </summary>
|
||||||
|
private string _defaultExpandNodeValue;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Api
|
#region Api
|
||||||
@@ -108,6 +140,7 @@ namespace Lskj.Main.Control
|
|||||||
public TreeViewCustom()
|
public TreeViewCustom()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.plTreeView.Resize += (s, e) => ReflowTreeNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
@@ -154,39 +187,42 @@ namespace Lskj.Main.Control
|
|||||||
/// <para>版本:1.0</para>
|
/// <para>版本:1.0</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetDataSource(DataTable dtTable)
|
public void SetDataSource(DataTable dtTable)
|
||||||
|
{
|
||||||
|
SetDataSource(dtTable, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载菜单并展开默认节点。
|
||||||
|
/// </summary>
|
||||||
|
public void SetDataSource(DataTable dtTable, string defaultExpandNodeValue)
|
||||||
{
|
{
|
||||||
int index = 1;
|
int index = 1;
|
||||||
this._dataSource = dtTable;
|
this._dataSource = dtTable;
|
||||||
|
this._lastTreeNode = null;
|
||||||
|
this._lastMenuId = null;
|
||||||
|
this._defaultExpandNodeValue = defaultExpandNodeValue;
|
||||||
|
this._dicTreeNodes.Clear();
|
||||||
|
this._dicButtons.Clear();
|
||||||
|
this._visibleNodeValues.Clear();
|
||||||
|
this.plTreeView.Controls.Clear();
|
||||||
if (_dataSource == null || _dataSource.Rows.Count == 0) return;
|
if (_dataSource == null || _dataSource.Rows.Count == 0) return;
|
||||||
|
var leftItems = _dataSource.Rows.Cast<DataRow>().OrderBy(n => n[ParentField] + "");
|
||||||
// 获取根节点
|
foreach (DataRow item in leftItems)
|
||||||
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;
|
string nodeValue = item[ParentField] + "";
|
||||||
|
int length = nodeValue.Length;
|
||||||
TreeNodeCustom treeNode = new TreeNodeCustom();
|
TreeNodeCustom treeNode = new TreeNodeCustom();
|
||||||
treeNode.Dock = DockStyle.Top;
|
treeNode.Dock = DockStyle.None;
|
||||||
treeNode.Tag = item[ParentField] + "";
|
treeNode.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
treeNode.Tag = nodeValue;
|
||||||
treeNode.TabIndex = index;
|
treeNode.TabIndex = index;
|
||||||
|
if (UseMenuBarTextStyle)
|
||||||
if (length == ParentKeyLength)
|
|
||||||
{
|
{
|
||||||
treeNode.btnTreeNode.BackgroundImage = Lskj.Main.Properties.Resources.node_default;
|
treeNode.Height = 44;
|
||||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 12);
|
|
||||||
}
|
|
||||||
else if (length / ParentKeyLength == 2)
|
|
||||||
{
|
|
||||||
treeNode.btnTreeNode.BackgroundImage = Lskj.Main.Properties.Resources.node2_default;
|
|
||||||
treeNode.btnTreeNode.Padding = new Padding(20, 1, 3, 3);
|
|
||||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 11);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
treeNode.btnTreeNode.BackgroundImage = Lskj.Main.Properties.Resources.node3_default;
|
|
||||||
treeNode.btnTreeNode.Padding = new Padding(30, 1, 3, 3);
|
|
||||||
treeNode.btnTreeNode.Font = new Font("微软雅黑", 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetNodeDefaultStyle(treeNode.btnTreeNode, GetNodeLevel(nodeValue));
|
||||||
|
|
||||||
treeNode.btnTreeNode.Name = index + "";
|
treeNode.btnTreeNode.Name = index + "";
|
||||||
treeNode.btnTreeNode.Text = item[TextField] + "";
|
treeNode.btnTreeNode.Text = item[TextField] + "";
|
||||||
treeNode.btnTreeNode.Tag = item;
|
treeNode.btnTreeNode.Tag = item;
|
||||||
@@ -197,12 +233,322 @@ namespace Lskj.Main.Control
|
|||||||
plTreeView.Controls.Add(treeNode);
|
plTreeView.Controls.Add(treeNode);
|
||||||
_dicButtons.Add(index + "", treeNode.btnTreeNode);
|
_dicButtons.Add(index + "", treeNode.btnTreeNode);
|
||||||
|
|
||||||
List<TreeNodeCustom> parentNodes = getParentNodes(item[ParentField] + "");
|
List<TreeNodeCustom> parentNodes = getParentNodes(nodeValue);
|
||||||
parentNodes.Add(treeNode);
|
parentNodes.Add(treeNode);
|
||||||
// 隐藏需要放在添加后,否则出现顺序错乱
|
// 隐藏需要放在添加后,否则出现顺序错乱
|
||||||
treeNode.Visible = length == ParentKeyLength;
|
SetNodeVisibleState(treeNode, ExpandAllNodes || length == ParentKeyLength || IsDefaultExpandedChildNode(nodeValue));
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
RefreshNodeStyles();
|
||||||
|
ReflowTreeNodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展开指定节点。
|
||||||
|
/// </summary>
|
||||||
|
public void ExpandNode(string nodeValue)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nodeValue)) return;
|
||||||
|
|
||||||
|
foreach (TreeNodeCustom node in plTreeView.Controls.OfType<TreeNodeCustom>())
|
||||||
|
{
|
||||||
|
string menuKey = node.Tag + "";
|
||||||
|
if (menuKey.Length <= nodeValue.Length || !menuKey.StartsWith(nodeValue)) continue;
|
||||||
|
SetNodeVisibleState(node, true);
|
||||||
|
}
|
||||||
|
RefreshNodeStyles();
|
||||||
|
ReflowTreeNodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 选中指定节点,仅更新样式,不触发业务回调。
|
||||||
|
/// </summary>
|
||||||
|
public void SelectNode(string nodeValue)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nodeValue)) return;
|
||||||
|
|
||||||
|
TreeNodeCustom treeNode = plTreeView.Controls.OfType<TreeNodeCustom>().FirstOrDefault(n => (n.Tag + "").Equals(nodeValue));
|
||||||
|
if (treeNode == null) return;
|
||||||
|
|
||||||
|
SelectNodeButton(treeNode.btnTreeNode, nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetNodeLevel(string nodeValue)
|
||||||
|
{
|
||||||
|
if (ParentKeyLength <= 0 || string.IsNullOrEmpty(nodeValue)) return 1;
|
||||||
|
return Math.Max(1, nodeValue.Length / ParentKeyLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetVisualNodeLevel(string nodeValue)
|
||||||
|
{
|
||||||
|
return GetNodeLevel(nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsDefaultExpandedChildNode(string nodeValue)
|
||||||
|
{
|
||||||
|
return !string.IsNullOrEmpty(_defaultExpandNodeValue)
|
||||||
|
&& nodeValue.Length > _defaultExpandNodeValue.Length
|
||||||
|
&& nodeValue.StartsWith(_defaultExpandNodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNodeVisibleState(TreeNodeCustom node, bool visible)
|
||||||
|
{
|
||||||
|
if (node == null) return;
|
||||||
|
|
||||||
|
string nodeValue = node.Tag + "";
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
|
_visibleNodeValues.Add(nodeValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_visibleNodeValues.Remove(nodeValue);
|
||||||
|
}
|
||||||
|
node.Visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool GetNodeVisibleState(TreeNodeCustom node)
|
||||||
|
{
|
||||||
|
if (node == null) return false;
|
||||||
|
|
||||||
|
return _visibleNodeValues.Contains(node.Tag + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshNodeStyles()
|
||||||
|
{
|
||||||
|
foreach (TreeNodeCustom node in plTreeView.Controls.OfType<TreeNodeCustom>())
|
||||||
|
{
|
||||||
|
string nodeValue = node.Tag + "";
|
||||||
|
SetNodeDefaultStyle(node.btnTreeNode, GetVisualNodeLevel(nodeValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(_lastMenuId) && _dicButtons.ContainsKey(_lastMenuId))
|
||||||
|
{
|
||||||
|
Button button = _dicButtons[_lastMenuId];
|
||||||
|
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
||||||
|
SetNodeSelectImage(button, GetVisualNodeLevel(treeNode == null ? string.Empty : treeNode.Tag + ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReflowTreeNodes()
|
||||||
|
{
|
||||||
|
if (plTreeView == null) return;
|
||||||
|
|
||||||
|
int top = 0;
|
||||||
|
int width = Math.Max(0, plTreeView.ClientSize.Width);
|
||||||
|
var parNodes = plTreeView.Controls.OfType<TreeNodeCustom>().OrderBy(n => n.TabIndex);
|
||||||
|
foreach (TreeNodeCustom node in parNodes)
|
||||||
|
{
|
||||||
|
node.Width = width;
|
||||||
|
node.Left = 0;
|
||||||
|
node.Top = top;
|
||||||
|
if (!GetNodeVisibleState(node)) continue;
|
||||||
|
|
||||||
|
top += node.Height;
|
||||||
|
}
|
||||||
|
plTreeView.AutoScrollMinSize = new Size(0, top);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool HasChildNodes(string nodeValue)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nodeValue) || !_dicTreeNodes.ContainsKey(nodeValue)) return false;
|
||||||
|
return _dicTreeNodes[nodeValue].Any(n => (n.Tag + "").Length > nodeValue.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool HasVisibleChildNodes(string nodeValue)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(nodeValue) || !_dicTreeNodes.ContainsKey(nodeValue)) return false;
|
||||||
|
return _dicTreeNodes[nodeValue].Any(n => (n.Tag + "").Length > nodeValue.Length && GetNodeVisibleState(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image GetGroupTreeDefaultImage(int nodeLevel)
|
||||||
|
{
|
||||||
|
if (nodeLevel <= 1) return Lskj.Main.Properties.Resources.tree_group_l1_default;
|
||||||
|
if (nodeLevel == 2) return Lskj.Main.Properties.Resources.tree_group_l2_default;
|
||||||
|
return Lskj.Main.Properties.Resources.tree_group_l3_default;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image GetGroupTreeMoveImage(int nodeLevel)
|
||||||
|
{
|
||||||
|
if (nodeLevel <= 1) return Lskj.Main.Properties.Resources.tree_group_l1_move;
|
||||||
|
if (nodeLevel == 2) return Lskj.Main.Properties.Resources.tree_group_l2_move;
|
||||||
|
return Lskj.Main.Properties.Resources.tree_group_l3_move;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image GetGroupTreeSelectImage(int nodeLevel)
|
||||||
|
{
|
||||||
|
if (nodeLevel <= 1) return Lskj.Main.Properties.Resources.tree_group_l1_select;
|
||||||
|
if (nodeLevel == 2) return Lskj.Main.Properties.Resources.tree_group_l2_select;
|
||||||
|
return Lskj.Main.Properties.Resources.tree_group_l3_select;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNodeDefaultStyle(Button button, int nodeLevel)
|
||||||
|
{
|
||||||
|
if (button == null) return;
|
||||||
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = GetGroupTreeDefaultImage(nodeLevel);
|
||||||
|
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
button.Image = null;
|
||||||
|
button.TextImageRelation = TextImageRelation.Overlay;
|
||||||
|
button.TabStop = false;
|
||||||
|
button.FlatAppearance.BorderSize = 0;
|
||||||
|
button.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
||||||
|
button.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
||||||
|
button.Padding = new Padding(34 + Math.Max(0, nodeLevel - 1) * 12, 0, 3, 0);
|
||||||
|
button.Font = new Font("微软雅黑", 12);
|
||||||
|
button.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseMenuBarTextStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.left_default;
|
||||||
|
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
button.Image = null;
|
||||||
|
button.TextImageRelation = TextImageRelation.Overlay;
|
||||||
|
button.Font = new Font("微软雅黑", 10);
|
||||||
|
button.Padding = new Padding(20 + Math.Max(0, nodeLevel - 1) * 20, 3, 3, 3);
|
||||||
|
button.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel <= 1)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node_default;
|
||||||
|
button.Image = null;
|
||||||
|
button.Padding = new Padding(10, 0, 0, 0);
|
||||||
|
button.Font = new Font("微软雅黑", 12);
|
||||||
|
}
|
||||||
|
else if (nodeLevel == 2)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node2_default;
|
||||||
|
button.Image = null;
|
||||||
|
button.Padding = new Padding(20, 1, 3, 3);
|
||||||
|
button.Font = new Font("微软雅黑", 11);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_default;
|
||||||
|
button.Image = null;
|
||||||
|
button.Padding = new Padding(30 + Math.Max(0, nodeLevel - 3) * 10, 1, 3, 3);
|
||||||
|
button.Font = new Font("微软雅黑", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNodeDefaultImage(Button button, int nodeLevel)
|
||||||
|
{
|
||||||
|
if (button == null) return;
|
||||||
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = GetGroupTreeDefaultImage(nodeLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseMenuBarTextStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.left_default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel <= 1)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node_default;
|
||||||
|
}
|
||||||
|
else if (nodeLevel == 2)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node2_default;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNodeSelectImage(Button button, int nodeLevel)
|
||||||
|
{
|
||||||
|
if (button == null) return;
|
||||||
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = GetGroupTreeSelectImage(nodeLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseMenuBarTextStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.left_select;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel <= 1)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node_select;
|
||||||
|
}
|
||||||
|
else if (nodeLevel == 2)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node2_select;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_select;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNodeMoveImage(Button button, int nodeLevel)
|
||||||
|
{
|
||||||
|
if (button == null) return;
|
||||||
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = GetGroupTreeMoveImage(nodeLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseMenuBarTextStyle)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.left_select;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel <= 1)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node_select;
|
||||||
|
}
|
||||||
|
else if (nodeLevel == 2)
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node2_move;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_move;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectNodeButton(Button button, string nodeValue)
|
||||||
|
{
|
||||||
|
if (button == null) return;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(_lastMenuId) && _lastMenuId != button.Name && _dicButtons.ContainsKey(_lastMenuId))
|
||||||
|
{
|
||||||
|
Button lastButton = _dicButtons[_lastMenuId];
|
||||||
|
TreeNodeCustom lastNode = lastButton.Parent as TreeNodeCustom;
|
||||||
|
SetNodeDefaultImage(lastButton, GetVisualNodeLevel(lastNode == null ? string.Empty : lastNode.Tag + ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetNodeSelectImage(button, GetVisualNodeLevel(nodeValue));
|
||||||
|
_lastMenuId = button.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerNodeEvent(Button button, string nodeValue)
|
||||||
|
{
|
||||||
|
SelectNodeButton(button, nodeValue);
|
||||||
|
if (OnButtonClickEvent != null)
|
||||||
|
{
|
||||||
|
this.OnButtonClickEvent(button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:树点击</para>
|
/// <para>说明:树点击</para>
|
||||||
@@ -226,54 +572,47 @@ namespace Lskj.Main.Control
|
|||||||
{
|
{
|
||||||
_lastTreeNode = nodeValue;
|
_lastTreeNode = nodeValue;
|
||||||
}
|
}
|
||||||
if (nodeValue.Length == ParentKeyLength)
|
int nodeLevel = GetVisualNodeLevel(nodeValue);
|
||||||
{
|
bool hasChildNodes = HasChildNodes(nodeValue);
|
||||||
treeNode.btnTreeNode.BackgroundImage = _dicTreeNodes[nodeValue][0].Visible ? Lskj.Main.Properties.Resources.node_default : Lskj.Main.Properties.Resources.node_select;
|
List<TreeNodeCustom> treeNodes = new List<TreeNodeCustom>();
|
||||||
}
|
|
||||||
if (nodeValue.Length == ParentKeyLength * 2)
|
|
||||||
{
|
|
||||||
treeNode.btnTreeNode.BackgroundImage = _dicTreeNodes[nodeValue][0].Visible ? Lskj.Main.Properties.Resources.node2_default : Lskj.Main.Properties.Resources.node2_select;
|
|
||||||
}
|
|
||||||
// 末节点
|
|
||||||
if (nodeValue.Length == ParentKeyLength * 3)
|
|
||||||
{
|
|
||||||
treeNode.btnTreeNode.BackgroundImage = Lskj.Main.Properties.Resources.node3_select;
|
|
||||||
if (!string.IsNullOrEmpty(_lastMenuId) && _lastMenuId != treeNode.btnTreeNode.Name)
|
|
||||||
{
|
|
||||||
_dicButtons[_lastMenuId].BackgroundImage = Lskj.Main.Properties.Resources.node3_default;
|
|
||||||
}
|
|
||||||
_lastMenuId = treeNode.btnTreeNode.Name;
|
|
||||||
}
|
|
||||||
List<TreeNodeCustom> treeNodes = new List<TreeNodeCustom>();
|
|
||||||
// 展开当前点击节点
|
// 展开当前点击节点
|
||||||
if (_dicTreeNodes.ContainsKey(nodeValue))
|
if (hasChildNodes && AllowNodeCollapse)
|
||||||
{
|
{
|
||||||
treeNodes = _dicTreeNodes[nodeValue];
|
treeNodes = _dicTreeNodes[nodeValue];
|
||||||
foreach (TreeNodeCustom node in treeNodes)
|
foreach (TreeNodeCustom node in treeNodes)
|
||||||
{
|
{
|
||||||
string menuKey = node.Tag + "";
|
string menuKey = node.Tag + "";
|
||||||
if (menuKey.Length == ParentKeyLength) continue;
|
if (menuKey.Length <= nodeValue.Length) continue;
|
||||||
node.Visible = !node.Visible;
|
SetNodeVisibleState(node, !GetNodeVisibleState(node));
|
||||||
Application.DoEvents();// 处理当前消息队列中的所有windows消息
|
}
|
||||||
|
ReflowTreeNodes();
|
||||||
|
if (!RaiseClickEventOnAllNodes)
|
||||||
|
{
|
||||||
|
if (HasVisibleChildNodes(nodeValue))
|
||||||
|
{
|
||||||
|
SetNodeSelectImage(treeNode.btnTreeNode, nodeLevel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetNodeDefaultImage(treeNode.btnTreeNode, nodeLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 点击根节点隐藏所有子节点
|
// 点击根节点隐藏所有子节点
|
||||||
if (nodeValue.Length == ParentKeyLength && !_dicTreeNodes[nodeValue][0].Visible)
|
if (AllowNodeCollapse && nodeValue.Length == ParentKeyLength && !HasVisibleChildNodes(nodeValue))
|
||||||
{
|
{
|
||||||
treeNodes = getChildNodes(nodeValue);
|
treeNodes = getChildNodes(nodeValue);
|
||||||
foreach (TreeNodeCustom node in treeNodes)
|
foreach (TreeNodeCustom node in treeNodes)
|
||||||
{
|
{
|
||||||
node.Visible = false;
|
SetNodeVisibleState(node, false);
|
||||||
//Application.DoEvents();// 处理当前消息队列中的所有windows消息
|
//Application.DoEvents();// 处理当前消息队列中的所有windows消息
|
||||||
}
|
}
|
||||||
|
ReflowTreeNodes();
|
||||||
}
|
}
|
||||||
// 点击末节点
|
// 点击末节点
|
||||||
if (nodeValue.Length == ParentKeyLength * 3)
|
if (RaiseClickEventOnAllNodes || nodeValue.Length == ParentKeyLength * 3)
|
||||||
{
|
{
|
||||||
if (OnButtonClickEvent != null)
|
TriggerNodeEvent(treeNode.btnTreeNode, nodeValue);
|
||||||
{
|
|
||||||
this.OnButtonClickEvent(treeNode.btnTreeNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_lastTreeNode = nodeValue;
|
_lastTreeNode = nodeValue;
|
||||||
}
|
}
|
||||||
@@ -303,15 +642,34 @@ namespace Lskj.Main.Control
|
|||||||
|
|
||||||
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
||||||
string treeNodeTag = treeNode.Tag + "";
|
string treeNodeTag = treeNode.Tag + "";
|
||||||
if (treeNodeTag.Length == ParentKeyLength)
|
int nodeLevel = GetVisualNodeLevel(treeNodeTag);
|
||||||
|
if (SwitchOnMouseMove && button.Name != _lastMenuId)
|
||||||
{
|
{
|
||||||
|
TriggerNodeEvent(button, treeNodeTag);
|
||||||
|
if (!UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
SetNodeMoveImage(button, nodeLevel);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (treeNodeTag.Length == ParentKeyLength * 2)
|
|
||||||
|
if (button.Name == _lastMenuId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
SetNodeMoveImage(button, nodeLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel == 2)
|
||||||
{
|
{
|
||||||
// 第一级节点
|
// 第一级节点
|
||||||
if (_dicTreeNodes.ContainsKey(treeNodeTag) && _dicTreeNodes[treeNodeTag].Count > 0)
|
if (HasChildNodes(treeNodeTag))
|
||||||
{
|
{
|
||||||
button.BackgroundImage = _dicTreeNodes[treeNodeTag][0].Visible ? Lskj.Main.Properties.Resources.node2_select : Lskj.Main.Properties.Resources.node2_move;
|
button.BackgroundImage = HasVisibleChildNodes(treeNodeTag) ? Lskj.Main.Properties.Resources.node2_select : Lskj.Main.Properties.Resources.node2_move;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -321,10 +679,7 @@ namespace Lskj.Main.Control
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 末节点
|
// 末节点
|
||||||
if (button.Name != _lastMenuId)
|
SetNodeMoveImage(button, nodeLevel);
|
||||||
{
|
|
||||||
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_move;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -353,15 +708,24 @@ namespace Lskj.Main.Control
|
|||||||
|
|
||||||
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
TreeNodeCustom treeNode = button.Parent as TreeNodeCustom;
|
||||||
string treeNodeTag = treeNode.Tag + "";
|
string treeNodeTag = treeNode.Tag + "";
|
||||||
if (treeNodeTag.Length == ParentKeyLength)
|
int nodeLevel = GetVisualNodeLevel(treeNodeTag);
|
||||||
|
if (button.Name == _lastMenuId)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (treeNodeTag.Length == ParentKeyLength * 2)
|
|
||||||
|
if (UseGroupTreeImageStyle)
|
||||||
|
{
|
||||||
|
SetNodeDefaultImage(button, nodeLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeLevel == 2)
|
||||||
{
|
{
|
||||||
// 第一级节点
|
// 第一级节点
|
||||||
if (_dicTreeNodes.ContainsKey(treeNodeTag) && _dicTreeNodes[treeNodeTag].Count > 0)
|
if (HasChildNodes(treeNodeTag))
|
||||||
{
|
{
|
||||||
button.BackgroundImage = _dicTreeNodes[treeNodeTag][0].Visible ? Lskj.Main.Properties.Resources.node2_select : Lskj.Main.Properties.Resources.node2_default;
|
button.BackgroundImage = HasVisibleChildNodes(treeNodeTag) ? Lskj.Main.Properties.Resources.node2_select : Lskj.Main.Properties.Resources.node2_default;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -371,10 +735,7 @@ namespace Lskj.Main.Control
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 末节点
|
// 末节点
|
||||||
if (button.Name != _lastMenuId)
|
SetNodeDefaultImage(button, nodeLevel);
|
||||||
{
|
|
||||||
button.BackgroundImage = Lskj.Main.Properties.Resources.node3_default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -414,5 +775,5 @@ namespace Lskj.Main.Control
|
|||||||
return treeNodes;
|
return treeNodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+7
-6
@@ -28,6 +28,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl();
|
this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl();
|
||||||
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
|
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
|
||||||
this.pl_left = new DevExpress.XtraEditors.PanelControl();
|
this.pl_left = new DevExpress.XtraEditors.PanelControl();
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl();
|
this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl();
|
||||||
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
|
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
|
||||||
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
|
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
|
||||||
this.barManager1 = new DevExpress.XtraBars.BarManager();
|
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
|
||||||
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
|
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
|
||||||
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
|
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
|
||||||
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
|
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
this.btnTreeSearch = new DevExpress.XtraEditors.SimpleButton();
|
this.btnTreeSearch = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl();
|
this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl();
|
||||||
this.dbpFP = new DevExpress.XtraEditors.DropDownButton();
|
this.dbpFP = new DevExpress.XtraEditors.DropDownButton();
|
||||||
this.pmFP = new DevExpress.XtraBars.PopupMenu();
|
this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||||
this.btnRefresh = new DevExpress.XtraEditors.SimpleButton();
|
this.btnRefresh = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.btnHiding = new DevExpress.XtraEditors.SimpleButton();
|
this.btnHiding = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.btnHelp = new DevExpress.XtraEditors.SimpleButton();
|
this.btnHelp = new DevExpress.XtraEditors.SimpleButton();
|
||||||
@@ -63,15 +64,15 @@
|
|||||||
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
|
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
|
||||||
this.btn_input = new DevExpress.XtraEditors.SimpleButton();
|
this.btn_input = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.dpbImport = new DevExpress.XtraEditors.DropDownButton();
|
this.dpbImport = new DevExpress.XtraEditors.DropDownButton();
|
||||||
this.pmBillExp = new DevExpress.XtraBars.PopupMenu();
|
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||||
this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton();
|
this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.btnBillApply = new DevExpress.XtraEditors.SimpleButton();
|
this.btnBillApply = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton();
|
this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton();
|
||||||
this.pmBill = new DevExpress.XtraBars.PopupMenu();
|
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||||
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
|
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
|
||||||
this.pMprint = new DevExpress.XtraBars.PopupMenu();
|
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||||
this.dpbTools = new DevExpress.XtraEditors.DropDownButton();
|
this.dpbTools = new DevExpress.XtraEditors.DropDownButton();
|
||||||
this.pMenu = new DevExpress.XtraBars.PopupMenu();
|
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||||
this.btnDelete = new DevExpress.XtraEditors.SimpleButton();
|
this.btnDelete = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.btnBillSave = new DevExpress.XtraEditors.SimpleButton();
|
this.btnBillSave = new DevExpress.XtraEditors.SimpleButton();
|
||||||
this.pl_main_top = new DevExpress.XtraEditors.PanelControl();
|
this.pl_main_top = new DevExpress.XtraEditors.PanelControl();
|
||||||
|
|||||||
@@ -4764,7 +4764,18 @@ namespace Lskj.PubBill
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.AddRowsToGridView(table, unionModel);
|
|
||||||
|
if (!this.BillModel.IsFastDragAddDetail)
|
||||||
|
{
|
||||||
|
this.AddRowsToGridView(table, unionModel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 全部行转数组
|
||||||
|
DataRow[] dragRows = table.Select();
|
||||||
|
this.AddRowsToGridViewFast(dragRows);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ namespace Lskj.Util
|
|||||||
{
|
{
|
||||||
if (bytes == null) return null;
|
if (bytes == null) return null;
|
||||||
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes))
|
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes))
|
||||||
|
using (System.Drawing.Image sourceImage = System.Drawing.Image.FromStream(ms))
|
||||||
{
|
{
|
||||||
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
|
return new Bitmap(sourceImage);
|
||||||
ms.Flush();
|
|
||||||
return returnImage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -56,14 +55,9 @@ namespace Lskj.Util
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileStream fs = File.OpenRead(path); //OpenRead
|
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return null;
|
||||||
int filelength = 0;
|
byte[] image = File.ReadAllBytes(path);
|
||||||
filelength = (int)fs.Length; //获得文件长度
|
return ReadImage(image);
|
||||||
Byte[] image = new Byte[filelength]; //建立一个字节数组
|
|
||||||
fs.Read(image, 0, filelength); //按字节流读取
|
|
||||||
System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
|
|
||||||
fs.Close();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -203,6 +203,21 @@ namespace Lskj.Util
|
|||||||
{
|
{
|
||||||
get { return BitMapPath + "Main/Module/"; }
|
get { return BitMapPath + "Main/Module/"; }
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 主界面左侧树图标路径
|
||||||
|
/// </summary>
|
||||||
|
public static string MainTreeviewImagePath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string path = BitMapPath + "Main\\MainTreeview\\";
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static string MesItemImage
|
public static string MesItemImage
|
||||||
{
|
{
|
||||||
get { return BitMapPath + "MesItem/"; }
|
get { return BitMapPath + "MesItem/"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user