1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public Plateau1 plateau;
public int reference { get; set; }
public Button forme { get; set; }
public LinearGradientBrush couleur { get; set; }
public element(int reference, SolidColorBrush sa_couleur, Plateau1 createur)
{
this.reference = reference;
this.forme = forme_defaut;
this.forme.Background = sa_couleur;
this.couleur = new LinearGradientBrush();
GradientStop gradient1 = new GradientStop(Color.FromRgb(0, 0, 0),0);
GradientStop gradient2 = new GradientStop(sa_couleur.Color,1);
GradientStopCollection grad = new GradientStopCollection(2);
grad.Add(gradient1);grad.Add(gradient2);
this.couleur.StartPoint = new Point(0.5, 0);
this.couleur.EndPoint = new Point(0.5, 1);
this.couleur.GradientStops = grad;
plateau = createur;
this.forme.Height = this.forme.Width = 300;
this.forme.Focusable = false;
this.forme.Background = couleur;
this.forme.Name = "piece"+reference.ToString();
NameScope.SetNameScope(this.forme, new NameScope());
this.forme.RegisterName(this.forme.Name, this.forme);
public void testanim()
{
Storyboard story = new Storyboard();
ColorAnimation anim = new ColorAnimation();
anim.From = this.couleur.GradientStops[1].Color;
anim.To = Color.Multiply(this.couleur.GradientStops[1].Color,3);
anim.Duration = new Duration(TimeSpan.FromSeconds(1));
anim.AutoReverse = true;
anim.RepeatBehavior = RepeatBehavior.Forever;
story.Children.Add(anim);
Storyboard.SetTargetName(anim,this.forme.Name);
Storyboard.SetTargetProperty(anim,new PropertyPath(this.forme.Background.DependencyObjectType.Name));
story.Begin();
} |
Partager