public void OpenFile(FileItem file) { string path = null; // if temp and changes exist (then remote) if (file.Temp) { // remote file that doesnt exist local yet if (file.Changes.Count > 0) { foreach (ulong id in file.Changes.Keys) if (file.Changes[id] == file.Details) path = UnlockFile(file); } // local temp file else path = Storages.GetRootPath(UserID, ProjectID) + file.GetPath(); } // non temp file else path = UnlockFile(file); if (path != null && File.Exists(path)) Process.Start(path); file.UpdateInterface(); FileListView.Invalidate(); }
private void SelectFolder(FolderNode folder) { if (folder == null) return; /* * * if (!SelectedInfo.IsFile && SelectedInfo.CurrentFolder != null) { if (SelectedInfo.CurrentFolder.Details.UID == SelectedFolder.Details.UID) SelectedInfo.ShowItem(SelectedFolder, null); else SelectedInfo.ShowDefault(); } * */ bool infoSet = false; string infoPath = SelectedInfo.CurrentPath; SelectedFolder = folder; folder.Selected = true; string dirpath = null; if (Working != null) dirpath = Working.RootPath + folder.GetPath(); ulong selectedUID = 0; if (SelectedInfo.CurrentItem != null) selectedUID = SelectedInfo.CurrentItem.UID; FileListView.Items.Clear(); FileListView.SmallImageList = FileIcons; // add sub folders if (!FoldersButton.Checked && folder.Parent.GetType() == typeof(FolderNode)) { FileItem dots = new FileItem(this, new FolderNode(this, new StorageFolder(), folder.Parent, false)); dots.Folder.Details.Name = ".."; dots.Text = ".."; if (string.Compare("..", infoPath, true) == 0) { infoSet = true; dots.Selected = true; SelectedInfo.ShowDots(); } FileListView.Items.Add(dots); } foreach (FolderNode sub in folder.Nodes) { FileItem subItem = new FileItem(this, sub); if (string.Compare(sub.GetPath(), infoPath, true) == 0) { infoSet = true; subItem.Selected = true; SelectedInfo.ShowItem(sub, null); } FileListView.Items.Add(subItem); } // if folder unlocked, add untracked folders, mark temp if(folder.Details.IsFlagged(StorageFlags.Unlocked) && Directory.Exists(dirpath)) try { foreach (string dir in Directory.GetDirectories(dirpath)) { string name = Path.GetFileName(dir); if (name.CompareTo(".history") == 0) continue; if (folder.GetFolder(name) != null) continue; StorageFolder details = new StorageFolder(); details.Name = name; FileItem tempFolder = new FileItem(this, new FolderNode(this, details, folder, true)); if (string.Compare(tempFolder.GetPath(), infoPath, true) == 0) { infoSet = true; tempFolder.Selected = true; SelectedInfo.ShowItem(tempFolder.Folder, null); } FileListView.Items.Add(tempFolder); } } catch { } // add tracked files foreach (FileItem file in folder.Files.Values) if (!file.Details.IsFlagged(StorageFlags.Archived) || GhostsButton.Checked) { if (string.Compare(file.GetPath(), infoPath, true) == 0) { infoSet = true; file.Selected = true; SelectedInfo.ShowItem(folder, file); } else file.Selected = false; FileListView.Items.Add(file); } // if folder unlocked, add untracked files, mark temp if (folder.Details.IsFlagged(StorageFlags.Unlocked) && Directory.Exists(dirpath)) try { foreach (string filepath in Directory.GetFiles(dirpath)) { string name = Path.GetFileName(filepath); if (folder.GetFile(name) != null) continue; StorageFile details = new StorageFile(); details.Name = name; details.InternalSize = new FileInfo(filepath).Length; FileItem tempFile = new FileItem(this, folder, details, true); if (string.Compare(tempFile.GetPath(), infoPath, true) == 0) { infoSet = true; tempFile.Selected = true; SelectedInfo.ShowItem(folder, tempFile); } FileListView.Items.Add(tempFile); } } catch { } UpdateListItems(); if (!infoSet && SelectedFolder.GetPath() == infoPath) { infoSet = true; SelectedInfo.ShowItem(SelectedFolder, null); } if (!infoSet) SelectedInfo.ShowDiffs(); }