mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
TabToTreeView improvements
This commit is contained in:
parent
b02c9c091e
commit
83f803adcf
3 changed files with 18 additions and 3 deletions
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HelpersLib
|
||||
|
@ -32,6 +33,7 @@ public partial class TabToListView : UserControl
|
|||
{
|
||||
private TabControl mainTabControl;
|
||||
|
||||
[Browsable(false)]
|
||||
public TabControl MainTabControl
|
||||
{
|
||||
get
|
||||
|
|
4
HelpersLib/Controls/TabToTreeView.Designer.cs
generated
4
HelpersLib/Controls/TabToTreeView.Designer.cs
generated
|
@ -41,9 +41,11 @@ private void InitializeComponent()
|
|||
//
|
||||
// tvMain
|
||||
//
|
||||
this.tvMain.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.tvMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.tvMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tvMain.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||
this.tvMain.FullRowSelect = true;
|
||||
this.tvMain.HideSelection = false;
|
||||
this.tvMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.tvMain.Name = "tvMain";
|
||||
this.tvMain.ShowLines = false;
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HelpersLib
|
||||
|
@ -31,6 +32,7 @@ public partial class TabToTreeView : UserControl
|
|||
{
|
||||
private TabControl mainTabControl;
|
||||
|
||||
[Browsable(false)]
|
||||
public TabControl MainTabControl
|
||||
{
|
||||
get
|
||||
|
@ -78,12 +80,18 @@ public TabToTreeView()
|
|||
TreeViewSize = 150;
|
||||
}
|
||||
|
||||
private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab)
|
||||
private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab, TreeNode parent = null)
|
||||
{
|
||||
if (nodeCollection != null && tab != null)
|
||||
{
|
||||
foreach (TabPage tabPage in tab.TabPages)
|
||||
{
|
||||
if (parent != null && tabPage.Text == "{Parent}")
|
||||
{
|
||||
parent.Tag = tabPage;
|
||||
continue;
|
||||
}
|
||||
|
||||
TreeNode treeNode = new TreeNode(tabPage.Text);
|
||||
if (!string.IsNullOrEmpty(tabPage.ImageKey))
|
||||
{
|
||||
|
@ -96,7 +104,7 @@ private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab)
|
|||
{
|
||||
if (control is TabControl)
|
||||
{
|
||||
FillTreeView(treeNode.Nodes, control as TabControl);
|
||||
FillTreeView(treeNode.Nodes, control as TabControl, treeNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -115,9 +123,12 @@ private void tvMain_AfterSelect(object sender, TreeViewEventArgs e)
|
|||
|
||||
if (tabPage != null)
|
||||
{
|
||||
tvMain.BeginUpdate();
|
||||
tcMain.Visible = true;
|
||||
tcMain.TabPages.Clear();
|
||||
tcMain.TabPages.Add(tabPage);
|
||||
tvMain.Focus();
|
||||
tvMain.EndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue