public void Disable() { EventManager.Off <PointerUpSignal>(OnPointerUp); EventManager.Off <PointerDownSignal>(OnPointerDown); EventManager.Off <PointerDragSignal>(OnPointerDrag); currentSvgRect = null; }
public void Add(SVGRectElement rectElement) { SVGGRect rect = new SVGGRect(rectElement.x.value, rectElement.y.value, rectElement.width.value, rectElement.height.value, rectElement.rx.value, rectElement.ry.value); SetFirstPoint(new Vector2(rect.x, rect.y)); listObject.Add(rect); }
private void OnPointerDown(PointerDownSignal ev) { currentSvgRect = currentSvgRect = document.createElementNS(ToolUtils.SvgNamespace, "rect") as SVGRectElement; currentSvgRect.setAttributeNS(null, "x", $"{ev.StageX}px"); currentSvgRect.setAttributeNS(null, "y", $"{ev.StageY}px"); currentSvgRect.setAttributeNS(null, "width", "0"); currentSvgRect.setAttributeNS(null, "height", "0"); currentSvgRect.setAttributeNS(null, "stroke", "black"); currentSvgRect.setAttributeNS(null, "fill", "transparent"); currentSvgRect.style.pointerEvents = "none"; Stage.Current.Canvas.CurrentLayer.Element.Append(new jQuery(currentSvgRect)); }
private void OnPointerUp(PointerUpSignal ev) { if (currentSvgRect != null) { if (ev.MouseButton != ev.ActualButton) { currentSvgRect.remove(); currentSvgRect = null; } else { currentSvgRect = null; } } }
private void RenderRectElement(SVGRectElement rectElement, ISVGPathDraw pathDraw) { SVGPoint p1, p2, p3, p4; float tx = rectElement.x.value; float ty = rectElement.y.value; float tw = rectElement.width.value; float th = rectElement.height.value; p1 = new SVGPoint(tx, ty); p2 = new SVGPoint(tx + tw, ty); p3 = new SVGPoint(tx + tw, ty + th); p4 = new SVGPoint(tx, ty + th); if(rectElement.rx.value == 0.0f && rectElement.ry.value == 0.0f) { p1 = p1.MatrixTransform(matrixTransform); p2 = p2.MatrixTransform(matrixTransform); p3 = p3.MatrixTransform(matrixTransform); p4 = p4.MatrixTransform(matrixTransform); pathDraw.Rect(p1, p2, p3, p4); } else { float t_rx = rectElement.rx.value; float t_ry = rectElement.ry.value; t_rx = (t_rx == 0.0f) ? t_ry : t_rx; t_ry = (t_ry == 0.0f) ? t_rx : t_ry; t_rx = (t_rx > (tw * 0.5f - 2f)) ? (tw * 0.5f - 2f) : t_rx; t_ry = (t_ry > (th * 0.5f - 2f)) ? (th * 0.5f - 2f) : t_ry; float angle = transformAngle; SVGPoint t_p1 = new SVGPoint(p1.x + t_rx, p1.y).MatrixTransform(matrixTransform); SVGPoint t_p2 = new SVGPoint(p2.x - t_rx, p2.y).MatrixTransform(matrixTransform); SVGPoint t_p3 = new SVGPoint(p2.x, p2.y + t_ry).MatrixTransform(matrixTransform); SVGPoint t_p4 = new SVGPoint(p3.x, p3.y - t_ry).MatrixTransform(matrixTransform); SVGPoint t_p5 = new SVGPoint(p3.x - t_rx, p3.y).MatrixTransform(matrixTransform); SVGPoint t_p6 = new SVGPoint(p4.x + t_rx, p4.y).MatrixTransform(matrixTransform); SVGPoint t_p7 = new SVGPoint(p4.x, p4.y - t_ry).MatrixTransform(matrixTransform); SVGPoint t_p8 = new SVGPoint(p1.x, p1.y + t_ry).MatrixTransform(matrixTransform); pathDraw.RoundedRect(t_p1, t_p2, t_p3, t_p4, t_p5, t_p6, t_p7, t_p8, t_rx, t_ry, angle); } }
public void Add(SVGRectElement rectElement) { SetFirstPoint(new SVGPoint(rectElement.x.value, rectElement.y.value)); SetLastPoint(new SVGPoint(rectElement.x.value, rectElement.y.value)); listType.Add(SVGPathElementType.Rect); listObject.Add(rectElement); }