using System.Windows; using System.Windows.Media; namespace ESRI.ArcGIS.Client.Toolkit.DataSources.Kml { /// /// For internal use only. /// /// /// Surrogate binder class for setting the angle/heading. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public static class SurrogateBindRotate { /// /// Dependency property to assign the heading/angle of the place marker symbol. /// public static readonly DependencyProperty AngleProperty = DependencyProperty.RegisterAttached("Angle", typeof(double), typeof(SurrogateBindRotate), new PropertyMetadata(OnAngleChanged)); /// /// Get function for angle property. /// /// Dependency object. /// The current angle/heading value. public static double GetAngle(DependencyObject d) { return (double)d.GetValue(AngleProperty); } /// /// Set function for angle property. /// /// Dependency object. /// The value to assign as the angle/heading. public static void SetAngle(DependencyObject d, double value) { d.SetValue(AngleProperty, value); } /// /// Called when the attached property is bound/changed. /// /// Dependency object. /// Event arguments. private static void OnAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is UIElement) { UIElement b = d as UIElement; if (e.NewValue is double) { double c = (double)e.NewValue; if (!double.IsNaN(c)) { if (b.RenderTransform is TransformGroup) { TransformGroup tg = b.RenderTransform as TransformGroup; foreach (Transform t in tg.Children) { RotateTransform rt = t as RotateTransform; if (rt != null) { rt.Angle = c; break; } } } } } } } } /// /// For internal use only. /// /// /// Surrogate binder class for setting the scale. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public static class SurrogateBindScale { /// /// Dependency property to assign the scale of the place marker symbol. /// public static readonly DependencyProperty ScaleProperty = DependencyProperty.RegisterAttached("Scale", typeof(double), typeof(SurrogateBindScale), new PropertyMetadata(OnScaleChanged)); /// /// Get function for scale property. /// /// Dependency object. /// The current scale value. public static double GetScale(DependencyObject d) { return (double)d.GetValue(ScaleProperty); } /// /// Set function for scale property. /// /// Dependency object. /// The value to assign as the scale. public static void SetScale(DependencyObject d, double value) { d.SetValue(ScaleProperty, value); } /// /// Called when the attached property is bound/changed. /// /// Dependency object. /// Event arguments. private static void OnScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is UIElement) { UIElement b = d as UIElement; if (e.NewValue is double) { double c = (double)e.NewValue; if (!double.IsNaN(c)) { if (b.RenderTransform is TransformGroup) { TransformGroup tg = b.RenderTransform as TransformGroup; foreach (Transform t in tg.Children) { ScaleTransform st = t as ScaleTransform; if (st != null) { st.ScaleX = c; st.ScaleY = c; break; } } } } } } } } /// /// For internal use only. /// /// /// Surrogate binder class for setting the translation along the X axis. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public static class SurrogateBindTranslateX { /// /// Dependency property to assign the translation along the X axis of the place marker symbol. /// public static readonly DependencyProperty TranslateXProperty = DependencyProperty.RegisterAttached("TranslateX", typeof(double), typeof(SurrogateBindTranslateX), new PropertyMetadata(OnTranslateXChanged)); /// /// Get function for translate X property. /// /// Dependency object. /// The current translation value. public static double GetTranslateX(DependencyObject d) { return (double)d.GetValue(TranslateXProperty); } /// /// Set function for translate X property. /// /// Dependency object. /// The value to assign as the translation. public static void SetTranslateX(DependencyObject d, double value) { d.SetValue(TranslateXProperty, value); } /// /// Called when the attached property is bound/changed. /// /// Dependency object. /// Event arguments. private static void OnTranslateXChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is UIElement) { UIElement b = d as UIElement; if (e.NewValue is double) { double c = (double)e.NewValue; if (!double.IsNaN(c)) { if (b.RenderTransform is TransformGroup) { TransformGroup tg = b.RenderTransform as TransformGroup; foreach (Transform t in tg.Children) { TranslateTransform st = t as TranslateTransform; if (st != null) { st.X = c; break; } } } } } } } } /// /// For internal use only. /// /// /// Surrogate binder class for setting the translation along the X axis. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public static class SurrogateBindTranslateY { /// /// Dependency property to assign the translation along the Y axis of the place marker symbol. /// public static readonly DependencyProperty TranslateYProperty = DependencyProperty.RegisterAttached("TranslateY", typeof(double), typeof(SurrogateBindTranslateY), new PropertyMetadata(OnTranslateYChanged)); /// /// Get function for translate Y property. /// /// Dependency object. /// The current translation value. public static double GetTranslateY(DependencyObject d) { return (double)d.GetValue(TranslateYProperty); } /// /// Set function for translate Y property. /// /// Dependency object. /// The value to assign as the translation. public static void SetTranslateY(DependencyObject d, double value) { d.SetValue(TranslateYProperty, value); } /// /// Called when the attached property is bound/changed. /// /// Dependency object. /// Event arguments. private static void OnTranslateYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is UIElement) { UIElement b = d as UIElement; if (e.NewValue is double) { double c = (double)e.NewValue; if (!double.IsNaN(c)) { if (b.RenderTransform is TransformGroup) { TransformGroup tg = b.RenderTransform as TransformGroup; foreach (Transform t in tg.Children) { TranslateTransform st = t as TranslateTransform; if (st != null) { st.Y = c; break; } } } } } } } } }