Exemplo n.º 1
0
        public void Copy(IList <string> path, string name, GroupTreeTypeEnum type, IList <string> otherPath)
        {
            string     fullCurrentPath   = String.Empty;
            IContainer itemDirectoryFrom = FindItemDirectory(path);
            IContainer itemDirectoryTo   = FindItemDirectory(otherPath);

            IGroupTreeItem itemForCopy =
                itemDirectoryFrom.Items.FirstOrDefault(it => it.Name == name && it.Type == type);

            if (itemForCopy == null)
            {
                throw new DirectoryNotFoundException();
            }

            if (NameScan(itemDirectoryTo, itemForCopy.Name, itemForCopy.Type))
            {
                throw new ArgumentException("Element has already been");
            }

            IGroupTreeItem newItem = itemForCopy.Clone();

            newItem.Parent = itemDirectoryTo;
            itemDirectoryTo.Items.Add(newItem);

            _settings.Copy(path, name, type, otherPath);

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(newItem, otherPath, RegistryActionEnum.Added);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemCopied);
        }
Exemplo n.º 2
0
 void OnChangedStructureEvent(IGroupTreeItem item, IList <string> path, RegistryActionEnum action)
 {
     ChangedStructureEvent?.Invoke(this, new GroupTreeStructureChangedEventArg(item, action)
     {
         Path = path
     });
 }
Exemplo n.º 3
0
        public void Add(IList <string> path, IGroupTreeItem item)
        {
            string     fullCurrentPath = String.Empty;
            IContainer itemDirectory   = FindItemDirectory(path);

            if (NameScan(itemDirectory, item.Name, item.Type))
            {
                throw new ArgumentException("Element has already been");
            }

            item.Parent = itemDirectory;
            itemDirectory.Items.Add(item);

            switch (item)
            {
            case IContainer container:
                _settings.Add(path, new GroupSettingsContainer(container));
                break;

            case IGroup group:
                _settings.Add(path, new GroupSettingsGroup(group));
                break;

            default:
                throw new ArgumentException("Unknown type");
            }

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(item, path, RegistryActionEnum.Added);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemMoved);
        }
Exemplo n.º 4
0
        private void GetChildrenAccounts(IGroupTreeItem item, List <IAccountProjection> result)
        {
            switch (item)
            {
            case IGroup group:
                foreach (var groupAccount in group.Items)
                {
                    if (result.Contains(groupAccount))
                    {
                        continue;
                    }

                    result.Add(groupAccount);
                }
                break;

            case IContainer container:
                foreach (var containerItem in container.Items)
                {
                    GetChildrenAccounts(containerItem, result);
                }
                break;

            default:
                throw new ArgumentException("Unknown type");
            }
        }
Exemplo n.º 5
0
 void OnChangedGroupTreeItemNameEvent(IGroupTreeItem item, IList <string> path, string oldName, string newName)
 {
     ChangedGroupTreeItemNameEvent?.Invoke(this,
                                           new GroupTreeItemNameChangedEventArg(item, oldName, newName)
     {
         Path = path
     });
 }
Exemplo n.º 6
0
        public GroupTreeStructureChangedEventArg(IGroupTreeItem item, RegistryActionEnum action)
        {
            Action = action;
            switch (item)
            {
            case IGroup group:
                Item = new GroupProjection(group);
                break;

            case IContainer container:
                Item = new ContainerProjection(container);
                break;

            default:
                throw new ArgumentException("Unknown type");
            }
        }
Exemplo n.º 7
0
        public GroupTreeItemNameChangedEventArg(IGroupTreeItem item, string oldName, string newName)
        {
            switch (item)
            {
            case IGroup group:
                Item = new GroupProjection(group);
                break;

            case IContainer container:
                Item = new ContainerProjection(container);
                break;

            default:
                throw new ArgumentException("Unknown type");
            }
            OldName = oldName;
            NewName = newName;
        }
Exemplo n.º 8
0
        public void Delete(IList <string> path, string name, GroupTreeTypeEnum type)
        {
            string     fullCurrentPath = String.Empty;
            IContainer itemDirectory   = FindItemDirectory(path);

            IGroupTreeItem itemForDelete = itemDirectory.Items.FirstOrDefault(it => it.Name == name && it.Type == type);

            if (itemForDelete == null)
            {
                throw new DirectoryNotFoundException();
            }

            itemDirectory.Items.Remove(itemForDelete);
            _settings.Delete(path, name, type);

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(itemForDelete, path, RegistryActionEnum.Removed);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemDeleted);
        }
Exemplo n.º 9
0
        public void Rename(IList <string> path, string oldName, GroupTreeTypeEnum type, string newName)
        {
            string     fullCurrentPath = String.Empty;
            IContainer itemDirectory   = FindItemDirectory(path);

            IGroupTreeItem itemForRename =
                itemDirectory.Items.FirstOrDefault(it => it.Name == oldName && it.Type == type);

            if (itemForRename == null)
            {
                throw new DirectoryNotFoundException();
            }

            if (NameScan(itemDirectory, newName, type))
            {
                throw new ArgumentException("Element has already been");
            }

            itemForRename.Name = newName;

            _settings.Rename(path, oldName, type, newName);

            OnChangedGroupTreeItemNameEvent(itemForRename, path, oldName, newName);
        }