/// <summary> /// 控件触摸按下方法 /// </summary> /// <param name="touchInfo">触摸信息</param> public virtual void onControlTouchDown(FCTouchInfo touchInfo) { FCGrid grid = Grid; if (m_control != null && grid != null) { FCTouchInfo newTouchInfo = touchInfo.clone(); newTouchInfo.m_firstPoint = grid.pointToControl(m_control.pointToNative(touchInfo.m_firstPoint)); newTouchInfo.m_secondPoint = grid.pointToControl(m_control.pointToNative(touchInfo.m_secondPoint)); grid.onTouchDown(newTouchInfo); } }
/// <summary> /// 控件项鼠标移动事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值</param> private void toolBoxItemTouchMove(object sender, FCTouchInfo touchInto) { if (m_dragingItem.Visible) { FCView control = sender as FCView; FCPoint mp = touchInto.m_firstPoint; FCPoint location = control.pointToNative(mp); location.x += 10; location.y -= 16; m_dragingItem.Location = location; Native.invalidate(); } }
/// <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(); }
/// <summary> /// 控件项鼠标按下事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值</param> private void toolBoxItemTouchDown(object sender, FCTouchInfo touchInto) { if (touchInto.m_firstTouch && touchInto.m_clicks == 1) { if (m_xml != null) { FCPoint mp = touchInto.m_firstPoint; FCView control = sender as FCView; m_dragingItem.Visible = true; m_dragingItem.Text = control.Tag.ToString(); m_dragingItem.Location = control.pointToNative(mp); m_dragingItem.BackImage = "file='\\images\\" + control.Name + ".bmp' highcolor='255,0,255' lowcolor='255,0,255'"; Native.invalidate(); } } }
/// <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(); }