/* Useful Functions */ private void RefreshTabs() { ListViewView leftList = leftTabControl.SelectedContent as ListViewView; ListViewView rightList = rightTabControl.SelectedContent as ListViewView; TreeListView leftTreeList = leftTabControl.SelectedContent as TreeListView; TreeListView rightTreeList = rightTabControl.SelectedContent as TreeListView; if (leftList != null) { leftList.PathManager.RefreshList(); } if (rightList != null) { rightList.PathManager.RefreshList(); } if (leftTreeList != null) { leftTreeList.LoadFromPath(leftTreeList.Driver); } if (rightTreeList != null) { rightTreeList.LoadFromPath(rightTreeList.Driver); } UpdatePathDisplays(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (ListViewView.TryFindResource("ListViewViewSource") is CollectionViewSource view) { view.Filter += new FilterEventHandler(View_Filter); } }
/* Useful functions */ void UpdateDisplayMode() { if (FocusedTabControl == null) { return; } string path = "C:\\"; if (FocusedTabControl == leftTabControl && leftPartition.SelectedItem != null) { path = leftPartition.SelectedItem.ToString(); } else if (rightPartition.SelectedItem != null) { path = rightPartition.SelectedItem.ToString(); } TabItem currentTab = (TabItem)FocusedTabControl.SelectedItem; ListViewView listView = currentTab.Content as ListViewView; TreeListView treeView = currentTab.Content as TreeListView; if (listView != null && IsTree) { currentTab.Content = null; currentTab.Content = new TreeListView(path); } else if (treeView != null && !IsTree) { currentTab.Content = null; currentTab.Content = new ListViewView(path); } }
private void ChangeButtonDisplay() { ListViewView leftList = leftTabControl.SelectedContent as ListViewView; ListViewView rightList = rightTabControl.SelectedContent as ListViewView; TreeListView leftTreeList = leftTabControl.SelectedContent as TreeListView; TreeListView rightTreeList = rightTabControl.SelectedContent as TreeListView; if (leftList != null && leftList == FocusedTabControl.SelectedContent) { if (leftList.MainListView.SelectedItem != null && (leftList.MainListView.SelectedItem as ListItem).Ext != "") { SetButtonDisplayOnFile(); } else { SetButtonDisplayOnDirectory(); } } if (rightList != null && rightList == FocusedTabControl.SelectedContent) { if (rightList.MainListView.SelectedItem != null && (rightList.MainListView.SelectedItem as ListItem).Ext != "") { SetButtonDisplayOnFile(); } else { SetButtonDisplayOnDirectory(); } } if (leftTreeList != null && leftTreeList == FocusedTabControl.SelectedContent) { if (leftTreeList.FolderView.SelectedItem != null && (leftTreeList.FolderView.SelectedItem as TreeViewItem).Header.ToString().Contains(".")) { SetButtonDisplayOnFile(); } else { SetButtonDisplayOnDirectory(); } } if (rightTreeList != null && rightTreeList == FocusedTabControl.SelectedContent) { if (rightTreeList.FolderView.SelectedItem != null && (rightTreeList.FolderView.SelectedItem as TreeViewItem).Header.ToString().Contains(".")) { SetButtonDisplayOnFile(); } else { SetButtonDisplayOnDirectory(); } } }
private void Unpack_Click(object sender, RoutedEventArgs e) { if (FocusedTabControl != null) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; if (listView != null) { listView.UnpackArchive(); } RefreshTabs(); } }
private void Pack_Click(object sender, RoutedEventArgs e) { if (FocusedTabControl != null) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; if (listView != null) { NewArchiveWindow archiveWindow = new NewArchiveWindow(listView); archiveWindow.ShowDialog(); RefreshTabs(); } } }
private void NewFolderButton_Click(object sender, RoutedEventArgs e) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; TreeListView treeListView = FocusedTabControl.SelectedContent as TreeListView; if (listView != null) { listView.NewFolder(); } else { //treeListView.NewFolder(); } }
private void CopyButton_Click(object sender, RoutedEventArgs e) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; TreeListView treeListView = FocusedTabControl.SelectedContent as TreeListView; if (listView != null) { listView.Copy(); } else { treeListView.Copy(); } RefreshTabs(); }
private void UpdatePathDisplays() { ListViewView leftList = leftTabControl.SelectedContent as ListViewView; ListViewView rightList = rightTabControl.SelectedContent as ListViewView; TabItem tabItem = FocusedTabControl.SelectedItem as TabItem; if (leftList != null) { LeftPathDisplay.Text = leftList.PathManager.Path; tabItem.Header = StringAfter(LeftPathDisplay.Text, @"\"); } if (rightList != null) { RightPathDisplay.Text = rightList.PathManager.Path; tabItem.Header = StringAfter(RightPathDisplay.Text, @"\"); } }
private void CompareByContent_Click(object sender, RoutedEventArgs e) { ListViewView leftListView = leftTabControl.SelectedContent as ListViewView; ListViewView rightListView = rightTabControl.SelectedContent as ListViewView; TreeListView leftTreeList = leftTabControl.SelectedContent as TreeListView; TreeListView rightTreeList = rightTabControl.SelectedContent as TreeListView; string leftPath = null, rightPath = null; string file1 = null, file2 = null; if (leftListView != null && leftListView.SelectedItems.Count == 1 && leftListView.SelectedItems.ElementAt(0).Ext == ".txt") { leftPath = leftListView.SelectedItems.ElementAt(0).Name; file1 = System.IO.Path.Combine(leftListView.PathManager.Path, leftPath); } else if (leftTreeList != null && leftTreeList.SelectedItems.Count == 1 && leftTreeList.SelectedItems.ElementAt(0).Header.ToString().Contains(".")) { leftPath = leftTreeList.SelectedItems.ElementAt(0).Name; file1 = System.IO.Path.Combine(leftTreeList.Path, leftPath); } if (rightListView != null && rightListView.SelectedItems.ElementAt(0).Ext == ".txt" && rightListView.SelectedItems.Count == 1) { rightPath = rightListView.SelectedItems.ElementAt(0).Name; file2 = System.IO.Path.Combine(rightListView.PathManager.Path, rightPath); } else if (rightTreeList != null && rightTreeList.SelectedItems.Count == 1 && rightTreeList.SelectedItems.ElementAt(0).Header.ToString().Contains(".")) { rightPath = rightTreeList.SelectedItems.ElementAt(0).Name; file2 = System.IO.Path.Combine(rightTreeList.Path, rightPath); } CompareFilesWindow compareWindow = new CompareFilesWindow(file1, file2); compareWindow.ShowDialog(); }
/* Buttons */ private void ViewButton_Click(object sender, RoutedEventArgs e) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; TreeListView treeListView = FocusedTabControl.SelectedContent as TreeListView; if (listView != null) { var currentItem = (listView.MainListView.SelectedItem as ListItem); var path = System.IO.Path.Combine(listView.PathManager.Path, currentItem.Name); MessageBox.Show(path + "\n" + "Total space occupied:" + GetDirectorySize(path) + "bytes \n" + currentItem.Date + "\n" + currentItem.Size); } else if (treeListView != null) { MessageBox.Show(treeListView.Path + "\n" + "Total space occupied:" + GetDirectorySize(treeListView.Path) + "bytes"); } }
public NewArchiveWindow(ListViewView window) { InitializeComponent(); listView = window; }
public NewFolderWindow(ListViewView window) { InitializeComponent(); listView = window; }