Pourriez-vous me montrer un bon tutoriel C# pour dessiner des graphiques 2d comme Ellipse et Rectangle (qui héritent de Shape) sur un canevas en utilisant WPF? Je suis également intéressé par la suite à cliquer sur les formes et à identifier quelle forme a été cliquée, et aussi à faire glisser et déposer des formes sur le canevas. Merci!C# wpf 2d graphics - Vous cherchez tutoriel/exemples
Merci pour les liens. Pourriez-vous s'il vous plaît me dire quel genre de projet dois-je commencer dans Visual Studio pour compiler et exécuter ce programme (extrait de Shapes and Basic Drawing in WPF):
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace SDKSample
{
public partial class SetBackgroundColorOfShapeExample : Page
{
public SetBackgroundColorOfShapeExample()
{
// Create a StackPanel to contain the shape.
StackPanel myStackPanel = new StackPanel();
// Create a red Ellipse.
Ellipse myEllipse = new Ellipse();
// Create a SolidColorBrush with a red color to fill the
// Ellipse with.
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
// Describes the brush's color using RGB values.
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
myEllipse.Fill = mySolidColorBrush;
myEllipse.StrokeThickness = 2;
myEllipse.Stroke = Brushes.Black;
// Set the width and height of the Ellipse.
myEllipse.Width = 200;
myEllipse.Height = 100;
// Add the Ellipse to the StackPanel.
myStackPanel.Children.Add(myEllipse);
this.Content = myStackPanel;
}
}
}