Ejemplo n.º 1
0
 private void treeListView1_BeforeCollapse(object sender, System.Windows.Forms.TreeListViewCancelEventArgs e)
 {
     if (e.Item.ImageIndex == 2)
     {
         e.Item.ImageIndex = 1;
     }
 }
Ejemplo n.º 2
0
 private void treeListView1_BeforeExpand(object sender, System.Windows.Forms.TreeListViewCancelEventArgs e)
 {
     if (e.Item.ImageIndex == 1)
     {
         e.Item.ImageIndex = 2;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises the BeforeExpand event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeforeExpand(TreeListViewCancelEventArgs e)
 {
     if(BeforeExpand != null) BeforeExpand(this, e);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Raises the BeforeCollapse event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeforeCollapse(TreeListViewCancelEventArgs e)
 {
     if(BeforeCollapse != null) BeforeCollapse(this, e);
 }
Ejemplo n.º 5
0
 internal void RaiseBeforeExpand(TreeListViewCancelEventArgs e)
 {
     OnBeforeExpand(e);
 }
Ejemplo n.º 6
0
 internal void RaiseBeforeCollapse(TreeListViewCancelEventArgs e)
 {
     OnBeforeCollapse(e);
 }
Ejemplo n.º 7
0
 /// <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();
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
                        }
                }
            }
        }
Ejemplo n.º 10
0
		void FSExplorer_BeforeCollapse(object sender, TreeListViewCancelEventArgs e)
		{
			if (e.Item.Level > 0)
			{
				if (e.Item.ImageKey == "文件夹展开")
				{
					e.Item.ImageKey = "文件夹收起";
				}
			}
		}
Ejemplo n.º 11
0
		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 = "文件夹展开";
				}
			}
		}