Пример #1
0
        private static void UpdateGame(GameBtn btn, Data_Games game, int width, int height)
        {
            btn.game = game;
            btn.Text = game.name;
            string icon = game.icon;

            if (icon.Length > 0)
            {
                try
                {
                    int idx = icon.LastIndexOf('.') + 1;
                    if (idx == 0)
                    {
                        return;
                    }
                    switch (icon.Substring(idx).ToLower())
                    {
                    case "ico":
                    case "exe":
                    case "dll":
                        btn.Image = new Bitmap(Icon.ExtractAssociatedIcon(icon).ToBitmap(), width, height);
                        break;

                    default:
                        btn.Image = new Bitmap(new Bitmap(icon), width, height);
                        break;
                    }
                }
                catch
                {
                }
            }
        }
Пример #2
0
        public static void UpdateStyle(Control cont, List <GameBtn> games, Data_Form stl)
        {
            cont.SuspendLayout();
            bool isform = cont is Form;

            //Form
            cont.Text = stl.title;
            if (stl.background)
            {
                cont.BackColor = stl.backg_col;
            }
            try
            {
                if (stl.background_img)
                {
                    cont.BackgroundImage = new Bitmap(stl.backg_img);
                }
            }
            catch (Exception ex)
            {
                Program.ShowWarning("Background image error: " + ex.Message, MessageBoxButtons.OK);
            }
            if (isform)
            {
                Form frm = (Form)cont;
                frm.Bounds        = new Rectangle(stl.x, stl.y, stl.width, stl.height);
                frm.StartPosition = stl.startpos;
                frm.Opacity       = (double)stl.opacity / 100;
                if (stl.transkey)
                {
                    frm.TransparencyKey = stl.trank_col;
                }
                frm.FormBorderStyle = stl.border;
            }
            cont.BackgroundImageLayout = stl.backg_lay;
            //Games
            GameBtn.enable_fg        = stl.gm_foreg_dyn;
            GameBtn.fg_unsel         = stl.gm_foreg_col;
            GameBtn.enable_fg_h      = stl.gm_foreg_h;
            GameBtn.fg_sel           = stl.gm_foreg_col_h;
            GameBtn.enable_fg_c      = stl.gm_foreg_c;
            GameBtn.fg_click         = stl.gm_foreg_col_c;
            GameBtn.enable_bg        = stl.gm_backg_dyn;
            GameBtn.bg_unsel         = stl.gm_backg_col;
            GameBtn.enable_bg_h      = stl.gm_backg_h;
            GameBtn.bg_sel           = stl.gm_backg_col_h;
            GameBtn.enable_bg_c      = stl.gm_backg_c;
            GameBtn.bg_click         = stl.gm_backg_col_c;
            GameBtn.enable_border    = stl.gm_border;
            GameBtn.border_unsel     = new SolidBrush(stl.gm_border_col);
            GameBtn.enable_border_h  = stl.gm_border_h;
            GameBtn.border_sel       = new SolidBrush(stl.gm_border_col_h);
            GameBtn.enable_border_c  = stl.gm_border_c;
            GameBtn.border_click     = new SolidBrush(stl.gm_border_col_c);
            GameBtn.enable_dynborder = stl.gm_border_dyn;
            GameBtn.enable_snd_h     = stl.gm_snd_hover;
            GameBtn.enable_snd_c     = stl.gm_snd_click;
            if (stl.gm_snd_hover)
            {
                GameBtn.snd_sel = new SoundPlayer(stl.gm_snd_h);
            }
            if (stl.gm_snd_click)
            {
                GameBtn.snd_click = new SoundPlayer(stl.gm_snd_c);
            }
            //Game list
            GameBtn btn;

            if (games.Count != game_list.Count)
            {
                cont.Controls.Clear();
                games.Clear();
                for (int i = 0; i < (isform || game_list.Count < 4 ? game_list.Count : 4); i++)
                {
                    btn = new GameBtn();
                    games.Add(btn);
                    cont.Controls.Add(btn);
                }
            }
            bool border = stl.gm_border;

            for (int i = 0; i < games.Count; i++)
            {
                btn = games[i];
                if (stl.gm_gen_mode)
                {
                    btn.Bounds = new Rectangle(
                        stl.gm_x + ((stl.gm_width + stl.gm_right) * (i % stl.gm_gen_elem)),
                        stl.gm_y + ((stl.gm_height + stl.gm_bottom) * (i / stl.gm_gen_elem)),
                        stl.gm_width, stl.gm_height);
                }
                else
                {
                    btn.Bounds = new Rectangle(
                        stl.gm_x + ((stl.gm_width + stl.gm_right) * (i / stl.gm_gen_elem)),
                        stl.gm_y + ((stl.gm_height + stl.gm_bottom) * (i % stl.gm_gen_elem)),
                        stl.gm_width, stl.gm_height);
                }
                //Style
                btn.TextAlign  = stl.gm_text_align;
                btn.ImageAlign = stl.gm_img_align;
                btn.Font       = stl.gm_font;
                btn.ForeColor  = stl.gm_foreg_col;
                if (border)
                {
                    btn.border_curr = GameBtn.border_unsel;
                }
                if (stl.gm_backg)
                {
                    btn.BackColor = stl.gm_backg_col;
                }
                else
                {
                    btn.BackColor = Color.Empty;
                }
                //Text
                UpdateGame(games[i], game_list[i], stl.gm_ic_w, stl.gm_ic_h);
            }
            cont.ResumeLayout(false);
        }