Beispiel #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
                {
                }
            }
        }
        private void ChangeIndexes(int src, int trg)
        {
            Data_Games tmp = game_list[src];

            game_list[src] = game_list[trg];
            game_list[trg] = tmp;
            object tmp2 = lbx_games.Items[src];

            lbx_games.Items[src]    = lbx_games.Items[trg];
            lbx_games.Items[trg]    = tmp2;
            lbx_games.SelectedIndex = trg;
            ChangedData(true);
        }
        private void lbx_games_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lbx_games.SelectedIndex < 0)
            {
                return;
            }
            if (PendingGameCancel())
            {
                return;
            }
            pending_game  = false;
            ignore_events = true;
            Data_Games game = game_list[lbx_games.SelectedIndex];

            tb_name.Text   = game.name;
            tb_target.Text = game.target;
            tb_params.Text = game.launch_pars;
            tb_icon.Text   = game.icon;
            tb_work.Text   = game.work_dir;
            ignore_events  = false;
        }
 private void bt_games_Click(object sender, EventArgs e)
 {
     if (sender == bt_new)
     {
         if (PendingGameCancel())
         {
             return;
         }
         lbx_games.SelectedIndex = -1;
         ClearFields(false);
     }
     else if (sender == bt_add)
     {
         Data_Games game = new Data_Games();
         game.name        = tb_name.Text;
         game.target      = tb_target.Text;
         game.launch_pars = tb_params.Text;
         game.icon        = tb_icon.Text;
         game.work_dir    = tb_work.Text;
         lbx_games.Items.Add(game.name);
         game_list.Add(game);
         ClearFields(true);
     }
     else if (sender == bt_del)
     {
         int idx = lbx_games.SelectedIndex;
         if (idx < 0)
         {
             return;
         }
         lbx_games.Items.RemoveAt(idx);
         game_list.RemoveAt(idx);
         pending_game = false;
         ChangedData(true);
     }
     else if (sender == bt_upd)
     {
         int idx = lbx_games.SelectedIndex;
         if (idx < 0)
         {
             return;
         }
         Data_Games game = game_list[idx];
         game.name            = tb_name.Text;
         game.target          = tb_target.Text;
         game.launch_pars     = tb_params.Text;
         game.icon            = tb_icon.Text;
         game.work_dir        = tb_work.Text;
         lbx_games.Items[idx] = game.name;
         ClearFields(true);
     }
     else if (sender == bt_up)
     {
         int idx = lbx_games.SelectedIndex;
         if (idx > 0)
         {
             ChangeIndexes(idx, idx - 1);
         }
     }
     else //if (sender == bt_down)
     {
         int idx = lbx_games.SelectedIndex;
         if (idx >= 0 && idx < lbx_games.Items.Count - 1)
         {
             ChangeIndexes(idx, idx + 1);
         }
     }
 }
Beispiel #5
0
        private void LoadFile(StreamReader sr)
        {
            Data_Games game;

            string[] tmp;
            int      tmpenum;
            float    tmpfl;

            //Form style
            //Text
            title = sr.ReadLine();
            //Bounds
            tmp = sr.ReadLine().Split(CHR_DELIM);
            int.TryParse(tmp[0], out x);
            int.TryParse(tmp[1], out y);
            int.TryParse(tmp[2], out width);
            int.TryParse(tmp[3], out height);
            //Background
            tmp = sr.ReadLine().Split(CHR_DELIM);
            bool.TryParse(tmp[0], out background);
            backg_col = HexToColor(tmp[1]);
            bool.TryParse(tmp[2], out background_img);
            backg_img = tmp[3];
            //Transparency
            tmp = sr.ReadLine().Split(CHR_DELIM);
            if (!int.TryParse(tmp[0], out opacity))
            {
                opacity = 100;
            }
            bool.TryParse(tmp[1], out transkey);
            trank_col = HexToColor(tmp[2]);
            //Start pos, border style, bacground image layout
            tmp = sr.ReadLine().Split(CHR_DELIM);
            if (int.TryParse(tmp[0], out tmpenum))
            {
                startpos = (FormStartPosition)tmpenum;
            }
            if (int.TryParse(tmp[1], out tmpenum))
            {
                border = (FormBorderStyle)tmpenum;
            }
            if (int.TryParse(tmp[2], out tmpenum))
            {
                backg_lay = (ImageLayout)tmpenum;
            }
            //Game style
            //Alignment
            tmp = sr.ReadLine().Split(CHR_DELIM);
            if (int.TryParse(tmp[0], out tmpenum))
            {
                gm_text_align = (ContentAlignment)tmpenum;
            }
            if (int.TryParse(tmp[1], out tmpenum))
            {
                gm_img_align = (ContentAlignment)tmpenum;
            }
            //Bounds, margin
            tmp = sr.ReadLine().Split(CHR_DELIM);
            int.TryParse(tmp[0], out gm_x);
            int.TryParse(tmp[1], out gm_y);
            int.TryParse(tmp[2], out gm_width);
            int.TryParse(tmp[3], out gm_height);
            int.TryParse(tmp[4], out gm_right);
            int.TryParse(tmp[5], out gm_bottom);
            //Column or row, how many elements
            bool.TryParse(tmp[6], out gm_gen_mode);
            if (!int.TryParse(tmp[7], out gm_gen_elem))
            {
                gm_gen_elem = 1;
            }
            //Icon size, close on launch
            tmp = sr.ReadLine().Split(CHR_DELIM);
            int.TryParse(tmp[0], out gm_ic_w);
            int.TryParse(tmp[1], out gm_ic_h);
            bool.TryParse(tmp[2], out gm_close);
            int.TryParse(tmp[3], out gm_snd_wait);
            //Font
            tmp = sr.ReadLine().Split(CHR_DELIM);
            if (!float.TryParse(tmp[1], out tmpfl))
            {
                tmpfl = 10;
            }
            if (!int.TryParse(tmp[2], out tmpenum))
            {
                tmpenum = 0;
            }
            gm_font = new Font(tmp[0], tmpfl, (FontStyle)tmpenum);
            //Text
            tmp          = sr.ReadLine().Split(CHR_DELIM);
            gm_foreg_col = Data_Form.HexToColor(tmp[0]);
            bool.TryParse(tmp[1], out gm_foreg_dyn);
            bool.TryParse(tmp[2], out gm_foreg_h);
            gm_foreg_col_h = Data_Form.HexToColor(tmp[3]);
            bool.TryParse(tmp[4], out gm_foreg_c);
            gm_foreg_col_c = Data_Form.HexToColor(tmp[5]);
            //Background
            tmp = sr.ReadLine().Split(CHR_DELIM);
            bool.TryParse(tmp[0], out gm_backg);
            gm_backg_col = Data_Form.HexToColor(tmp[1]);
            bool.TryParse(tmp[2], out gm_backg_dyn);
            bool.TryParse(tmp[3], out gm_backg_h);
            gm_backg_col_h = Data_Form.HexToColor(tmp[4]);
            bool.TryParse(tmp[5], out gm_backg_c);
            gm_backg_col_c = Data_Form.HexToColor(tmp[6]);
            //Border
            tmp = sr.ReadLine().Split(CHR_DELIM);
            bool.TryParse(tmp[0], out gm_border);
            gm_border_col = Data_Form.HexToColor(tmp[1]);
            bool.TryParse(tmp[2], out gm_border_dyn);
            bool.TryParse(tmp[3], out gm_border_h);
            gm_border_col_h = Data_Form.HexToColor(tmp[4]);
            bool.TryParse(tmp[5], out gm_border_c);
            gm_border_col_c = Data_Form.HexToColor(tmp[6]);
            //Sounds
            tmp = sr.ReadLine().Split(CHR_DELIM);
            bool.TryParse(tmp[0], out gm_snd_hover);
            gm_snd_h = tmp[1];
            tmp      = sr.ReadLine().Split(CHR_DELIM);
            bool.TryParse(tmp[0], out gm_snd_click);
            gm_snd_c = tmp[1];
            //Game list
            game_list.Clear();
            while (sr.Peek() > -1)
            {
                game = new Data_Games();
                sr.ReadLine();
                game.name        = sr.ReadLine();
                game.target      = sr.ReadLine();
                game.launch_pars = sr.ReadLine();
                game.icon        = sr.ReadLine();
                game.work_dir    = sr.ReadLine();
                game_list.Add(game);
            }
        }