主界面左侧菜单相关
This commit is contained in:
@@ -129,6 +129,12 @@ namespace Lskj.Main.Control
|
||||
/// 缓存分组控件
|
||||
/// </summary>
|
||||
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>
|
||||
@@ -301,7 +307,7 @@ namespace Lskj.Main.Control
|
||||
if (HiddenAccountSet && (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4))
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -332,7 +338,10 @@ namespace Lskj.Main.Control
|
||||
{
|
||||
this.SetMenus();
|
||||
this.SetSearchMenus();
|
||||
this.tv_left.Visible = false;
|
||||
if (!this._allMenus.Columns.Contains("groupcaption") || isFlowLayout)
|
||||
{
|
||||
this.tv_left.Visible = false;
|
||||
}
|
||||
}
|
||||
if (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4)
|
||||
{
|
||||
@@ -671,6 +680,365 @@ namespace Lskj.Main.Control
|
||||
|
||||
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 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>
|
||||
/// <para>说明:设置左侧菜单</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
@@ -683,6 +1051,7 @@ namespace Lskj.Main.Control
|
||||
private void SetMenus()
|
||||
{
|
||||
this._menus.Clear();
|
||||
this._firstMenuBar = null;
|
||||
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"))
|
||||
{
|
||||
@@ -714,6 +1083,8 @@ namespace Lskj.Main.Control
|
||||
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)
|
||||
{
|
||||
bool useLeftGroupTreeMenu = this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout;
|
||||
DataTable leftGroupTreeTable = useLeftGroupTreeMenu ? CreateLeftGroupTreeTable() : null;
|
||||
int buttonTop = 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); // 旧模块宽度,模块高度
|
||||
@@ -923,7 +1294,6 @@ namespace Lskj.Main.Control
|
||||
// 加载左侧菜单
|
||||
if (menuStruct.Length == 2)
|
||||
{
|
||||
|
||||
DataTable childs = rows.Cast<DataRow>().Where(x => (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
|
||||
if (childs != null && childs.Rows.Count > 1)
|
||||
{
|
||||
@@ -931,33 +1301,40 @@ namespace Lskj.Main.Control
|
||||
defaultParentMenu = menuStruct;
|
||||
// menuLeft = 5; menuTop = 5;
|
||||
menuLeft = Convert.ToInt32(0.05 * DpiX); menuTop = Convert.ToInt32(0.05 * DpiY);
|
||||
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 (useLeftGroupTreeMenu)
|
||||
{
|
||||
AddLeftGroupTreeNode(leftGroupTreeTable, menuStruct, item["menucaption"] + "", LeftGroupTreeNodeTypeMenu, menuStruct, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
|
||||
button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
|
||||
}
|
||||
if (SystemInfo.Instance.MenuBarWidth > 0)
|
||||
{
|
||||
button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
|
||||
button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
|
||||
}
|
||||
|
||||
if (_firstMenuBar == null)
|
||||
{
|
||||
_firstMenuBar = button;
|
||||
if (_firstMenuBar == null)
|
||||
{
|
||||
_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 +1468,34 @@ namespace Lskj.Main.Control
|
||||
}
|
||||
}
|
||||
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();
|
||||
groupPanel.AutoScroll = true;
|
||||
groupPanel.Dock = DockStyle.Fill;
|
||||
int groupControlIndex = 0;
|
||||
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 minMenuRow = this._allMenus.Columns.Contains("menuRow") ? groupByDataRow.Min(n => Convert.ToInt32(n["menuRow"])) : 1;
|
||||
int menuGroupLeft = Convert.ToInt32(0.05 * DpiY);
|
||||
int menuGroupTop = 0; // 模块距离左边距,模块距离顶部边距
|
||||
GroupControl groupControl = new GroupControl();
|
||||
groupControl.Name = groupTreeKey;
|
||||
groupControl.Tag = groupTreeCaption;
|
||||
groupControl.TipsLabel.ForeColor = Color.DimGray;
|
||||
groupControl.Dock = DockStyle.Top;
|
||||
if (groupControlIndex == groupByDataRows.Count() - 1 && !isShowGrallyInTop)
|
||||
{
|
||||
groupControl.Padding = new Padding(0, 0, 0, 0);
|
||||
}
|
||||
groupControl.Padding = new Padding(0, GroupControlTopPadding, 0, 0);
|
||||
groupPanel.Controls.Add(groupControl);
|
||||
List<DataRow> groupOrderDataRow = groupByDataRow.ToList();
|
||||
if (this._allMenus.Columns.Contains("menuRow"))
|
||||
@@ -1231,12 +1619,13 @@ namespace Lskj.Main.Control
|
||||
}
|
||||
groupControlIndex += 1;
|
||||
groupControl.TipsText = $"{groupControl.TipsText}({count})";
|
||||
groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + 16);
|
||||
groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + GroupControlTopPadding);
|
||||
}
|
||||
if (groupPanel.Controls.Count == 1)
|
||||
{
|
||||
(groupPanel.Controls[0] as GroupControl).TipsVisable = false;
|
||||
}
|
||||
NormalizeGroupPanelSpacing(groupPanel);
|
||||
if (!_groupItems.ContainsKey(menuStruct))
|
||||
{
|
||||
_groupItems.Add(menuStruct, groupPanel);
|
||||
@@ -1331,6 +1720,10 @@ namespace Lskj.Main.Control
|
||||
}
|
||||
}
|
||||
}
|
||||
if (useLeftGroupTreeMenu)
|
||||
{
|
||||
BindLeftGroupTreeMenu(leftGroupTreeTable, defaultParentMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1599,9 +1992,27 @@ namespace Lskj.Main.Control
|
||||
private void InitLeftMenu()
|
||||
{
|
||||
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.ParentKeyLength = 2;
|
||||
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.SetDataSource(dtLvTree);
|
||||
}
|
||||
@@ -2484,6 +2895,13 @@ namespace Lskj.Main.Control
|
||||
if (this._groupItems.ContainsKey(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;
|
||||
allMenuPanel.Controls.Add(groupPanel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user