A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

待会分享下各个功能的代码

QQ截图20130804113654.jpg (96.85 KB, 下载次数: 25)

QQ截图20130804113654.jpg

QQ截图20130804113716.jpg (42.81 KB, 下载次数: 28)

QQ截图20130804113716.jpg

评分

参与人数 1技术分 +1 收起 理由
赵宗荣 + 1 赞一个!

查看全部评分

15 个回复

倒序浏览
   这是魔方listBox1查看步骤的SelectedIndexChanged事件
  1.            if (startstep == 1)
  2.             {
  3.                 //listBox1.SetSelected(listBox1.Items.Count - 1, true);
  4.                 //string y = listBox1.SelectedItem.ToString();
  5.                 if (listBox1.SelectedIndex == listBox1.Items.Count - 1)
  6.                 {
  7.                     fangxiang(listBox1.Items[listBox1.Items.Count - 1].ToString());
  8.                 }
  9.                 if (listBox1.SelectedIndex != listBox1.Items.Count - 1)
  10.                 {
  11.                     for (int x = listBox1.Items.Count - 1; x >= listBox1.SelectedIndex; x--)
  12.                     {
  13.                         fangxiang(listBox1.Items[x].ToString());
  14.                     }
  15.                 }

  16.                 flag = listBox1.SelectedIndex;
  17.                 flag2 = -1;
  18.                 startstep = 0;
  19.             }
  20.             else
  21.             {
  22.                 if (listBox1.SelectedIndex > flag)
  23.                 {
  24.                     if (flag2 == -1)
  25.                     { zhengxiang(listBox1.Items[flag].ToString()); }
  26.                     for (int x = flag; x < listBox1.SelectedIndex; x++)
  27.                     {
  28.                         zhengxiang(listBox1.Items[x + 1].ToString());
  29.                     }
  30.                     flag = listBox1.SelectedIndex;
  31.                     flag2 = 1;
  32.                 }
  33.                 if (listBox1.SelectedIndex < flag)
  34.                 {
  35.                     if (flag2 == 1)
  36.                     { fangxiang(listBox1.Items[flag].ToString()); }
  37.                     for (int x = flag; x > listBox1.SelectedIndex; x--)
  38.                     {
  39.                         fangxiang(listBox1.Items[x - 1].ToString());
  40.                     }
  41.                     flag = listBox1.SelectedIndex;
  42.                     flag2 = -1;
  43.                 }

  44.             }/*
  45.                 if (listBox1.SelectedIndex > flag)
  46.                 {

  47.                     if (flag2 >= listBox1.SelectedIndex)
  48.                     {
  49.                         fangxiang(listBox1.Items[flag].ToString());
  50.                     }
  51.                     
  52.                     for (int x = flag; x < listBox1.SelectedIndex; x++)
  53.                     {
  54.                         fangxiang(listBox1.Items[x + 1].ToString());
  55.                     }
  56.                     if (flag2 == 0)
  57.                     {
  58.                         fangxiang(listBox1.Items[0].ToString());
  59.                     }
  60.                     flag2 = flag;
  61.                     flag = listBox1.SelectedIndex;
  62.                 }
  63.                 if (listBox1.SelectedIndex < flag)
  64.                 {
  65.                     if (flag2 <= listBox1.SelectedIndex)
  66.                     {
  67.                         fangxiang(listBox1.Items[flag].ToString());
  68.                     }
  69.                     for (int x = flag; x > listBox1.SelectedIndex; x--)
  70.                     {
  71.                         fangxiang(listBox1.Items[x - 1].ToString());
  72.                     }
  73.                     flag2 = flag;
  74.                     flag = listBox1.SelectedIndex;
  75.                 }/*
  76.                     /*if (listBox1.SelectedIndex <flag)
  77.                     {
  78.                         if (listBox1.SelectedIndex != 0)
  79.                         {
  80.                             //fangxiang(listBox1.Items[flag].ToString());
  81.                             if (flag == listBox1.Items.Count - 1)
  82.                             {
  83.                                 fangxiang(listBox1.Items[listBox1.Items.Count - 1].ToString());
  84.                             }
  85.                             for (int x = flag; x > listBox1.SelectedIndex; x--)
  86.                             {
  87.                                 fangxiang(listBox1.Items[x - 1].ToString());
  88.                             }
  89.                         }
  90.                         if (listBox1.SelectedIndex == 0)
  91.                         {
  92.                             if (flag == listBox1.Items.Count - 1)
  93.                             {
  94.                                 fangxiang(listBox1.Items[listBox1.Items.Count - 1].ToString());
  95.                             }
  96.                             for (int x = flag; x > listBox1.SelectedIndex; x--)
  97.                             {
  98.                                 fangxiang(listBox1.Items[x-1].ToString());
  99.                             }
  100.                             //fangxiang(listBox1.Items[0].ToString());
  101.                         }
  102.                         flag = listBox1.SelectedIndex;
  103.                     }*/
  104.                
  105.                 //string x=listBox1.SelectedIndex.ToString();
  106.                 //string y = listBox1.SelectedItem.ToString();
  107.                 //MessageBox.Show("111"+x+"222"+y);
  108.             this.Invalidate();
复制代码

QQ截图20130804113742.jpg (174.57 KB, 下载次数: 30)

QQ截图20130804113742.jpg
回复 使用道具 举报
通过鼠标拖动下面平面的3D的方法
  1.         private void Form1_MouseDown(object sender, MouseEventArgs e)
  2.         {
  3.             
  4.             mouseX = e.X;
  5.             mouseY = e.Y;
  6.             if (mouseX >= 694 && mouseX <= 950 && mouseY >= 400 && mouseY <= 75*Math.Sqrt(2)+150+400)
  7.             { isMouseDown = true;
  8.             this.Cursor = Cursors.Hand;
  9.             }
  10.         }
复制代码
  1.         private void Form1_MouseUp(object sender, MouseEventArgs e)
  2.         {
  3.             if (isMouseDown == true)
  4.             {
  5.                 this.Cursor = Cursors.Default;
  6.                 #region positive
  7.                 if (mouseX >= 694 && mouseX <= 744 && mouseY >= 506 && mouseY <= 556)
  8.                 {
  9.                     if (e.X >= 744 && e.X <= 844 && e.Y >= 506 && e.Y <= 556)
  10.                     { E1();
  11.                     this.Invalidate(); }
  12.                     if (e.X >= 694 && e.X <= 744 && e.Y >= 556 && e.Y <= 656)
  13.                     { DD1();
  14.                     this.Invalidate();}
  15.                 }
  16.                 //r2
  17.                 else if (mouseX >= 744 && mouseX <= 794 && mouseY >= 506 && mouseY <= 556)
  18.                 {

  19.                     if (e.X >= 744 && e.X <= 794 && e.Y >= 556 && e.Y <= 656)
  20.                     {
  21.                         DD2();
  22.                         this.Invalidate();
  23.                     }
  24.                 }
  25.                 //r3
  26.                 else if (mouseX >= 794 && mouseX <= 844 && mouseY >= 506 && mouseY <= 556)
  27.                 {
  28.                     if (e.X >= 694 && e.X <= 794 && e.Y >= 506 && e.Y <= 556)
  29.                     {
  30.                         EE1();
  31.                         this.Invalidate();
  32.                     }
  33.                     if (e.X >= 794 && e.X <= 844 && e.Y >= 556 && e.Y <= 656)
  34.                     {
  35.                         DD3();
  36.                         this.Invalidate();
  37.                     }
  38.                 }
  39.                 //r4
  40.                 else if (mouseX >= 694 && mouseX <= 744 && mouseY >= 556 && mouseY <= 606)
  41.                 {

  42.                     if (e.X >= 744 && e.X <= 844 && e.Y >= 556 && e.Y <= 606)
  43.                     {
  44.                         E2();
  45.                         this.Invalidate();
  46.                     }
  47.                 }
  48.                 //r6
  49.                 else if (mouseX >= 794 && mouseX <= 844 && mouseY >= 556 && mouseY <= 606)
  50.                 {

  51.                     if (e.X >= 694 && e.X <= 794 && e.Y >= 556 && e.Y <= 606)
  52.                     {
  53.                         EE2();
  54.                         this.Invalidate();
  55.                     }
  56.                 }
  57.                 //r7
  58.                 if (mouseX >= 694 && mouseX <= 744 && mouseY >= 596 && mouseY <= 656)
  59.                 {
  60.                     if (e.X >= 744 && e.X <= 844 && e.Y >= 596 && e.Y <= 656)
  61.                     {
  62.                         E3();
  63.                         this.Invalidate();
  64.                     }
  65.                     if (e.X >= 694 && e.X <= 744 && e.Y >= 506 && e.Y <= 606)
  66.                     {
  67.                         D1();
  68.                         this.Invalidate();
  69.                     }
  70.                 }
  71.                 //r8
  72.                 else if (mouseX >= 744 && mouseX <= 794 && mouseY >= 606 && mouseY <= 656)
  73.                 {

  74.                     if (e.X >= 744 && e.X <= 794 && e.Y >= 506 && e.Y <= 606)
  75.                     {
  76.                         D2();
  77.                         this.Invalidate();
  78.                     }
  79.                 }
  80.                 //r9
  81.                 else if (mouseX >= 794 && mouseX <= 844 && mouseY >= 606 && mouseY <= 656)
  82.                 {
  83.                     if (e.X >= 694 && e.X <= 794 && e.Y >= 606 && e.Y <= 656)
  84.                     {
  85.                         EE3();
  86.                         this.Invalidate();
  87.                     }
  88.                     if (e.X >= 794 && e.X <= 844 && e.Y >= 506 && e.Y <= 606)
  89.                     {
  90.                         D3();
  91.                         this.Invalidate();
  92.                     }
  93.                 }
  94.                 //--------end
  95.                 #endregion
  96.                 cubece cubece = new cubece();
  97.                 string step=cubece.cemian(mouseX, mouseY, e.X, e.Y);
  98.                 zhengxiangx(step);
  99.                 //MessageBox.Show(step);
  100.                 //if (step == "E1")
  101.                 //{ MessageBox.Show("DDDD"); }
  102.                 isMouseDown = false;
  103.                 this.Refresh();
  104.             }
  105.         }
复制代码
回复 使用道具 举报
随机的方法
  1. private void button20_Click(object sender, EventArgs e)/*随机按键*/
  2.         {
  3.             if (textBox1.Text == "")
  4.             {
  5.                 MessageBox.Show("Please enter the random number!");
  6.                 return;
  7.             }
  8.             Random ra = new Random(unchecked((int)DateTime.Now.Ticks));
  9.             int tmp = 0;
  10.             int num = int.Parse(textBox1.Text);

  11.             for (int i = 0; i <= num - 1; i++)
  12.             {
  13.                 tmp = ra.Next(1, 12); //随机取数
  14.                 switch (tmp)
  15.                 {
  16.                     case 1:
  17.                         E1();
  18.                         break;
  19.                     case 2:
  20.                         U1();
  21.                         break;
  22.                     case 3:
  23.                         E3();
  24.                         break;
  25.                     case 4:
  26.                         EE1();
  27.                         break;
  28.                     case 5:
  29.                         UU1();
  30.                         break;
  31.                     case 6:
  32.                         EE3();
  33.                         break;
  34.                     case 7:
  35.                         D1();
  36.                         break;
  37.                     case 8:
  38.                         U3();
  39.                         break;
  40.                     case 9:
  41.                         D3();
  42.                         break;
  43.                     case 10:
  44.                         UU3();
  45.                         break;
  46.                     case 11:
  47.                         DD1();
  48.                         break;
  49.                     case 12:
  50.                         DD3();
  51.                         break;
  52.                     default:
  53.                         break;
  54.                 }
  55.             }
  56.             this.Invalidate();
  57.         }
复制代码
回复 使用道具 举报
视频窗体

QQ截图20130804114607.jpg (95.77 KB, 下载次数: 28)

QQ截图20130804114607.jpg

QQ截图20130804114645.jpg (99.72 KB, 下载次数: 24)

QQ截图20130804114645.jpg
回复 使用道具 举报
能分享一下源代码么
回复 使用道具 举报
得到坐标点颜色的方法 并分解成10进制16进制
分解成10进制后进行判断颜色
  1. Point p = new Point(MousePosition.X, MousePosition.Y);
  2.             textBox_p.Text = p.X + "," + p.Y;//The coordinates to the window display
  3.             IntPtr hdc = GetDC(new IntPtr(0));//Take to the device scene (0 is full screen equipment scenarios)
  4.             int c = GetPixel(hdc, p);
  5.             int r = (c & 0xFF);//transitionR
  6.             int g = (c & 0xFF00) / 256;//transitionG
  7.             int b = (c & 0xFF0000) / 65536;//transitionB
  8.             textBox_10jz.Text = c.ToString();//10 hexadecimal color output
  9.             textBox_16jz.Text = r.ToString("x").PadLeft(2, '0') + g.ToString("x").PadLeft(2, '0') + b.ToString("x").PadLeft(2, '0');//输出16进制颜色
  10.             textBox_RGB.Text = r.ToString() + ',' + g.ToString() + ',' + b.ToString();//Output RGB
  11.             textBox1.Text = this.Location.X + " " + this.Location.Y;
  12.             pictureBox9.BackColor = Color.FromArgb(r, g, b);//Set the color box
复制代码
回复 使用道具 举报
进行颜色的修正,将模糊的颜色分析修改成自己需要的指定颜色
  1.         private void MODcolor1()
  2.         {
  3.             int CR;
  4.             int CG;
  5.             int CB;
  6.             int MODC = 0;

  7.             CR = int.Parse(PIC1.BackColor.R.ToString());
  8.             CG = int.Parse(PIC1.BackColor.G.ToString());
  9.             CB = int.Parse(PIC1.BackColor.B.ToString());
  10.             if (CR > CG && CR > CG && (System.Math.Abs(CG - CB)) <= 30)
  11.             {
  12.                 MODC = 1;
  13.             }
  14.             else if (CB > CG && CB > CR && (System.Math.Abs(CG - CR)) <= 38 && CG > CR)
  15.             {
  16.                 MODC = 2;
  17.             }
  18.             else if (CG > CB && CG > CR && (System.Math.Abs(CB - CR)) <= 38 && CB > CR)
  19.             {
  20.                 MODC = 3;
  21.             }
  22.             else if (CR > CB && CG > CB && (System.Math.Abs(CG - CR)) <= 38)
  23.             {
  24.                 MODC = 4;
  25.             }
  26.             else if (CR > CG && CG > CB && (System.Math.Abs(CG - CR)) <= 95 && (System.Math.Abs(CG - CR)) >= 55)
  27.             {
  28.                 MODC = 5;
  29.             }
  30.             if ((System.Math.Abs(CG - CB)) <= 30 && (System.Math.Abs(CB - CR)) <= 30 && (System.Math.Abs(CG - CR)) <= 30)
  31.             {
  32.                 MODC = 6;
  33.             }
  34.             switch (MODC)
  35.             {

  36.                 case 0:
  37.                     //MessageBox.Show("1");
  38.                     error += " 1 ";
  39.                     break;
  40.                 case 1:
  41.                     PIC1.BackColor = Color.Red;
  42.                     break;
  43.                 case 2:
  44.                     PIC1.BackColor = Color.Blue;
  45.                     break;
  46.                 case 3:
  47.                     PIC1.BackColor = Color.Green;
  48.                     break;
  49.                 case 4:
  50.                     PIC1.BackColor = Color.Yellow;
  51.                     break;
  52.                 case 5:
  53.                     PIC1.BackColor = Color.Orange;
  54.                     break;
  55.                 case 6:
  56.                     PIC1.BackColor = Color.White;
  57.                     break;
  58.                 default:
  59.                     break;
  60.             }
  61.         }
复制代码
回复 使用道具 举报
发完了,欢迎大家喷我。。。。。
回复 使用道具 举报
小然 发表于 2013-8-4 12:11
能分享一下源代码么

会发的,但是不是现在:D
回复 使用道具 举报
回复 使用道具 举报
这么牛还来培训!!,让我们情何以堪
回复 使用道具 举报
进入黑马~技术分和博客都好难弄。。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马