Пример #1
0
        private void GetIcon(object state)
        {
            UserGameInfo game = (UserGameInfo)state;
            Icon         icon = Shell32.GetIcon(game.ExePath, false);

            Bitmap bmp = icon.ToBitmap();

            icon.Dispose();
            game.Icon = bmp;

            GameControl control = controls[game];

            control.Image = game.Icon;
        }
Пример #2
0
        private void ChangeIconToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title  = "Open Image";
                dlg.Filter = "All Images Files (*.png;*.jpg;*.jpeg;*.gif;*.bmp;*.tiff;*.tif;*.ico;*.exe)|*.png;*.jpg;*.jpeg;*.gif;*.bmp;*.tiff;*.tif;*.ico;*.exe" +
                             "|PNG Portable Network Graphics (*.png)|*.png" +
                             "|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif" +
                             "|BMP Windows Bitmap (*.bmp)|*.bmp" +
                             "|TIF Tagged Imaged File Format (*.tif *.tiff)|*.tif;*.tiff" +
                             "|Icon (*.ico)|*.ico" +
                             "|Executable (*.exe)|*.exe";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //PictureBox PictureBox1 = new PictureBox();

                    // Create a new Bitmap object from the picture file on disk,
                    // and assign that to the PictureBox.Image property
                    //PictureBox1.Image = new Bitmap(dlg.FileName);

                    if (dlg.FileName.EndsWith(".exe"))
                    {
                        Icon icon = Shell32.GetIcon(dlg.FileName, false);

                        Bitmap bmp = icon.ToBitmap();
                        icon.Dispose();
                        currentGameInfo.Icon = bmp;
                    }
                    else
                    {
                        currentGameInfo.Icon = new Bitmap(dlg.FileName);
                    }
                    ini.IniWriteValue("GameIcons", currentGameInfo.Game.GameName, dlg.FileName);

                    GetIcon(currentGameInfo);
                    //this.Controls.Clear();
                    //this.InitializeComponent();
                    RefreshGames();
                }
            }
        }
Пример #3
0
        private void GetIcon(object state)
        {
            UserGameInfo game = (UserGameInfo)state;
            Bitmap       bmp;
            string       iconPath = ini.IniReadValue("GameIcons", game.Game.GameName);

            if (!string.IsNullOrEmpty(iconPath))
            {
                if (iconPath.EndsWith(".exe"))
                {
                    Icon icon = Shell32.GetIcon(iconPath, false);
                    bmp = icon.ToBitmap();
                    icon.Dispose();
                }
                else
                {
                    bmp = new Bitmap(iconPath);
                }
            }
            else
            {
                Icon icon = Shell32.GetIcon(game.ExePath, false);
                bmp = icon.ToBitmap();
                icon.Dispose();
            }

            game.Icon = bmp;

            lock (controls)
            {
                if (controls.ContainsKey(game))
                {
                    GameControl control = controls[game];
                    control.Invoke((Action) delegate()
                    {
                        control.Image = game.Icon;
                    });
                }
            }
        }
Пример #4
0
        private void GetIcon(object state)
        {
            UserGameInfo game = (UserGameInfo)state;
            Icon         icon = Shell32.GetIcon(game.ExePath, false);

            Bitmap bmp = icon.ToBitmap();

            icon.Dispose();
            game.Icon = bmp;

            lock (controls)
            {
                if (controls.ContainsKey(game))
                {
                    GameControl control = controls[game];
                    control.Invoke((Action) delegate()
                    {
                        control.Image = game.Icon;
                    });
                }
            }
        }