Exemple #1
0
        public GameBoardView()
        {
            this.MinimumSize = new Size(4*250/3, 250);

            QuizShow.Board.AddView(this);

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.StandardDoubleClick, false);
            SetStyle(ControlStyles.StandardClick, true);
            SetStyle(ControlStyles.Selectable, true);

            BackColor = Color.FromArgb(240, 200, 70);
            ClueBackColor = Color.Blue;

            Board board = QuizShow.Board;

            for (int x = 0; x < 6; x++)
            {
                for (int y = -1; y < 5; y++)
                {
                    GameBoardButton b = new GameBoardButton(this);
                    b.Clickable = (y >= 0);
                    b.IsTitle = (y < 0);
                    b.Click += new EventHandler(OnBoardButtonClick);
                    b.TrackingChanged += new EventHandler(OnBoardButtonTrackChange);
                    btnPoints.Add(b, new Point(x, y));

                    if (y >= 0)
                        b.Text = board.PointValues[y].ToString();
                    else
                    {
                        if (x < board.Category.Length)
                            b.Text = board.Category[x].Name;
                        board.Category[x].PropertyChanged += new PropertyChangedEventHandler(WeakItemChanged);
                    }

                    btns[x, y+1] = b;
                }
            }

            OnSizeChanged(EventArgs.Empty);
        }
Exemple #2
0
 private MouseEventArgs TranslateMouseEvent(MouseEventArgs e, GameBoardButton b)
 {
     return new MouseEventArgs(e.Button, e.Clicks, e.X-b.Location.X, e.Y-b.Location.Y, e.Delta);
 }
Exemple #3
0
        private void OnMouseOverButton(GameBoardButton btn)
        {
            // if we're over the same button, nothing's changed (duh)
            if (mouseOverButton == btn)
                return;

            // if we used to be over a button... need to notify it that the mouse left
            if (mouseOverButton != null)
            {
                mouseOverButton.OnMouseLeave(EventArgs.Empty);

                // if there's no new active button, and we're tracking a button but don't
                // have focus, we need to do one of two things:
                if (btn == null && !Focused && HasTrackedButton)
                {
                    if (HasSelectedButton)
                        // set the tracking button back to the one that is selected
                        SetTracked(btnPoints[SelectedButton].X, btnPoints[SelectedButton].Y);
                    else
                    {
                        // or keep the tracking on but just hidden
                        TrackedButton.Tracking = false;
                    }
                }
            }

            mouseOverButton = btn;

            Point pt = btn != null ? btnPoints[btn] : new Point(-1, -1);

            if (btn != null)
            {
                // send mouse-enter event, and update tracking
                mouseOverButton.OnMouseEnter(EventArgs.Empty);
                SetTracked(pt.X, pt.Y);
            }
        }
Exemple #4
0
 public void SetCapture(GameBoardButton btn, bool capture)
 {
     if (!capture)
     {
         Capture = false;
         captureButton = null;
     }
     else
     {
         Capture = true;
         captureButton = btn;
     }
 }