sérieux .-. wait c'est quoi ça ?
perso moi c'est :
Code (cpp):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace METHODE020
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
int nbrePas;
char sensBouton;
Rectangle carreChoisi;
bool redSquareCheck;
public MainWindow()
{
InitializeComponent();
nbrePas = 5;
}
private void btnUp_Click(object sender, RoutedEventArgs e)
{
sensBouton = 'u';
if (redSquareCheck)
{
carreChoisi = recRed;
}
else
{
carreChoisi = recBlue;
}
BougeCarre(carreChoisi, sensBouton, nbrePas);
}
private void btnDown_Click(object sender, RoutedEventArgs e)
{
sensBouton = 'd';
if (redSquareCheck)
{
carreChoisi = recRed;
}
else
{
carreChoisi = recBlue;
}
BougeCarre(carreChoisi, sensBouton, nbrePas);
}
private void btnRight_Click(object sender, RoutedEventArgs e)
{
sensBouton = 'r';
if (redSquareCheck)
{
carreChoisi = recRed;
}
else
{
carreChoisi = recBlue;
}
BougeCarre(carreChoisi, sensBouton, nbrePas);
}
private void btnLeft_Click(object sender, RoutedEventArgs e)
{
sensBouton = 'l';
if (redSquareCheck)
{
carreChoisi = recRed;
}
else
{
carreChoisi = recBlue;
}
BougeCarre(carreChoisi, sensBouton, nbrePas);
}
public void BougeCarre(Rectangle leCarre, char sens, int pas)
{
double upActual = leCarre.Margin.Top;
double downActual = leCarre.Margin.Bottom;
double rightActual = leCarre.Margin.Right;
double leftActual = leCarre.Margin.Left;
if (sens == 'u')
{
leCarre.Margin = new Thickness(leftActual, upActual - pas, rightActual, downActual);
}
else if (sens == 'd')
{
leCarre.Margin = new Thickness(leftActual, upActual + pas, rightActual, downActual);
}
else if (sens == 'r')
{
leCarre.Margin = new Thickness(leftActual + pas, upActual, rightActual, downActual);
}
else if (sens == 'l')
{
leCarre.Margin = new Thickness(leftActual - pas, upActual, rightActual, downActual);
}
}
private void radBtnRed_Checked(object sender, RoutedEventArgs e)
{
redSquareCheck = true;
}
private void radBtnBlue_Checked(object sender, RoutedEventArgs e)
{
redSquareCheck = false;
}
}
}
Oui ...
je me faisais chier ...