private void CreateLink(Point actualPos, ShapeStroke strokeTo, int number, int linkAnchorNumber, LinkTypes linkType, Point pos) { LinkStroke linkBeingCreated = new LinkStroke(pos, shapeStroke?.guid.ToString(), linkAnchorNumber, linkType, new StylusPointCollection { new StylusPoint(0, 0) }); shapeStroke?.linksFrom.Add(linkBeingCreated.guid.ToString()); linkBeingCreated.addToPointToLink(actualPos, strokeTo?.guid.ToString(), number); strokeTo?.linksTo.Add(linkBeingCreated.guid.ToString()); canvas.AddStroke(linkBeingCreated); DrawingService.CreateLink(linkBeingCreated); StrokeCollection shapesToUpdate = new StrokeCollection(); if (shapeStroke != null) { shapesToUpdate.Add(shapeStroke); } if (strokeTo != null && !shapesToUpdate.Contains(strokeTo)) { shapesToUpdate.Add(strokeTo); } DrawingService.UpdateShapes(shapesToUpdate); canvas.Select(new StrokeCollection { linkBeingCreated }); }
// On retire le trait du dessus de la pile de traits retirés et on le place sur la surface de dessin. public void Depiler(object o) { try { isStackUpToDate = false; CustomStroke trait = (CustomStroke)traitsRetires.Last(); if (trait.isLinkStroke()) { LinkStroke linkStroke = trait as LinkStroke; linkStroke.from.SetDefaults(); linkStroke.to.SetDefaults(); } else { ShapeStroke shapeStroke = trait as ShapeStroke; shapeStroke.linksTo = new List <string> { }; shapeStroke.linksFrom = new List <string> { }; } traits.Add(trait); if (trait.isLinkStroke()) { DrawingService.CreateLink(trait as LinkStroke); } else { DrawingService.CreateShape(trait as ShapeStroke); } traitsRetires.Remove(trait); } catch { } }