コード例 #1
0
        //Initialize
        public override void Initialize(System.Windows.Forms.Form form, SpriteBatch spriteBatch)
        {
            //Load Images
            shapeHelper = new DirectX_Shape_Helper(Game.Content);

            //Initialize Shapes (get bounds and images)
            for (int i = 0; i < 4; i++)
            {
                stimStruct[i].shape     = Shape.Rectangle;
                stimStruct[i].type      = (Type)i;
                stimStruct[i].stimScale = 1;
                stimStruct[i]           = shapeHelper.GetShape(stimStruct[i]);
            }

            ////set up the Initial stimuli locations
            stimStruct[0].stimRect.Location = new Point((SCREENWIDTH - stimStruct[0].stimRect.Width) / 2, 0);                                              //Up
            stimStruct[1].stimRect.Location = new Point((SCREENWIDTH - stimStruct[1].stimRect.Width) / 2, SCREENHEIGHT - stimStruct[1].stimRect.Height);   //Down
            stimStruct[2].stimRect.Location = new Point((SCREENWIDTH - stimStruct[2].stimRect.Width), (SCREENHEIGHT - stimStruct[2].stimRect.Height) / 2); //Right
            stimStruct[3].stimRect.Location = new Point(0, (SCREENHEIGHT - stimStruct[3].stimRect.Height) / 2);                                            //Left

            ////Event Handlers
            form.MouseDown        += onMouseDown;
            form.MouseMove        += onMouseMove;
            form.MouseUp          += onMouseUp;
            form.MouseClick       += onMouseClick;
            form.MouseDoubleClick += onMouseDoubleClick;
            form.MouseWheel       += onMouseScroll;
            form.AllowTransparency = false;
            this.form = form;

            InterceptKeys.KeyDown += handleKeyDown;
            InterceptKeys.KeyUp   += handleKeyUp;

            base.Initialize(form, spriteBatch);
        }
コード例 #2
0
        //Handle mouse wheel
        private void onMouseScroll(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (mouseDown)
            {
                if (stimStruct[0].stimRect.Contains(new Point(e.X, e.Y)))
                {
                    if (e.Delta > 0)
                    {
                        stimStruct[0].stimScale += 0.05;
                        stimStruct[0]            = shapeHelper.GetShape(stimStruct[0]);
                    }
                    else if (e.Delta < 0)
                    {
                        stimStruct[0].stimScale -= 0.05;
                        stimStruct[0]            = shapeHelper.GetShape(stimStruct[0]);
                    }
                }
                else if (stimStruct[1].stimRect.Contains(new Point(e.X, e.Y)))
                {
                    if (e.Delta > 0)
                    {
                        stimStruct[1].stimScale += 0.05;
                        stimStruct[1]            = shapeHelper.GetShape(stimStruct[1]);
                    }
                    else if (e.Delta < 0)
                    {
                        stimStruct[1].stimScale -= 0.05;
                        stimStruct[1]            = shapeHelper.GetShape(stimStruct[1]);
                    }
                }
                else if (stimStruct[2].stimRect.Contains(new Point(e.X, e.Y)))
                {
                    if (e.Delta > 0)
                    {
                        stimStruct[2].stimScale += 0.05;
                        stimStruct[2]            = shapeHelper.GetShape(stimStruct[2]);
                    }
                    else if (e.Delta < 0)
                    {
                        stimStruct[2].stimScale -= 0.05;
                        stimStruct[2]            = shapeHelper.GetShape(stimStruct[2]);
                    }
                }
                else if (stimStruct[3].stimRect.Contains(new Point(e.X, e.Y)))
                {
                    if (e.Delta > 0)
                    {
                        stimStruct[3].stimScale += 0.05;
                        stimStruct[3]            = shapeHelper.GetShape(stimStruct[3]);
                    }
                    else if (e.Delta < 0)
                    {
                        stimStruct[3].stimScale -= 0.05;
                        stimStruct[3]            = shapeHelper.GetShape(stimStruct[3]);
                    }
                }
            }
            else
            {
                if (e.Delta > 0)
                {
                    stimStruct[0].stimScale += 0.05;
                    stimStruct[0]            = shapeHelper.GetShape(stimStruct[0]);
                    stimStruct[1].stimScale += 0.05;
                    stimStruct[1]            = shapeHelper.GetShape(stimStruct[1]);
                    stimStruct[2].stimScale += 0.05;
                    stimStruct[2]            = shapeHelper.GetShape(stimStruct[2]);
                    stimStruct[3].stimScale += 0.05;
                    stimStruct[3]            = shapeHelper.GetShape(stimStruct[3]);
                }
                else if (e.Delta < 0)
                {
                    stimStruct[0].stimScale -= 0.05;
                    stimStruct[0]            = shapeHelper.GetShape(stimStruct[0]);
                    stimStruct[1].stimScale -= 0.05;
                    stimStruct[1]            = shapeHelper.GetShape(stimStruct[1]);
                    stimStruct[2].stimScale -= 0.05;
                    stimStruct[2]            = shapeHelper.GetShape(stimStruct[2]);
                    stimStruct[3].stimScale -= 0.05;
                    stimStruct[3]            = shapeHelper.GetShape(stimStruct[3]);
                }
            }

            //Update background rectangles
            dxInterface.UpdateFormImages(stimStruct);
        }