コード例 #1
0
        /// <summary>
        /// 鼠标抬起方法
        /// </summary>
        /// <param name="touchInto">触摸信息</param>
        public override void onTouchUp(FCTouchInfo touchInto)
        {
            m_point2 = Native.TouchPoint;
            base.onTouchUp(touchInto);
            if (!IsDragging)
            {
                FCView divDesigner = Parent;
                if (m_resizePoint != -1)
                {
                    FCRect nowRect = convertBoundsToPRect(Bounds);
                    //移动控件
                    int targetsSize = m_targets.Count;
                    if (targetsSize > 0)
                    {
                        m_designerDiv.saveUndo();
                        for (int i = 0; i < targetsSize; i++)
                        {
                            FCView  target      = m_targets[i];
                            FCPoint oldLocation = target.Location;
                            FCSize  oldSize     = target.Size;
                            oldLocation.x += nowRect.left - m_startRect.left;
                            oldLocation.y += nowRect.top - m_startRect.top;
                            oldSize.cx    += (nowRect.right - nowRect.left) - (m_startRect.right - m_startRect.left);
                            oldSize.cy    += (m_startRect.top - m_startRect.bottom) - (nowRect.top - nowRect.bottom);
                            if (oldSize.cx < 4)
                            {
                                oldSize.cx = 4;
                            }
                            else if (oldSize.cy < 4)
                            {
                                oldSize.cy = 4;
                            }
                            m_xml.setProperty(target, "location", FCStr.convertPointToStr(oldLocation));
                            m_xml.setProperty(target, "size", FCStr.convertSizeToStr(oldSize));
                            target.update();
                        }
                    }
                    m_designerDiv.Designer.refreshProperties();
                }
                else
                {
                    if (m_targets.Count == 1)
                    {
                        if (Math.Abs(m_point1.x - m_point2.x) > 5 && Math.Abs(m_point1.y - m_point2.y) > 5)
                        {
                            //获取选中控件
                            FCView        target = m_targets[0];
                            FCRect        moveRect = getRectangle(pointToControl(m_point1), pointToControl(m_point2));
                            List <FCView> newTargets = new List <FCView>();
                            List <FCView> subControls = target.getControls();
                            int           left = 0, top = 0, right = 0, bottom = 0, idx = 0;
                            int           subControlsSize = subControls.Count;
                            for (int i = 0; i < subControlsSize; i++)
                            {
                                FCView subControl = subControls[i];
                                FCRect bounds     = subControl.Bounds;
                                FCRect tempRect   = new FCRect();
                                if (Native.Host.getIntersectRect(ref tempRect, ref moveRect, ref bounds) > 0)
                                {
                                    newTargets.Add(subControl);
                                    if (idx == 0)
                                    {
                                        left   = bounds.left;
                                        top    = bounds.top;
                                        right  = bounds.right;
                                        bottom = bounds.bottom;
                                    }
                                    else
                                    {
                                        if (left > bounds.left)
                                        {
                                            left = bounds.left;
                                        }
                                        if (top > bounds.top)
                                        {
                                            top = bounds.top;
                                        }
                                        if (right < bounds.right)
                                        {
                                            right = bounds.right;
                                        }
                                        if (bottom < bounds.bottom)
                                        {
                                            bottom = bounds.bottom;
                                        }
                                    }
                                    idx++;
                                }
                            }
                            if (newTargets.Count > 0)
                            {
                                FCPoint p1 = target.pointToNative(new FCPoint(left, top));
                                FCPoint p2 = target.pointToNative(new FCPoint(right, bottom));
                                p1     = divDesigner.pointToControl(p1);
                                p2     = divDesigner.pointToControl(p2);
                                Bounds = convertPRectToBounds(new FCRect(p1.x, p1.y, p2.x, p2.y));
                                clearTargets();
                                addTargets(newTargets);
                                m_designerDiv.Designer.refreshProperties(newTargets);
                            }
                        }
                    }
                }
            }
            refreshStatusBar();
            m_resizePoint = -1;
            Cursor        = FCCursors.Arrow;
            FCNative native = Native;

            native.Host.setCursor(FCCursors.Arrow);
            native.update();
            native.invalidate();
        }