// This method establishes a link between current thumb and specified thumb. // Returns a line geometry with updated positions to be processed outside. public LineGeometry LinkTo(MyThumb target) { // Create new line geometry LineGeometry line = new LineGeometry(); // Save as starting line for current thumb this.StartLines.Add(line); // Save as ending line for target thumb target.EndLines.Add(line); // Ensure both thumbs the latest layout this.UpdateLayout(); target.UpdateLayout(); // Update line position line.StartPoint = new Point(Canvas.GetLeft(this) + this.ActualWidth / 2, Canvas.GetTop(this) + this.ActualHeight / 2); line.EndPoint = new Point(Canvas.GetLeft(target) + target.ActualWidth / 2, Canvas.GetTop(target) + target.ActualHeight / 2); // return line for further processing return line; }
// This method establishes a link between current thumb and target thumb using a predefined line geometry // Note: this is commonly to be used for drawing links with mouse when the line object is predefined outside this class public bool LinkTo(MyThumb target, LineGeometry line) { // Save as starting line for current thumb this.StartLines.Add(line); // Save as ending line for target thumb target.EndLines.Add(line); // Ensure both tumbs the latest layout this.UpdateLayout(); target.UpdateLayout(); // Update line position line.StartPoint = new Point(Canvas.GetLeft(this) + this.ActualWidth / 2, Canvas.GetTop(this) + this.ActualHeight / 2); line.EndPoint = new Point(Canvas.GetLeft(target) + target.ActualWidth / 2, Canvas.GetTop(target) + target.ActualHeight / 2); return true; }