Example #1
0
        /// <summary>
        /// 拖动结束方法
        /// </summary>
        public override void onDragEnd()
        {
            base.onDragEnd();
            int    targetsSize = m_targets.Count;
            FCView divDesigner = Parent;
            //判定区域
            FCNative native = Native;

            m_designerDiv.saveUndo();
            FCPoint mp = Native.TouchPoint;

            for (int i = 0; i < targetsSize; i++)
            {
                FCView  target            = m_targets[i];
                FCView  parent            = target.Parent;
                bool    outControl        = false;
                FCPoint oldNativeLocation = target.pointToNative(new FCPoint(0, 0));
                if (parent != null)
                {
                    if (divDesigner != null)
                    {
                        //查找新的控件
                        m_acceptTouch = false;
                        FCView newParent = native.findControl(mp, divDesigner);
                        m_acceptTouch = true;
                        if (newParent != null && m_xml.isContainer(newParent) && newParent != this && newParent != parent &&
                            target != newParent)
                        {
                            //移除控件
                            m_xml.removeControl(target);
                            //添加控件
                            m_xml.addControl(target, newParent);
                            parent     = newParent;
                            outControl = true;
                        }
                    }
                }
                if (outControl || canDragTargets())
                {
                    FCRect newRect = convertBoundsToPRect(Bounds);
                    oldNativeLocation.x += newRect.left - m_startRect.left;
                    oldNativeLocation.y += newRect.top - m_startRect.top;
                    m_xml.setProperty(target, "location", FCStr.convertPointToStr(target.Parent.pointToControl(oldNativeLocation)));
                    target.update();
                }
            }
            m_designerDiv.Designer.refreshProperties();
            refreshStatusBar();
            divDesigner.update();
        }