Skip to content
Snippets Groups Projects
Commit 163d871f authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Windrose dreht sich jetzt

parent ac544120
No related branches found
No related tags found
1 merge request!23Windrose dreht sich jetzt
This diff is collapsed.
...@@ -145,10 +145,29 @@ namespace Wetterstation ...@@ -145,10 +145,29 @@ namespace Wetterstation
lbWindSpeed.Invoke(new Action(() => { lbWindSpeed.Text = weatherData.windSpeed + " ms"; })); lbWindSpeed.Invoke(new Action(() => { lbWindSpeed.Text = weatherData.windSpeed + " ms"; }));
lbWindricht.Invoke(new Action(() => { lbWindricht.Text = weatherData.windDeg + " °"; })); lbWindricht.Invoke(new Action(() => { lbWindricht.Text = weatherData.windDeg + " °"; }));
lbLuftdruck.Invoke(new Action(() => { lbLuftdruck.Text = weatherData.pressure + " mbar"; })); 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) { } 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) public void updateFormForecast(String message)
{ {
Console.WriteLine("Entered updateFormForecast"); Console.WriteLine("Entered updateFormForecast");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment