コード例 #1
0
        private void FinalizeOrdering(FrameworkElement element)
        {
            _returnSite    = null;
            _mouseLockSite = null;

            ReleaseOrderedSequence(element, _elements);

            _elements = null;
        }
コード例 #2
0
        private void ArrangeElements(ElementSite except)
        {
            var offset = 0.0;

            foreach (var element in _elements)
            {
                if (element != except)
                {
                    element.Offset = offset;
                }

                offset += element.Size;
            }
        }
コード例 #3
0
        public void OnOrderMove(FrameworkElement element, Vector delta)
        {
            var elementSite   = GetActualSite(element);
            var mousePosition = GetMousePosition(element);

            elementSite.Position = elementSite.OriginalPosition.Offset((Point)delta);

            if (_returnSite != null && _returnSite.Contains(mousePosition))
            {
                _elements.Swap(_returnSiteData.Item1, _returnSiteData.Item2);

                ArrangeElements(elementSite);

                _mouseLockSite = null;
                _returnSite    = null;

                return;
            }

            if (_mouseLockSite != null && _mouseLockSite.Contains(mousePosition))
            {
                return;
            }

            _mouseLockSite = null;

            var mouseSite = _elements.SingleOrDefault(e => e != elementSite && e.Contains(mousePosition));

            if (mouseSite == null)
            {
                return;
            }

            _returnSite     = GetArrangedElement(elementSite);
            _returnSiteData = new Tuple <ElementSite, ElementSite>(mouseSite, elementSite);
            _elements.Swap(elementSite, mouseSite);

            ArrangeElements(elementSite);

            _mouseLockSite = GetArrangedElement(mouseSite);
        }
コード例 #4
0
 private ElementSite GetArrangedElement(ElementSite element)
 {
     return(new ElementSite(CalcElementOffset(_elements, element), element.Size, element.Orientation));
 }
コード例 #5
0
 public double CalcElementOffset(List <ElementSite> elementSites, ElementSite element)
 {
     return(elementSites.TakeWhile(c => c != element).Sum(c => c.Size));
 }