<small id='C2Z9X'></small><noframes id='C2Z9X'>

<tfoot id='C2Z9X'></tfoot>

    <bdo id='C2Z9X'></bdo><ul id='C2Z9X'></ul>
<legend id='C2Z9X'><style id='C2Z9X'><dir id='C2Z9X'><q id='C2Z9X'></q></dir></style></legend>
  • <i id='C2Z9X'><tr id='C2Z9X'><dt id='C2Z9X'><q id='C2Z9X'><span id='C2Z9X'><b id='C2Z9X'><form id='C2Z9X'><ins id='C2Z9X'></ins><ul id='C2Z9X'></ul><sub id='C2Z9X'></sub></form><legend id='C2Z9X'></legend><bdo id='C2Z9X'><pre id='C2Z9X'><center id='C2Z9X'></center></pre></bdo></b><th id='C2Z9X'></th></span></q></dt></tr></i><div id='C2Z9X'><tfoot id='C2Z9X'></tfoot><dl id='C2Z9X'><fieldset id='C2Z9X'></fieldset></dl></div>

        如何旋转图片框中的图像

        How to rotate image in picture box(如何旋转图片框中的图像)

          1. <small id='fvfS4'></small><noframes id='fvfS4'>

              <bdo id='fvfS4'></bdo><ul id='fvfS4'></ul>
            • <tfoot id='fvfS4'></tfoot>
            • <legend id='fvfS4'><style id='fvfS4'><dir id='fvfS4'><q id='fvfS4'></q></dir></style></legend>

                • <i id='fvfS4'><tr id='fvfS4'><dt id='fvfS4'><q id='fvfS4'><span id='fvfS4'><b id='fvfS4'><form id='fvfS4'><ins id='fvfS4'></ins><ul id='fvfS4'></ul><sub id='fvfS4'></sub></form><legend id='fvfS4'></legend><bdo id='fvfS4'><pre id='fvfS4'><center id='fvfS4'></center></pre></bdo></b><th id='fvfS4'></th></span></q></dt></tr></i><div id='fvfS4'><tfoot id='fvfS4'></tfoot><dl id='fvfS4'><fieldset id='fvfS4'></fieldset></dl></div>
                    <tbody id='fvfS4'></tbody>
                  本文介绍了如何旋转图片框中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在制作一个 winforms 应用程序.我希望实现的功能之一是主窗体上的旋转齿轮.

                  I am making a winforms application. One of the features I hope to implement is a rotating gear on the home form.

                  加载主页表单时,您应该将鼠标悬停在齿轮图片上,并且它应该旋转到位.

                  When the home form is loaded, you should hover over the picture of the gear, and it should rotate in place.

                  但到目前为止,我只有 RotateFlip,它只是翻转图片.

                  But all I have so far is the RotateFlip and that just flips the picture.

                  当鼠标悬停在齿轮上时,有没有办法让齿轮转动到位?

                  Is there a way to make the gear turn in place when the mouse is hovering over it?

                  我目前的代码是:

                  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

                  Like I said, I just want to turn the gear. I am trying to do this in a Windows Form application. Using C#. Framework 4

                  推荐答案

                  您必须使用 Timer 来创建 Image 的旋转.没有内置的旋转方法.

                  You'll have to use Timer to create rotation of the Image. There is no built in method exists for rotation.

                  创建一个全局计时器:

                  Timer rotationTimer;
                  

                  在表单的构造函数中初始化定时器并创建PictureBox MouseEnterMouseLeave事件:

                  Initialize timer in the constructor of the form and create PictureBox MouseEnter and MouseLeave events:

                  //initializing timer
                  rotationTimer = new Timer();
                  rotationTimer.Interval = 150;    //you can change it to handle smoothness
                  rotationTimer.Tick += rotationTimer_Tick;
                  
                  //create pictutrebox events
                  pictureBox1.MouseEnter += pictureBox1_MouseEnter;
                  pictureBox1.MouseLeave += pictureBox1_MouseLeave;
                  

                  然后创建他们的Event Handlers:

                  void rotationTimer_Tick(object sender, EventArgs e)
                  {
                      Image flipImage = pictureBox1.Image;
                      flipImage.RotateFlip(RotateFlipType.Rotate90FlipXY);
                      pictureBox1.Image = flipImage;
                  }
                  
                  private void pictureBox1_MouseEnter(object sender, EventArgs e)
                  {
                      rotationTimer.Start();
                  }
                  
                  private void pictureBox1_MouseLeave(object sender, EventArgs e)
                  {
                      rotationTimer.Stop();
                  }
                  

                  这篇关于如何旋转图片框中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  • <small id='HuzCa'></small><noframes id='HuzCa'>

                    <legend id='HuzCa'><style id='HuzCa'><dir id='HuzCa'><q id='HuzCa'></q></dir></style></legend><tfoot id='HuzCa'></tfoot>

                      <tbody id='HuzCa'></tbody>
                      <bdo id='HuzCa'></bdo><ul id='HuzCa'></ul>
                        <i id='HuzCa'><tr id='HuzCa'><dt id='HuzCa'><q id='HuzCa'><span id='HuzCa'><b id='HuzCa'><form id='HuzCa'><ins id='HuzCa'></ins><ul id='HuzCa'></ul><sub id='HuzCa'></sub></form><legend id='HuzCa'></legend><bdo id='HuzCa'><pre id='HuzCa'><center id='HuzCa'></center></pre></bdo></b><th id='HuzCa'></th></span></q></dt></tr></i><div id='HuzCa'><tfoot id='HuzCa'></tfoot><dl id='HuzCa'><fieldset id='HuzCa'></fieldset></dl></div>