Exemple #1
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var searcher        = new Searcher(@"E:\GitHub Project\Everything\PhotoApplication\bin\Debug\SearchIndex");
            var hits            = searcher.Search(SearchInupt.Text);
            var fileSystemItems = new List <FileSystemItem>();

            for (int i = 0; i < hits.Count(); i++)
            {
                var      hit           = hits[i];
                Document doc           = searcher.GetDocument(hit.Doc);
                Field    fileNameField = doc.GetField("Name");
                Field    pathField     = doc.GetField("Path");
                Field    typeField     = doc.GetField("Type");
                var      fileItemType  = FileItemType.File;
                switch (typeField.StringValue)
                {
                case "File":
                    fileItemType = FileItemType.File;
                    break;

                case "Directory":
                    fileItemType = FileItemType.Directory;
                    break;

                case "Driver":
                    fileItemType = FileItemType.Drive;
                    break;
                }
                fileSystemItems.Add(new FileSystemItem(pathField.StringValue, fileNameField.StringValue, fileItemType));
            }

            FileBrowserHistory.PushBackHistory(FileBrowserHistory.SearchPage);
            SetDataContext(new FileItemsViewModel(fileSystemItems));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public void OnItemDoubleClicked(object sender, MouseEventArgs args)
        {
            var selectedFileItem = (sender as FrameworkElement).DataContext as FileSystemItem;

            if (selectedFileItem.Type == FileItemType.Directory || selectedFileItem.Type == FileItemType.Drive)
            {
                FileBrowserHistory.PushBackHistory(selectedFileItem.FullName);
                if (FileBrowserHistory.ForwardHistoryCount() > 0 && selectedFileItem.FullName == FileBrowserHistory.GetTopForwardHistory())
                {
                    FileBrowserHistory.PopForwardHistory();
                }
                SetDataContext(new FileItemsViewModel(new DirectoryRecord()
                {
                    Info = new DirectoryInfo(selectedFileItem.FullName)
                }));
            }
        }
Exemple #4
0
        /// <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;
        }
Exemple #5
0
        private static void ForwardCommandHandler(object parameter)
        {
            var filesItemView = parameter as FileItemsView;
            var lastDirectory = FileBrowserHistory.GetTopForwardHistory();

            if (lastDirectory == String.Empty)
            {
                filesItemView.SetDataContext(new FileItemsViewModel());
            }
            else
            {
                filesItemView.SetDataContext(new FileItemsViewModel(new DirectoryRecord()
                {
                    Info = new DirectoryInfo(lastDirectory)
                }));
            }
            FileBrowserHistory.PushBackHistory(FileBrowserHistory.PopForwardHistory());
            // filesItemView.LoadImagesAsync();
        }