Beispiel #1
0
 public SearchItem(string iconName, string title, string toolTip, ICatTreeViewItem item)
 {
     IconName = iconName;
     Title    = title;
     ToolTip  = toolTip;
     Item     = item;
 }
 public CatTreeViewItemDoppedEventArgs(object data, ICatTreeViewItem dest, bool aboveDest, bool copy)
 {
     Data      = data;
     Dest      = dest;
     AboveDest = aboveDest;
     Copy      = copy;
 }
Beispiel #3
0
        public override void GroupCreate(ICatTreeViewItem root)
        {
            if (!GetNewName(false, string.Empty, out var newName,
                            root, ValidateNewGroupName, CategoryToIconName(Category)))
            {
                return;
            }

            ModelGroupCreate(root, newName);
        }
Beispiel #4
0
        public override void ItemRename(ICatTreeViewItem item)
        {
            if (!GetNewName(true, GetTitle(item), out var newName,
                            item, ValidateNewItemName, CategoryToIconName(Category)))
            {
                return;
            }

            try {
                ModelItemRename(item, newName);
                OnAfterItemRename(item, EventArgs.Empty);
            }
            catch (Exception ex) {
                ErrorDialog.Show(ex);
            }
        }
Beispiel #5
0
        public override void ItemCreate(ICatTreeViewItem root)
        {
            if (!GetNewName(true, string.Empty, out var newName,
                            root, ValidateNewItemName, CategoryToIconName(Category)))
            {
                return;
            }

            try {
                root.IsExpanded = true;
                var item = ModelItemCreate(root, newName);
                OnAfterItemCreate(item, EventArgs.Empty);
            }
            catch (Exception ex) {
                ErrorDialog.Show(ex);
            }
        }
        public static bool CanDrop(ICatTreeViewItem src, ICatTreeViewItem dest)
        {
            if (src == null || dest == null || Equals(src, dest) ||
                src.Parent.Equals(dest) || dest.Parent?.Equals(src) == true ||
                (src is ICatTreeViewGroup && dest is not ICatTreeViewGroup))
            {
                return(false);
            }

            // if src or dest categories are null or they are not equal
            if (Tree.GetTopParent(src) is not ICatTreeViewCategory srcCat ||
                Tree.GetTopParent(dest) is not ICatTreeViewCategory destCat ||
                !Equals(srcCat, destCat))
            {
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        public override void ItemDelete(ICatTreeViewItem item)
        {
            if (!DeleteAccepted(GetTitle(item)))
            {
                return;
            }

            try {
                var parent = item.Parent as ICatTreeViewItem;

                ModelItemDelete(item);

                // collapse parent if doesn't have any sub items
                if (parent != null && parent.Items.Count == 0)
                {
                    parent.IsExpanded = false;
                }

                OnAfterItemDelete(item, EventArgs.Empty);
            }
            catch (Exception ex) {
                ErrorDialog.Show(ex);
            }
        }
        public virtual void OnDrop(object src, ICatTreeViewItem dest, bool aboveDest, bool copy)
        {
            // groups
            if (src is ICatTreeViewGroup srcGroup && dest is ICatTreeViewGroup destGroup)
            {
                GroupMove(srcGroup, destGroup, aboveDest);
                return;
            }

            // items
            if (src is ICatTreeViewItem srcItem && dest != null)
            {
                if (copy)
                {
                    ItemCopy(srcItem, dest);
                }
                else
                {
                    ItemMove(srcItem, dest, aboveDest);
                }
            }

            OnAfterDrop(this, new(src, dest, aboveDest, copy));
        }
Beispiel #9
0
 protected virtual void ModelGroupCreate(ICatTreeViewItem root, string name) => throw new NotImplementedException();
Beispiel #10
0
 protected virtual string ValidateNewGroupName(ICatTreeViewItem root, string name) => throw new NotImplementedException();
Beispiel #11
0
 protected virtual void ModelItemDelete(ICatTreeViewItem item) => throw new NotImplementedException();
 public virtual void ItemCopy(ICatTreeViewItem item, ICatTreeViewItem dest) => throw new NotImplementedException();
Beispiel #13
0
        private static bool GetNewName(bool forItem, string oldName, out string newName, ICatTreeViewItem item, Func <ICatTreeViewItem, string, string> validator, string icon)
        {
            var action   = string.IsNullOrEmpty(oldName) ? "New" : "Rename";
            var target   = forItem ? "Item" : "Group";
            var question = string.IsNullOrEmpty(oldName)
        ? $"Enter the name of the new {target}."
        : $"Enter the new name for the {target}.";
            var result = InputDialog.Open(
                icon,
                $"{action} {target}",
                question,
                oldName,
                answer => validator(item, answer),
                out newName);

            return(result);
        }
 public virtual bool CanDrop(object src, ICatTreeViewItem dest) => CanDrop(src as ICatTreeViewItem, dest);
 public virtual void GroupCreate(ICatTreeViewItem root) => throw new NotImplementedException();
 public virtual void ItemMove(ICatTreeViewItem item, ICatTreeViewItem dest, bool aboveDest) => throw new NotImplementedException();
Beispiel #17
0
 protected virtual void ModelItemRename(ICatTreeViewItem item, string name) => throw new NotImplementedException();
 public virtual void ItemDelete(ICatTreeViewItem item) => throw new NotImplementedException();