Beispiel #1
0
        public void SwapWith(TagWrap second, DragProcessor.SwapMode mode)
        {
            if (second == null)
            {
                second = new TagWrap();
            }
            if (object.ReferenceEquals(this, second))
            {
                return;
            }
            switch (mode)
            {
            case DragProcessor.SwapMode.Copy:
                Tag = second.Tag.GetClone(this); break;

            case DragProcessor.SwapMode.Swap:
                var tmpTag = second.Tag;
                second.Tag = Tag;
                Tag        = tmpTag; break;

            default:
                Tag        = second.Tag;
                second.Tag = new Tag(); break;
            }
        }
Beispiel #2
0
        public static void DragNodes(TagWrap curTag, DragEventArgs e, Node insertBefore = null)
        {
            var data = (KVPair <TagWrap, Node[]>)e.Data.GetData(typeof(KVPair <TagWrap, Node[]>));

            if (data == null || !data.Val.Any())
            {
                return;
            }
            var tagFrom = data.Key;

            var mode = GetDragMode(e);

            if (mode == SwapMode.Copy)
            {
                curTag.Tag.Add(data.Val, insertBefore, true);
            }
            else
            {
                curTag.Tag.Add(data.Val, insertBefore, false);
                if (tagFrom != curTag)
                {
                    tagFrom.Tag.Remove(data.Val);
                }
            }
        }
Beispiel #3
0
        public Tag GetClone(TagWrap tWrap)
        {
            var clone = new Tag();

            clone.Header = Header;
            foreach (Node node in Nodelist)
            {
                clone.Nodelist.Add(node);
            }
            return(clone);
        }
Beispiel #4
0
        private void List_Drop(object sender, DragEventArgs e)
        {
            var pt = e.GetPosition(this);

            if (Math.Abs(pt.Y - _prewPt.Y) < 10)
            {
                return;
            }
            if (TagGrp == null)
            {
                return;
            }
            var tagWrap = e.Data.GetData(typeof(TagWrap)) as TagWrap;
            var mode    = DragProcessor.GetDragMode(e);

            if (tagWrap != null)
            {
                if (DragTo == null) // перетащили на пустое место
                {
                    TagGrp.TagList.Add(new TagWrap()
                    {
                        Tag = tagWrap.Tag
                    });
                    if (!CopyMode)
                    {
                        tagWrap.Tag = new Tag();
                    }
                }
                else
                {
                    if (SwapMode)
                    {
                        tagWrap.SwapWith(DragTo, mode);
                    }
                    else
                    {
                        TagWrap newTag = new TagWrap();
                        int     pos    = TagGrp.TagList.IndexOf(DragTo);
                        if (pos == -1)
                        {
                            pos = 0;
                        }
                        newTag.SwapWith(tagWrap, mode);
                        TagGrp.TagList.Insert(pos, newTag);
                    }
                }
            }

            else
            {
                DragProcessor.DragNodes(DragTo, e);
            }
        }
Beispiel #5
0
 public SmartFiled()
 {
     TagGrp    = new TagGroup();
     GridWidth = new GridWidth();
     TagGrp.TagList.Add(new TagWrap("Корзина"));
     TagGrp.TagList.Add(new TagWrap("Важное"));
     Cells = new TagWrap[3, 3];
     for (int i = 0; i < Cells.GetLength(0); i++)
     {
         for (int j = 0; j < Cells.GetLength(1); j++)
         {
             Cells[i, j] = new TagWrap(i.ToString() + j);
         }
     }
     foreach (var node in Cells[0, 0].Tag)
     {
         node.ViewStl.DetailsVisile = true;
     }
     WorkTag = new TagWrap("текущий");
     WorkTag.Tag.ViewStl.DetailsVisile = true;
 }
Beispiel #6
0
 private void ListItemDrop(object sender, DragEventArgs e)
 {
     DragTo = ((FrameworkElement)sender).DataContext as TagWrap;
 }
Beispiel #7
0
 public void Remove(TagWrap tag)
 {
     TagList.Remove(tag);
     OnPropertyChanged(nameof(TagList));
 }