Example #1
0
        public MainForm()
        {
            InitializeComponent();
            this.groupBox2.Enabled = false;

            GameManager = new GameManager();
            Dictionary<string, GameInfo> allGames = GameManager.Games;
            for (int i = 0; i < allGames.Count; i++)
            {
                GameInfo info = allGames[i];
                this.combo_Games.Items.Add(info);
            }

            Panels = new List<Panel>();
            Players = new List<PlayerInfo>();
            Screens = new List<ScreenControl>();

            Screen[] screens = Screen.AllScreens;
            int MinX = 0;
            int MinY = 0;
            int factor = 10;
            for (int i = 0; i < screens.Length; i++)
            {
                Screen scr = screens[i];

                int width = scr.Bounds.Width;
                int height = scr.Bounds.Height;
                int X = scr.Bounds.X;
                int Y = scr.Bounds.Y;
                if (X < MinX)
                {
                    MinX += Math.Abs(X);
                }
                if (Y < MinY)
                {
                    MinY += Math.Abs(Y);
                }

                width /= factor;
                height /= factor;
                X /= factor;
                Y /= factor;

                ScreenControl scrPanel = new ScreenControl();
                Screens.Add(scrPanel);
                scrPanel.Size = new Size(width, height);
                scrPanel.Location = new Point(X, Y);
                scrPanel.SetName(scr.DeviceName.Remove(0, scr.DeviceName.Length - 1));
                this.panel1.Controls.Add(scrPanel);
            }

            for (int i = 0; i < Screens.Count; i++)
            {
                ScreenControl con = Screens[i];
                con.Location = new Point(con.Location.X + (MinX / factor), con.Location.Y + (MinY / factor));
            }

            num_Players_ValueChanged(null, null);
        }
Example #2
0
        private void num_Players_ValueChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < Panels.Count; i++)
            {
                Panels[i].Dispose();
            }

            for (int i = 0; i < Players.Count; i++)
            {
                PlayerInfo p = Players[i];
                if (p.Control != null)
                {
                    p.Control.Dispose();
                }
            }
            Players.Clear();
            int players = (int)this.num_Players.Value;

            for (int i = 0; i < players; i++)
            {
                PlayerInfo p = new PlayerInfo();
                Players.Add(p);
            }

            for (int z = 0; z < Screens.Count; z++)
            {
                ScreenControl scr = Screens[z];

                ContextMenu context = new System.Windows.Forms.ContextMenu();
                for (int i = 0; i < players; i++)
                {
                    MenuItem player1 = new MenuItem("Set Player " + (i + 1).ToString(CultureInfo.InvariantCulture));
                    context.MenuItems.Add(player1);

                    for (int x = 0; x < 5; x++)
                    {
                        ScreenType screen = (ScreenType)x;

                        MenuItem SetPlayer = new MenuItem("To " + screen.ToString());
                        Holder   holder    = new Holder();
                        holder.Player      = i;
                        holder.Control     = scr;
                        holder.Screen      = screen;
                        holder.ScreenIndex = z;
                        SetPlayer.Tag      = holder;

                        SetPlayer.Click += new EventHandler(SetPlayer_Click);
                        player1.MenuItems.Add(SetPlayer);
                    }
                }

                if (scr.ContextMenu != null)
                {
                    scr.ContextMenu.Dispose();
                }

                scr.ContextMenu = context;
            }
        }
Example #3
0
        public MainForm()
        {
            InitializeComponent();
            this.groupBox2.Enabled = false;

            GameManager = new GameManager();
            Dictionary <string, GameInfo> allGames = GameManager.Games;

            for (int i = 0; i < allGames.Count; i++)
            {
                GameInfo info = allGames[i];
                this.combo_Games.Items.Add(info);
            }

            Panels  = new List <Panel>();
            Players = new List <PlayerInfo>();
            Screens = new List <ScreenControl>();

            Screen[] screens = Screen.AllScreens;
            int      MinX    = 0;
            int      MinY    = 0;
            int      factor  = 10;

            for (int i = 0; i < screens.Length; i++)
            {
                Screen scr = screens[i];

                int width  = scr.Bounds.Width;
                int height = scr.Bounds.Height;
                int X      = scr.Bounds.X;
                int Y      = scr.Bounds.Y;
                if (X < MinX)
                {
                    MinX += Math.Abs(X);
                }
                if (Y < MinY)
                {
                    MinY += Math.Abs(Y);
                }

                width  /= factor;
                height /= factor;
                X      /= factor;
                Y      /= factor;

                ScreenControl scrPanel = new ScreenControl();
                Screens.Add(scrPanel);
                scrPanel.Size     = new Size(width, height);
                scrPanel.Location = new Point(X, Y);
                scrPanel.SetName(scr.DeviceName.Remove(0, scr.DeviceName.Length - 1));
                this.panel1.Controls.Add(scrPanel);
            }

            for (int i = 0; i < Screens.Count; i++)
            {
                ScreenControl con = Screens[i];
                con.Location = new Point(con.Location.X + (MinX / factor), con.Location.Y + (MinY / factor));
            }

            num_Players_ValueChanged(null, null);
        }