private void GenerateArc2(Arc arc, SysCAD.Protocol.Size defaultSize) { tempText += "MDrw_Arc2 " + (arc.x / 100.0F * defaultSize.Width).ToString() + ", " + (arc.y / 100.0F * defaultSize.Height).ToString() + ", " + (arc.w / 100.0F * defaultSize.Width).ToString() + ", " + (arc.h / 100.0F * defaultSize.Height).ToString() + ", " + arc.a.ToString() + ", " + arc.s.ToString() + "\r\n"; }
private void Generate(SysCAD.Protocol.Rectangle rectangle, SysCAD.Protocol.Size defaultSize, TextBox textBox) { textBox.Text = rectangle.X.ToString() + ", " + rectangle.Y.ToString() + ", " + rectangle.Width.ToString() + ", " + rectangle.Height.ToString(); }
private void GeneratePoly(bool first, Line line, SysCAD.Protocol.Size defaultSize) { if ((first) || ((line.x1 != xj) || (line.y1 != yj))) { if (!first) tempText += "\r\n"; tempText += "MDrw_Poly " + (line.x1 / 100.0F * defaultSize.Width).ToString() + ", " + (line.y1 / 100.0F * defaultSize.Height).ToString() + ", " + (line.x2 / 100.0F * defaultSize.Width).ToString() + ", " + (line.y2 / 100.0F * defaultSize.Height).ToString(); } else { tempText += ", " + (line.x2 / 100.0F * defaultSize.Width).ToString() + ", " + (line.y2 / 100.0F * defaultSize.Height).ToString(); } xj = line.x2; yj = line.y2; }
private bool ParseTagArea(ref SysCAD.Protocol.Rectangle rectangleF, TextBox textBox) { if (textBox.Text.Length > 0) { string[] atoms = textBox.Text.Split(charSplitArray, StringSplitOptions.RemoveEmptyEntries); if (atoms.Length != 4) { toolStripStatusLabel1.Text = "Incorrect number of parameters (x, y, w, h): " + textBox.Text; toolStripStatusLabel1.BackColor = Color.Yellow; return false; } try { rectangleF.X = float.Parse(atoms[0]); rectangleF.Y = float.Parse(atoms[1]); rectangleF.Width = float.Parse(atoms[2]); rectangleF.Height = float.Parse(atoms[3]); } catch { toolStripStatusLabel1.Text = "Error parsing parameters (x, y, w, h): " + textBox.Text; toolStripStatusLabel1.BackColor = Color.Yellow; return false; } } return true; }
private void Generate(ArrayList arrayList, SysCAD.Protocol.Size defaultSize, TextBox textBox) { bool firstLineInPoly = true; tempText = ""; xj = float.NaN; yj = float.NaN; foreach (object element in arrayList) { if (element is Line) { Line line = element as Line; GeneratePoly(firstLineInPoly, line, defaultSize); firstLineInPoly = false; } else if (element is Arc) { if (!firstLineInPoly) tempText += "\r\n"; Arc arc = element as Arc; GenerateArc2(arc, defaultSize); firstLineInPoly = true; } else if (element is Bezier) { if (!firstLineInPoly) tempText += "\r\n"; Bezier bezier = element as Bezier; GenerateBezier(bezier, defaultSize); firstLineInPoly = true; } else if (element is Anchor) { if (!firstLineInPoly) tempText += "\r\n"; Anchor anchor = element as Anchor; GenerateAnchor(anchor, defaultSize); firstLineInPoly = true; } } textBox.Text = tempText; }
public void LogMessage(out Int64 requestId, String message, SysCAD.Log.MessageType messageType) { serviceGraphic.LogMessage(out requestId, message, messageType); }
private void fcFlowChart_LinkChanged(Int64 eventId, Int64 requestId, Guid guid, String tag, String classId, Guid origin, Guid destination, String originPort, String destinationPort, List<SysCAD.Protocol.Point> controlPoints, SysCAD.Protocol.Rectangle textArea, Double textAngle) { EditorLink link = state.Link(guid); if (link != null) { GraphicLink graphicLink = link.GraphicLink; ModelLink modelLink = link.ModelLink; graphicLink.Origin = origin; graphicLink.Destination = destination; modelLink.OriginPort = originPort; modelLink.DestinationPort = destinationPort; graphicLink.ControlPoints = controlPoints; graphicLink.TagArea = textArea; graphicLink.TagAngle = textAngle; Arrow arrow = link.Arrow; EditorNode originItem = null; EditorNode destinationItem = null; if (graphicLink.Origin != Guid.Empty) originItem = state.Item(graphicLink.Origin); if (graphicLink.Destination != Guid.Empty) destinationItem = state.Item(graphicLink.Destination); if (originItem != null) arrow.Origin = originItem.ModelBox; if (destinationItem != null) arrow.Destination = destinationItem.ModelBox; if ((modelLink.OriginPort != null) && ((originItem.ModelBox.Tag as EditorNode).anchorTagToInt.ContainsKey(modelLink.OriginPort + graphicLink.OriginPortID.ToString(CultureInfo.InvariantCulture)))) arrow.OrgnAnchor = (originItem.ModelBox.Tag as EditorNode).anchorTagToInt[modelLink.OriginPort + graphicLink.OriginPortID.ToString(CultureInfo.InvariantCulture)]; else arrow.OrgnAnchor = -1; if ((modelLink.DestinationPort != null) && ((destinationItem.ModelBox.Tag as EditorNode).anchorTagToInt.ContainsKey(modelLink.DestinationPort + graphicLink.DestinationPortID.ToString(CultureInfo.InvariantCulture)))) arrow.DestAnchor = (destinationItem.ModelBox.Tag as EditorNode).anchorTagToInt[modelLink.DestinationPort + graphicLink.DestinationPortID.ToString(CultureInfo.InvariantCulture)]; else arrow.DestAnchor = -1; String toolTipOriginPort = modelLink.OriginPort; String toolTipDestinationPort = modelLink.DestinationPort; if (toolTipOriginPort == null) toolTipOriginPort = "*"; if (toolTipDestinationPort == null) toolTipDestinationPort = "*"; String originItemTag = "--"; if (originItem != null) originItemTag = originItem.Tag; String destinationItemTag = "--"; if (destinationItem != null) destinationItemTag = destinationItem.Tag; arrow.ToolTip = "Tag:" + graphicLink.Tag + "\nSrc: " + originItemTag + ":" + toolTipOriginPort + "\nDst: " + destinationItemTag + ":" + toolTipDestinationPort; arrow.ArrowHead = ArrowHead.Triangle; arrow.Style = ArrowStyle.Cascading; if (graphicLink.ControlPoints != null && graphicLink.ControlPoints.Count > 1) { State.SetControlPoints(arrow, graphicLink.ControlPoints); } } }
static private Double Distance(SysCAD.Protocol.Point a, SysCAD.Protocol.Point b) { return Math.Sqrt(((a.X - b.X) * (a.X - b.X)) + ((a.Y - b.Y) * (a.Y - b.Y))); }
private ShapeTemplate GetShapeTemplate(SysCAD.Protocol.ModelStencil stencil) { int i; if (stencil != null) { ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; i = 0; foreach (Element element in stencil.Elements) { elementTemplate[i] = Element(element); i++; } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; i = 0; foreach (Element decoration in stencil.Decorations) { decorationTemplate[i] = Element(decoration); i++; } return (new ShapeTemplate(elementTemplate, decorationTemplate, null, System.Drawing.Drawing2D.FillMode.Alternate, stencil.Tag)); } else return null; }
internal bool MergePoints(SysCAD.Protocol.Point point1, SysCAD.Protocol.Point point2) { return Math.Abs(point1.X - point2.X) <= fcFlowChart.MergeThreshold && Math.Abs(point1.Y - point2.Y) <= fcFlowChart.MergeThreshold; }
internal static SysCAD.Protocol.Point rotatePointAt(SysCAD.Protocol.Point point, SysCAD.Protocol.Point pivot, Double angle) { PointF[] points = new PointF[] { point.ToPointF() }; Matrix rotation = new Matrix(); rotation.RotateAt((float)angle, pivot.ToPointF()); rotation.TransformPoints(points); rotation.Dispose(); return new SysCAD.Protocol.Point(points[0]); }
internal static SysCAD.Protocol.Point getCenter(SysCAD.Protocol.Rectangle rect) { return new SysCAD.Protocol.Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); }
static public SysCAD.Protocol.Point GetRelativeAnchorPosition(SysCAD.Protocol.Rectangle nodeRect, Double x, Double y, Double angle) { SysCAD.Protocol.Point point = new SysCAD.Protocol.Point(nodeRect.X + nodeRect.Width * x / 100.0, nodeRect.Y + nodeRect.Height * y / 100.0); if (angle != 0) { point = rotatePointAt(point, getCenter(nodeRect), angle); } return point; }
public void AddAction(SysCAD.Protocol.Action newAction) { actionExpire.Stop(); foreach (Item item in newAction.Create) { action.Create.Add(item); } foreach (Item item in newAction.Modify) { action.Modify.Add(item); } actionExpire.Start(); }
private void GenerateBezier(Bezier bezier, SysCAD.Protocol.Size defaultSize) { tempText += "MDrw_Bezier " + (bezier.x1 / 100.0F * defaultSize.Width).ToString() + ", " + (bezier.y1 / 100.0F * defaultSize.Height).ToString() + ", " + (bezier.x2 / 100.0F * defaultSize.Width).ToString() + ", " + (bezier.y2 / 100.0F * defaultSize.Height).ToString() + ", " + (bezier.x3 / 100.0F * defaultSize.Width).ToString() + ", " + (bezier.y3 / 100.0F * defaultSize.Height).ToString() + ", " + (bezier.x4 / 100.0F * defaultSize.Width).ToString() + ", " + (bezier.y4 / 100.0F * defaultSize.Height).ToString() + "\r\n"; }
public void LogMessage(out Int64 requestId, String message, SysCAD.Log.MessageType messageType) { logMessageHandler(out requestId, message, messageType); }
private void GenerateAnchor(Anchor anchor, SysCAD.Protocol.Size defaultSize) { tempText += "MDrw_Anchor "; tempText += anchor.Tag + ", "; tempText += ((anchor.Positions[0] as SysCAD.Protocol.Point).X / 100.0F * defaultSize.Width).ToString() + ", " + ((anchor.Positions[0] as SysCAD.Protocol.Point).Y / 100.0F * defaultSize.Height).ToString() + "\r\n"; }
public bool Change(out Int64 requestId, SysCAD.Protocol.Action action) { this.requestId++; requestId = this.requestId; Collection<ModelItem> modelCreate = new Collection<ModelItem>(); Collection<ModelItem> modelModify = new Collection<ModelItem>(); Collection<Guid> modelDelete = new Collection<Guid>(); Collection<GraphicItem> graphicCreate = new Collection<GraphicItem>(); Collection<GraphicItem> graphicModify = new Collection<GraphicItem>(); Collection<Guid> graphicDelete = new Collection<Guid>(); { // Check if OK to go ahead. if (action.Create != null) { foreach (Item item in action.Create) { if (Exists(item)) { LogMessage(out requestId, "Create: Item " + item.Guid + ", " + item.Tag + " already exists.", MessageType.Error); return false; // Can't create an item if guid already exists. } else { if (item is ModelItem) modelCreate.Add(item as ModelItem); else if (item is GraphicItem) { if (item is GraphicLink) { GraphicLink graphicLink = item as GraphicLink; if (graphicLink.ControlPoints.Count > 2) // Check for duplicate points. { List<SysCAD.Protocol.Point> newControlPoints = new List<SysCAD.Protocol.Point>(); SysCAD.Protocol.Point pointA = graphicLink.ControlPoints[0]; SysCAD.Protocol.Point pointB = graphicLink.ControlPoints[1]; SysCAD.Protocol.Point pointC = graphicLink.ControlPoints[2]; int i = 3; while (i < graphicLink.ControlPoints.Count) { if (((pointA.X == pointB.X) && (pointB.X == pointC.X) && (pointC.X == pointA.X)) || ((pointA.Y == pointB.Y) && (pointB.Y == pointC.Y) && (pointC.Y == pointA.Y))) { pointB = pointC; pointC = graphicLink.ControlPoints[i]; i++; } if (i < graphicLink.ControlPoints.Count) { newControlPoints.Add(pointA); pointA = pointB; pointB = pointC; pointC = graphicLink.ControlPoints[i]; i++; } } newControlPoints.Add(pointA); newControlPoints.Add(pointB); newControlPoints.Add(pointC); //if (newControlPoints.Count % 2 == 0) // newControlPoints.Add(pointC); graphicLink.ControlPoints = newControlPoints; } } graphicCreate.Add(item as GraphicItem); } } } } if (action.Modify != null) { foreach (Item item in action.Modify) { if (!Exists(item)) { LogMessage(out requestId, "Modify: Item " + item.Guid + ", " + item.Tag + " doesn't exist.", MessageType.Error); return false; // Can't modify an item if guid doesn't exist. } else { if (item is ModelItem) modelModify.Add(item as ModelItem); else if (item is GraphicItem) graphicModify.Add(item as GraphicItem); } } } if (action.Delete != null) { foreach (Guid guid in action.Delete) { if (!Exists(guid)) { LogMessage(out requestId, "Delete: Item " + guid + " doesn't exist.", MessageType.Error); return false; // Can't modify an item if guid doesn't exist. } else { if (ModelExists(guid)) { modelDelete.Add(guid); } else if (GraphicExists(guid)) { graphicDelete.Add(guid); } } } } } //!!!if (engineClientServiceProtocol.Change(eventId, requestId, modelCreate, modelModify, modelDelete)) //!!!{ Actioned actioned = new Actioned(); foreach (ModelItem modelItem in modelCreate) { model.Create(modelItem); actioned.Created.Add(modelItem.Guid); } foreach (ModelItem modelItem in modelModify) { model.Modify(modelItem); actioned.Modified.Add(modelItem.Guid); } foreach (Guid guid in modelDelete) { model.Delete(guid); actioned.Deleted.Add(guid); } foreach (GraphicItem graphicItem in graphicCreate) { graphic.Create(graphicItem); actioned.Created.Add(graphicItem.Guid); } foreach (GraphicItem graphicItem in graphicModify) { graphic.Modify(graphicItem); actioned.Modified.Add(graphicItem.Guid); } foreach (Guid guid in graphicDelete) { graphic.Delete(guid); actioned.Deleted.Add(guid); } { // Do Change here. eventId++; clientClientServiceProtocol.DoChanged(eventId, requestId, actioned); } return true; //!!!} //!!!else //!!!{ //!!! return false; //!!!} }
public void LogMessage(out Int64 requestId, String message, SysCAD.Log.MessageType messageType) { try { serviceGraphic.LogMessage(out requestId, message, messageType); } catch (Exception originalException) { try { Connect(); serviceGraphic.LogMessage(out requestId, message, messageType); } catch (Exception subsequentException) { throw new ConnectionLostException(originalException, subsequentException); } } }
private static void fcFlowChart_AreaModified(Int64 eventId, Int64 requestId, Guid guid, String tag, String path, SysCAD.Protocol.Rectangle boundingRect) { throw new NotImplementedException("The method or operation is not implemented."); }