// All equality tests pass void TestStylusPointsEquality() { //<Snippet6> StylusPoint point1 = new StylusPoint(); StylusPoint point2 = new StylusPoint(); point1.X = 150; point1.Y = 400; point1.PressureFactor = 0.45f; point2.X = 150; point2.Y = 400; point2.PressureFactor = 0.45f; //</Snippet6> //<Snippet7> if (point2.Equals(point1)) { MessageBox.Show("The two StylusPoint objects are equal."); } else { MessageBox.Show("The two StylusPoint objects are not equal."); } //</Snippet7> //<Snippet8> if (StylusPoint.Equals(point1, point2)) { MessageBox.Show("The two StylusPoint objects are equal."); } else { MessageBox.Show("The two StylusPoint objects are not equal."); } //</Snippet8> //<Snippet9> if (point1 == point2) { MessageBox.Show("The two StylusPoint objects are equal."); } else { MessageBox.Show("The two StylusPoint objects are not equal."); } //</Snippet9> //<Snippet10> if (point1 != point2) { MessageBox.Show("The two StylusPoint objects are not equal."); } else { MessageBox.Show("The two StylusPoint objects are equal."); } //</Snippet10> }
public LinkStroke(StylusPointCollection pts) : base(pts) { guid = Guid.NewGuid(); name = "Link"; from = new AnchorPoint(); from.SetDefaults(); to = new AnchorPoint(); to.SetDefaults(); strokeType = (int)StrokeTypes.LINK; linkType = (int)LinkTypes.TWO_WAY_ASSOCIATION; style = new LinkStyle(); style.SetDefaults(); path = new List <Coordinates>(); DrawingAttributes.Width = getThickness(); DrawingAttributes.Height = getThickness(); StylusPoint firstPoint = pts[0]; StylusPoint lastPoint = pts[pts.Count - 1]; // garder uniquement le premier point while (StylusPoints.Count > 1) { StylusPoints.RemoveAt(1); } path.Add(new Coordinates(StylusPoints[0].ToPoint())); if (!lastPoint.Equals(firstPoint)) { StylusPoints.Add(new StylusPoint(lastPoint.X, lastPoint.Y)); path.Add(new Coordinates(lastPoint.X, lastPoint.Y)); } else { StylusPoints.Add(new StylusPoint(firstPoint.X + 100, lastPoint.Y + 100)); path.Add(new Coordinates(StylusPoints[1].X, StylusPoints[1].Y)); } addStylusPointsToLink(); }