/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void resetScaleSize(FCSize clientSize) { FCNative native = Native; if (native != null) { FCHost host = native.Host; FCSize nativeSize = native.DisplaySize; List <FCView> controls = native.getControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { FCWindowFrame frame = controls[i] as FCWindowFrame; if (frame != null) { WindowEx window = frame.getControls()[0] as WindowEx; if (window != null && !window.AnimateMoving) { FCPoint location = window.Location; if (location.x < 10 || location.x > nativeSize.cx - 10) { location.x = 0; } if (location.y < 30 || location.y > nativeSize.cy - 30) { location.y = 0; } window.Location = location; } } } native.ScaleSize = new FCSize((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.update(); } }
/// <summary> /// 加载 /// </summary> /// <param name="name">名称</param> public void loadXml(String name) { if (name == "MainFrame") { m_xml = new MainFrame(); } m_xml.createNative(); m_native = m_xml.Native; m_native.Paint = new GdiPlusPaintEx(); m_host = new WinHostEx(); m_host.Native = m_native; m_native.Host = m_host; m_host.HWnd = Handle; m_native.AllowScaleSize = true; m_native.DisplaySize = new FCSize(ClientSize.Width, ClientSize.Height); m_xml.resetScaleSize(GetClientSize()); m_xml.Script = new FaceCatScript(m_xml); m_xml.Native.ResourcePath = DataCenter.getAppPath() + "\\config"; m_xml.load(DataCenter.getAppPath() + "\\config\\" + name + ".html"); m_host.ToolTip = new FCToolTip(); m_host.ToolTip.Font = new FCFont("SimSun", 20, true, false, false); (m_host.ToolTip as FCToolTip).InitialDelay = 250; m_native.update(); Invalidate(); }
/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void resetScaleSize(FCSize clientSize) { FCNative native = Native; if (native != null) { native.ScaleSize = new FCSize((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.update(); } }
/// <summary> /// 加载XML /// </summary> /// <param name="fileName">文件名</param> public void loadFile(String fileName) { //创建XML解析器 m_xml = new UIXmlEx3(); //链接控件库 m_xml.createNative(); m_native = m_xml.Native; m_xml.Script = new DesignerScript(m_xml); m_native.Paint = new GdiPlusPaintEx(); m_native.Host = new WinHostEx(); m_native.Host.Native = m_native; m_host = m_native.Host as WinHostEx; m_host.HWnd = Handle; m_native.AllowScaleSize = true; m_native.DisplaySize = new FCSize(ClientSize.Width, ClientSize.Height); m_xml.resetScaleSize(getClientSize()); m_native.invalidate(); m_xml.loadFile(fileName, null); m_native.update(); m_native.invalidate(); }
/// <summary> /// 添加镜像 /// </summary> /// <param name="native">库</param> /// <param name="target">目标</param> public void addBugHole(FCNative native, FCView target) { if (m_native == null) { m_native = new FCNative(); m_native.MirrorMode = FCMirrorMode.BugHole; m_native.Paint = new GdiPlusPaintEx(); m_native.Host = new WinHostEx(); m_native.Host.Native = m_native; m_native.ResourcePath = WinHostEx.getAppPath() + "\\config"; m_host = m_native.Host as WinHostEx; m_host.HWnd = Handle; //设置尺寸 m_native.AllowScaleSize = true; m_native.DisplaySize = new FCSize(ClientSize.Width, ClientSize.Height); resetScaleSize(getClientSize()); } m_native.addMirror(native, target); m_native.update(); m_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(); }