From 23bf1ed322a972360a025dccab68d576d7f40a5c Mon Sep 17 00:00:00 2001 From: thchazot1 Date: Fri, 10 Jun 2022 09:15:38 +0200 Subject: [PATCH] Ajout de position au cas ou --- Modèle/Position.cs | 31 +++++++++++ WpfApp1.sln | 2 +- WpfApp1/UserControlPosition.xaml | 12 +++++ WpfApp1/UserControlPosition.xaml.cs | 84 +++++++++++++++++++++++++++++ testMap/Program.cs | 12 +++++ testMap/testMap.csproj | 8 +++ 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 Modèle/Position.cs create mode 100644 WpfApp1/UserControlPosition.xaml create mode 100644 WpfApp1/UserControlPosition.xaml.cs create mode 100644 testMap/Program.cs create mode 100644 testMap/testMap.csproj diff --git a/Modèle/Position.cs b/Modèle/Position.cs new file mode 100644 index 0000000..9f3bc03 --- /dev/null +++ b/Modèle/Position.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Modèle +{ + public class Position + { + public float LattitudeDeb { get; set; } + public float LattitudeFin { get; set; } + public float LongitudeDeb { get; set; } + public float LongitudeFin { get; set; } + + + public bool Equals(Position p) + { + return p.LattitudeDeb == LattitudeDeb && p.LattitudeFin == LattitudeFin && p.LongitudeDeb == LongitudeDeb && p.LongitudeFin == LongitudeFin; + } + + + public Position(int lDeb, int lFin, int longDeb, int longFin) + { + LattitudeDeb = lDeb; + LattitudeFin = lFin; + LongitudeDeb = longDeb; + LongitudeFin = longFin; + } + } +} diff --git a/WpfApp1.sln b/WpfApp1.sln index 40c09be..cc07caa 100644 --- a/WpfApp1.sln +++ b/WpfApp1.sln @@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistance", "Persistance\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{D92A482A-06C4-4F7B-B51F-3934A2E4C8E2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Business", "Business\Business.csproj", "{E53C613D-8DC0-470A-A215-72C7CCDF98DC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{E53C613D-8DC0-470A-A215-72C7CCDF98DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WpfApp1/UserControlPosition.xaml b/WpfApp1/UserControlPosition.xaml new file mode 100644 index 0000000..5d5dcc9 --- /dev/null +++ b/WpfApp1/UserControlPosition.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/WpfApp1/UserControlPosition.xaml.cs b/WpfApp1/UserControlPosition.xaml.cs new file mode 100644 index 0000000..9a4308f --- /dev/null +++ b/WpfApp1/UserControlPosition.xaml.cs @@ -0,0 +1,84 @@ +using Business; +using Modèle; +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 WpfApp1 +{ + /// + /// Logique d'interaction pour UserControlPosition.xaml + /// + public partial class UserControlPosition : UserControl + { + public UserControlPosition() + { + InitializeComponent(); + } + + + private Position _pos; + public Position position + { + get { return _pos; } + set + { + _pos = value; + UpdateUi(_pos); + } + } + + private double _widthImage; + public double widthImage + { + get { return _widthImage; } + set + { + _widthImage = value; + } + } + private double _heightImage; + + public double heightImage + { + get { return _heightImage; } + set + { + _heightImage = value; + } + } + + + private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e) + { + + } + + + + private void UpdateUi(Position pos) + { + + double middleWidth = widthImage / 2; + double middleHeight = heightImage / 2; + double coefWidth = widthImage/90; + double coefHeight = heightImage/90; + Canvas.SetTop(Ellipse, middleHeight + coefHeight * pos.LattitudeFin); + Canvas.SetLeft(Ellipse, middleWidth + coefWidth * pos.LongitudeDeb); + Ellipse.Width = (pos.LongitudeFin - pos.LongitudeDeb) * coefWidth; + Ellipse.Height = (pos.LattitudeFin - pos.LattitudeDeb) * coefHeight; + Ellipse.Fill = System.Windows.Media.Brushes.Red; + } + } +} diff --git a/testMap/Program.cs b/testMap/Program.cs new file mode 100644 index 0000000..ce17b64 --- /dev/null +++ b/testMap/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace testMap +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/testMap/testMap.csproj b/testMap/testMap.csproj new file mode 100644 index 0000000..2082704 --- /dev/null +++ b/testMap/testMap.csproj @@ -0,0 +1,8 @@ + + + + Exe + net5.0 + + +