/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaint(FCPaint paint, FCRect clipRect) { int vh = 0; FCLayoutDiv layoutDiv = Parent as FCLayoutDiv; if (layoutDiv.HScrollBar != null && layoutDiv.HScrollBar.Visible) { vh = layoutDiv.HScrollBar.Height; } int width = Width, height = Height - vh; FCRect drawRect = new FCRect(0, 0, width, height); paint.fillRect(FCColor.argb(0, 0, 0), drawRect); paint.drawRect(FCColor.argb(50, 105, 217), 1, 0, drawRect); String text = Text; FCFont font = Font; FCSize tSize = paint.textSize(text, font); FCRect tRect = new FCRect((width - tSize.cx) / 2, (height - tSize.cy) / 2, (width + tSize.cx) / 2, (height + tSize.cy) / 2); paint.drawText(text, FCColor.argb(255, 0, 0), font, tRect); FCPoint[] points = new FCPoint[3]; points[0] = new FCPoint(0, 0); points[1] = new FCPoint(50, 0); points[2] = new FCPoint(0, 30); FCFont font3 = new FCFont("微软雅黑", 10, false, false, false); if (m_isUser) { paint.fillPolygon(FCColor.argb(255, 200, 0), points); FCDraw.drawText(paint, "自定义", FCColor.argb(0, 0, 0), font3, 2, 2); String btn1 = "编辑"; FCFont font2 = new FCFont("微软雅黑", 12, false, false, false); FCSize tSize2 = paint.textSize(btn1, font2); tRect = new FCRect(width - tSize2.cx - 20, height - tSize2.cy - 5, 0, 0); tRect.right = tRect.left + tSize2.cx; tRect.bottom = tRect.top + tSize2.cy; m_tRect = tRect; paint.drawText(btn1, FCColor.argb(80, 255, 80), font2, m_tRect); } else { paint.fillPolygon(FCColor.argb(80, 255, 255), points); FCDraw.drawText(paint, "系统", FCColor.argb(0, 0, 0), font3, 2, 2); } }
/// <summary> /// 加载布局控件的模板 /// </summary> /// <param name="layoutDiv">布局控件</param> /// <param name="node">节点</param> public static void LayoutDivTemplate(FCLayoutDiv layoutDiv, UIXmlEx xml, XmlNode node) { XmlDocument xmlDoc = node.OwnerDocument; layoutDiv.Size = new FCSize(200, 200); FCDiv div1 = new FCDiv(); div1.Name = CreateControlName(div1, xml); div1.Size = new FCSize(100, 100); layoutDiv.addControl(div1); XmlNode div1Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); node.AppendChild(div1Node); XmlAttribute xmlAtr4 = xmlDoc.CreateAttribute("name"); xmlAtr4.Value = div1.Name; div1Node.Attributes.Append(xmlAtr4); XmlAttribute xmlAtr5 = xmlDoc.CreateAttribute("size"); xmlAtr5.Value = "100,100"; div1Node.Attributes.Append(xmlAtr5); xml.m_controls.Add(div1); xml.Nodes[div1] = div1Node; FCDiv div2 = new FCDiv(); div2.Name = CreateControlName(div2, xml); div2.Size = new FCSize(100, 100); layoutDiv.addControl(div2); XmlNode div2Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); node.AppendChild(div2Node); XmlAttribute xmlAtr6 = xmlDoc.CreateAttribute("name"); xmlAtr6.Value = div2.Name; div2Node.Attributes.Append(xmlAtr6); XmlAttribute xmlAtr7 = xmlDoc.CreateAttribute("size"); xmlAtr7.Value = "100,100"; div2Node.Attributes.Append(xmlAtr7); xml.m_controls.Add(div2); xml.Nodes[div2] = div2Node; layoutDiv.update(); }