コード例 #1
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (!_gameStarted && _startRectangle.Contains(e.Location))
            {
                ResetTiles();

                GameStarted = true;
                OnStartClicked?.Invoke(this, null);
            }
            else if (_gameStarted && _cashOutRectangle.Contains(e.Location))
            {
                ResetTiles();

                GameStarted = false;
                OnCashoutClicked?.Invoke(this, null);
            }
            else
            {
                var tile = _tiles.FirstOrDefault(t => t.Rectangle.Contains(e.Location));
                if (tile != null)
                {
                    OnGridClicked?.Invoke(tile.Guess);
                }
            }

            base.OnMouseClick(e);
        }
コード例 #2
0
        private void CreateContextMenu()
        {
            var contextMenu = new System.Windows.Forms.ContextMenu();

            var showMenuItem = CreateMenuItem("Show", () =>
            {
                _window.Show();
                _window.WindowState = System.Windows.WindowState.Normal;
            });

            contextMenu.MenuItems.Add(showMenuItem);

            var startMenuItem = CreateMenuItem("Start", () =>
            {
                OnStartClicked?.Invoke();
                _window.Hide();
            });

            contextMenu.MenuItems.Add(startMenuItem);

            NotifyIcon.ContextMenu = contextMenu;
        }