我正在製作一個winforms應用程序。我希望實現的功能之一是家庭窗體上的旋轉裝置。如何在圖片框中旋轉圖像
裝入家庭表單時,應將鼠標懸停在設備圖片上,並且應該旋轉到位。
但我到目前爲止所有的RotateFlip,只是翻轉圖片。
當鼠標懸停在其上時,是否有辦法讓齒輪轉動到位?
我到目前爲止的代碼是:
Bitmap bitmap1;
public frmHome()
{
InitializeComponent();
try
{
bitmap1 = (Bitmap)Bitmap.FromFile(@"gear.jpg");
gear1.SizeMode = PictureBoxSizeMode.AutoSize;
gear1.Image = bitmap1;
}
catch (System.IO.FileNotFoundException)
{
MessageBox.Show("There was an error." +
"Check the path to the bitmap.");
}
}
private void frmHome_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
private void frmHome_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void pictureBox1_MouseHover(object sender, EventArgs e)
{
bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY);
gear1.Image = bitmap1;
}
就像我說的,我只是想將齒輪。我正在嘗試在Windows窗體應用程序中執行此操作。使用C#。框架4
最簡單的方法可能是創建一個動畫GIF,讓PictureBox的爲你做 – Plutonix 2014-10-19 12:58:35
工作這是相當簡單的繪製圖像(而不是設置它)和轉換圖形.. – TaW 2014-10-19 13:05:21
你可能想看看[我的例子](http://stackoverflow.com/a/14711744/643085)這樣的一個使用當前的,不推薦的.Net Windows UI技術的東西,w這不需要愚蠢的「所有者抽取」黑客之類的事情,並將這項任務簡化爲僅有的兩行DataBinding事物。 – 2014-10-20 01:47:59