/// <summary> /// Called when [color property changed]. /// </summary> /// <param name="d">The d.</param> /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static void OnColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FleetControl b = d as FleetControl; if (b == null) { return; } var color = (int)e.NewValue; b.Label.Foreground = Settings.AvailableColors[color]; }
private void ShowFleet(PlanetWars game, Fleet fleet) { var control = new FleetControl(); control.Owner = fleet.Owner(); control.Text = fleet.NumShips().ToString(); var source = game.GetPlanet(fleet.SourcePlanet()); var dest = game.GetPlanet(fleet.DestinationPlanet()); var steps = fleet.TotalTripLength(); var remaing = fleet.TurnsRemaining(); var x = source.X + (dest.X - source.X) * (steps - remaing) / steps; var y = source.Y + (dest.Y - source.Y) * (steps - remaing) / steps; ShowControl(control, x, y); }