void MoveFromGroup(BadgeFolder bf, ArgPoint ap)
        {
            if (!unsolvedCurrentTopicItems.Contains(ap) && bf.model.ArgPoint.Contains(ap))
            {
                ap.AgreementCode = (int)AgreementCode.Unsolved;
                bf.model.ArgPoint.Remove(ap);
                ap.Group = null;
                CtxSingleton.SaveChangesIgnoreConflicts();

                if (bf.model.ArgPoint.Count == 0)
                {
                    unsolvedCurrentTopicItems.Remove(bf.Parent); //todo: remove svi
                    bf = null;
                }
                unsolvedCurrentTopicItems.Add(ap);
            }
        }
 public void OnAttemptToBeginDragFromBadgeFolder(InputEventArgs e,
                                               BadgeFolder DragSource,
                                               ListBoxItem draggedElement,
                                               ObservableCollection<object> src)
 {
     if(cursorState==null)
         StartDragDrop(e, draggedElement, DragSource, src);
 }
        void MergeTwoBadges(ArgPoint p1, ArgPoint p2)
        {
            //merge operation is only possible over unsolved field 
            if (unsolvedCurrentTopicItems.Contains(p1) &&
                unsolvedCurrentTopicItems.Contains(p2))
            {
                p1.AgreementCode = (int)AgreementCode.UnsolvedAndGrouped;
                p2.AgreementCode = (int)AgreementCode.UnsolvedAndGrouped;

                unsolvedCurrentTopicItems.Remove(p1);
                unsolvedCurrentTopicItems.Remove(p2);

                BadgeFolder bf = new BadgeFolder();             
                
                p1.Group = bf.model;
                p2.Group = bf.model;              
                
                CtxSingleton.SaveChangesIgnoreConflicts();
                 
                bf.onAttemptToBeginDrag += OnAttemptToBeginDragFromBadgeFolder;
                bf.Width = 310;
                unsolvedCurrentTopicItems.Add(GetSVI(bf,true));
            }
        }
        bool MoveToGroup(BadgeFolder bf, ArgPoint ap)
        {
            if (unsolvedCurrentTopicItems.Contains(ap))
            {
                //rec. bin special case 
                if (bf == RecycleBin)
                {
                    //point moved to recycle bin, remove it
                    if (MessageBox.Show("Do you want to delete the point?",
                                        "About to delete",
                                        MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        ap.Group = null;
                        unsolvedCurrentTopicItems.Remove(ap);
                        CtxSingleton.Get().DeleteObject(ap);
                        CtxSingleton.SaveChangesIgnoreConflicts();
                        return true;
                    }
                }
                //move to private special case
                else if (bf == PrivIcon)
                {
                    if (ap.Person.Id == SessionInfo.Get().getPerson(null).Id)
                    {
                        ap.SharedToPublic = false;
                        CtxSingleton.SaveChangesIgnoreConflicts();
                        unsolvedCurrentTopicItems.Remove(ap);
                        _sharedClient.clienRt.SendNotifyStructureChanged(selectedTopic.Id);

                        return true;
                    }
                    else
                    {
                        MessageBox.Show("No permission");
                    }
                }
                else
                {
                    ap.AgreementCode = (int)AgreementCode.UnsolvedAndGrouped;
                    ap.Group = bf.model;
                    unsolvedCurrentTopicItems.Remove(ap);                                        
                    CtxSingleton.SaveChangesIgnoreConflicts();
                    return true;
                }  
            }

            return false;
        }
 ScatterViewItem CreateContainer(BadgeFolder bf)
 {
     ScatterViewItem svi = GetSVI(bf, true);
     return svi;
 }
        ScatterViewItem CreateSmallContainer(BadgeFolder bf)
        {
            Viewbox vb = new Viewbox();
            vb.StretchDirection = StretchDirection.Both;
            vb.Stretch = Stretch.Uniform;
            vb.Child = bf;

            ScatterViewItem svi = GetSVI(vb, true);
            return svi;
        }
 BadgeFolder GetBadgeFolder(Group g)
 {
     BadgeFolder bf = new BadgeFolder();
     bf.model = g;
     bf.onAttemptToBeginDrag += OnAttemptToBeginDragFromBadgeFolder;
     bf.Width = 310;
     return bf;
 }
        void _CreatePrivIconBin()
        {
            //recreate the bin for every topic to avoid duplicate visual parents
            PrivIcon = makeSpecialBadgeFolder("PrivIcon"); 

            //we add the recycle bin to all topics  
            if (!unsolvedCurrentTopicItems.Contains(PrivIcon))
            {
                ScatterViewItem svi = GetSVI(PrivIcon, true);
                svi.CanMove = false;
                svi.CanRotate = false;
                unsolvedCurrentTopicItems.Add(svi);
                svi.Center = new Point(RecycleBin.Width + PrivIcon.Width / 2, PrivIcon.Height / 2);
                svi.Orientation = 0;
            }
        }
 BadgeFolder makeSpecialBadgeFolder(string imgBrushName)
 {
     var res = new BadgeFolder();
     res.Width = 70;
     res.Height = 110;
     res.headerRect.Height = 0.1;
     res.headerText.Height = 0.1;
     res.argPointGroup.Width = res.Width;
     res.argPointGroup.Height = res.Height;
     res.headerText.Visibility = Visibility.Hidden;
     res.Background = (Brush)Application.Current.Resources[imgBrushName];
     res.scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
     res.scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
     return res;
 }