private static void OnScaleChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ZoomElement thisLabel = (ZoomElement)source;//get this label if (Math.Abs((double)e.NewValue - (double)e.OldValue) < 0.00001) { return; } if (thisLabel.ParentScaleX != 0) { double tempScaleX = (1.0 / thisLabel.ParentScaleX) * (thisLabel.Scale); thisLabel.SetScaleX(tempScaleX); } if (thisLabel.ParentScaleY != 0) { double tempScaleY = (1.0 / thisLabel.ParentScaleY) * (thisLabel.Scale); thisLabel.SetScaleY(tempScaleY); } thisLabel.ReinitializePosition(null, null);//update the label position }
private static void OnYLocationPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ZoomElement thisLabel = (ZoomElement)source; //get this label thisLabel.ReinitializePosition(null, null); //update the label position }
/// <summary> /// When the canvas size changes. ie on window maximization, recalculates the position of the label in the canvas /// </summary> /// <param name="source"></param> /// <param name="e"></param> private static void OnParentWidthAndHeightPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ZoomElement thisLabel = (ZoomElement)source; //get this label thisLabel.ReinitializePosition(null, null); //update its margins based on the new size }