Пример #1
0
        internal static string makeDescription(FileSysItem item)
        {
            string s = item.DisplayName;

            if (s != null)
            {
                s = item.DisplayName.Trim();
            }

            return(string.IsNullOrEmpty(s) ? item.Sysname : string.Format("{0} ({1})", item.DisplayName, item.Sysname));
        }
Пример #2
0
 void removeDir(TreeNodeCollection coll, FileSysItem item)
 {
     if (item.ItemType == ItemType.Drive || item.ItemType == ItemType.Dir)
     {
         TreeNode nd = coll.Find(item.Sysname, false).FirstOrDefault();
         if (nd != null)
         {
             coll.Remove(nd);
         }
     }
 }
Пример #3
0
        internal static int getImageIndexByType(FileSysItem item)
        {
            switch (item.ItemType)
            {
            case ItemType.Dir:
            case ItemType.Drive:
                return(0);

            default:
                return(item.IsXml ? 3 : 2);
            }
        }
Пример #4
0
 void watcher_Renamed(object sender, RenamedEventArgs e)
 {
     threadSafeExec(() =>
     {
         FileSysItem item = new FileSysItem(this, e.OldName);
         int i            = IndexOf(item);
         if (i > -1)
         {
             this[i] = new FileSysItem(this, e.Name);
         }
     });
 }
Пример #5
0
 void watcher_Deleted(object sender, FileSystemEventArgs e)
 {
     threadSafeExec(() =>
     {
         FileSysItem item = new FileSysItem(this, e.Name);
         int i            = IndexOf(item);
         if (i > -1)
         {
             RemoveAt(i);
         }
     });
 }
Пример #6
0
 void watcher_Created(object sender, FileSystemEventArgs e)
 {
     threadSafeExec(() =>
     {
         FileSysItem item = new FileSysItem(this, e.Name);
         int i            = IndexOf(item);
         if (i < 0)
         {
             Add(item);
         }
     });
 }
Пример #7
0
        void removeDetail(FileSysItem item)
        {
            if (string.Compare(currentSelectedDetailsPath, item.Parent.Path, true) != 0)
            {
                return;
            }

            var it = lstCurDir.Items.Find(item.Sysname, false).FirstOrDefault();

            if (it != null)
            {
                lstCurDir.Items.Remove(it);
            }
        }
Пример #8
0
 TreeItem addTreeDir(TreeNodeCollection coll, FileSysItem item)
 {
     if (item.ItemType == ItemType.Drive || item.ItemType == ItemType.Dir)
     {
         var tn = coll.Add(item.Sysname, ViewHelpers.makeDescription(item), 0);
         tn.Tag = new TreeItem()
         {
             Item = item
         };
         tn.Nodes.Add("stub", "stub");
         return((TreeItem)tn.Tag);
     }
     return(null);
 }
Пример #9
0
        void onItemPicked(FileSysItem it)
        {
            ItemPickedHandler h = ItemPicked;

            if (h != null)
            {
                ViewHelpers.execWithWaitCursor(() =>
                {
                    h(this, new ItemPickedArgs()
                    {
                        Item = it
                    });
                });
            }
        }
Пример #10
0
        void addDetail(FileSysItem item, bool withCheck = false)
        {
            if (withCheck)
            {
                if (string.Compare(currentSelectedDetailsPath, item.Parent.Path, true) != 0)
                {
                    return;
                }
            }

            var listItem = new ListViewItem(ViewHelpers.makeDescription(item));

            listItem.Name       = item.Sysname;
            listItem.Tag        = item;
            listItem.ImageIndex = ViewHelpers.getImageIndexByType(item);
            lstCurDir.Items.Add(listItem);
        }
Пример #11
0
        void descr_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (FileSysItem it in e.OldItems)
                {
                    TreeNode           nd    = findParentNode(it.Parent);
                    TreeNodeCollection nodes = nd == null ? treeDirs.Nodes : nd.Nodes;
                    removeDir(nodes, it);
                    removeDetail(it);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (FileSysItem it in e.NewItems)
                {
                    TreeNode           nd    = findParentNode(it.Parent);
                    TreeNodeCollection nodes = nd == null ? treeDirs.Nodes : nd.Nodes;
                    addTreeDir(nodes, it);
                    addDetail(it, true);
                }
                lstCurDir.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                for (int i = 0; i < e.OldItems.Count; ++i)
                {
                    FileSysItem itOld = (FileSysItem)e.OldItems[i];
                    FileSysItem itNew = (FileSysItem)e.NewItems[i];
                    TreeNode    nd    = findParentNode(itOld.Parent);

                    removeDir(nd.Nodes, itOld);
                    addTreeDir(nd.Nodes, itNew);

                    removeDetail(itOld);
                    addDetail(itNew, true);
                }
                lstCurDir.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }
Пример #12
0
        public int Compare(object x, object y)
        {
            int res;

            ListViewItem t1 = (ListViewItem)x;
            ListViewItem t2 = (ListViewItem)y;

            if (t1 == null && t2 == null)
            {
                res = 0;
            }
            else if (t1 == null && t1 != t2)
            {
                res = 1;
            }
            else if (t2 == null && t1 != t2)
            {
                res = -1;
            }
            else
            {
                FileSysItem i1 = (FileSysItem)t1.Tag;
                FileSysItem i2 = (FileSysItem)t2.Tag;

                if (i1.ItemType == i2.ItemType)
                {
                    res = i1.Sysname.CompareTo(i2.Sysname);
                }
                else
                {
                    res = i1.ItemType == ItemType.Dir || i1.ItemType == ItemType.Drive ? -1 : 1;
                }
            }

            return(_asc ? res : -res);
        }