Esempio n. 1
0
        static void Main(string[] args)
        {
            new Log(true);

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);

            // Set the unhandled exception mode to force all Windows Forms errors
            // to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm(args);

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Esempio n. 2
0
        public HandlerControl(GameHandlerMetadata metadata)
        {
            Metadata = metadata;

            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            title = new Label();
            if (metadata == null)
            {
                title.Text = "No handlers";
            }
            else
            {
                title.Text = metadata.ToString();
            }
            TitleText = title.Text;

            BackColor = Color.FromArgb(30, 30, 30);
            Size      = new Size(200, 52);

            Controls.Add(picture);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 3
0
        static void Main()
        {
            if (!StartChecks.StartCheck())
            {
                return;
            }

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm();

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();
            Settings sform = new Settings();

            DPIManager.AddForm(sform);
            DPIManager.ForceUpdate();
            SearchDisksForm sdf = new SearchDisksForm(form);

            DPIManager.AddForm(sdf);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Esempio n. 4
0
        public void RefreshGames()
        {
            lock (controls)
            {
                foreach (var con in controls)
                {
                    if (con.Value != null)
                    {
                        con.Value.Dispose();
                    }
                }
                this.list_Games.Controls.Clear();
                controls.Clear();

                List <UserGameInfo> games = gameManager.User.Games;
                for (int i = 0; i < games.Count; i++)
                {
                    UserGameInfo game = games[i];
                    NewUserGame(game);
                }

                if (games.Count == 0)
                {
                    noGamesPresent = true;
                    GameControl con = new GameControl(null, null);
                    con.Width = list_Games.Width;
                    con.Text  = "No games";
                    this.list_Games.Controls.Add(con);
                }
            }

            DPIManager.ForceUpdate();
            GameManager.Instance.SaveUserProfile();
        }
Esempio n. 5
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            SuspendLayout();

            border = DPIManager.Adjust(4, scale);
            int dborder = border * 2;

            picture.Location = new Point(border, border);

            Height       = DPIManager.Adjust(46, scale);
            picture.Size = new Size(Size.Height - dborder, Height - dborder);

            Width = picture.Width + dborder + title.Width;

            float height  = this.Height / 2.0f;
            float lheight = title.Size.Height / 2.0f;

            title.Location = new Point(picture.Width + picture.Left + border, (int)(height - lheight));

            ResumeLayout();
        }
Esempio n. 6
0
        public GameControl(GenericGameInfo game, UserGameInfo userGame)
        {
            GameInfo     = game;
            UserGameInfo = userGame;

            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            title = new Label();
            if (game == null)
            {
                title.Text = "No games";
            }
            else
            {
                title.Text = GameInfo.GameName;
            }

            BackColor = Color.FromArgb(30, 30, 30);
            Size      = new Size(200, 52);

            Controls.Add(picture);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 7
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            RefreshGames();

            DPIManager.ForceUpdate();
        }
Esempio n. 8
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            SuspendLayout();

            int border  = DPIManager.Adjust(4, scale);
            int dborder = border * 2;

            picture.Location = new Point(border, border);
            picture.Size     = new Size(DPIManager.Adjust(44, scale), DPIManager.Adjust(44, scale));

            Height = DPIManager.Adjust(52, scale);

            Size labelSize = TextRenderer.MeasureText(title.Text, title.Font);

            title.Size = labelSize;

            float height  = this.Height / 2.0f;
            float lheight = labelSize.Height / 2.0f;

            title.Location = new Point(picture.Width + picture.Left + border, (int)(height - lheight));

            ResumeLayout();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            new Log(true);

            ThreadUtil.Initialize();

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);

            // Set the unhandled exception mode to force all Windows Forms errors
            // to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware,
            // or else Windows will give us pre-scaled monitor sizes
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GameManager gameManager = new GameManager();

            StartMainForm(args, gameManager);
        }
Esempio n. 10
0
        private void btn_Browse_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog open = new OpenFileDialog())
            {
                open.Filter = "Game Executable Files|*.exe";
                if (open.ShowDialog() == DialogResult.OK)
                {
                    string path = open.FileName;

                    List <GameHandlerMetadata> allGames = gameManager.User.InstalledHandlers;

                    GameList list = new GameList(allGames);
                    DPIManager.ForceUpdate();

                    if (list.ShowDialog() == DialogResult.OK)
                    {
                        GameHandlerMetadata selected = list.Selected;
                        UserGameInfo        game     = gameManager.TryAddGame(path, list.Selected);

                        if (game == null)
                        {
                            MessageBox.Show("Game already in your library!");
                        }
                        else
                        {
                            MessageBox.Show("Game accepted as ID " + game.GameID);
                            RefreshGames();
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public GameControl(UserGameInfo userGame)
        {
            UserGameInfo = userGame;

            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            title = new Label();
            if (userGame == null)
            {
                title.Text = "No games";
            }
            else
            {
                title.Text = GameManager.Instance.NameManager.GetGameName(userGame.GameID);
            }
            TitleText = title.Text;

            BackColor = Color.FromArgb(30, 30, 30);
            Size      = new Size(200, 52);

            Controls.Add(picture);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 12
0
 private void PositionsControl_Paint(object sender, PaintEventArgs e)
 {
     if (positionsControl.isDisconnected)
     {
         DPIManager.ForceUpdate();
         positionsControl.isDisconnected = false;
     }
 }
Esempio n. 13
0
        public void ChangeSelectedGame(UserGameInfo userGame)
        {
            this.userGame = userGame;

            panel_steps.Controls.Clear();

#if false
            string gameId = userGame.GameID;

            if (mainForm == null)
            {
                mainForm = MainForm.Instance;
                mainForm.BrowserBtns.OnBrowse += BrowserBtns_OnBrowse;
            }

            currentHandlers = GameManager.Instance.PackageManager.GetInstalledHandlers(gameId);
            if (currentHandlers.Length == 0)
            {
                // uninstalled package perhaps?
                return;
            }

            if (currentHandlers.Length > 1)
            {
                MainForm.Instance.ChangeTitle("Choose one handler to run game",
                                              FormGraphicsUtil.BuildCharToBitmap(new Size(40, 40), 30, Color.FromArgb(240, 240, 240), "⤷"));

                panel_steps.Controls.Add(list_handlers);

                list_handlers.Width  = panel_steps.Width;
                list_handlers.Height = panel_steps.Height;
                list_handlers.Left   = 1;
                list_handlers.Controls.Clear();

                //TODO fix
                //for (var i = 0; i < currentHandlers.Length; i++) {
                //    GameHandlerMetadata metadata = currentHandlers[i];

                //    GameControl handlerControl = new GameControl();
                //    handlerControl.Width = list_handlers.Width;
                //    handlerControl.Click += HandlerControl_Click;

                //    handlerControl.SetHandlerMetadata(metadata);
                //    list_handlers.Controls.Add(handlerControl);
                //}
            }
            else
            {
                // create first step
                SetupSteps(currentHandlers[0]);
                GoToStep(0);
            }
#endif

            DPIManager.ForceUpdate();
        }
Esempio n. 14
0
        public GameControl(GenericGameInfo game, UserGameInfo userGame)
        {
            GameInfo     = game;
            UserGameInfo = userGame;

            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            playerIcon          = new PictureBox();
            playerIcon.SizeMode = PictureBoxSizeMode.StretchImage;
            playerIcon.Image    = Gaming.Properties.Resources.players;

            numPlayersTt = new ToolTip();
            numPlayersTt.SetToolTip(playerIcon, "Number of players");

            title        = new Label();
            title.Font   = new Font("Segoe UI", 11, FontStyle.Bold);
            players      = new Label();
            players.Font = new Font("Segoe UI", 9);
            if (game == null)
            {
                title.Text   = "No games";
                players.Text = string.Empty;
                title.Font   = new Font("Segoe UI", 11, FontStyle.Regular);
            }
            else
            {
                title.Text = GameInfo.GameName;
                if (GameInfo.MaxPlayers > 2)
                {
                    players.Text = "2-" + GameInfo.MaxPlayers;
                }
                else
                {
                    players.Text = GameInfo.MaxPlayers.ToString();
                }
                //players.Text = "Players: " + GameInfo.MaxPlayers;
            }
            TitleText  = title.Text;
            PlayerText = players.Text;

            BackColor = Color.FromArgb(30, 30, 30);
            Size      = new Size(200, 52);

            Controls.Add(picture);
            Controls.Add(title);
            Controls.Add(players);
            Controls.Add(playerIcon);

            DPIManager.Register(this);
        }
Esempio n. 15
0
        public void RefreshGames()
        {
            lock (controls)
            {
                foreach (var con in controls)
                {
                    if (con.Value != null)
                    {
                        con.Value.Dispose();
                    }
                }
                this.list_Games.Controls.Clear();
                this.list_Handlers.Controls.Clear();
                controls.Clear();

                List <GameHandlerMetadata> handlers = gameManager.User.InstalledHandlers;
                for (int i = 0; i < handlers.Count; i++)
                {
                    GameHandlerMetadata handler = handlers[i];
                    NewGameHandler(handler);
                }

                List <UserGameInfo> games = gameManager.User.Games;
                for (int i = 0; i < games.Count; i++)
                {
                    UserGameInfo game = games[i];
                    NewUserGame(game);
                }

                if (games.Count == 0)
                {
                    noGamesPresent = true;
                    GameControl con = new GameControl(null);
                    con.Width = list_Games.Width;
                    con.Text  = "No games";
                    this.list_Games.Controls.Add(con);
                }

                if (handlers.Count == 0)
                {
                    noGamesPresent = true;
                    HandlerControl con = new HandlerControl(null);
                    con.Width = list_Games.Width;
                    con.Text  = "No handlers";
                    this.list_Handlers.Controls.Add(con);
                }
            }

            DPIManager.ForceUpdate();
            gameManager.User.Save();
        }
Esempio n. 16
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            SuspendLayout();

            int border  = DPIManager.Adjust(4, scale);
            int dborder = border * 2;

            picture.Location = new Point(border, border);
            picture.Size     = new Size(DPIManager.Adjust(44, scale), DPIManager.Adjust(44, scale));

            Height = DPIManager.Adjust(52, scale);

            Size  labelSize          = TextRenderer.MeasureText(TitleText, title.Font);
            Size  plabelSize         = TextRenderer.MeasureText(PlayerText, players.Font);
            float reservedSpaceLabel = this.Width - picture.Width;

            if (labelSize.Width > reservedSpaceLabel)
            {
                // make text smaller
                int charSize = TextRenderer.MeasureText("g", title.Font).Width;
                int toRemove = (int)((reservedSpaceLabel - labelSize.Width) / (float)charSize);
                toRemove   = Math.Max(toRemove + 3, 7);
                title.Text = TitleText.Remove(TitleText.Length - toRemove, toRemove) + "...";
            }
            else
            {
                title.Text = TitleText;
            }
            players.Text = PlayerText;
            title.Size   = labelSize;
            players.Size = plabelSize;

            float height  = this.Height / 2.0f;
            float lheight = labelSize.Height / 2.0f;

            title.Location   = new Point(picture.Width + picture.Left + border, (int)(height - labelSize.Height) /*(int)(height - lheight)*/);
            players.Location = new Point(picture.Width + picture.Left + border + playerIcon.Width + 10, (int)height);

            playerIcon.Location = new Point(picture.Width + picture.Left + border + 10, (int)height);
            playerIcon.Size     = new Size(DPIManager.Adjust(players.Size.Height, scale), DPIManager.Adjust(players.Size.Height, scale));

            ResumeLayout();
        }
Esempio n. 17
0
        public CheckedTextControl()
        {
            checkbox = new SizeableCheckbox();

            title    = new Label();
            checkbox = new SizeableCheckbox();

            BackColor = ColorUnselected;
            Size      = new Size(200, 52);

            Controls.Add(checkbox);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 18
0
        public GameControl()
        {
            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            title = new Label();

            BackColor = ColorUnselected;
            Size      = new Size(200, 52);

            Controls.Add(picture);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 19
0
        private void btnAutoSearch_Click(object sender, EventArgs e)
        {
            if (form != null)
            {
                return;
            }

            form = new SearchDisksForm(this);
            //DPIManager.AddForm(form);

            form.FormClosed += Form_FormClosed;
            form.Show();
            SetUpForm(form);

            DPIManager.ForceUpdate();
        }
Esempio n. 20
0
        public GameNameControl()
        {
            picture          = new PictureBox();
            picture.SizeMode = PictureBoxSizeMode.StretchImage;

            title          = new Label();
            title.Text     = "Nothing selected";
            title.AutoSize = true;

            BackColor = Color.FromArgb(30, 30, 30);

            Controls.Add(picture);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Esempio n. 21
0
        static void Main()
        {
            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm();

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Esempio n. 22
0
        private void ListInstalled_Click(object sender, EventArgs e)
        {
            MainForm.Instance.ChangeTitle("Remove Game From List", listInstalled.Image);

            panel_disks.Visible          = false;
            panel_installedGames.Visible = true;
            panel_gameData.Visible       = false;

            GameManager gm = GameManager.Instance;

            list_installedGames.Controls.Clear();
            // force a collect?
            GC.Collect();

            var installedGames = gm.GetInstalledGamesOrdered();

            foreach (var pair in installedGames)
            {
                List <UserGameInfo> games = pair.Value;

                string         gameTitle = gm.MetadataManager.GetGameName(pair.Key);
                TitleSeparator sep       = new TitleSeparator();
                sep.SetTitle(gameTitle);
                sep.Height = 20;
                this.list_installedGames.Controls.Add(sep);

                // get all Repository Game Infos
                for (int i = 0; i < games.Count; i++)
                {
                    GameControl  con  = new GameControl();
                    UserGameInfo game = games[i];
                    con.SetUserGameExe(game);
                    con.Width  = list_installedGames.Width;
                    con.Click += Installed_Game_Click;

                    gm.MetadataManager.GetIcon(game, (Bitmap bmp) => {
                        con.Image = bmp;
                    });
                    this.list_installedGames.Controls.Add(con);
                }
            }

            DPIManager.ForceUpdate();
            DPIManager.ForceUpdate();
        }
        public void UpdateUsers(List <UserGameInfo> users, Image newIcon)
        {
            Image = newIcon;

            list_gameFolders.Controls.Clear();
            for (int i = 0; i < users.Count; i++)
            {
                UserGameInfo game       = users[i];
                GameControl  gameFolder = new GameControl();
                gameFolder.Width = list_gameFolders.Width;
                gameFolder.SetUserGameExe(game);

                gameFolder.Click += GameFolder_Click;
                list_gameFolders.Controls.Add(gameFolder);
            }

            DPIManager.ForceUpdate();
        }
Esempio n. 24
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog open = new OpenFileDialog())
            {
                open.Filter = "Game Executable Files|*.exe";
                if (open.ShowDialog() == DialogResult.OK)
                {
                    string path = open.FileName;

                    List <GenericGameInfo> info = gameManager.GetGames(path);

                    if (info.Count > 1)
                    {
                        GameList list = new GameList(info);
                        DPIManager.ForceUpdate();

                        if (list.ShowDialog() == DialogResult.OK)
                        {
                            UserGameInfo game = gameManager.TryAddGame(path, list.Selected);

                            if (game == null)
                            {
                                MessageBox.Show("Game already in your library!");
                            }
                            else
                            {
                                MessageBox.Show("Game accepted as " + game.Game.GameName);
                                RefreshGames();
                            }
                        }
                    }
                    else if (info.Count == 1)
                    {
                        UserGameInfo game = gameManager.TryAddGame(path, info[0]);
                        MessageBox.Show("Game accepted as " + game.Game.GameName);
                        RefreshGames();
                    }
                    else
                    {
                        MessageBox.Show("Unknown game");
                    }
                }
            }
        }
Esempio n. 25
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            SuspendLayout();

            int border  = DPIManager.Adjust(8, scale);
            int dborder = border * 2;

            checkbox.Location = new Point(12, 11);
            checkbox.Size     = new Size(30, 30);

            Height = DPIManager.Adjust(52, scale);

            Size  labelSize          = TextRenderer.MeasureText(TitleText, title.Font);
            float reservedSpaceLabel = this.Width - checkbox.Width;

            if (labelSize.Width > reservedSpaceLabel)
            {
                // make text smaller
                int charSize = TextRenderer.MeasureText("g", title.Font).Width;
                int toRemove = (int)((reservedSpaceLabel - labelSize.Width) / (float)charSize);
                toRemove   = Math.Max(toRemove + 3, 7);
                title.Text = TitleText.Remove(TitleText.Length - toRemove, toRemove) + "...";
            }
            else
            {
                title.Text = TitleText;
            }
            title.Size = labelSize;

            float height  = this.Height / 2.0f;
            float lheight = labelSize.Height / 2.0f;

            title.Location = new Point(checkbox.Width + checkbox.Left + border, (int)(height - lheight));

            ResumeLayout();
        }
Esempio n. 26
0
        public SearchDisksForm(MainForm main)
        {
            this.main = main;
            InitializeComponent();

            DPIManager.AddForm(this);
            DPIManager.ForceUpdate();

            for (int x = 1; x <= 100; x++)
            {
                if (ini.IniReadValue("SearchPaths", x.ToString()) == "")
                {
                    break;
                }
                else
                {
                    disksBox.Items.Add(ini.IniReadValue("SearchPaths", x.ToString()), true);
                }
            }
        }
Esempio n. 27
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            //SuspendLayout();

            //Font = DPIManager.Font;

            //Size defaultSize = DefaultSize;
            //int wid = DPIManager.Adjust(defaultSize.Width, scale);
            //int hei = DPIManager.Adjust(defaultSize.Height, scale);
            ////Size = new Size(wid, hei);
            //Console.WriteLine("Changed to {0}x{1}", wid, hei);

            //ResumeLayout();
        }
Esempio n. 28
0
        public BaseForm()
        {
            // Default DPI = 96 = 100%
            // 1 pt = 1/72 inch
            // 12pt = 1/6 inch
            // 12 * 300% = 36
            // 12 * 125% = 15
            // 12 * 150% = 18
            AutoScaleMode = AutoScaleMode.None;
            BackColor     = Color.FromArgb(50, 50, 50);
            ForeColor     = Color.White;
            Margin        = new Padding(4, 4, 4, 4);
            Name          = "BaseForm";
            Text          = "BaseForm";

            // create it here, else the desgienr will show the default windows font
            Font = new Font("Segoe UI", 12, GraphicsUnit.Point);

            DPIManager.Register(this);
        }
Esempio n. 29
0
        public void UpdateSize(float scale)
        {
            if (IsDisposed)
            {
                DPIManager.Unregister(this);
                return;
            }

            SuspendLayout();

            Font = DPIManager.Font;
            //AutoScaleMode = AutoScaleMode.Font;
            //AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            //Size defaultSize = DefaultSize;
            //int wid = DPIManager.Adjust(defaultSize.Width, scale);
            //int hei = DPIManager.Adjust(defaultSize.Height, scale);
            ////Size = new Size(wid, hei);
            //Console.WriteLine("Changed to {0}x{1}", wid, hei);

            ResumeLayout();
        }
        private void ScanGames_Click(object sender, EventArgs e)
        {
            ResetPanels();

            if (form != null)
            {
                return;
            }

            if (GameManager.Instance.User.InstalledHandlers.Count == 0)
            {
                MessageBox.Show("You have no game handlers installed. No games to search for.");
                return;
            }

            form = new SearchStorageForm();

            form.FormClosed += Form_FormClosed;
            form.Show();

            DPIManager.ForceUpdate();
        }