internal void AddTask(FileSystemItemModelBase item) { if (item.Checked != true) { return; } calcQueue.ProcessTask(item); }
public override ImageSource Select(DevExpress.Xpf.Grid.TreeList.TreeListRowData rowData) { FileSystemItemModelBase item = rowData.Row as FileSystemItemModelBase; if (item == null) { return(null); } return(GetImageByFileItemType(item.ItemType, rowData.Node.IsExpanded, item.HasChildren())); }
void view_NodeChanged(object sender, DevExpress.Xpf.Grid.TreeList.TreeListNodeChangedEventArgs e) { if (e.ChangeType == NodeChangeType.Add) { FileSystemItemModelBase item = e.Node.Content as FileSystemItemModelBase; if (item.ItemType == "File") { e.Node.IsExpandButtonVisible = DevExpress.Utils.DefaultBoolean.False; } } }
FileSystemItemModelBase GetItemFromQueue() { FileSystemItemModelBase item = null; lock (locker) { if (items.Count != 0) { item = items.Dequeue(); } } return(item); }
void Calc() { while (true) { FileSystemItemModelBase item = GetItemFromQueue(); if (item != null) { SizeUpdater.Instance.RecursiveCalculator(item); } else { waitHandle.WaitOne(); } } }
long RecursiveCalculatorHelper(FileSystemItemModelBase item) { long resSize = 0; DispatcherOperation op; Action <FileSystemItemModelBase> sizeCalculatingAction = delegate(FileSystemItemModelBase i) { i.Size.Change(FileSystemItemSize.Calculating); }; Action <FileSystemItemModelBase> sizeCalculatedAction = delegate(FileSystemItemModelBase i) { i.Size.Change(resSize); }; if (item.ItemType == "File") { return(item.Size.NumSize); } FolderSystemItemModel folderItem = item as FolderSystemItemModel; if (folderItem == null) { return(0); } if (item.Size.IsCalculated()) { return(item.Size.NumSize); } op = WindowDispatcher.BeginInvoke(DispatcherPriority.Normal, sizeCalculatingAction, item); if (item.HasChildren()) { foreach (FileSystemItemModelBase child in folderItem.Source) { resSize += RecursiveCalculatorHelper(child); } } else { resSize = DataHelper.Instance.GetFolderSize(item.FullName); } op = WindowDispatcher.BeginInvoke(DispatcherPriority.Normal, sizeCalculatedAction, item); return(resSize); }
public void ProcessTask(FileSystemItemModelBase item) { lock (locker) items.Enqueue(item); waitHandle.Set(); }
internal void RecursiveCalculator(FileSystemItemModelBase item) { RecursiveCalculatorHelper(item); }