private TreeViewItemFat addItemInRevertList(TreeViewItemFat item) { TreeViewItemFat ret = null; if (item.item.GetType() == typeof(FBDirectory)) { foreach (TreeViewItemFat i in item.Items) { addItemInRevertList(i); } } else { TreeViewItemFat el = findItem(revertList.Items, item); if (el != null) { UsefullMethods.setLabelAlert("danger", errorBox, "File is already in the revert list"); flashItem(el); } else { ret = item.Duplicate(); revertList.Items.Add(ret); item.Select = true; } } return(ret); }
public TreeViewItemFat Duplicate() { TreeViewItemFat newNode = new TreeViewItemFat() { Header = this.Header }; newNode.item = this.item; newNode.version = this.version; newNode.relativePath = this.relativePath; return newNode; }
private async void flashItem(TreeViewItemFat item) { Brush pc = item.Background; Color c = (Color)ColorConverter.ConvertFromString("#FFB13D14"); item.Background = new SolidColorBrush(c); await Task.Delay(700); item.Background = pc; }
public TreeViewItemFat Duplicate() { TreeViewItemFat newNode = new TreeViewItemFat() { Header = this.Header }; newNode.item = this.item; newNode.version = this.version; newNode.relativePath = this.relativePath; return(newNode); }
private void VersionView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeViewItemFat selectedItem = (TreeViewItemFat)this.versionView.SelectedItem; if (selectedItem != null) { if (selectedItem.item.GetType() == typeof(FBDirectory)) { this.preview.IsEnabled = false; } else { this.preview.IsEnabled = true; } } }
private void VersionView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { TreeViewItemFat selectedItem = (TreeViewItemFat)((TreeView)sender).SelectedItem; if (selectedItem != null && selectedItem.item != null) { if (sender == versionView) { addItemInRevertList(selectedItem); } else { revertList.Items.Remove(selectedItem); TreeViewItemFat el = findItem(versionView.Items, selectedItem); el.Select = false; } } }
private void preview_Click(object sender, RoutedEventArgs e) { TreeViewItemFat seletedItem = (TreeViewItemFat)versionView.SelectedItem; string filePath = null; try { filePath = se.getFile((FBFile)seletedItem.item); System.Diagnostics.Process.Start(filePath); } catch (System.ServiceModel.CommunicationException) { UsefullMethods.setLabelAlert("danger", errorBox, "Error with communication! Check your connection!"); } catch { UsefullMethods.setLabelAlert("danger", errorBox, "No file selected!"); } }
private TreeViewItem CreateDirectoryNode(FBDirectory root, string path) { TreeViewItemFat treeItem = new TreeViewItemFat(); treeItem.version = selectedVersion; treeItem.item = root; treeItem.Header = root.Name; treeItem.relativePath = path; foreach (String key in root.content.Keys) { if (root.content[key].GetType() == typeof(FBDirectory)) { FBDirectory child = (FBDirectory)root.content[key]; treeItem.Items.Add(CreateDirectoryNode(child, path + "\\" + child.Name)); treeItem.IsExpanded = true; } else { TreeViewItemFat ti = new TreeViewItemFat() { Header = key }; ti.version = selectedVersion; ti.item = root.content[key]; ti.relativePath = path; if (findItem(revertList.Items, ti) != null) { ti.Select = true; } treeItem.Items.Add(ti); } } if (root.content.Count == 0) { treeItem.Items.Add(new TreeViewItemFat() { Header = "" }); } return(treeItem); }
private TreeViewItemFat findItem(ItemCollection view, TreeViewItemFat item) { TreeViewItemFat ret = null; foreach (TreeViewItemFat el in view) { if (el.item != null) { if (el.item.GetType() == typeof(FBDirectory)) { ret = findItem(el.Items, item); if (ret != null) { return(ret); } } if (el.Equals(item)) { return(el); } } } return(null); }
public bool Equals(TreeViewItemFat other) { return (this.item.Name.Equals(other.item.Name) && this.relativePath.Equals(other.relativePath)); }
private TreeViewItemFat addItemInRevertList(TreeViewItemFat item) { TreeViewItemFat ret = null; if (item.item.GetType() == typeof(FBDirectory)) { foreach (TreeViewItemFat i in item.Items) { addItemInRevertList(i); } } else { TreeViewItemFat el = findItem(revertList.Items, item); if (el != null) { UsefullMethods.setLabelAlert("danger", errorBox, "File is already in the revert list"); flashItem(el); }else { ret = item.Duplicate(); revertList.Items.Add(ret); item.Select = true; } } return ret; }
private TreeViewItemFat findItem(ItemCollection view,TreeViewItemFat item) { TreeViewItemFat ret = null; foreach (TreeViewItemFat el in view) { if (el.item != null) { if (el.item.GetType() == typeof(FBDirectory)) { ret = findItem(el.Items, item); if (ret != null) { return ret; } } if (el.Equals(item)) { return el; } } } return null; }
private TreeViewItem CreateDirectoryNode(FBDirectory root, string path) { TreeViewItemFat treeItem = new TreeViewItemFat(); treeItem.version = selectedVersion; treeItem.item = root; treeItem.Header = root.Name; treeItem.relativePath = path; foreach (String key in root.content.Keys) { if (root.content[key].GetType() == typeof(FBDirectory)) { FBDirectory child = (FBDirectory)root.content[key]; treeItem.Items.Add(CreateDirectoryNode(child, path + "\\" + child.Name)); treeItem.IsExpanded = true; } else { TreeViewItemFat ti = new TreeViewItemFat() { Header = key }; ti.version = selectedVersion; ti.item = root.content[key]; ti.relativePath = path; if (findItem(revertList.Items, ti)!=null) { ti.Select = true; } treeItem.Items.Add(ti); } } if (root.content.Count == 0) { treeItem.Items.Add(new TreeViewItemFat() { Header = "" }); } return treeItem; }
public bool Equals(TreeViewItemFat other) { return(this.item.Name.Equals(other.item.Name) && this.relativePath.Equals(other.relativePath)); }