public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { Point p = new Point(0, Transformer.CurrCanvasY((Figure)value)); return(Transformer.ConvertToScreen(p).Y); } return(null); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { Area area = value as Area; Point p = new Point(area.Polygon.Center().X, 0); return(Transformer.ConvertToScreen(p).X); } else { return(null); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { System.Windows.Point p = new System.Windows.Point(); if (value != null) { Point point = value as Point; var pp = Transformer.ConvertToScreen(point); p.X = pp.X; p.Y = pp.Y; return(p); } else { return(null); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { List <System.Windows.Point> Points = new List <System.Windows.Point>(); if (value != null) { Polyline poline = value as Polyline; var centerP = Transformer.ConvertToScreen(poline.Center()); foreach (Point p in poline.Points) { var p1 = Transformer.ConvertToScreen(p); Points.Add(new System.Windows.Point(p1.X - centerP.X, p1.Y - centerP.Y)); } return(new PointCollection(Points)); } else { return(null); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { List <System.Windows.Point> Points = new List <System.Windows.Point>(); if (value != null) { Segment segment = value as Segment; var p = (Transformer.ConvertToScreen(segment.Begin)); var p1 = (Transformer.ConvertToScreen(segment.End)); var centerP = Transformer.ConvertToScreen(segment.Center()); Points.Add(new System.Windows.Point(p.X - centerP.X, p.Y - centerP.Y)); Points.Add(new System.Windows.Point(p1.X - centerP.X, p1.Y - centerP.Y)); return(new PointCollection(Points)); } else { return(null); } }
public static Storyboard GetAnimation(Stories stories) { Storyboard st = new Storyboard(); var mapPresenter = FindVisualChild <ContentPresenter>(UI.TheMapControl); var unitPresenter = (ItemsControl)UI.TheMapControl.ContentTemplate.FindName("UnitsMap", mapPresenter); foreach (Story story in stories.GetStories) { if (story is UnitStory) { for (int i = 0; i < unitPresenter.Items.Count; i++) { var unitContainer = (ContentPresenter)unitPresenter.ItemContainerGenerator.ContainerFromIndex(i); var unit = (unitPresenter.Items[i] as UnitPresenter).Unit; if (unit == (story as UnitStory).Unit) { var unitStates = (story as UnitStory).States.ConvertAll(x => x as UnitState); double time = 0; for (int j = 0; j < unitStates.Count; j++) { if (unitStates[j].Action == StateAction.Move && j + 1 < unitStates.Count) { Storyboard states = new Storyboard(); var p1 = Transformer.ConvertToScreen(unitStates[j].Position); var p2 = Transformer.ConvertToScreen(unitStates[j + 1].Position); var t1 = unitStates[j + 1].Time; DoubleAnimation xAnimation = new DoubleAnimation(p1.X, p2.X, new Duration( TimeSpan.FromSeconds(t1))); DoubleAnimation yAnimation = new DoubleAnimation(p1.Y, p2.Y, new Duration( TimeSpan.FromSeconds(t1))); Storyboard stY = new Storyboard(); stY.Children.Add(yAnimation); Storyboard stX = new Storyboard(); stX.Children.Add(xAnimation); time += unitStates[j].Time; xAnimation.BeginTime = TimeSpan.FromSeconds(time); yAnimation.BeginTime = TimeSpan.FromSeconds(time); Storyboard.SetTarget(stX, unitContainer); Storyboard.SetTarget(stY, unitContainer); Storyboard.SetTargetProperty(stX, new PropertyPath("(Canvas.Left)")); Storyboard.SetTargetProperty(stY, new PropertyPath("(Canvas.Top)")); st.Children.Add(stX); st.Children.Add(stY); } else if (unitStates[j].Action == StateAction.Attack) { var c = unitContainer.ContentTemplate.FindName("TheCanvas", unitContainer); var m = (c as Canvas).FindName("CombatMarker"); //AttackAnimation(m as Shape); DoubleAnimation oAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1))); Storyboard cm = new Storyboard(); Storyboard.SetTarget(cm, m as Shape); Storyboard.SetTargetProperty(cm, new PropertyPath("Opacity")); cm.Children.Add(oAnimation); st.Children.Add(cm); } } } } } } return(st); }