Exemple #1
0
        private void DisplayBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_cellSelection)
            {
                m_cellSelection = false;

                Point topLeft = SnapToScaledGrid(m_movingPoint);
                Point cell    = SnapToScaledGrid(m_cellMousePoint);

                int cellX = Convert.ToInt32((cell.X - topLeft.X) / m_scaleDpi);
                int cellY = Convert.ToInt32((cell.Y - topLeft.Y) / m_scaleDpi);

                Tuple <int, int> selectedCell = new Tuple <int, int>(cellX, cellY);

                CellSelected?.Invoke(this, new CellSelectedEventArgs(selectedCell));
            }
            else
            {
                m_isPanning     = true;
                m_startingPoint = new Point(e.Location.X - m_movingPoint.X,
                                            e.Location.Y - m_movingPoint.Y);

                this.Cursor = Cursors.SizeAll;
            }
        }
Exemple #2
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            if (e.Button == MouseButtons.Left)
            {
                var hit = HitTest(e.Location);

                if (hit != null)
                {
                    SelectedIndex = hit.Index;

                    foreach (var pair in Cells)
                    {
                        pair.Value.Selected = false;
                    }

                    hit.Selected = true;

                    CellSelected?.Invoke(this, new EventArgs());

                    Invalidate();
                }
            }
        }
Exemple #3
0
        private static void ClearEventHandlers()
        {
            if (CellSelected != null && CellUnselected != null && ScoreUpdated != null)
            {
                foreach (EventHandler <ActionCellEventArgs> handler in CellSelected.GetInvocationList())
                {
                    CellSelected -= handler;
                }

                foreach (EventHandler <ActionCellEventArgs> handler in CellUnselected.GetInvocationList())
                {
                    CellUnselected -= handler;
                }

                foreach (Action <int> handler in ScoreUpdated?.GetInvocationList())
                {
                    ScoreUpdated -= handler;
                }

                foreach (Action handler in GameOver.GetInvocationList())
                {
                    GameOver -= handler;
                }
            }
        }
        /// <summary>
        ///     Updates current online selections or adds a new one if not found
        /// </summary>
        /// <param name="selected">CellSelected Json object</param>
        private void OnNewCellSelection(CellSelected selected)
        {
            int col = Regex.Match(selected.GetCellName(), @"^[A-Z]").Value[0] - 'A';
            int row = int.Parse(Regex.Match(selected.GetCellName(), @"\d*$").Value);

            spreadsheetPanel.UpdateOnlineSelection(col, row - 1, selected.GetClientID(), selected.GetClientName());
        }
Exemple #5
0
    public void OnClickCell()
    {
        if (_card == null)
        {
            return;
        }

        CellSelected?.Invoke(_card);
    }
Exemple #6
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == MouseButtons.Left)
     {
         clickX = e.X;
         clickY = e.Y;
         oldX   = x;
         oldY   = y;
     }
     else if (e.Button == MouseButtons.Right)
     {
         cellC    = (x + e.X) / tileSize;
         cellR    = (y + e.Y) / tileSize;
         oldCellX = cellC;
         oldCellY = cellR;
         drawCell = true;
         CellSelected?.Invoke(this, new CellSelectedEventArgs()
         {
             Column = cellC, Row = cellR
         });
         this.Invalidate();
     }
 }
Exemple #7
0
 private void Awake()
 {
     for (int row = 0; row < FieldState.Dimension; ++row)
     {
         for (int column = 0; column < FieldState.Dimension; ++column)
         {
             // Prevent reference capture by the lambda.
             int copyRow    = row;
             int copyColumn = column;
             selectors[row * FieldState.Dimension + column].onClick.AddListener(() => CellSelected?.Invoke(this, new CellSelectedEventArgs(copyRow, copyColumn)));
         }
     }
 }
Exemple #8
0
 public static void OnCellSelected(Cell cell) => CellSelected?.Invoke(cell);
Exemple #9
0
 /// <summary>
 /// Method called when the cell is selected.
 /// Raises the CellSelected event.
 /// </summary>
 protected virtual void OnCellSelected()
 {
     CellSelected?.Invoke(this, Row, Column);
 }