public void LoadImagesAsync(FileItemsViewModel fileItemsViewModel) { if (_loadingThread != null && _loadingThread.IsAlive) { _loadingThread.Abort(); } _fileItemsViewModel = fileItemsViewModel; // Load place holder CreateDefaultIcon(FileItemType.Drive); CreateDefaultIcon(FileItemType.Directory); CreateDefaultIcon(FileItemType.File); _loadingThread = new Thread(new ThreadStart(DoLoadImagesAsync)); _loadingThread.Start(); // if (_oldTask != null) // { // _oldTask.CancelAsync(); // } // _newTask = new BackgroundWorker(); // _newTask.WorkerSupportsCancellation = true; // _newTask.WorkerReportsProgress = true; // _newTask.DoWork += new DoWorkEventHandler(DoLoadImagesAsync); // _newTask.RunWorkerAsync(); }
public FileSystemTreeViewer(ILeftPanel fileSystemTreePanel) { InitializeComponent(); var directories = FileSystemUtilities.GetRootDirectories(); TreeViewer.DataContext = directories; _fileSystemTreePanel = fileSystemTreePanel; var fileItemsViewModel = new FileItemsViewModel(); MainSiteManager.Instance().SetVisibleSite(_fileSystemTreePanel.MainSite); (_fileSystemTreePanel.MainSite.RootFrameworkElement as FileItemsView).SetDataContext(fileItemsViewModel); FileBrowserHistory.PushBackHistory(String.Empty); }
/// <summary> /// Double click on tree view item /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void OnDirectoryDoubleClicked(object sender, MouseButtonEventArgs args) { var currentItem = sender as TreeViewItem; if (!currentItem.IsSelected) { return; } var selectedDirectory = currentItem.DataContext as DirectoryRecordViewModel; var fileItemsViewModel = new FileItemsViewModel(selectedDirectory.DirectoryRecord); MainSiteManager.Instance().SetVisibleSite(_fileSystemTreePanel.MainSite); (_fileSystemTreePanel.MainSite.RootFrameworkElement as FileItemsView).SetDataContext(fileItemsViewModel); FileBrowserHistory.PushBackHistory(selectedDirectory.DirectoryRecord.Info.FullName); args.Handled = true; }
public void SetDataContext(FileItemsViewModel viewModel) { DataContext = viewModel; LoadImagesAsync(); }