/// <summary> /// Links the transforms of a border to this one so they zoom and pan in tandem. /// </summary> /// <param name="borderToLink">Border to link to this one.</param> public void Link(PanAndZoomBorder borderToLink) { if (Links.Contains(borderToLink) || borderToLink.Links.Contains(this)) return; Links.Add(borderToLink); borderToLink.Links.Add(this); // Set borderToLink to same transform as this one var thisScale = GetScaleTransform(); var thisTranslate = GetTranslateTransform(); borderToLink.GetTranslateTransform().X = thisTranslate.X; borderToLink.GetTranslateTransform().Y = thisTranslate.Y; borderToLink.GetScaleTransform().ScaleX = thisScale.ScaleX; borderToLink.GetScaleTransform().ScaleY = thisScale.ScaleY; // Link changes on both borders to each other. this.MouseWheel += borderToLink.child_MouseWheel; this.MouseLeftButtonDown += borderToLink.child_MouseLeftButtonDown; this.MouseLeftButtonUp += borderToLink.child_MouseLeftButtonUp; this.MouseRightButtonDown += borderToLink.child_MouseRightButtonDown; borderToLink.MouseWheel += this.child_MouseWheel; borderToLink.MouseLeftButtonDown += this.child_MouseLeftButtonDown; borderToLink.MouseLeftButtonUp += this.child_MouseLeftButtonUp; borderToLink.MouseRightButtonDown += this.child_MouseRightButtonDown; }
/// <summary> /// Links the transforms of a border to this one so they zoom and pan in tandem. /// </summary> /// <param name="borderToLink">Border to link to this one.</param> public void Link(PanAndZoomBorder borderToLink) { if (Links.Contains(borderToLink) || borderToLink.Links.Contains(this)) { return; } Links.Add(borderToLink); borderToLink.Links.Add(this); // Set borderToLink to same transform as this one var thisScale = GetScaleTransform(); var thisTranslate = GetTranslateTransform(); borderToLink.GetTranslateTransform().X = thisTranslate.X; borderToLink.GetTranslateTransform().Y = thisTranslate.Y; borderToLink.GetScaleTransform().ScaleX = thisScale.ScaleX; borderToLink.GetScaleTransform().ScaleY = thisScale.ScaleY; // Link changes on both borders to each other. this.MouseWheel += borderToLink.child_MouseWheel; this.MouseLeftButtonDown += borderToLink.child_MouseLeftButtonDown; this.MouseLeftButtonUp += borderToLink.child_MouseLeftButtonUp; this.MouseRightButtonDown += borderToLink.child_MouseRightButtonDown; borderToLink.MouseWheel += this.child_MouseWheel; borderToLink.MouseLeftButtonDown += this.child_MouseLeftButtonDown; borderToLink.MouseLeftButtonUp += this.child_MouseLeftButtonUp; borderToLink.MouseRightButtonDown += this.child_MouseRightButtonDown; }
/// <summary> /// Unlinks a border from this one to move independently. /// </summary> /// <param name="linkedBorder">Border to remove link from.</param> public void Unlink(PanAndZoomBorder linkedBorder) { Links.Remove(linkedBorder); linkedBorder.Links.Remove(this); // Link changes on both borders to each other. this.MouseWheel -= linkedBorder.child_MouseWheel; this.MouseLeftButtonDown -= linkedBorder.child_MouseLeftButtonDown; this.MouseLeftButtonUp -= linkedBorder.child_MouseLeftButtonUp; this.MouseRightButtonDown -= linkedBorder.child_MouseRightButtonDown; linkedBorder.MouseWheel -= this.child_MouseWheel; linkedBorder.MouseLeftButtonDown -= this.child_MouseLeftButtonDown; linkedBorder.MouseLeftButtonUp -= this.child_MouseLeftButtonUp; linkedBorder.MouseRightButtonDown -= this.child_MouseRightButtonDown; }