Beispiel #1
0
        public FileItem(StorageView view, FolderNode parent, StorageFile file, bool temp)
        {
            View = view;
            Folder = parent;

            SubItems.Add("");
            SubItems.Add("");

            Details = file;
            Temp = temp;

            UpdateInterface();
        }
Beispiel #2
0
        public FileItem(StorageView view, FolderNode folder)
        {
            View = view;
            Folder = folder;

            SubItems.Add("");
            SubItems.Add("");

            IsFolder = true;
            ImageIndex = folder.Details.IsFlagged(StorageFlags.Archived) ? 3 : 2;

            Details = folder.Details;
            Changes = folder.Changes;
            Temp = folder.Temp;

            UpdateInterface();
        }
Beispiel #3
0
        public void SetNote(string path, StorageItem targetItem, bool isFile, string note)
        {
            note = (note.Length == 0) ? null : note;

            LinkedList<StorageItem> archived = null;

            string name = "";

            // file
            if (isFile)
            {
                name = Path.GetFileName(path);
                path = Utilities.StripOneLevel(path);
                LocalFolder folder = GetLocalFolder(path);
                LocalFile file = folder.GetFile(name);

                archived = file.Archived;
            }

            // folder
            else
            {
                LocalFolder folder = GetLocalFolder(path);

                archived = folder.Archived;
            }

            // update
            foreach (StorageItem item in archived)
                if (item == targetItem)
                {
                    item.Note = note;
                    item.SetFlag(StorageFlags.Modified);

                    Modified = true;
                    PeriodicSave = true;
                }

            if(isFile)
                Storages.CallFileUpdate(ProjectID, path, targetItem.UID, WorkingChange.Updated);
            else
                Storages.CallFolderUpdate(ProjectID, Utilities.StripOneLevel(path), targetItem.UID, WorkingChange.Updated);
        }
Beispiel #4
0
        public StorageActions ItemDiff(StorageItem item, StorageItem original)
        {
            StorageActions actions = StorageActions.None;

            if (original == null)
                return StorageActions.Created;

            if (item.Name != original.Name)
                actions = actions | StorageActions.Renamed;

            if (ScopeChanged(item.Scope, original.Scope))
                actions = actions | StorageActions.Scoped;

            if (item.IsFlagged(StorageFlags.Archived) && !original.IsFlagged(StorageFlags.Archived))
                actions = actions | StorageActions.Deleted;

            if (!item.IsFlagged(StorageFlags.Archived) && original.IsFlagged(StorageFlags.Archived))
                actions = actions | StorageActions.Restored;

            if (item.GetType() == typeof(StorageFile))
                if (!Utilities.MemCompare(((StorageFile)item).InternalHash, ((StorageFile)original).InternalHash))
                    actions = actions | StorageActions.Modified;

            return actions;
        }