/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void registerEvents(FCView control) { FCTouchEvent clickButtonEvent = new FCTouchEvent(clickButton); List <FCView> controls = control.getControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { FCView subControl = controls[i]; FCButton button = subControl as FCButton; FCGrid grid = subControl as FCGrid; if (button != null) { button.addEvent(clickButtonEvent, FCEventID.CLICK); } else if (grid != null) { FCGridRowStyle rowStyle = new FCGridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = FCColor.None; rowStyle.SelectedBackColor = FCDraw.FCCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = FCDraw.FCCOLORS_HOVEREDROWCOLOR; rowStyle.SelectedTextColor = FCDraw.FCCOLORS_TEXTCOLOR4; } registerEvents(subControl); } }
/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void registerEvents(FCView control) { FCTouchEvent clickButtonEvent = new FCTouchEvent(clickButton); List <FCView> controls = control.getControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { FCButton button = controls[i] as FCButton; if (button != null) { button.addEvent(clickButtonEvent, FCEventID.CLICK); } registerEvents(controls[i]); } }
/// <summary> /// 检查焦点 /// </summary> /// <param name="control">控件</param> /// <returns>是否有焦点</returns> protected bool checkFocused(FCView control) { if (control.Focused) { return(true); } else { ArrayList <FCView> subControls = control.getControls(); if (subControls != null && subControls.size() > 0) { int subControlSize = subControls.size(); for (int i = 0; i < subControlSize; i++) { bool focused = checkFocused(subControls.get(i)); if (focused) { return(true); } } } return(false); } }
/// <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(); }