public PlayerPanel(PlayerType playerType, PanelPos panelPos, GameDelegate turn, GameDelegate over, GameDelegate check)
        {
            this.playerType = playerType;
            this.panelPos   = panelPos;
            this.turn       = turn;

            cellSize = 25;

            switch (panelPos)
            {
            case PanelPos.left:
                Name = "player1";
                break;

            case PanelPos.right:
                Name = "player2";
                break;
            }

            CreateBtns();

            brain = new Brain(DrawBtns, over, check, RedrawBtns, playerType);

            if (playerType == PlayerType.human)
            {
                CreateSwitchBtn();
            }

            if (playerType == PlayerType.bot)
            {
                BotPlacement();
            }
        }
        public Panel(PanelPos panelPos)
        {
            this.Show();
            InitializeComponent();
            PanelPosition = panelPos;
            SetPanelPos(PanelPosition);

            PanelID = LastPanelID++;
        }
        public void SetPanelPos(PanelPos panelPos)// Sets working area and checks if panels arent overlaying
        {
            switch (panelPos)
            {
            case PanelPos.Bottom:
                if (!MainWindow.Panels.Any(x => x.PanelPosition == PanelPos.Bottom))
                {
                    SpaceReserver.MakeNewDesktopArea(0, 0, 0, PanelHeight);
                    PanelPosition = PanelPos.Bottom;
                    this.Left     = 0;
                    this.Top      = System.Windows.SystemParameters.PrimaryScreenHeight - PanelHeight;
                }
                break;

            case PanelPos.Top:
                if (!MainWindow.Panels.Any(x => x.PanelPosition == PanelPos.Top))
                {
                    SpaceReserver.MakeNewDesktopArea(0, PanelHeight, 0, 0);
                    PanelPosition = PanelPos.Top;
                    this.Left     = 0;
                    this.Top      = 0;
                }
                break;

            case PanelPos.Left:
                if (!MainWindow.Panels.Any(x => x.PanelPosition == PanelPos.Left))
                {
                    int tmp = PanelHeight;
                    PanelHeight = PanelWidth;
                    PanelWidth  = tmp;
                    SpaceReserver.MakeNewDesktopArea(PanelHeight, 0, 0, 0);
                    PanelPosition = PanelPos.Left;
                    this.Left     = 0;
                    this.Top      = 0;
                }
                break;

            case PanelPos.Right:
                if (!MainWindow.Panels.Any(x => x.PanelPosition == PanelPos.Right))
                {
                    int tmp = PanelHeight;
                    PanelHeight = PanelWidth;
                    PanelWidth  = tmp;
                    SpaceReserver.MakeNewDesktopArea(0, 0, PanelHeight, 0);
                    PanelPosition = PanelPos.Right;
                    this.Left     = System.Windows.SystemParameters.PrimaryScreenWidth - PanelWidth;
                    this.Top      = 0;
                }
                break;
            }
            this.Width          = PanelWidth;
            this.Height         = PanelHeight;
            PanelElem.MaxWidth  = PanelWidth;
            PanelElem.MaxHeight = PanelHeight;
        }
Exemple #4
0
 public void SetPanelPos(PanelPos panelPos)// Sets working area and checks if panels arent overlaying
 {
     SpaceReserver.MakeNewDesktopArea(0, 32, 0, 0);
     Dispatcher.Invoke(
         () =>
     {
         PanelPosition = PanelPos.Top;
         this.Left     = 0;
         this.Top      = 0;
         this.Width    = PanelWidth;
         this.Height   = PanelHeight;
     });
     InteropHelper.SetWindowPos(Process.GetCurrentProcess().MainWindowHandle, InteropHelper.HWND_TOPMOST, 0, 0, 0, 0, InteropHelper.TOPMOST_FLAGS);
 }