示例#1
0
 public void onSound(string sender, string type)
 {
     if (type == "MouseUp")
     {
         this.SoundOn = !this.SoundOn;
         UI.Element elementByName = this.myUI.GetElementByName("Sound");
         elementByName.isDisplayFore = !elementByName.isDisplayFore;
         this.myUI.myPictureBox.Invalidate();
     }
 }
示例#2
0
        private void ThunderAnimation()
        {
            UI.Element  elementByName = null;
            Form_Fidget squareCnt     = this;

            squareCnt.SquareCnt = squareCnt.SquareCnt + 1;
            Form_Fidget redCnt = this;

            redCnt.RedCnt = redCnt.RedCnt + 1;
            Form_Fidget blueCnt1 = this;

            blueCnt1.BlueCnt1 = blueCnt1.BlueCnt1 + 1;
            Form_Fidget blueCnt2 = this;

            blueCnt2.BlueCnt2 = blueCnt2.BlueCnt2 + 1;
            if (this.FireAniEn)
            {
                Form_Fidget fireButtonCnt = this;
                fireButtonCnt.FireButtonCnt = fireButtonCnt.FireButtonCnt + 1;
            }
            if (this.SquareCnt == 8)
            {
                elementByName = this.myUI.GetElementByName("Square1");
                elementByName.isDisplayFore = false;
                elementByName = this.myUI.GetElementByName("Square2");
                elementByName.isDisplayFore = false;
                elementByName = this.myUI.GetElementByName("Square3");
                elementByName.isDisplayFore = false;
            }
            else if (this.SquareCnt == 16)
            {
                elementByName = this.myUI.GetElementByName("Square1");
                elementByName.isDisplayFore = false;
                elementByName = this.myUI.GetElementByName("Square2");
                elementByName.isDisplayFore = false;
                elementByName = this.myUI.GetElementByName("Square3");
                elementByName.isDisplayFore = true;
            }
            else if (this.SquareCnt == 24)
            {
                elementByName = this.myUI.GetElementByName("Square1");
                elementByName.isDisplayFore = false;
                elementByName = this.myUI.GetElementByName("Square2");
                elementByName.isDisplayFore = true;
                elementByName = this.myUI.GetElementByName("Square3");
                elementByName.isDisplayFore = true;
            }
            else if (this.SquareCnt >= 32)
            {
                elementByName = this.myUI.GetElementByName("Square1");
                elementByName.isDisplayFore = true;
                elementByName = this.myUI.GetElementByName("Square2");
                elementByName.isDisplayFore = true;
                elementByName = this.myUI.GetElementByName("Square3");
                elementByName.isDisplayFore = true;
                this.SquareCnt = 0;
            }
            if (this.FireButtonCnt == this.SpeedCnt)
            {
                elementByName = this.myUI.GetElementByName("Fire");
                elementByName.ImageForeground = this.FirePic1;
                elementByName.isDisplayFore   = true;
            }
            else if (this.FireButtonCnt == this.SpeedCnt * 2)
            {
                elementByName = this.myUI.GetElementByName("Fire");
                elementByName.ImageForeground = this.FirePic2;
                elementByName.isDisplayFore   = true;
            }
            else if (this.FireButtonCnt == this.SpeedCnt * 3)
            {
                elementByName = this.myUI.GetElementByName("Fire");
                elementByName.ImageForeground = this.FirePic3;
                elementByName.isDisplayFore   = true;
            }
            else if (this.FireButtonCnt >= this.SpeedCnt * 4)
            {
                elementByName = this.myUI.GetElementByName("Fire");
                elementByName.ImageForeground = this.FirePic0;
                elementByName.isDisplayFore   = false;
                this.FireButtonCnt            = 0;
            }
            if (this.RedCnt > this.RedRandCnt)
            {
                elementByName = this.myUI.GetElementByName("RedRect1");
                elementByName.isDisplayFore = !elementByName.isDisplayFore;
                this.RedCnt = 0;
                if (elementByName.isDisplayFore)
                {
                    this.RedRandCnt = this.Rand.Next(20, 50);
                }
                else
                {
                    this.RedRandCnt = this.Rand.Next(10, 20);
                }
            }
            if (this.BlueCnt1 > this.BlueRandCnt1)
            {
                elementByName = this.myUI.GetElementByName("BlueRect1");
                elementByName.isDisplayFore = !elementByName.isDisplayFore;
                this.BlueCnt1 = 0;
                if (elementByName.isDisplayFore)
                {
                    this.BlueRandCnt1 = this.Rand.Next(30, 70);
                }
                else
                {
                    this.BlueRandCnt1 = this.Rand.Next(5, 20);
                }
            }
            if (this.BlueCnt2 > this.BlueRandCnt2)
            {
                elementByName = this.myUI.GetElementByName("BlueRect2");
                elementByName.isDisplayFore = !elementByName.isDisplayFore;
                this.BlueCnt2 = 0;
                if (elementByName.isDisplayFore)
                {
                    this.BlueRandCnt2 = this.Rand.Next(50, 120);
                }
                else
                {
                    this.BlueRandCnt2 = this.Rand.Next(5, 10);
                }
            }
            this.myUI.myPictureBox.Invalidate();
        }
示例#3
0
        private void KeyHandle(bool IsDown, KeyEventArgs e)
        {
            UI.Element elementByName = null;
            if (!IsDown)
            {
                this.Action        = false;
                this.CurrentAction = Form_Fidget.STATUS.IDLE;
                if (!this.Firing && !this.nFire && !this.ReSet && !this.Calibrate)
                {
                    switch (e.KeyCode)
                    {
                    case Keys.Left:
                    {
                        elementByName = this.myUI.GetElementByName("Left");
                        break;
                    }

                    case Keys.Up:
                    {
                        this.UpPress  = false;
                        elementByName = this.myUI.GetElementByName("Up");
                        break;
                    }

                    case Keys.Right:
                    {
                        elementByName = this.myUI.GetElementByName("Right");
                        break;
                    }

                    case Keys.Down:
                    {
                        this.DownPress = false;
                        elementByName  = this.myUI.GetElementByName("Down");
                        break;
                    }
                    }
                    if (elementByName != null)
                    {
                        if (this.SoundOn)
                        {
                            this.Wavplayer.Stop();
                        }
                        elementByName.isDisplayFore = false;
                        this.myUI.myPictureBox.Invalidate();
                    }
                    this.SendUSBData(this.STOP);
                    DateTime now = DateTime.Now;
                    this.TestTime[this.TestTimeCnt] = now.Subtract(this.start);
                    Form_Fidget testTimeCnt = this;
                    testTimeCnt.TestTimeCnt = testTimeCnt.TestTimeCnt + 1;
                    if (this.TestTimeCnt >= 10)
                    {
                        this.TestTimeCnt = 0;
                    }
                }
            }
            else
            {
                Keys keyCode = e.KeyCode;
                if (keyCode != Keys.Return)
                {
                    switch (keyCode)
                    {
                    case Keys.Space:
                    {
                        if (!this.Firing && !this.Fired && !this.nFire && !this.ReSet && this.DevicePresent)
                        {
                            if (this.SoundOn)
                            {
                                this.Wavplayer.SoundLocation = Path.Combine(this.uiPath, "firing.wav");
                                this.Wavplayer.PlayLooping();
                            }
                            elementByName    = this.myUI.GetElementByName("Fire");
                            this.Firing      = true;
                            this.FireCheck   = false;
                            this.FireTimeout = 0;
                            this.SendUSBData(this.FIRE);
                            this.FireCnt   = 0;
                            this.FireAniEn = true;
                            this.SpeedCnt  = 2;
                        }
                        this.Action = true;
                        break;
                    }

                    case Keys.Left:
                    {
                        if ((this.Current_Status & 4) != 4 && !this.Firing && !this.Fired && !this.Action && !this.ReSet && this.DevicePresent)
                        {
                            Thread.Sleep(100);
                            this.Action   = true;
                            elementByName = this.myUI.GetElementByName("Left");
                            if (this.SoundOn)
                            {
                                this.Wavplayer.SoundLocation = Path.Combine(this.uiPath, "move.wav");
                                this.Wavplayer.PlayLooping();
                            }
                            this.SendUSBData(this.LEFT);
                            this.CurrentAction = Form_Fidget.STATUS.LEFT_LIMIT;
                        }
                        this.Action = true;
                        break;
                    }

                    case Keys.Up:
                    {
                        if ((this.Current_Status & 2) != 2 && !this.Firing && !this.Fired && !this.Action && !this.ReSet && this.DevicePresent)
                        {
                            this.UpPress  = true;
                            this.UpCnt    = 0;
                            this.Action   = true;
                            elementByName = this.myUI.GetElementByName("Up");
                            if (this.SoundOn)
                            {
                                this.Wavplayer.SoundLocation = Path.Combine(this.uiPath, "move.wav");
                                this.Wavplayer.PlayLooping();
                            }
                            this.SendUSBData(this.UP);
                            Thread.Sleep(40);
                            this.SendUSBData(this.STOP);
                            this.start         = DateTime.Now;
                            this.CurrentAction = Form_Fidget.STATUS.UP_LIMIT;
                        }
                        this.Action = true;
                        break;
                    }

                    case Keys.Right:
                    {
                        if ((this.Current_Status & 8) != 8 && !this.Firing && !this.Fired && !this.Action && !this.ReSet && this.DevicePresent)
                        {
                            Thread.Sleep(100);
                            this.Action   = true;
                            elementByName = this.myUI.GetElementByName("Right");
                            if (this.SoundOn)
                            {
                                this.Wavplayer.SoundLocation = Path.Combine(this.uiPath, "move.wav");
                                this.Wavplayer.PlayLooping();
                            }
                            this.SendUSBData(this.RIGHT);
                            this.CurrentAction = Form_Fidget.STATUS.RIGHT_LIMIT;
                        }
                        this.Action = true;
                        break;
                    }

                    case Keys.Down:
                    {
                        if ((this.Current_Status & 1) != 1 && !this.Firing && !this.Fired && !this.Action && !this.ReSet && this.DevicePresent)
                        {
                            this.DownPress = true;
                            this.DownCnt   = 0;
                            this.Action    = true;
                            elementByName  = this.myUI.GetElementByName("Down");
                            if (this.SoundOn)
                            {
                                this.Wavplayer.SoundLocation = Path.Combine(this.uiPath, "move.wav");
                                this.Wavplayer.PlayLooping();
                            }
                            this.SendUSBData(this.DOWN);
                            Thread.Sleep(40);
                            this.SendUSBData(this.STOP);
                            this.start         = DateTime.Now;
                            this.CurrentAction = Form_Fidget.STATUS.DOWN_LIMIT;
                        }
                        this.Action = true;
                        break;
                    }
                    }
                }
                if (elementByName != null)
                {
                    elementByName.isDisplayFore = true;
                    this.myUI.myPictureBox.Invalidate();
                    return;
                }
            }
        }
示例#4
0
        private void Form_Fidget_Load(object sender, EventArgs e)
        {
            Application.ThreadException += new ThreadExceptionEventHandler(ExceptionHandle.Application_ThreadException);
            if (File.Exists("debug"))
            {
                this.DebugMode = true;
            }
            string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            folderPath = Path.Combine(folderPath, "Thunder");
            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
            this.appPath   = Application.StartupPath;
            this.uiPath    = Path.Combine(this.appPath, "Skin");
            this.Wavplayer = new SoundPlayer();
            this.Vertical  = TimeSpan.Parse("00:00:00.8720499");
            this.Horizon   = TimeSpan.Parse("00:00:08.1919686");
            //this.about = new AboutBox();
            this.myUI         = new UI(this, this.pictureBox1, this.toolTip1, this.uiPath, "Launcher.xml");
            this.myUITrayIcon = new UITrayIcon(this, this.about, this.notifyIcon1, this.contextMenuStrip1);
            UI.Element elementByName = this.myUI.GetElementByName("Fire");
            this.FirePic0   = new Bitmap(elementByName.ImageForeground);
            this.FirePic1   = new Bitmap(Path.Combine(this.uiPath, "fire1.png"));
            this.FirePic2   = new Bitmap(Path.Combine(this.uiPath, "fire2.png"));
            this.FirePic3   = new Bitmap(Path.Combine(this.uiPath, "fire3.png"));
            this.IconOff    = new Icon(string.Concat(this.uiPath, "\\icon2.ico"));
            this.IconActive = new Icon(string.Concat(this.uiPath, "\\icon1.ico"));
            this.myUITrayIcon.myNotifyIcon.Text = "THUNDER";
            this.myUITrayIcon.myNotifyIcon.Icon = this.IconOff;
            this.myUI.AddEvent("Close", new UI.FunctionPointer(this.onClose));
            this.myUI.AddEvent("Minimize", new UI.FunctionPointer(this.onMinimize));
            this.myUI.AddEvent("Up", new UI.FunctionPointer(this.KeyHandle));
            this.myUI.AddEvent("Down", new UI.FunctionPointer(this.KeyHandle));
            this.myUI.AddEvent("Left", new UI.FunctionPointer(this.KeyHandle));
            this.myUI.AddEvent("Right", new UI.FunctionPointer(this.KeyHandle));
            this.myUI.AddEvent("Fire", new UI.FunctionPointer(this.KeyHandle));
            this.myUI.AddEvent("Exit", new UI.FunctionPointer(this.onClose));
            this.myUI.AddEvent("Sound", new UI.FunctionPointer(this.onSound));
            this.myUI.AddEvent("Reset", new UI.FunctionPointer(this.onReset));
            this.myUI.AddEvent("logo", new UI.FunctionPointer(this.onLogo));
            this.pictureBox1.MouseMove += new MouseEventHandler(this.myUI.MouseMove);
            this.pictureBox1.MouseDown += new MouseEventHandler(this.myUI.MouseDown);
            this.pictureBox1.MouseUp   += new MouseEventHandler(this.myUI.MouseUp);
            this.pictureBox1.Paint     += new PaintEventHandler(this.myUI.Paint);
            this.MoveHeight             = 12;
            this.MoveWidth              = 8;
            this.RedCnt          = this.Rand.Next(0, 40);
            this.BlueCnt1        = this.Rand.Next(0, 40);
            this.BlueCnt2        = this.Rand.Next(0, 40);
            this.RedRandCnt      = this.Rand.Next(40, 80);
            this.BlueRandCnt1    = this.Rand.Next(40, 80);
            this.BlueRandCnt2    = this.Rand.Next(40, 80);
            this.SpeedCnt        = 5;
            this.USB.VID_List[0] = 2689;
            this.USB.PID_List[0] = 1793;
            this.USB.VID_List[1] = 8483;
            this.USB.PID_List[1] = 4112;
            this.USB.ID_List_Cnt = 2;
            this.USB.RegisterHandle(base.Handle);
            this.timer1.Start();
        }