diff --git a/Wetterstation/Form1.cs b/Wetterstation/Form1.cs index e2826885970fcfd948fb7d263f7d3ebee2111e06..30a3cada8082e1abd12e0e8b46487e0c819ef6ff 100644 --- a/Wetterstation/Form1.cs +++ b/Wetterstation/Form1.cs @@ -265,9 +265,29 @@ namespace Wetterstation lbWindSpeed.Invoke(new Action(() => { lbWindSpeed.Text = weatherData.windSpeed + " ms"; })); lbWindricht.Invoke(new Action(() => { lbWindricht.Text = weatherData.windDeg + " °"; })); lbLuftdruck.Invoke(new Action(() => { lbLuftdruck.Text = weatherData.pressure + " mbar"; })); + pictureBox1.Invoke(new Action(() => { + pictureBox1.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("WindRose_neu"), (int)weatherData.windDeg); + })); + } catch (Exception ignored) { } } + private Bitmap RotateImage(Bitmap bmp, float angle) + { + float height = bmp.Height; + float width = bmp.Width; + int hypotenuse = System.Convert.ToInt32(System.Math.Floor(Math.Sqrt(height * height + width * width))); + Bitmap rotatedImage = new Bitmap(hypotenuse, hypotenuse); + using (Graphics g = Graphics.FromImage(rotatedImage)) + { + g.TranslateTransform((float)rotatedImage.Width / 2, (float)rotatedImage.Height / 2); //set the rotation point as the center into the matrix + g.RotateTransform(angle); //rotate + g.TranslateTransform(-(float)rotatedImage.Width / 2, -(float)rotatedImage.Height / 2); //restore rotation point into the matrix + g.DrawImage(bmp, (hypotenuse - width) / 2, (hypotenuse - height) / 2, width, height); + } + return rotatedImage; + } + public void updateFormForecast(String message) {