本文介绍了图像滑块使用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我正在开发一个应用程序,其中我必须实现一个图像滑块...我几乎设法实现了它.当我对代码进行finla检查时,我发现某些内容丢失了...

我的情况是:

我有4张图片,必须在2个按钮中单击事件才能更改.

右键:图1,图2,图3,图4

左键:图4,图3,图2,图1


从图1到图4& Vice Versa,它的工作正常..但是,如果我停在img 3,然后单击鼠标左键,它就不会改变....

希望你们能理解我的问题.

这是我的代码:


Hi Guys..

Am developing an application in which i have to implement an image slider ... Which i almost managed to achieve . When i did a finla check on my code i found out that something is missing ...

My Situation is :

I have 4 Pictures which i have to change in 2 buttons click event .

Right Button : Img 1, Img 2, Img3 , Img4

Left Button : Img 4, Img 3, Img2 , Img1


from Img 1 to Img 4 & Vice Versa it''s working fine .. but if i stop at img 3 and then if click left button it''s not changing ....

Hope you guys understood my problem .

This is my Code :


private void btnNextArrow_Click(object sender, EventArgs e)
        {

            // Default >> Lime Green >> Cyan >> Black >> Blue



            clickCount = clickCount + 1;

            if (clickCount == 1)
            {
                btnNextArrow.Enabled = true;
            }
            if (clickCount < 5)
            {
                switch (clickCount)
                {

                    case 1:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                        break;
                    case 2:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                        break;
                    case 3:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.black1;
                        break;
                    case 4:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.BlueTheme;
                        btnNextArrow.Enabled = false;
                        btnPreviousArrow.Enabled = true;
                        clickCount = 0;
                        break;
                }
            }


        }

        private void btnPreviousArrow_Click(object sender, EventArgs e)
        {

            // Blue >> Black >> Cyan >> Lime Green >> Default

            clickCount = clickCount + 1;
            if (clickCount == 1)
            {
                btnPreviousArrow.Enabled = true;
            }
            if (clickCount <= 5)
            {
                switch (clickCount)
                {
                    case 1:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.black1;
                        break;
                    case 2:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                        break;
                    case 3:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                        break;
                    case 4:
                        pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.Default_Blue;
                        btnPreviousArrow.Enabled = false;
                        btnNextArrow.Enabled = true;
                        clickCount = 0;
                        break;
                }
            }
        }






我是菜鸟...请帮助我..谢谢您提前


Jewel Joy(JwL)






Am a Rookie ... please help me with the situation.. Thank you in Advance


Jewel Joy (JwL)

推荐答案

// General Declarations

private int clickCount=0;

// Next Button from 0 to 4

private void btnNextArrow_Click(object sender, EventArgs e)
      {

          // Default >> Lime Green >> Cyan >> Blue >> Black  // order of the templates

          if (clickCount <4)
          {
              clickCount++;
              switch (clickCount)
              {
                  //case 0 shouldn''t occur so let''s skip it
                  case 1:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                      label1.Text = "Lime Green";
                      break;
                  case 2:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                      label1.Text = "Cyan";
                      break;
                  case 3:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.BlueTheme;
                      label1.Text = "Blue";
                      break;
                  case 4:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.black1;
                      label1.Text = "Black";
                      break;
              }
          }


      }


// Previous Button


      private void btnPreviousArrow_Click(object sender, EventArgs e)
      {

          // Default >> Lime Green >> Cyan >> Blue >> Black  // same template as above


          if (clickCount > 0)
          {
              clickCount--;
              switch (clickCount)
              {
                  case 0:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.Default;
                      label1.Text = "Default";
                      break;
                  case 1:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                      label1.Text = "Lime Green";
                      break;
                  case 2:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                      label1.Text = "Cyan";
                      break;
                  case 3:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.BlueTheme;
                      label1.Text = "Blue";
                      break;
              }
          }
      }


// General Declarations

private int clickCount=0;


// Next Button

private void btnNextArrow_Click(object sender, EventArgs e)
      {

          // Default >> Lime Green >> Cyan >> Blue >> Black  // order of the templates
          clickCount = clickCount + 1;

          if (clickCount <=5)
          {
              switch (clickCount)
              {
                  case 1:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.Default_Blue;
                      label1.Text = "Default Blue";
                      break;
                  case 2:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                      label1.Text = "Lime Green";
                      break;
                  case 3:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                      label1.Text = "Cyan";
                      break;
                  case 4:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.BlueTheme;
                      label1.Text = "Blue";
                      break;
                  case 5:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.black1;
                      label1.Text = "Black";
                      clickCount = 0;
                      break;
              }
          }


      }


// Previous Button


      private void btnPreviousArrow_Click(object sender, EventArgs e)
      {

          // Blue >> Black >> Cyan >> Lime Green >> Default   // order of the templates


          clickCount = clickCount + 1;
          if (clickCount <= 5)
          {
              switch (clickCount)
              {
                  case 1:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.BlueTheme;
                      label1.Text = "Blue";
                      break;
                  case 2:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.black1;
                      label1.Text = "Black";
                      break;
                  case 3:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.cyan;
                      label1.Text = "Cyan";
                      break;
                  case 4:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.LimeGreen;
                      label1.Text = "Lime Green";
                      break;
                  case 5:
                      pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.Default_Blue;
                      label1.Text = "Default Blue";
                      clickCount = 0;
                      break;
              }
          }
      }

      private void ControlThemeSettings_Load(object sender, EventArgs e)
      {
          //btnPreviousArrow.Visible = false;
          pict_ThemeDisplay.Image = Sms.UI.Properties.Resources.Default_Blue;
      }


这篇关于图像滑块使用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 09:22