Beispiel #1
0
 private void TableDisplay_MouseMove(object sender, MouseEventArgs e)
 {
     if (mouseDown)
     {
         if (tablePositionValid(e))
         {
             if (GameTableArrayVisible[e.X / 16, e.Y / 16] == State.Normal || GameTableArrayVisible[e.X / 16, e.Y / 16] == State.Question)
             {
                 MouseDownAction(e);
             }
             else
             {
                 previousPosition   = new Point(e.X / 16, e.Y / 16);
                 TableDisplay.Image = temp;
                 TableDisplay.Refresh();
             }
         }
         else
         {
             TableDisplay.Image = temp;
             previousPosition   = new Point(-1, -1);
             TableDisplay.Refresh();
         }
     }
 }
 public void LoadList(object list, TableDisplay tableDisplay)
 {
     try
     {
         QueryControl.LoadList(list, tableDisplay);
     }
     catch (Exception e)
     {
     }
 }
Beispiel #3
0
        private void TableDisplay_MouseDown(object sender, MouseEventArgs e)
        {
            if (!ignore)
            {
                int x = e.X / 16;
                int y = e.Y / 16;
                if (e.Button == MouseButtons.Left)
                {
                    mouseDown     = true;
                    MainBtn.Image = Face(Faces.Wow);
                    temp          = new Bitmap((Bitmap)TableDisplay.Image);

                    if (GameTableArrayVisible[x, y] == State.Normal || GameTableArrayVisible[x, y] == State.Question)
                    {
                        MouseDownAction(e);
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    switch (GameTableArrayVisible[x, y])
                    {
                    case State.Normal:
                        UpdateMines(--Mines);
                        GameTableArrayVisible[x, y] = State.Flag;
                        GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.Flag]);
                        break;

                    case State.Flag:
                        UpdateMines(++Mines);
                        if (MNU_Marks.Checked)
                        {
                            GameTableArrayVisible[x, y] = State.Question;
                            GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.Question]);
                        }
                        else
                        {
                            GameTableArrayVisible[x, y] = State.Normal;
                            GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.Normal]);
                        }
                        break;

                    case State.Question:
                        GameTableArrayVisible[x, y] = State.Normal;
                        GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.Normal]);
                        break;
                    }
                    TableDisplay.Refresh();
                }
            }
        }
Beispiel #4
0
        public void LoadList(object list, TableDisplay tableDisplay)
        {
            DataGuest.Columns.Clear();


            foreach (DataGridColumn column in tableDisplay.getGridColumns())
            {
                DataGuest.Columns.Add(column);
            }

            DataGuest.ItemsSource = list as IEnumerable <object>;

            InitGridContextMenu(tableDisplay.ToView, tableDisplay.ToUpdate, tableDisplay.ToDelete);
        }
Beispiel #5
0
 void MouseDownAction(MouseEventArgs e)
 {
     if (temp != null)
     {
         if (previousPosition.X != e.X / 16 || previousPosition.Y != e.Y / 16)
         {
             TableDisplay.Image = temp;
             TableDisplay.Refresh();
             HoverAction(e);
         }
     }
     else
     {
         HoverAction(e);
     }
     previousPosition = new Point(e.X / 16, e.Y / 16);
 }
Beispiel #6
0
 void HoverAction(MouseEventArgs e)
 {
     temp = new Bitmap((Bitmap)TableDisplay.Image);
     if (tablePositionValid(e))
     {
         int x = e.X / 16;
         int y = e.Y / 16;
         if (GameTableArrayVisible[x, y] == State.Normal)
         {
             GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.Empty]);
         }
         else if (GameTableArrayVisible[x, y] == State.Question)
         {
             GraphicsOver((Bitmap)TableDisplay.Image, x * 16, y * 16, Buttons[(int)State.QuestionClicked]);
         }
         TableDisplay.Refresh();
     }
 }
Beispiel #7
0
        void CheckVictory()
        {
            int cnt  = 0;
            int cnt2 = 0;

            foreach (var element in GameTableArrayVisible)
            {
                if (element == State.Flag || element == State.Normal)
                {
                    cnt++;
                }
            }
            foreach (var element in GameTableArrayVisible)
            {
                if (element == State.Question)
                {
                    cnt2++;
                }
            }
            if (cnt == Settings.Default.StartMines && cnt2 == 0)
            {
                timer1.Enabled = false;
                MainBtn.Image  = Face(Faces.Win);
                ignore         = true;

                Bitmap act = (Bitmap)TableDisplay.Image;
                for (int x = 0; x < Settings.Default.StartSize.Width; x++)
                {
                    for (int y = 0; y < Settings.Default.StartSize.Height; y++)
                    {
                        if (GameTableArrayVisible[x, y] == State.Normal)
                        {
                            GameTableArrayVisible[x, y] = State.Flag;
                            FastGraphicsOver(act, x * 16, y * 16, Buttons[(int)State.Flag]);
                        }
                    }
                }
                TableDisplay.Refresh();
            }
        }
Beispiel #8
0
 private void TableDisplay_MouseUp(object sender, MouseEventArgs e)
 {
     if (!ignore)
     {
         Bitmap act = (Bitmap)TableDisplay.Image;
         int    x = e.X / 16, y = e.Y / 16;
         mouseDown = false;
         if (e.Button == MouseButtons.Left)
         {
             if (e.X >= 0 && e.Y >= 0 && e.X < TableDisplay.Image.Size.Width && e.Y < TableDisplay.Image.Size.Height)
             {
                 if (GameTableArray[x, y] == State.Mine)
                 {
                     timer1.Enabled = false;
                     FastGraphicsOver(act, x * 16, y * 16, Buttons[(int)State.MineClicked]);
                     TableDisplay.Refresh();
                     MainBtn.Image = Face(Faces.Sad);
                     ignore        = true;
                     for (int y2 = 0; y2 < Settings.Default.StartSize.Height; y2++)
                     {
                         for (int x2 = 0; x2 < Settings.Default.StartSize.Width; x2++)
                         {
                             if (GameTableArray[x2, y2] == State.Mine && GameTableArrayVisible[x2, y2] != State.Flag)
                             {
                                 GraphicsOver(act, x2 * 16, y2 * 16, Buttons[(int)State.Mine]);
                             }
                             else if (GameTableArray[x2, y2] != State.Mine && GameTableArrayVisible[x2, y2] == State.Flag)
                             {
                                 FastGraphicsOver(act, x2 * 16, y2 * 16, Buttons[(int)State.NotMine]);
                             }
                         }
                     }
                     GraphicsOver(act, x * 16, y * 16, Buttons[(int)State.MineClicked]);
                 }
                 else
                 {
                     if (!timer1.Enabled)
                     {
                         timer1.Enabled = true;
                     }
                     MainBtn.Image = Face(Faces.Happy);
                     GameTableArrayVisible[x, y] = State.Empty;
                     FastGraphicsOver(act, x * 16, y * 16, Buttons[(int)GameTableArray[x, y]]);
                     freeSpace(new Point(x, y), new Size(Settings.Default.StartSize.Width, Settings.Default.StartSize.Height));
                 }
                 TableDisplay.Refresh();
                 CheckVictory();
             }
             else
             {
                 MainBtn.Image = Face(Faces.Happy);
             }
         }
         else if (e.Button == MouseButtons.Right)
         {
             if (e.X >= 0 && e.Y >= 0 && e.X < TableDisplay.Image.Size.Width && e.Y < TableDisplay.Image.Size.Height)
             {
                 CheckVictory();
             }
         }
     }
 }