Example #1
0
        public DetailsForm(StorageView view, FolderNode folder, FileItem file)
        {
            InitializeComponent();

            View = view;
            Core = View.Core;
            Trust = View.Trust;

            TargetFolder = folder;
            TargetFile = file;

            EnableControls(View.Working != null);

            NameBox.Text = file.Text;

            SizeLabel.Text = Utilities.CommaIze(((StorageFile)file.Details).InternalSize) + " Bytes";

            LoadVis(file.Details.Scope);
        }
Example #2
0
        public string UnlockFile(FileItem file)
        {
            List<LockError> errors = new List<LockError>();

            string path = Storages.UnlockFile(UserID, ProjectID, file.Folder.GetPath(), (StorageFile)file.Details, false, errors);

            LockMessage.Alert(this, errors);

            file.UpdateInterface();
            SelectedInfo.RefreshItem();

            return path;
        }
Example #3
0
        public void LockFile(FileItem file)
        {
            List<LockError> errors = new List<LockError>();

            Storages.LockFileCompletely(UserID, ProjectID, file.Folder.GetPath(), file.Archived, errors);

            LockMessage.Alert(this, errors);

            file.UpdateInterface();
            SelectedInfo.RefreshItem();
        }
Example #4
0
        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();
        }
Example #5
0
        public int GetImageIndex(FileItem file)
        {
            if (file.IsFolder)
                return file.Folder.Details.IsFlagged(StorageFlags.Archived) ? 3 : 2;

            string ext = Path.GetExtension(file.Text);

            if (!IconMap.ContainsKey(ext))
            {
                IconMap[ext] = FileIcons.Count;

                Bitmap img = Win32.GetIcon(ext);

                if (img == null)
                    img = new Bitmap(16, 16);

                FileIcons.Add(img);
            }

            if (file.Details != null && file.Details.IsFlagged(StorageFlags.Archived))
                return 1;

            return IconMap[ext];
        }
Example #6
0
 public RescanFile(string path, FileItem item)
 {
     Path = path;
     Item = item;
 }
Example #7
0
        void Storages_WorkingFileUpdate(uint project, string dir, ulong uid, WorkingChange action)
        {
            if (project != ProjectID)
                return;

             try
             {
                 LocalFolder workingFolder = Working.GetLocalFolder(dir);
                 FolderNode treeFolder = GetFolderNode(dir);

                 if (treeFolder == null || workingFolder == null)
                     return;

                 if (action == WorkingChange.Created)
                 {
                     LocalFile workingFile;

                     if (workingFolder.Files.SafeTryGetValue(uid, out workingFile))
                     {
                         FileItem treeFile = new FileItem(this, treeFolder, workingFile.Info, false);
                         treeFile.Archived = workingFile.Archived;

                         treeFolder.Files[treeFile.Details.UID] = treeFile;
                     }
                 }

                 else if (action == WorkingChange.Updated)
                 {
                     FileItem treeFile;
                     treeFolder.Files.TryGetValue(uid, out treeFile);

                     LocalFile workingFile;

                     if (workingFolder.Files.SafeTryGetValue(uid, out workingFile))
                         if (treeFile != null)
                         {
                             treeFile.Details = workingFile.Info;
                             treeFile.Archived = workingFile.Archived;

                             treeFile.UpdateInterface();
                             UpdateListItems();

                             if (treeFile == SelectedInfo.CurrentFile)
                                 SelectedInfo.ShowItem(SelectedFolder, treeFile);
                         }

                         // not there, add
                         else
                         {
                             treeFile = new FileItem(this, treeFolder, workingFile.Info, false);
                             treeFile.Archived = workingFile.Archived;

                             treeFolder.Files[treeFile.Details.UID] = treeFile;
                         }
                 }

                 else if (action == WorkingChange.Removed)
                 {
                     FileItem treeFile;
                     treeFolder.Files.TryGetValue(uid, out treeFile);

                     if (treeFile != null && treeFolder.Files.ContainsKey(treeFile.Details.UID))
                         treeFolder.Files.Remove(treeFile.Details.UID);
                 }

                 if (treeFolder == SelectedFolder)
                     SelectFolder(treeFolder);  // doesnt

                 CheckWorkingStatus();
             }
             catch (Exception ex)
             {
                 Core.Network.UpdateLog("Storage", "Interface:WorkingFileUpdate: " + ex.Message);
             }
        }
Example #8
0
        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();
        }
Example #9
0
        private FolderNode LoadWorking(TreeListNode parent, LocalFolder folder)
        {
            FolderNode node = new FolderNode(this, folder.Info, parent, false);
            node.Archived = folder.Archived;
            node.Integrated = folder.Integrated;

            if (SelectedFolder != null && node.Details.UID == SelectedFolder.Details.UID)
            {
                node.Selected = true;
                SelectedFolder = node;
            }

            if (!folder.Info.IsFlagged(StorageFlags.Archived) || GhostsButton.Checked)
                GuiUtils.InsertSubNode(parent, node);

            if (parent.GetType() == typeof(FolderNode))
            {
                FolderNode parentNode = (FolderNode)parent;
                parentNode.Folders[folder.Info.UID] = node;
            }

            if (node.Details.IsFlagged(StorageFlags.Modified))
                node.EnsureVisible();

            folder.Folders.LockReading(delegate()
            {
                foreach (LocalFolder sub in folder.Folders.Values)
                    LoadWorking(node, sub);
            });

            folder.Files.LockReading(delegate()
            {
                foreach (LocalFile file in folder.Files.Values)
                {
                    FileItem item = new FileItem(this, node, file.Info, false);
                    item.Archived = file.Archived;
                    item.Integrated = file.Integrated;

                    node.Files[file.Info.UID] = item;
                }
            });

            return node;
        }