コード例 #1
0
 private void treeListView1_BeforeCollapse(object sender, System.Windows.Forms.TreeListViewCancelEventArgs e)
 {
     if (e.Item.ImageIndex == 2)
     {
         e.Item.ImageIndex = 1;
     }
 }
コード例 #2
0
 private void treeListView1_BeforeExpand(object sender, System.Windows.Forms.TreeListViewCancelEventArgs e)
 {
     if (e.Item.ImageIndex == 1)
     {
         e.Item.ImageIndex = 2;
     }
 }
コード例 #3
0
ファイル: TreeListView.cs プロジェクト: moisesiq/aupaga
 /// <summary>
 /// Raises the BeforeExpand event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeforeExpand(TreeListViewCancelEventArgs e)
 {
     if(BeforeExpand != null) BeforeExpand(this, e);
 }
コード例 #4
0
ファイル: TreeListView.cs プロジェクト: moisesiq/aupaga
 /// <summary>
 /// Raises the BeforeCollapse event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeforeCollapse(TreeListViewCancelEventArgs e)
 {
     if(BeforeCollapse != null) BeforeCollapse(this, e);
 }
コード例 #5
0
ファイル: TreeListView.cs プロジェクト: moisesiq/aupaga
 internal void RaiseBeforeExpand(TreeListViewCancelEventArgs e)
 {
     OnBeforeExpand(e);
 }
コード例 #6
0
ファイル: TreeListView.cs プロジェクト: moisesiq/aupaga
 internal void RaiseBeforeCollapse(TreeListViewCancelEventArgs e)
 {
     OnBeforeCollapse(e);
 }
コード例 #7
0
ファイル: TreeListView.cs プロジェクト: andreigec/Folder-View
 /// <summary>
 /// expand all nodes from this item to the top
 /// </summary>
 /// <param name="TLVI"></param>
 public void Expand(TreeListViewItem TLVI)
 {
     BeginUpdate();
     SelectedItems.Clear();
     TLVI.Selected = true;
     while (TLVI != null)
     {
         TreeListViewCancelEventArgs e = new TreeListViewCancelEventArgs(
         TLVI, TreeListViewAction.Expand);
         RaiseBeforeExpand(e);
         TLVI = TLVI.Parent;
     }
     EndUpdate();
 }
コード例 #8
0
        internal void ExpandInternal()
        {
            if (IsInATreeListView)
                if (ListView.InvokeRequired)
                    throw (new Exception("Invoke Required"));

            TreeListViewItem selItem = null;
            if (TreeListView != null) selItem = TreeListView.FocusedItem;

            // Must set ListView.checkDirection to CheckDirection.None.
            // Forbid recursively checking.
            CheckDirection oldDirection = CheckDirection.All;
            if (ListView != null)
            {
                oldDirection = ListView._checkDirection;
                ListView._checkDirection = CheckDirection.None;
            }

            // The item wasn't expanded -> raise an event
            if (Visible && !_isexpanded && ListView != null)
            {
                TreeListViewCancelEventArgs e = new TreeListViewCancelEventArgs(
                    this, TreeListViewAction.Expand);
                ListView.RaiseBeforeExpand(e);
                if (e.Cancel) return;
            }

            if (Visible)
                for (int i = Items.Count - 1; i >= 0; i--)
                {
                    TreeListViewItem item = this.Items[i];
                    if (!item.Visible)
                    {
                        ListView LView = this.ListView;
                        LView.Items.Insert(
                            this.Index + 1, item);
                        item.SetIndentation();
                    }
                    if (item.IsExpanded) item.Expand();
                }
            // The item wasn't expanded -> raise an event
            if (Visible && !_isexpanded && IsInATreeListView)
            {
                this._isexpanded = true;
                TreeListViewEventArgs e = new TreeListViewEventArgs(
                    this, TreeListViewAction.Expand);
                ListView.RaiseAfterExpand(e);
                if (AfterExpand != null) AfterExpand(this);
            }
            this._isexpanded = true;

            // Reset ListView.checkDirection
            if (IsInATreeListView)
                ListView._checkDirection = oldDirection;
            if (TreeListView != null && selItem != null)
                if (selItem.Visible)
                    selItem.Focused = true;
        }
コード例 #9
0
        internal void CollapseInternal()
        {
            if (IsInATreeListView)
                if (ListView.InvokeRequired)
                    throw (new Exception("Invoke Required"));
            TreeListViewItem selItem = null;
            if (TreeListView != null) selItem = TreeListView.FocusedItem;
            // The item was expanded -> raise an event
            if (Visible && _isexpanded && ListView != null)
            {
                TreeListViewCancelEventArgs e = new TreeListViewCancelEventArgs(
                    this, TreeListViewAction.Collapse);
                ListView.RaiseBeforeCollapse(e);
                if (e.Cancel) return;
            }

            // Collapse
            if (this.Visible)
                foreach (TreeListViewItem item in Items)
                    item.Hide();

            // The item was expanded -> raise an event
            if (Visible && _isexpanded && IsInATreeListView)
            {
                this._isexpanded = false;
                TreeListViewEventArgs e = new TreeListViewEventArgs(
                    this, TreeListViewAction.Collapse);
                ListView.RaiseAfterCollapse(e);
                if (AfterCollapse != null) AfterCollapse(this);
            }
            this._isexpanded = false;
            if (IsInATreeListView && selItem != null)
            {
                if (selItem.Visible)
                    selItem.Focused = true;
                else
                {
                    ListView listview = (ListView)TreeListView;
                    listview.SelectedItems.Clear();
                    TreeListViewItem[] items = selItem.ParentsInHierarch;
                    for (int i = items.Length - 1; i >= 0; i--)
                        if (items[i].Visible)
                        {
                            items[i].Focused = true;
                            break;
                        }
                }
            }
        }
コード例 #10
0
ファイル: FSExplorer.cs プロジェクト: lujinlong/Apq
		void FSExplorer_BeforeCollapse(object sender, TreeListViewCancelEventArgs e)
		{
			if (e.Item.Level > 0)
			{
				if (e.Item.ImageKey == "文件夹展开")
				{
					e.Item.ImageKey = "文件夹收起";
				}
			}
		}
コード例 #11
0
ファイル: FSExplorer.cs プロジェクト: lujinlong/Apq
		void FSExplorer_BeforeExpand(object sender, TreeListViewCancelEventArgs e)
		{
			if (e.Item.Level > 0)
			{
				if (e.Item.ImageKey == "文件夹收起")
				{
					Shell32.SHFILEINFO shFolderInfo = new Shell32.SHFILEINFO();
					Apq.Windows.Forms.IconChache.GetFileSystemIcon(e.Item.FullPath, ref shFolderInfo, true);
					e.Item.ImageKey = "文件夹展开";
				}
			}
		}