using DragonVideoPlayer.Properties;
using System.Drawing.Printing;

namespace DragonVideoPlayer
{


    class MenuBuilder
    {
        public static ToolStripMenuItem BuildMenu(
            string title,
            List<string> urls,
            Action<string> clickAction)
        {
            var menu = new ToolStripMenuItem(title);

            foreach (var url in urls)
            {
                var item = new ToolStripMenuItem(url);

                item.Click += (s, e) =>
                {
                    clickAction(url);
                };

                menu.DropDownItems.Add(item);
            }

            return menu;
        }
        public static ToolStripMenuItem BuildCategoryMenu(MenuStrip menuStrip, MainForm form)
        {
            // 既存の「カテゴリ」だけ削除（あれば）
            //var old = menuStrip.Items
            //    .OfType<ToolStripMenuItem>()
            //    .FirstOrDefault(x => x.Name == "cat_menu");


            // 新規作成
            var catRoot = new ToolStripMenuItem("カテゴリ");
            catRoot.Name = "cat_menu";

            foreach (var category in cat_url.category_map)
            {
                var catItem = new ToolStripMenuItem(category.Key);

                foreach (var item in category.Value)
                {
                    string url = item.Key;
                    string title = item.Value;

                    var sub = new ToolStripMenuItem(title);

                    sub.Click += (s, e) =>
                    {
                        form.StartMpv(url);
                    };

                    catItem.DropDownItems.Add(sub);
                }

                catRoot.DropDownItems.Add(catItem);
            }

            menuStrip.Items.Add(catRoot);

            return catRoot;
        }
        public static ToolStripMenuItem BuildMenu_urlsol(
    string title,
    List<string> urls,
    Action<string> onClick,
    Func<string, string> nameResolver)
        {
            var menu = new ToolStripMenuItem(title);

            foreach (var url in urls)
            {
                string name = nameResolver(url);

                var item = new ToolStripMenuItem(name);

                item.Click += (s, e) => onClick(url);

                menu.DropDownItems.Add(item);
            }

            return menu;
        }

        public static ToolStripMenuItem BuildMenu_dic(
     string title,
     List<string> urlList,
     Action<string> onClick,
     Func<string, string> getTitle)
        {
            var menu = new ToolStripMenuItem(title);

            foreach (var url in urlList)
            {
                string name = getTitle(url);

                if (string.IsNullOrEmpty(name))

                    name = url;

                var item = new ToolStripMenuItem(name);

                item.Click += (s, e) => onClick(url);

                menu.DropDownItems.Add(item);
            }

            return menu;
        }
    }

    public static class UIBuilder
    {
        private static List<string> GetGlslFiles()
        {
            string dir = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                "glsl");

            if (!Directory.Exists(dir))
                Directory.CreateDirectory(dir);

            return Directory.EnumerateFiles(dir)
                .Where(f =>
                    f.EndsWith(".glsl", StringComparison.OrdinalIgnoreCase) ||
                    f.EndsWith(".hook", StringComparison.OrdinalIgnoreCase))
                .OrderBy(f => Path.GetFileName(f))
                .ToList();
        }
        private static void ApplyGlsl(MainForm form, string path)
        {
            path = path.Replace("\\", "/");



            form.ApplyGlsl(path);
        }
        public static void Build(MainForm form, List<string> abema_low_list,
              List<string> mov3_list, List<string> fast_list,
            List<string> history_list, List<string> ranking_list, List<string> rakuten_lists,
               List<string> zhongying_list, List<string> akariko_list)
        {

            form._mainLayout = new TableLayoutPanel();

            form._mainLayout.Dock = DockStyle.Fill;
            form._mainLayout.RowCount = 3;
            form._mainLayout.ColumnCount = 1;
            form._mainLayout.ColumnStyles.Clear();
            form._mainLayout.RowStyles.Clear();



            form._mainLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));


            form._mainLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            form._mainLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
            form._mainLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));

            form.TopMenuPanel = new MenuStrip();


            form.TopMenuPanel.Location = new Point(0, 0);

            form.TopMenuPanel.BringToFront();
            form._mainLayout.Controls.Add(form.TopMenuPanel, 0, 0);


            var menuStrip = new MenuStrip();



            // ===== ファイルメニュー =====
            var playMenu = new ToolStripMenuItem("再生");

            var openItem = new ToolStripMenuItem("開く");
            openItem.Click += form.BtnOpen_Click;

            var openfolderItem = new ToolStripMenuItem("フォルダを開く");
            openfolderItem.Click += (s, e) => form.open_folder_func();

            var openUrlItem = new ToolStripMenuItem("URL開く");
            openUrlItem.Click += (s, e) =>
            {
                string url = Microsoft.VisualBasic.Interaction.InputBox(
                    "Enter URL:", "Open URL", "");
                if (!string.IsNullOrWhiteSpace(url))
                    form.StartMpv(url);
            };
            var recorfItem = new ToolStripMenuItem("録画");
            recorfItem.Click += (s, e) => form.record_url();

            var searchItem = new ToolStripMenuItem("検索");
            searchItem.Click += (s, e) => form.search_func();

            var dvdItem = new ToolStripMenuItem("DVDドライブ再生");
            dvdItem.Click += (s, e) => form.DVD_Play();

            var bluerayItem = new ToolStripMenuItem("Blu-rayドライブ再生");
            bluerayItem.Click += (s, e) => form.Blueray_Play();


            var search_youtube_Item = new ToolStripMenuItem("youtube検索");
            search_youtube_Item.Click += (s, e) => form.search_youtube_func();

            var open_mp4_folder_Item = new ToolStripMenuItem("動画のフォルダを開く");
            open_mp4_folder_Item.Click += (s, e) => form.open_mp4_folder();



            var stats_Item = new ToolStripMenuItem("動画情報オーバーレイ");

            stats_Item.DropDownItems.Add("ぺージ1", null, (s, e) => { form.stats_script_binding("1"); });
            stats_Item.DropDownItems.Add("ぺージ2", null, (s, e) => { form.stats_script_binding("2"); });

            stats_Item.DropDownItems.Add("ぺージ3", null, (s, e) => { form.stats_script_binding("3"); });

            stats_Item.DropDownItems.Add("ぺージ4", null, (s, e) => { form.stats_script_binding("5"); });







            var pauseItem = new ToolStripMenuItem("ポーズ");
            pauseItem.Click += (s, e) => form.pause_func();

            var stopItem = new ToolStripMenuItem("停止");
            stopItem.Click += (s, e) => form.StopMpv();
            var playItem = new ToolStripMenuItem("再生");
            playItem.Click += (s, e) => form.play_func();
            var muteItem = new ToolStripMenuItem("ミュート");
            muteItem.Click += (s, e) => form.mute_func();

            var pasteUrlItem = new ToolStripMenuItem("url貼る");
            pasteUrlItem.Click += (s, e) => form.url_paste_func();

            ToolStripMenuItem speedItem = new ToolStripMenuItem("再生速度");
            speedItem.DropDownItems.Add("ノーマル", null, (s, e) => { form.Speed_change(1.0); });
            speedItem.DropDownItems.Add("1.1倍", null, (s, e) => { form.Speed_change(1.1); });
            speedItem.DropDownItems.Add("1.2倍", null, (s, e) => { form.Speed_change(1.2); });

            speedItem.DropDownItems.Add("1.5倍", null, (s, e) => { form.Speed_change(1.5); });
            speedItem.DropDownItems.Add("2倍", null, (s, e) => { form.Speed_change(2.0); });
            speedItem.DropDownItems.Add("0.9倍", null, (s, e) => { form.Speed_change(0.9); });
            speedItem.DropDownItems.Add("0.8倍", null, (s, e) => { form.Speed_change(0.8); });
            speedItem.DropDownItems.Add("0.5倍", null, (s, e) => { form.Speed_change(0.5); });



            var closeItem = new ToolStripMenuItem("閉じる");
            closeItem.Click += (s, e) => form.close_func();



            playMenu.DropDownItems.Add(openItem);



            playMenu.DropDownItems.Add(openUrlItem);
            playMenu.DropDownItems.Add(recorfItem);
            playMenu.DropDownItems.Add(bluerayItem);
            playMenu.DropDownItems.Add(dvdItem);

            playMenu.DropDownItems.Add(searchItem);

            playMenu.DropDownItems.Add(search_youtube_Item);
            playMenu.DropDownItems.Add(stats_Item);


            playMenu.DropDownItems.Add(openfolderItem);
            playMenu.DropDownItems.Add(open_mp4_folder_Item);


            playMenu.DropDownItems.Add(pauseItem);


            playMenu.DropDownItems.Add(stopItem);
            playMenu.DropDownItems.Add(playItem);
            playMenu.DropDownItems.Add(speedItem);
            playMenu.DropDownItems.Add(pasteUrlItem);
            playMenu.DropDownItems.Add(closeItem);

            // ===== 表示メニュー =====
            var listMenu = new ToolStripMenuItem("リスト");

            var nextItem = new ToolStripMenuItem("次の動画");
            nextItem.Click += (s, e) => form.next_movie();

            listMenu.DropDownItems.Add(nextItem);
            var prevItem = new ToolStripMenuItem("前の動画");
            prevItem.Click += (s, e) => form.prev_movie();
            listMenu.DropDownItems.Add(prevItem);
            var list_folderItem = new ToolStripMenuItem("リストをフォルダ");
            list_folderItem.Click += (s, e) => form.list_folder();
            listMenu.DropDownItems.Add(list_folderItem);
            var list_db_Item = new ToolStripMenuItem("リストをDB");
            list_db_Item.Click += (s, e) => form.list_db();
            listMenu.DropDownItems.Add(list_db_Item);
            var list_abema_Item = new ToolStripMenuItem("リストをAbema");
            list_abema_Item.Click += (s, e) => form.list_abema();
            listMenu.DropDownItems.Add(list_abema_Item);




            var list_fast_Item = new ToolStripMenuItem("リストをfast");
            list_fast_Item.Click += (s, e) => form.list_fast();
            listMenu.DropDownItems.Add(list_fast_Item);
            var list_search_Item = new ToolStripMenuItem("リストを検索");
            list_search_Item.Click += (s, e) => form.list_seach();
            listMenu.DropDownItems.Add(list_search_Item);
            var list_rakjuten_Item = new ToolStripMenuItem("リストを楽天");
            list_rakjuten_Item.Click += (s, e) => form.list_rakuten();
            listMenu.DropDownItems.Add(list_rakjuten_Item);

        
      
            var list_zhon_Item = new ToolStripMenuItem("リストをzhon");
            list_zhon_Item.Click += (s, e) => form.list_zhon();
            listMenu.DropDownItems.Add(list_zhon_Item);
            var list_mov3_Item = new ToolStripMenuItem("リストをmov3");
            list_mov3_Item.Click += (s, e) => form.list_mov3();
            listMenu.DropDownItems.Add(list_mov3_Item);
            var list_akariko_Item = new ToolStripMenuItem("リストをakari");
            list_akariko_Item.Click += (s, e) => form.list_akari();
            listMenu.DropDownItems.Add(list_akariko_Item);


            var list_cat_Item = new ToolStripMenuItem("リストをカテゴリー");
            if (config_class.config_bool_read("カテゴリーを有効") == true)
            {
                listMenu.DropDownItems.Add(list_cat_Item);

                var list_cat_music_Item = new ToolStripMenuItem("音楽");
                list_cat_music_Item.Click += (s, e) => form.list_cat_music();

                list_cat_Item.DropDownItems.Add(list_cat_music_Item);

                var list_cat_gamble_Item = new ToolStripMenuItem("ギャンブル");
                list_cat_gamble_Item.Click += (s, e) => form.list_cat_gamble();

                list_cat_Item.DropDownItems.Add(list_cat_gamble_Item);


                var list_cat_movie_Item = new ToolStripMenuItem("映画・ドラマ");
                list_cat_movie_Item.Click += (s, e) => form.list_cat_movie();

                list_cat_Item.DropDownItems.Add(list_cat_movie_Item);

                var list_cat_hobby_Item = new ToolStripMenuItem("趣味");
                list_cat_hobby_Item.Click += (s, e) => form.list_cat_hobby();

                list_cat_Item.DropDownItems.Add(list_cat_hobby_Item);

                var list_cat_sprts_Item = new ToolStripMenuItem("スポーツ");
                list_cat_sprts_Item.Click += (s, e) => form.list_cat_sports();

                list_cat_Item.DropDownItems.Add(list_cat_sprts_Item);

                var list_cat_culture_Item = new ToolStripMenuItem("教養");
                list_cat_culture_Item.Click += (s, e) => form.list_cat_culture();

                list_cat_Item.DropDownItems.Add(list_cat_culture_Item);
                var list_cat_anime_Item = new ToolStripMenuItem("アニメ");
                list_cat_anime_Item.Click += (s, e) => form.list_cat_anime();
                list_cat_Item.DropDownItems.Add(list_cat_anime_Item);
                var list_cat_kanisa_Item = new ToolStripMenuItem("関西地上波TV");
                list_cat_kanisa_Item.Click += (s, e) => form.list_cat_kansai();

                list_cat_Item.DropDownItems.Add(list_cat_kanisa_Item);

                var list_cat_tv_Item = new ToolStripMenuItem("地上波TV");
                list_cat_tv_Item.Click += (s, e) => form.list_cat_tv();

                list_cat_Item.DropDownItems.Add(list_cat_tv_Item);
                var list_cat_bs_Item = new ToolStripMenuItem("BS無料");
                list_cat_bs_Item.Click += (s, e) => form.list_cat_bs();

                list_cat_Item.DropDownItems.Add(list_cat_bs_Item);

                var list_cat_news_Item = new ToolStripMenuItem("ニュース");
                list_cat_news_Item.Click += (s, e) => form.list_cat_news();

                list_cat_Item.DropDownItems.Add(list_cat_news_Item);

            }



            var list_playlistItem = new ToolStripMenuItem("リストをyt-dlpのプレイリスト");
            list_playlistItem.Click += (s, e) => form.list_youtube_playlist();
            listMenu.DropDownItems.Add(list_playlistItem);
            if (config_class.config_bool_read("OverClockedReMixをリスト追加") == true)
            {
                var list_OverClocked_Item = new ToolStripMenuItem("リストをOverClocked ReMix");
                list_OverClocked_Item.Click += (s, e) => form.list_OverClocked_remix();
                listMenu.DropDownItems.Add(list_OverClocked_Item);
            }
            var windowMenu = new ToolStripMenuItem("別窓");

            var settingItem = new ToolStripMenuItem("設定");
            settingItem.Click += (s, e) => form.setting_open();
            windowMenu.DropDownItems.Add(settingItem);
            var video_eq_Item = new ToolStripMenuItem("ビデオイコライザー");
            video_eq_Item.Click += (s, e) => form.open_video_window();

            windowMenu.DropDownItems.Add(video_eq_Item);
            var audio_eq_Item = new ToolStripMenuItem("オーディオイコライザー");
            audio_eq_Item.Click += (s, e) => form.open_audio_window();

            windowMenu.DropDownItems.Add(audio_eq_Item);

            var d_d_window_Item = new ToolStripMenuItem("D＆D動画登録");
            d_d_window_Item.Click += (s, e) => form.d_d_window_open();

            windowMenu.DropDownItems.Add(d_d_window_Item);

            var videoinfo_Item = new ToolStripMenuItem("動画情報");
            videoinfo_Item.Click += (s, e) => form.videoinfo_window_open();

            windowMenu.DropDownItems.Add(videoinfo_Item);

            var listview_Item = new ToolStripMenuItem("listview");
            listview_Item.Click += (s, e) => form.listview_open();

            windowMenu.DropDownItems.Add(listview_Item);

            var argumentItem = new ToolStripMenuItem("Mpvの起動引数");
            argumentItem.Click += (s, e) => form.argument_window_open();
            windowMenu.DropDownItems.Add(argumentItem);

            playMenu.DropDownItems.Add(windowMenu);

            var yoyakuItem = new ToolStripMenuItem("予約録画");
            yoyakuItem.Click += (s, e) => form.yoyaku_window_open();
            windowMenu.DropDownItems.Add(yoyakuItem);

            playMenu.DropDownItems.Add(windowMenu);

            var abema_low_menu = MenuBuilder.BuildMenu_urlsol(
      "Abe低",
       abema_low_list,
         url => form.StartMpv(url),
         url => title_generate.Get_title(url, title_generate._abemaMap, 3, "abema")

  );




            var fast_menu = MenuBuilder.BuildMenu_dic(
 "fast",
  fast_list,
    url => form.StartMpv(url),
      url => title_generate.Get_title(url, title_generate._fast_channelMap, 2, "fast")
);
          

            var mov3_menu = MenuBuilder.BuildMenu_dic(
"mov3",
 mov3_list,
   url => form.StartMpv(url),
       url => title_generate.Get_mov3(url)
);

        var zhongyingMenu = MenuBuilder.BuildMenu_urlsol(
"zhon",
zhongying_list,
url => form.StartMpv(url),
url => title_generate.Get_title(url, title_generate._naori_channelMap, 1, "zhon")
);
            var akarikoMenu = MenuBuilder.BuildMenu_urlsol(
"akari",
akariko_list,
url => form.StartMpv(url),
url => title_generate.Get_title(url, title_generate._akari_ChannelMap, 3, "akari")
);

            var rakutenMenu = MenuBuilder.BuildMenu_urlsol(
     "楽天",
     rakuten_lists,
     url => form.StartMpv(url),
       url => title_generate.Get_title(url, title_generate._rakuten_ChannelNameMap, 2, "rakuten")
     );
            var abema_high_list = TextListLoader.Load("abema2.txt");


            var abema_high_menu = MenuBuilder.BuildMenu_urlsol(
"Abe高",
abema_high_list,
url => form.StartMpv(url),
  url => title_generate.Get_abema(url, 2)
);


            var radiko_list = TextListLoader.Load("radiko.txt");





            var radiko_menu = MenuBuilder.BuildMenu_urlsol(
"ラジコ",
radiko_list,
url => form.StartMpv(url),
  url => title_generate.GetRadikoStation(url)
);
            var cat_menuStrip = new MenuStrip();


            var cat_menu = MenuBuilder.BuildCategoryMenu(cat_menuStrip, form);




            var rirekiMenu = MenuBuilder.BuildMenu(
"履歴",
history_list,
url => form.StartMpv(url)
);
            var rankMenu = MenuBuilder.BuildMenu(
        "ランク",
        ranking_list,
        url => form.StartMpv(url)
        );


            var effectMenu = new ToolStripMenuItem("エフェクト");

            var aspect_Item = new ToolStripMenuItem("アスペクト比");


            var aspect_normal_Item = new ToolStripMenuItem("ノーマル");
            aspect_normal_Item.Click += (s, e) =>
            {
                form.vf_normal();
            };

            aspect_Item.DropDownItems.Add(aspect_normal_Item);

            effectMenu.DropDownItems.Add(aspect_Item);
            var aspect_43_Item = new ToolStripMenuItem("昔のTV(4:3)");
            aspect_43_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["4:3"]);


            };

            aspect_Item.DropDownItems.Add(aspect_43_Item);

            var aspect_16_9_Item = new ToolStripMenuItem("フルHD(16:9)");
            aspect_16_9_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["16:9"]);


            };

            aspect_Item.DropDownItems.Add(aspect_16_9_Item);

            var aspect_9_16_Item = new ToolStripMenuItem("スマホ(9:16)");
            aspect_9_16_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["スマホ"]);
            };

            aspect_Item.DropDownItems.Add(aspect_16_9_Item);
            var cinesco_Item = new ToolStripMenuItem("シネスコ(2.35)");
            cinesco_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["シネスコ"]);
            };
            aspect_Item.DropDownItems.Add(aspect_16_9_Item);

            var aspect_vista_Item = new ToolStripMenuItem("ビスタ(1.85:1)");
            aspect_vista_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["Vista"]);
            };

            aspect_Item.DropDownItems.Add(cinesco_Item);

            aspect_Item.DropDownItems.Add(aspect_16_9_Item);
            aspect_Item.DropDownItems.Add(aspect_9_16_Item);
            aspect_Item.DropDownItems.Add(aspect_vista_Item);

            var panscan_Item = new ToolStripMenuItem("パンスキャン");
            panscan_Item.Click += (s, e) =>
            {
                form.panscan();
            };

            aspect_Item.DropDownItems.Add(panscan_Item);

            var panscan_zero_Item = new ToolStripMenuItem("パンスキャン解除");
            panscan_zero_Item.Click += (s, e) =>
            {
                form.panscan_normal();
            };

            aspect_Item.DropDownItems.Add(panscan_zero_Item);

            effectMenu.DropDownItems.Add(aspect_Item);

            var glslMenu = MenuBuilder.BuildMenu_urlsol(
    "GLSL",
    GetGlslFiles(),
    path => ApplyGlsl(form, path),
    path => Path.GetFileNameWithoutExtension(path)
);
            effectMenu.DropDownItems.Add(glslMenu);

            ToolStripMenuItem cropItem = new ToolStripMenuItem("クロップ");
            cropItem.Click += (s, e) =>
            {
                string crop = Microsoft.VisualBasic.Interaction.InputBox(
                    "横幅x高さ、もしくは横幅x高さ+X軸の開始地点+Y軸の開始地点。" + Environment.NewLine
                    + "例えば400x300、もしくは400x300+100+100" + Environment.NewLine +
                    "解除するには空を入れる。", "クロップを入力せよ", "");

                form.video_crop(crop);

            };
            effectMenu.DropDownItems.Add(cropItem);


            var vr_mode_Item = new ToolStripMenuItem("360度3DVRモード");
            vr_mode_Item.Click += (s, e) =>
            {
                form.vr_360mode();
            };
            effectMenu.DropDownItems.Add(vr_mode_Item);

            ToolStripMenuItem rotateItem = new ToolStripMenuItem("回転");
            effectMenu.DropDownItems.Add(rotateItem);


            var flipItem = new ToolStripMenuItem("左右反転");
            flipItem.Click += (s, e) =>
            {
                form.video_flip();
            };
            rotateItem.DropDownItems.Add(flipItem);

            var rotate_90_right_Item = new ToolStripMenuItem("90度右");
            rotate_90_right_Item.Click += (s, e) =>
            {
                form.video_rotate_90_right();
            };
            rotateItem.DropDownItems.Add(rotate_90_right_Item);

            var rotate_90_left_Item = new ToolStripMenuItem("90度左");
            rotate_90_left_Item.Click += (s, e) =>
            {
                form.video_rotate_90_left();
            };
            rotateItem.DropDownItems.Add(rotate_90_left_Item);



            var audio_efect_Item = new ToolStripMenuItem("音声エフェクト(セット)");

            effectMenu.DropDownItems.Add(audio_efect_Item);

            var sound_normal_Item = new ToolStripMenuItem("音声エフェクト除去");
            sound_normal_Item.Click += (s, e) =>
            {
                form.audio_lavfi_normal();
            };



            audio_efect_Item.DropDownItems.Add(sound_normal_Item);

            var karaoke_Item = new ToolStripMenuItem("声除去");
            karaoke_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["声除去"]);
            };



            audio_efect_Item.DropDownItems.Add(karaoke_Item);





            var voice_Item = new ToolStripMenuItem("声強調");
            voice_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["声強調"]);
            };



            audio_efect_Item.DropDownItems.Add(voice_Item);

            var auidio_cinema_Item = new ToolStripMenuItem("映画館音響");
            auidio_cinema_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["映画館音響"]);

            };



            audio_efect_Item.DropDownItems.Add(auidio_cinema_Item);


            var sp_record_Item = new ToolStripMenuItem("蓄音機");
            sp_record_Item.Click += (s, e) =>
            {

                form.audio_lavfi(Effect_dictionary.AudioPresets["蓄音機"]);
            };



            audio_efect_Item.DropDownItems.Add(sp_record_Item);




            var old_radio_Item = new ToolStripMenuItem("AMラジオ");
            old_radio_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["AMラジオ"]);

            };



            audio_efect_Item.DropDownItems.Add(old_radio_Item);



            var movie_Item = new ToolStripMenuItem("映画");
            movie_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["映画"]);

            };



            audio_efect_Item.DropDownItems.Add(movie_Item);

            var music_Item = new ToolStripMenuItem("音楽");
            music_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["音楽"]);


            };



            audio_efect_Item.DropDownItems.Add(music_Item);

            var haishin_Item = new ToolStripMenuItem("配信");
            haishin_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["配信"]);

            };



            audio_efect_Item.DropDownItems.Add(haishin_Item);

            var audio_efect_single_Item = new ToolStripMenuItem("音声エフェクト(単体)");

            effectMenu.DropDownItems.Add(audio_efect_single_Item);

            var acompressor_Item = new ToolStripMenuItem("音量差を圧縮(acompressor)");
            acompressor_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["コンプレッサー"]);


            };



            audio_efect_single_Item.DropDownItems.Add(acompressor_Item);


            var Reverb_Item = new ToolStripMenuItem("リバーブ");
            Reverb_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["リバーブ"]);


            };



            audio_efect_single_Item.DropDownItems.Add(Reverb_Item);

            var loudnorm_Item = new ToolStripMenuItem("ラウドネス正規化");
            loudnorm_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["ラウドネス"]);

            };



            audio_efect_single_Item.DropDownItems.Add(loudnorm_Item);

            var noiz_Item = new ToolStripMenuItem("ノイズ除去");
            noiz_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["ノイズ除去"]);


            };



            audio_efect_single_Item.DropDownItems.Add(noiz_Item);

            var extra_stereo_Item = new ToolStripMenuItem("エクストラステレオ");
            extra_stereo_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["エクストラステレオ"]);


            };



            audio_efect_single_Item.DropDownItems.Add(extra_stereo_Item);

            var earwax_Item = new ToolStripMenuItem("ヘッドホンの最適化(earwax)");
            earwax_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["earwax"]);


            };



            audio_efect_single_Item.DropDownItems.Add(earwax_Item);

            var video_efect_Item = new ToolStripMenuItem("映像エフェクト");

            effectMenu.DropDownItems.Add(video_efect_Item);

            var normal_Item = new ToolStripMenuItem("映像エフェクト除去");
            normal_Item.Click += (s, e) =>
            {
                form.vf_normal();
            };



            video_efect_Item.DropDownItems.Add(normal_Item);

            effectMenu.DropDownItems.Add(video_efect_Item);


            var fps_Item = new ToolStripMenuItem("FPS補完");
            fps_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["FPS"]);
            };



            video_efect_Item.DropDownItems.Add(fps_Item);

            var motion_blur_Item = new ToolStripMenuItem("モーションブラー");
            motion_blur_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["モーションブラー"]);
            };



            video_efect_Item.DropDownItems.Add(motion_blur_Item);

            var sharp_Item = new ToolStripMenuItem("シャープ");

            video_efect_Item.DropDownItems.Add(sharp_Item);
            var sharp_strong_Item = new ToolStripMenuItem("強シャープ");
            sharp_strong_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["強シャープ"]);
            };
            sharp_Item.DropDownItems.Add(sharp_strong_Item);

            var sharp_high_Item = new ToolStripMenuItem("高画質シャープ");
            sharp_high_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["高画質シャープ"]);
            };
            sharp_Item.DropDownItems.Add(sharp_high_Item);



            var soft_Item = new ToolStripMenuItem("ソフトフォーカス");

            video_efect_Item.DropDownItems.Add(soft_Item);
            var soft_dorama_Item = new ToolStripMenuItem("昔のドラマ風");
            soft_dorama_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["昔のドラマ風"]);
            };
            soft_Item.DropDownItems.Add(soft_dorama_Item);

            var soft_natural_Item = new ToolStripMenuItem("ナチュラル");
            soft_natural_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["ソフトフォーカス_ナチュラル"]);
            };
            soft_Item.DropDownItems.Add(soft_natural_Item);

            var soft_bihada_Item = new ToolStripMenuItem("美肌ソフト");
            soft_bihada_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["美肌ソフト"]);
            };
            soft_Item.DropDownItems.Add(soft_bihada_Item);




            var soft_vhs_Item = new ToolStripMenuItem("VHS_AVソフト");
            soft_vhs_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["VHS_AVソフト"]);
            };
            soft_Item.DropDownItems.Add(soft_vhs_Item);

            var soft_old_cinema_Item = new ToolStripMenuItem("戦前白黒ソフト");
            soft_old_cinema_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["戦前白黒ソフト"]);
            };
            soft_Item.DropDownItems.Add(soft_old_cinema_Item);

            var crtItem = new ToolStripMenuItem("CRT(ブラウン管)");
            crtItem.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["CRT"]);
            };



            video_efect_Item.DropDownItems.Add(crtItem);

            var vhsItem = new ToolStripMenuItem("VHS");
            vhsItem.Click += (s, e) =>
            {


                form.video_lavfi(Effect_dictionary.VideoLavfi["VHS"]);
            };



            video_efect_Item.DropDownItems.Add(vhsItem);


            var old_coler_Item = new ToolStripMenuItem("古い映画カラー");
            old_coler_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["OldColor"]);
            };




            video_efect_Item.DropDownItems.Add(old_coler_Item);

            var old_mono_Item = new ToolStripMenuItem("古い映画モノクロ");
            old_mono_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["OldMono"]);
            };



            video_efect_Item.DropDownItems.Add(old_mono_Item);


            var vhs_CRT_Item = new ToolStripMenuItem("VHS+CRT");
            vhs_CRT_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["VHS-CRT"]);
            };



            video_efect_Item.DropDownItems.Add(vhs_CRT_Item);


            var silent_Item = new ToolStripMenuItem("サイレント映画");
            silent_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["Silent"]);
            };



            video_efect_Item.DropDownItems.Add(silent_Item);
            ToolStripMenuItem video_preset = new ToolStripMenuItem("ビデオプリセット");
            video_preset.DropDownItems.Add("フラット", null, (s, e) => { form.Video_Preset("Flat"); });
            video_preset.DropDownItems.Add("映画", null, (s, e) => { form.Video_Preset("Cinema"); });
            video_preset.DropDownItems.Add("ブルーライトカット", null, (s, e) => { form.Video_Preset("Night"); });
            video_preset.DropDownItems.Add("ダイナミック", null, (s, e) => { form.Video_Preset("Dynamic"); });
            video_preset.DropDownItems.Add("Game", null, (s, e) => { form.Video_Preset("Game"); });
            video_preset.DropDownItems.Add("映画風モノクロ", null, (s, e) => { form.Video_Preset("Cinema_mono"); });
            video_preset.DropDownItems.Add("レトロ映画", null, (s, e) => { form.Video_Preset("Retoro_cinema"); });
            video_preset.DropDownItems.Add("HDR風", null, (s, e) => { form.Video_Preset("HDR"); });
            video_preset.DropDownItems.Add("アニメ", null, (s, e) => { form.Video_Preset("Anime"); });
            video_preset.DropDownItems.Add("ハードモノ", null, (s, e) => { form.Video_Preset("Hard_mono"); });
            video_preset.DropDownItems.Add("VHS", null, (s, e) => { form.Video_Preset("VHS"); });
            video_preset.DropDownItems.Add("昭和TV", null, (s, e) => { form.Video_Preset("ShowaTV"); });

            video_preset.DropDownItems.Add("白黒", null, (s, e) => { form.Video_Preset("Mono"); });
            video_preset.DropDownItems.Add("暖色", null, (s, e) => { form.Video_Preset("Warm"); });
            video_preset.DropDownItems.Add("ブルー", null, (s, e) => { form.Video_Preset("Blue"); });

            // メニューに追加
            effectMenu.DropDownItems.Add(video_preset);

            ToolStripMenuItem audio_preset = new ToolStripMenuItem("オーディオプリセット");
            audio_preset.DropDownItems.Add("フラット", null, (s, e) => { form.Audio_Preset("Flat"); });

            audio_preset.DropDownItems.Add("Talk", null, (s, e) => { form.Audio_Preset("Talk"); });
            audio_preset.DropDownItems.Add("重低音", null, (s, e) => { form.Audio_Preset("重低音"); });
            audio_preset.DropDownItems.Add("映画", null, (s, e) => { form.Audio_Preset("Movie"); });
            audio_preset.DropDownItems.Add("Sports", null, (s, e) => { form.Audio_Preset("Sports"); });
            audio_preset.DropDownItems.Add("Jazz", null, (s, e) => { form.Audio_Preset("Jazz"); });
            audio_preset.DropDownItems.Add("Classic", null, (s, e) => { form.Audio_Preset("Classic"); });
            audio_preset.DropDownItems.Add("Rock", null, (s, e) => { form.Audio_Preset("Rock"); });
            audio_preset.DropDownItems.Add("重低音", null, (s, e) => { form.Audio_Preset("重低音"); });



            effectMenu.DropDownItems.Add(audio_preset);

            ToolStripMenuItem a_b_markerItem = new ToolStripMenuItem("A-Bマーカー");
            a_b_markerItem.DropDownItems.Add("A点（開始)の設定", null, (s, e) => { form.a_marker_creat(); });
            a_b_markerItem.DropDownItems.Add("B点（終了)の設定", null, (s, e) => { form.b_marker_creat(); });
            a_b_markerItem.DropDownItems.Add("A-Bループ開始", null, (s, e) => { form.ab_loop_start(); });
            effectMenu.DropDownItems.Add(a_b_markerItem);


            var epgMenu = new ToolStripMenuItem("TV欄");


            var tvran_now_open_Item = new ToolStripMenuItem("TV欄表示(現在時間");
            tvran_now_open_Item.Click += (s, e) => form.open_now_tv_ran();
            epgMenu.DropDownItems.Add(tvran_now_open_Item);

            var tvran_single_open_Item = new ToolStripMenuItem("TV欄表示(現在のチャンネル）");
            tvran_single_open_Item.Click += (s, e) => form.open_single_tv_ran();
            epgMenu.DropDownItems.Add(tvran_single_open_Item);
            var tvran_all_open_Item = new ToolStripMenuItem("TV欄表示(全て）");
            tvran_all_open_Item.Click += (s, e) => form.open_all_tv_ran();
            epgMenu.DropDownItems.Add(tvran_all_open_Item);
            var tvran_whitelist_open_Item = new ToolStripMenuItem("TV欄表示(ジャンル別）");

            var epg_chijou_tv_Item = new ToolStripMenuItem("地上波TV");
            epg_chijou_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.chijoou_tv, "地上波TV", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_chijou_tv_Item);

            var epg_kansai_tv_Item = new ToolStripMenuItem("地上波TV(関西）");
            epg_kansai_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.kansai_tv, "関西TV", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_kansai_tv_Item);

            var epg_bs_free_tv_Item = new ToolStripMenuItem("BS(無料)");
            epg_bs_free_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.bs_free, "BS(無料)", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_bs_free_tv_Item);
            var epg_bs_cs_yuryou_tv_Item = new ToolStripMenuItem("BS/CS(有料)");
            epg_bs_cs_yuryou_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.bs_cs_yuryou, "BS/CS(有料)", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_bs_cs_yuryou_tv_Item);

            var epg_rakuten_tv_Item = new ToolStripMenuItem("楽天");
            epg_rakuten_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.rakuten, "楽天", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_rakuten_tv_Item);


            var epg_fast_tv_Item = new ToolStripMenuItem("fast");
            epg_fast_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.fast, "fast", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_fast_tv_Item);

            epgMenu.DropDownItems.Add(tvran_whitelist_open_Item);
            var epg_abema_tv_Item = new ToolStripMenuItem("abema");
            epg_abema_tv_Item.Click += (s, e) => form.open_white_list_tv_ran(epg_White_list.abema, "abema", "");

            tvran_whitelist_open_Item.DropDownItems.Add(epg_abema_tv_Item);

            var epg_radiko_tv_Item = new ToolStripMenuItem("ラジコ");
            epg_radiko_tv_Item.Click += (s, e) => form.open_radiko_all_tv_ran();

            tvran_whitelist_open_Item.DropDownItems.Add(epg_radiko_tv_Item);
            epgMenu.DropDownItems.Add(tvran_whitelist_open_Item);
            var otherMenu = new ToolStripMenuItem("その他");
            var updateItem = new ToolStripMenuItem("更新");

            otherMenu.DropDownItems.Add(updateItem);
            var abemaGetItem = new ToolStripMenuItem("Abema.txt更新");
            abemaGetItem.Click += (s, e) => form.abema_url_update();
            updateItem.DropDownItems.Add(abemaGetItem);


            var radikoItem = new ToolStripMenuItem("radiko.txt更新");
            radikoItem.Click += (s, e) => form.radiko_url_update();
            updateItem.DropDownItems.Add(radikoItem);
            var mov3_updateItem = new ToolStripMenuItem("mov3.txt更新");
            mov3_updateItem.Click += (s, e) => form.mov3_url_update();
            updateItem.DropDownItems.Add(mov3_updateItem);



            var mytdlp_updateItem = new ToolStripMenuItem("yt-dlp更新");
            mytdlp_updateItem.Click += (s, e) => form.ytdlp_update();
            updateItem.DropDownItems.Add(mytdlp_updateItem);

            var epgItem = new ToolStripMenuItem("epg(xml)の保存");
            otherMenu.DropDownItems.Add(epgItem);

            var animenosekai_xml_down_Item = new ToolStripMenuItem("animenosekaiのepg保存");
            animenosekai_xml_down_Item.Click += (s, e) => form.animenosekai_xml_get();

            var karenda_xml_down_Item = new ToolStripMenuItem("karenda-jpのepg保存");
            karenda_xml_down_Item.Click += (s, e) => form.karenda_xml_get();
            var jp_epg_26f0ce_xml_down_Item = new ToolStripMenuItem("jp-epg-26f0ceのepg保存");
            jp_epg_26f0ce_xml_down_Item.Click += (s, e) => form.jp_epg_26f0ce_xml_get();

            var radiko_xml_down_Item = new ToolStripMenuItem("ラジコのepg保存");
            radiko_xml_down_Item.Click += (s, e) => form.radiko_xml_get();

            var all_xml_down_Item = new ToolStripMenuItem("epgを全て保存");
            all_xml_down_Item.Click += (s, e) => form.all_xml_get();


            epgItem.DropDownItems.Add(jp_epg_26f0ce_xml_down_Item);
            epgItem.DropDownItems.Add(karenda_xml_down_Item);
            epgItem.DropDownItems.Add(animenosekai_xml_down_Item);
            epgItem.DropDownItems.Add(radiko_xml_down_Item);
            epgItem.DropDownItems.Add(all_xml_down_Item);
            var verItem = new ToolStripMenuItem("ver");
            verItem.Click += (s, e) => form.ver_mes_bosx();
            otherMenu.DropDownItems.Add(verItem);
            var pingItem = new ToolStripMenuItem("TV鯖の反応速度を取得");
            pingItem.Click += (s, e) => form.play_ping();
            otherMenu.DropDownItems.Add(pingItem);



            var srt_wite_Item = new ToolStripMenuItem("字幕(SRT)書き出し");
            srt_wite_Item.Click += (s, e) => form.button_SaveSubtitleDelay_Click();
            otherMenu.DropDownItems.Add(srt_wite_Item);



            // ===== メニュー追加 =====
            form.TopMenuPanel.Items.Add(playMenu);
            form.TopMenuPanel.Items.Add(listMenu);
            form.TopMenuPanel.Items.Add(windowMenu);
            if (config_class.config_bool_read("AbemaTV低画質を有効") == true)
            {
                form.TopMenuPanel.Items.Add(abema_low_menu);
            }


            if (config_class.config_bool_read("fastを有効") == true)
            {
                form.TopMenuPanel.Items.Add(fast_menu);
            }


            if (config_class.config_bool_read("mov3を有効") == true)
            {
                form.TopMenuPanel.Items.Add(mov3_menu);
            }
            if (config_class.config_bool_read("楽天を有効") == true)
            {
                form.TopMenuPanel.Items.Add(rakutenMenu);
            }
        
           
            if (config_class.config_bool_read("zhonを有効") == true)
            {
                form.TopMenuPanel.Items.Add(zhongyingMenu);
            }
            if (config_class.config_bool_read("akariを有効") == true)
            {
                form.TopMenuPanel.Items.Add(akarikoMenu);
            }

            if (config_class.config_bool_read("AbemaTV高画質を有効") == true)
            {
                form.TopMenuPanel.Items.Add(abema_high_menu);
            }




            if (config_class.config_bool_read("ラジコを有効") == true)
            {
                form.TopMenuPanel.Items.Add(radiko_menu);
            }




            if (config_class.config_bool_read("カテゴリーを有効") == true)
            {
                form.TopMenuPanel.Items.Add(cat_menu);
            }
            form.TopMenuPanel.Items.Add(effectMenu);

            if (config_class.config_bool_read("ランキングを有効") == true)
            {
                form.TopMenuPanel.Items.Add(rankMenu);
            }
            if (config_class.config_bool_read("履歴を有効") == true)
            {
                form.TopMenuPanel.Items.Add(rirekiMenu);
            }
            form.TopMenuPanel.Items.Add(epgMenu);
            form.TopMenuPanel.Items.Add(otherMenu);

            form.BottomControlPanel = new Panel();
            form.BottomControlPanel.Dock = DockStyle.Fill;
            form.BottomControlPanel.Height = 130;  // 130

            form.BottomControlPanel.BackColor = Color.White;
            // 文字色を黒に設定
            form.BottomControlPanel.ForeColor = Color.Black;
            // Video Panel
            form.videoPanel = new Panel();

            form.videoPanel.Dock = DockStyle.Fill;
            form.videoPanel.BackColor = Color.Black;
            form.videoPanel.DoubleClick += form.PlayerPanel_DoubleClick;
            form.videoPanel.Click += form.PlayerPanel_SIngleClick;
            form.videoPanel.MouseMove += form.PlayerPanel_MouseMove; // 追加
            form._mainLayout.Controls.Add(form.videoPanel, 0, 1);


            ContextMenuStrip menu = new ContextMenuStrip();

            // 通常メニュー
            menu.Items.Add("削除", null, (s, e) => { form.delete(); });
            menu.Items.Add("再起動", null, (s, e) => { form.reboot(); });
            menu.Items.Add("動画情報", null, (s, e) => { form.videoinfo_window_open(); });

            menu.Items.Add("フルスクリーン", null, (s, e) => { form.ToggleFullScreen(); });



            menu.Items.Add("ミニプレイヤー", null, (s, e) => { form.ToggleMiniPlayer(); });


            // サブメニューの親
            ToolStripMenuItem settingsItem = new ToolStripMenuItem("リスト");

            // サブメニューの子
            settingsItem.DropDownItems.Add("次の動画", null, (s, e) => { form.next_movie(); });
            settingsItem.DropDownItems.Add("前の動画", null, (s, e) => { form.prev_movie(); });
            settingsItem.DropDownItems.Add("ランダム", null, (s, e) => { form.randam_movie(); });
            settingsItem.DropDownItems.Add("最初の動画", null, (s, e) => { });
            settingsItem.DropDownItems.Add("真ん中の動画", null, (s, e) => { /* 映像処理 */ });

            settingsItem.DropDownItems.Add("リストをフォルダ", null, (s, e) => { form.list_folder(); });
            settingsItem.DropDownItems.Add("リストを動画DB", null, (s, e) => { form.list_db(); });
            settingsItem.DropDownItems.Add("リストをAbema", null, (s, e) => { form.list_abema(); });
            settingsItem.DropDownItems.Add("リストをfast", null, (s, e) => { form.list_fast(); });


            // settingsItem.DropDownItems.Add("動画のフォルダを開く", null, (s, e) => { /* 字幕処理 */ });

            //
            // メニューに追加
            menu.Items.Add(settingsItem);
            // サブメニューの親
            ToolStripMenuItem right_playItem = new ToolStripMenuItem("再生");

            // サブメニューの子
            right_playItem.DropDownItems.Add("停止", null, (s, e) => { form.StopMpv(); });
            right_playItem.DropDownItems.Add("ミュート", null, (s, e) => { form.mute_func(); });

            right_playItem.DropDownItems.Add("ポーズ", null, (s, e) => { form.pause_func(); });

            right_playItem.DropDownItems.Add("再起動", null, (s, e) => { form.reboot(); });
            right_playItem.DropDownItems.Add("リロード", null, (s, e) => { form.reload(); });
            right_playItem.DropDownItems.Add("ボリューム最大", null, (s, e) => { /* 音声処理 */ });
            right_playItem.DropDownItems.Add("ボリューム半分", null, (s, e) => { /* 音声処理 */ });



            // メニューに追加
            menu.Items.Add(right_playItem);

            ToolStripMenuItem right_window_item = new ToolStripMenuItem("ウインドウ");


            // サブメニューの親
            ToolStripMenuItem right_site_item = new ToolStripMenuItem("TVチャンネル");
            menu.Items.Add(right_site_item);

            var right_abema_low_menu = MenuBuilder.BuildMenu_urlsol(
       "Abe低",
        abema_low_list,
          url => form.StartMpv(url),
          url => title_generate.Get_abema(url, 3)

   );
            right_site_item.DropDownItems.Add(right_abema_low_menu);






            var right_fast_menu = MenuBuilder.BuildMenu_dic(
 "fast",
  fast_list,
    url => form.StartMpv(url),
      url => title_generate.Get_title(url, title_generate._fast_channelMap, 2, "fast")
);
            right_site_item.DropDownItems.Add(right_fast_menu);


            var right_mov3_menu = MenuBuilder.BuildMenu_dic(
"mov3",
 mov3_list,
   url => form.StartMpv(url),
       url => title_generate.Get_mov3(url)
);
            right_site_item.DropDownItems.Add(right_mov3_menu);

            var right_rakutenMenu = MenuBuilder.BuildMenu_urlsol(
     "楽天",
     rakuten_lists,
     url => form.StartMpv(url),
       url => title_generate.Get_title(url, title_generate._rakuten_ChannelNameMap, 2, "rakuten")
     );
            right_site_item.DropDownItems.Add(right_rakutenMenu);




            var right_abema_high_menu = MenuBuilder.BuildMenu_urlsol(
"Abe高",
abema_high_list,
url => form.StartMpv(url),
  url => title_generate.Get_abema(url, 2)
);
            right_site_item.DropDownItems.Add(right_abema_high_menu);
            var right_radiko_menu = MenuBuilder.BuildMenu_urlsol(
"ラジコ",
radiko_list,
url => form.StartMpv(url),
  url => title_generate.GetRadikoStation(url)
);
            right_site_item.DropDownItems.Add(right_radiko_menu);

            // サブメニューの子
            right_window_item.DropDownItems.Add("設定", null, (s, e) => { form.setting_open(); });
            right_window_item.DropDownItems.Add("映像設定", null, (s, e) => { form.open_video_window(); });


            right_window_item.DropDownItems.Add("オーディオ設定", null, (s, e) => { form.audio_window_open(); });
            right_window_item.DropDownItems.Add("フォルダ登録", null, (s, e) => { form.d_d_window_open(); });

            // メニューに追加
            menu.Items.Add(right_window_item);
            // サブメニューの親
            ToolStripMenuItem right_efectItem = new ToolStripMenuItem("エフェクト");
            ToolStripMenuItem right_aspectItem = new ToolStripMenuItem("アスペクト比");


            var right_aspect_normal_Item = new ToolStripMenuItem("ノーマル");
            right_aspect_normal_Item.Click += (s, e) =>
            {
                form.vf_normal();
            };
            right_aspectItem.DropDownItems.Add(right_aspect_normal_Item);

            var right_aspect_4_3_Item = new ToolStripMenuItem("昔のTV(4:3)");
            right_aspect_4_3_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["4:3"]);

            };

            right_aspectItem.DropDownItems.Add(right_aspect_4_3_Item);




            var right_aspect_16_9_Item = new ToolStripMenuItem("フルHD(16:9)");
            right_aspect_16_9_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["16:9"]);
            };

            right_aspectItem.DropDownItems.Add(right_aspect_16_9_Item);

            var right_aspect_9_16_Item = new ToolStripMenuItem("スマホ(9:16)");
            right_aspect_9_16_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["スマホ"]);
            };

            right_aspectItem.DropDownItems.Add(right_aspect_9_16_Item);
            var right_cinesco_Item = new ToolStripMenuItem("シネスコ(2.35)");
            right_cinesco_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["シネスコ"]);
            };
            right_aspectItem.DropDownItems.Add(right_cinesco_Item);

            var right_aspect_vista_Item = new ToolStripMenuItem("ビスタ(1.85:1)");
            right_aspect_vista_Item.Click += (s, e) =>
            {
                form.video_aspect(Effect_dictionary.AspectPresets["Vista"]);
            };



            right_aspectItem.DropDownItems.Add(right_aspect_vista_Item);

            var right_panscan_Item = new ToolStripMenuItem("パンスキャン");
            right_panscan_Item.Click += (s, e) =>
            {
                form.panscan();
            };

            right_aspectItem.DropDownItems.Add(right_panscan_Item);

            var right_panscan_zero_Item = new ToolStripMenuItem("パンスキャン解除");
            right_panscan_zero_Item.Click += (s, e) =>
            {
                form.panscan_normal();
            };
            right_aspectItem.DropDownItems.Add(right_panscan_zero_Item);

            right_efectItem.DropDownItems.Add(right_aspectItem);



            var right_audio_efect_Item = new ToolStripMenuItem("音声エフェクト(セット)");

            right_efectItem.DropDownItems.Add(right_audio_efect_Item);

            var right_sound_normal_Item = new ToolStripMenuItem("音声エフェクト除去");
            right_sound_normal_Item.Click += (s, e) =>
            {
                form.audio_lavfi_normal();
            };



            right_audio_efect_Item.DropDownItems.Add(right_sound_normal_Item);

            var right_karaoke_Item = new ToolStripMenuItem("声除去");
            right_karaoke_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["声除去"]);
            };



            right_audio_efect_Item.DropDownItems.Add(right_karaoke_Item);





            var right_voice_Item = new ToolStripMenuItem("声強調");
            right_voice_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["声強調"]);
            };



            right_audio_efect_Item.DropDownItems.Add(right_voice_Item);

            var right_auidio_cinema_Item = new ToolStripMenuItem("映画館音響");
            right_auidio_cinema_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["映画館音響"]);

            };



            right_audio_efect_Item.DropDownItems.Add(right_auidio_cinema_Item);


            var right_sp_record_Item = new ToolStripMenuItem("蓄音機");
            right_sp_record_Item.Click += (s, e) =>
            {

                form.audio_lavfi(Effect_dictionary.AudioPresets["蓄音機"]);
            };



            right_audio_efect_Item.DropDownItems.Add(right_sp_record_Item);




            var right_old_radio_Item = new ToolStripMenuItem("AMラジオ");
            right_old_radio_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["AMラジオ"]);

            };



            right_audio_efect_Item.DropDownItems.Add(right_old_radio_Item);



            var right_movie_Item = new ToolStripMenuItem("映画");
            right_movie_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["映画"]);

            };



            right_audio_efect_Item.DropDownItems.Add(right_movie_Item);

            var right_music_Item = new ToolStripMenuItem("音楽");
            right_music_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["音楽"]);


            };



            right_audio_efect_Item.DropDownItems.Add(right_music_Item);

            var right_haishin_Item = new ToolStripMenuItem("配信");
            right_haishin_Item.Click += (s, e) =>
            {
                form.audio_lavfi(Effect_dictionary.AudioPresets["配信"]);

            };



            right_audio_efect_Item.DropDownItems.Add(right_haishin_Item);

            var right_audio_efect_single_Item = new ToolStripMenuItem("音声エフェクト(単体)");
            right_efectItem.DropDownItems.Add(right_audio_efect_single_Item);

            var right_acompressor_Item = new ToolStripMenuItem("音量差を圧縮(acompressor)");
            right_acompressor_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["コンプレッサー"]);


            };



            right_audio_efect_single_Item.DropDownItems.Add(right_acompressor_Item);


            var right_Reverb_Item = new ToolStripMenuItem("リバーブ");
            Reverb_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["リバーブ"]);


            };



            right_audio_efect_single_Item.DropDownItems.Add(right_Reverb_Item);

            var right_loudnorm_Item = new ToolStripMenuItem("ラウドネス正規化");
            right_loudnorm_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["ラウドネス"]);

            };



            right_audio_efect_single_Item.DropDownItems.Add(right_loudnorm_Item);

            var right_noiz_Item = new ToolStripMenuItem("ノイズ除去");
            right_noiz_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["ノイズ除去"]);


            };



            right_audio_efect_single_Item.DropDownItems.Add(right_noiz_Item);

            var right_extra_stereo_Item = new ToolStripMenuItem("エクストラステレオ");
            right_extra_stereo_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["エクストラステレオ"]);


            };



            right_audio_efect_single_Item.DropDownItems.Add(right_extra_stereo_Item);

            var right_earwax_Item = new ToolStripMenuItem("ヘッドホンの最適化(earwax)");
            right_earwax_Item.Click += (s, e) =>
            {
                form.audio_lavfi_single(Effect_dictionary.AudioPresets["earwax"]);


            };



            right_audio_efect_single_Item.DropDownItems.Add(right_earwax_Item);

            var right_video_efect_Item = new ToolStripMenuItem("映像エフェクト");



            var right_normal_Item = new ToolStripMenuItem("映像エフェクト除去");
            right_normal_Item.Click += (s, e) =>
            {
                form.vf_normal();
            };



            right_video_efect_Item.DropDownItems.Add(right_normal_Item);




            var right_fps_Item = new ToolStripMenuItem("FPS補完");
            right_fps_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["FPS"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_fps_Item);

            var right_motion_blur_Item = new ToolStripMenuItem("モーションブラー");
            right_motion_blur_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["モーションブラー"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_motion_blur_Item);


            var right_crtItem = new ToolStripMenuItem("CRT(ブラウン管)");
            right_crtItem.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["CRT"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_crtItem);

            var right_vhsItem = new ToolStripMenuItem("VHS");
            right_vhsItem.Click += (s, e) =>
            {


                form.video_lavfi(Effect_dictionary.VideoLavfi["VHS"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_vhsItem);


            var right_old_coler_Item = new ToolStripMenuItem("古い映画カラー");
            right_old_coler_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["OldColor"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_old_coler_Item);

            var right_old_mono_Item = new ToolStripMenuItem("古い映画モノクロ");
            right_old_mono_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["OldMono"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_old_mono_Item);


            var right_vhs_CRT_Item = new ToolStripMenuItem("VHS+CRT");
            right_vhs_CRT_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["VHS-CRT"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_vhs_CRT_Item);


            var right_silent_Item = new ToolStripMenuItem("サイレント映画");
            right_silent_Item.Click += (s, e) =>
            {
                form.video_lavfi(Effect_dictionary.VideoLavfi["Silent"]);
            };



            right_video_efect_Item.DropDownItems.Add(right_silent_Item);
            right_efectItem.DropDownItems.Add(right_video_efect_Item);
            // メニューに追加
            menu.Items.Add(right_efectItem);


            ToolStripMenuItem settingsItem6 = new ToolStripMenuItem("再生速度");
            settingsItem6.DropDownItems.Add("ノーマル", null, (s, e) => { form.Speed_change(1.0); });
            settingsItem6.DropDownItems.Add("1.1倍", null, (s, e) => { form.Speed_change(1.1); });
            settingsItem6.DropDownItems.Add("1.2倍", null, (s, e) => { form.Speed_change(1.2); });

            settingsItem6.DropDownItems.Add("1.5倍", null, (s, e) => { form.Speed_change(1.5); });
            settingsItem6.DropDownItems.Add("2倍", null, (s, e) => { form.Speed_change(2.0); });
            settingsItem6.DropDownItems.Add("0.9倍", null, (s, e) => { form.Speed_change(0.9); });
            settingsItem6.DropDownItems.Add("0.8倍", null, (s, e) => { form.Speed_change(0.8); });
            settingsItem6.DropDownItems.Add("0.5倍", null, (s, e) => { form.Speed_change(0.5); });



            // メニューに追加
            menu.Items.Add(settingsItem6);

            ToolStripMenuItem settingsItem7 = new ToolStripMenuItem("履歴");

            var right_rirekiMenu = MenuBuilder.BuildMenu(
"履歴",
history_list,
url => form.StartMpv(url)
);
            var right_rankMenu = MenuBuilder.BuildMenu(
     "ランク",
     ranking_list,
     url => form.StartMpv(url)
     );

            settingsItem7.DropDownItems.Add(right_rirekiMenu);
            settingsItem7.DropDownItems.Add(right_rankMenu);
            // メニューに追加
            menu.Items.Add(settingsItem7);

            ToolStripMenuItem right_video_preset = new ToolStripMenuItem("ビデオプリセット");
            right_video_preset.DropDownItems.Add("フラット", null, (s, e) => { form.Video_Preset("Flat"); });
            right_video_preset.DropDownItems.Add("映画", null, (s, e) => { form.Video_Preset("Cinema"); });
            right_video_preset.DropDownItems.Add("ブルーライトカット", null, (s, e) => { form.Video_Preset("Night"); });
            right_video_preset.DropDownItems.Add("ダイナミック", null, (s, e) => { form.Video_Preset("Dynamic"); });
            right_video_preset.DropDownItems.Add("Game", null, (s, e) => { form.Video_Preset("Game"); });
            right_video_preset.DropDownItems.Add("映画風モノクロ", null, (s, e) => { form.Video_Preset("Cinema_mono"); });
            right_video_preset.DropDownItems.Add("レトロ映画", null, (s, e) => { form.Video_Preset("Retoro_cinema"); });
            right_video_preset.DropDownItems.Add("HDR風", null, (s, e) => { form.Video_Preset("HDR"); });
            right_video_preset.DropDownItems.Add("アニメ", null, (s, e) => { form.Video_Preset("Anime"); });
            right_video_preset.DropDownItems.Add("ハードモノ", null, (s, e) => { form.Video_Preset("Hard_mono"); });
            right_video_preset.DropDownItems.Add("VHS", null, (s, e) => { form.Video_Preset("VHS"); });
            right_video_preset.DropDownItems.Add("昭和TV", null, (s, e) => { form.Video_Preset("ShowaTV"); });

            right_video_preset.DropDownItems.Add("白黒", null, (s, e) => { form.Video_Preset("Mono"); });
            right_video_preset.DropDownItems.Add("暖色", null, (s, e) => { form.Video_Preset("Warm"); });
            right_video_preset.DropDownItems.Add("ブルー", null, (s, e) => { form.Video_Preset("Blue"); });

            // メニューに追加
            menu.Items.Add(right_video_preset);
            ToolStripMenuItem settingsItem9 = new ToolStripMenuItem("オーディオプリセット");
            settingsItem9.DropDownItems.Add("フラット", null, (s, e) => { form.Audio_Preset("Flat"); });

            settingsItem9.DropDownItems.Add("Talk", null, (s, e) => { form.Audio_Preset("Talk"); });

            settingsItem9.DropDownItems.Add("映画", null, (s, e) => { form.Audio_Preset("Movie"); });
            settingsItem9.DropDownItems.Add("Sports", null, (s, e) => { form.Audio_Preset("Sports"); });
            settingsItem9.DropDownItems.Add("Jazz", null, (s, e) => { form.Audio_Preset("Jazz"); });
            settingsItem9.DropDownItems.Add("Classic", null, (s, e) => { form.Audio_Preset("Classic"); });
            settingsItem9.DropDownItems.Add("Rock", null, (s, e) => { form.Audio_Preset("Rock"); });
            settingsItem9.DropDownItems.Add("重低音", null, (s, e) => { form.Audio_Preset("重低音"); });



            // メニューに追加
            menu.Items.Add(settingsItem9);
            menu.Items.Add("閉じる", null, (s, e) => { /* 処理 */ });
            // コントロールに設定

            form.ContextMenuStrip = menu;
            form._mainLayout.Controls.Add(form.videoPanel, 0, 1);

            // Bottom Controls





            var controlRow = new FlowLayoutPanel();
            controlRow.Dock = DockStyle.Top;
            controlRow.Height = 40;
            controlRow.Padding = new Padding(0);
            controlRow.Margin = new Padding(0);
            controlRow.AutoSize = true;
            Button bt_ss = new Button();
            if (config_class.config_bool_read("スクリーンショットボタンを有効") == true)
            {

                bt_ss.Size = new Size(36, 36);

                bt_ss.Image = Resources.bt_ss;


                bt_ss.ImageAlign = ContentAlignment.MiddleCenter;
                bt_ss.Click += (s, e) => form.ss_func();

                controlRow.Controls.Add(bt_ss);
            }
            Button bt_full = new Button();
            if (config_class.config_bool_read("フルスクリーンボタンを有効") == true)
            {

                bt_full.Size = new Size(36, 36);
                {
                    bt_full.Image = Resources.bt_full;




                    bt_full.ImageAlign = ContentAlignment.MiddleCenter;
                    bt_full.Click += (s, e) => form.ToggleFullScreen();

                    controlRow.Controls.Add(bt_full);
                }
            }
            Button bt_mute = new Button();
            if (config_class.config_bool_read("ミュートボタンを有効") == true)
            {

                bt_mute.Size = new Size(36, 36);
             
                bt_mute.Image = Resources.bt_mute;


                bt_mute.ImageAlign = ContentAlignment.MiddleCenter;
                bt_mute.Click += (s, e) => form.mute_func();

                controlRow.Controls.Add(bt_mute);
            }
            Button bt_stop = new Button();
            if (config_class.config_bool_read("停止ボタンを有効") == true)
            {

                bt_stop.Size = new Size(36, 36);


                bt_stop.Image = Resources.bt_stop;


                bt_stop.ImageAlign = ContentAlignment.MiddleCenter;
                bt_stop.Click += (s, e) => form.StopMpv();

                controlRow.Controls.Add(bt_stop);
            }
            Button bt_open = new Button();
            if (config_class.config_bool_read("オープンボタンを有効") == true)
            {

                bt_open.Size = new Size(36, 36);

                bt_open.Image = Resources.bt_open;


                bt_open.ImageAlign = ContentAlignment.MiddleCenter;
                bt_open.Click += form.BtnOpen_Click;


                controlRow.Controls.Add(bt_open);
            }
            Button bt_Pause = new Button();
            if (config_class.config_bool_read("ポーズボタンを有効") == true)
            {

                bt_Pause.Size = new Size(36, 36);


                bt_Pause.Image = Resources.bt_pause;

                bt_Pause.ImageAlign = ContentAlignment.MiddleCenter;
                bt_Pause.Click += (s, e) => form.pause_func();

                controlRow.Controls.Add(bt_Pause);
            }

            Button bt_prev = new Button();
            bt_prev.Size = new Size(36, 36);


            bt_prev.Image = Resources.bt_prev;

            bt_prev.ImageAlign = ContentAlignment.MiddleCenter;

            form._prev_movie_Timer = new System.Windows.Forms.Timer();
            form._prev_movie_Timer.Interval = 200; // 200msごとにSeek
            form._prev_movie_Timer.Tick += (s, e) => form.prev_movie();

            // 押した瞬間
            bt_prev.MouseDown += (s, e) =>
            {
                form.prev_movie();      // まず1回実行
                form._prev_movie_Timer.Start();
            };

            // 離したら停止
            bt_prev.MouseUp += (s, e) =>
            {
                form._prev_movie_Timer.Stop();
            };

            // ボタン外に出ても止める
            bt_prev.MouseLeave += (s, e) =>
            {
                form._prev_movie_Timer.Stop();
            };
            controlRow.Controls.Add(bt_prev);

            Button bt_next = new Button();
            bt_next.Size = new Size(36, 36);


            bt_next.Image = Resources.bt_next;

            bt_next.ImageAlign = ContentAlignment.MiddleCenter;
            bt_next.Click += (s, e) => form.next_movie();
            form._next_movie_Timer = new System.Windows.Forms.Timer();
            form._next_movie_Timer.Interval = 200; // 200msごとにSeek
            form._next_movie_Timer.Tick += (s, e) => form.next_movie();

            // 押した瞬間
            bt_next.MouseDown += (s, e) =>
            {
                form.next_movie();      // まず1回実行
                form._next_movie_Timer.Start();
            };

            // 離したら停止
            bt_next.MouseUp += (s, e) =>
            {
                form._next_movie_Timer.Stop();
            };

            // ボタン外に出ても止める
            bt_next.MouseLeave += (s, e) =>
            {
                form._next_movie_Timer.Stop();
            };

            controlRow.Controls.Add(bt_next);

            Button bt_PrevSeek = new Button();
            bt_PrevSeek.Size = new Size(36, 36);


            bt_PrevSeek.Image = Resources.bt_prev2;

            bt_PrevSeek.ImageAlign = ContentAlignment.MiddleCenter;

            form._prevseekTimer = new System.Windows.Forms.Timer();
            form._prevseekTimer.Interval = 200; // 200msごとにSeek
            form._prevseekTimer.Tick += (s, e) => form.PrevSeek();

            // 押した瞬間
            bt_PrevSeek.MouseDown += (s, e) =>
            {
                form.PrevSeek();     // まず1回実行
                form._prevseekTimer.Start();
            };

            // 離したら停止
            bt_PrevSeek.MouseUp += (s, e) =>
            {
                form._prevseekTimer.Stop();
            };

            // ボタン外に出ても止める
            bt_PrevSeek.MouseLeave += (s, e) =>
            {
                form._prevseekTimer.Stop();
            };
            controlRow.Controls.Add(bt_PrevSeek);

            Button bt_NextSeek = new Button();
            bt_NextSeek.Size = new Size(36, 36);

            bt_NextSeek.Image = Resources.bt_next2;

            bt_NextSeek.ImageAlign = ContentAlignment.MiddleCenter;

            form._seekTimer = new System.Windows.Forms.Timer();
            form._seekTimer.Interval = 200; // 200msごとにSeek
            form._seekTimer.Tick += (s, e) => form.NextSeek();


            // 押した瞬間
            bt_NextSeek.MouseDown += (s, e) =>
            {
                form.NextSeek();      // まず1回実行
                form._seekTimer.Start();
            };

            // 離したら停止
            bt_NextSeek.MouseUp += (s, e) =>
            {
                form._seekTimer.Stop();
            };

            // ボタン外に出ても止める
            bt_NextSeek.MouseLeave += (s, e) =>
            {
                form._seekTimer.Stop();
            };
            controlRow.Controls.Add(bt_NextSeek);

            Button bt_play = new Button();
            if (config_class.config_bool_read("再起動ボタンを有効") == true)
            {
                bt_play.Size = new Size(36, 36);


                bt_play.Image = Resources.bt_play;


                bt_play.ImageAlign = ContentAlignment.MiddleCenter;
                bt_play.Click += (s, e) => form.reboot();
                controlRow.Controls.Add(bt_play);
            }


            Button bt_reload = new Button();
            if (config_class.config_bool_read("リロードボタンを有効") == true)
            {
                bt_reload.Size = new Size(36, 36);


                bt_reload.Image = Resources.bt_play;


                bt_reload.ImageAlign = ContentAlignment.MiddleCenter;
                bt_reload.Click += (s, e) => form.reload();
                controlRow.Controls.Add(bt_reload);
            }


            Button bt_speed_down = new Button();
            Button bt_speed_normal = new Button();
            Button bt_speed_up = new Button();
            if (config_class.config_bool_read("スピードUPボタンを有効") == true)
            {

                bt_speed_down.Size = new Size(36, 36);


                bt_speed_down.Image = Resources.bt_prev;

                bt_speed_down.ImageAlign = ContentAlignment.MiddleCenter;
                form._speed_down_Timer = new System.Windows.Forms.Timer();
                form._speed_down_Timer.Interval = 200; // 200msごとにSeek
                form._speed_down_Timer.Tick += (s, e) => form.SpeedDown();

                // 押した瞬間
                bt_speed_down.MouseDown += (s, e) =>
                {
                    form.SpeedDown();    // まず1回実行
                    form._speed_down_Timer.Start();
                };

                // 離したら停止
                bt_speed_down.MouseUp += (s, e) =>
                {
                    form._speed_down_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_speed_down.MouseLeave += (s, e) =>
                {
                    form._speed_down_Timer.Stop();
                };



                controlRow.Controls.Add(bt_speed_down);

                bt_speed_normal.Size = new Size(36, 36);
                bt_speed_normal.Image = Resources.bt_play; ;
                bt_speed_normal.ImageAlign = ContentAlignment.MiddleCenter;
                bt_speed_normal.Click += (s, e) => form.Speed_change(1.1);

                controlRow.Controls.Add(bt_speed_normal);



                bt_speed_up.Size = new Size(36, 36);


                bt_speed_up.Image = Resources.bt_next;


                bt_speed_up.ImageAlign = ContentAlignment.MiddleCenter;
                bt_speed_up.Click += (s, e) => form.SpeedUp();
                form._speed_up_Timer = new System.Windows.Forms.Timer();
                form._speed_up_Timer.Interval = 200; // 200msごとにSeek
                form._speed_up_Timer.Tick += (s, e) => form.SpeedUp();

                // 押した瞬間
                bt_speed_up.MouseDown += (s, e) =>
                {
                    form.SpeedUp();    // まず1回実行
                    form._speed_up_Timer.Start();
                };

                // 離したら停止
                bt_speed_up.MouseUp += (s, e) =>
                {
                    form._speed_up_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_speed_up.MouseLeave += (s, e) =>
                {
                    form._speed_up_Timer.Stop();
                };

                controlRow.Controls.Add(bt_speed_up);
            }
            Button bt_flame_back_step = new Button();
            Button bt_flame_step = new Button();
            if (config_class.config_bool_read("コマ送りボタンを有効") == true)
            {

                bt_flame_back_step.Size = new Size(36, 36);


                bt_flame_back_step.Image = Resources.bt_prev;


                bt_flame_back_step.ImageAlign = ContentAlignment.MiddleCenter;
                form._flame_back_step_Timer = new System.Windows.Forms.Timer();
                form._flame_back_step_Timer.Interval = 80; // 200msごとにSeek
                form._flame_back_step_Timer.Tick += (s, e) => form.FrameBackStep();

                // 押した瞬間
                bt_flame_back_step.MouseDown += (s, e) =>
                {
                    form.FrameBackStep();    // まず1回実行
                    form._flame_back_step_Timer.Start();
                };

                // 離したら停止
                bt_flame_back_step.MouseUp += (s, e) =>
                {
                    form._flame_back_step_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_flame_back_step.MouseLeave += (s, e) =>
                {
                    form._flame_back_step_Timer.Stop();
                };

                controlRow.Controls.Add(bt_flame_back_step);


                bt_flame_step.Size = new Size(36, 36);


                bt_flame_step.Image = Resources.bt_next;

                bt_flame_step.ImageAlign = ContentAlignment.MiddleCenter;
                form._flame_step_Timer = new System.Windows.Forms.Timer();
                form._flame_step_Timer.Interval = 80; // 200msごとにSeek
                form._flame_step_Timer.Tick += (s, e) => form.FrameStep();

                // 押した瞬間
                bt_flame_step.MouseDown += (s, e) =>
                {
                    form.FrameStep();    // まず1回実行
                    form._flame_step_Timer.Start();
                };

                // 離したら停止
                bt_flame_step.MouseUp += (s, e) =>
                {
                    form._flame_step_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_flame_step.MouseLeave += (s, e) =>
                {
                    form._flame_step_Timer.Stop();
                };

                controlRow.Controls.Add(bt_flame_step);
            }

            Button bt_cap_back = new Button();
            Button bt_cap_next = new Button();

            if (config_class.config_bool_read("チャプター移動ボタンを有効") == true)
            {

                bt_cap_back.Size = new Size(36, 36);


                bt_cap_back.Image = Resources.bt_prev;


                bt_cap_back.ImageAlign = ContentAlignment.MiddleCenter;
                form._cap_back_Timer = new System.Windows.Forms.Timer();
                form._cap_back_Timer.Interval = 80; // 
                form._cap_back_Timer.Tick += (s, e) => form.bt_cap_prev();

                // 押した瞬間
                bt_cap_back.MouseDown += (s, e) =>
                {
                    form.bt_cap_prev();    // まず1回実行
                    form._cap_back_Timer.Start();
                };

                // 離したら停止
                bt_cap_back.MouseUp += (s, e) =>
                {
                    form._cap_back_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_cap_back.MouseLeave += (s, e) =>
                {
                    form._cap_back_Timer.Stop();
                };

                controlRow.Controls.Add(bt_cap_back);


                bt_cap_next.Size = new Size(36, 36);


                bt_cap_next.Image = Resources.bt_next;

                bt_cap_next.ImageAlign = ContentAlignment.MiddleCenter;
                form._cap_next_Timer = new System.Windows.Forms.Timer();
                form._cap_next_Timer.Interval = 80; // 
                form._cap_next_Timer.Tick += (s, e) => form.bt_cap_next();

                // 押した瞬間
                bt_cap_next.MouseDown += (s, e) =>
                {
                    form.bt_cap_next();    // まず1回実行
                    form._cap_next_Timer.Start();
                };

                // 離したら停止
                bt_cap_next.MouseUp += (s, e) =>
                {
                    form._cap_next_Timer.Stop();
                };

                // ボタン外に出ても止める
                bt_cap_next.MouseLeave += (s, e) =>
                {
                    form._cap_next_Timer.Stop();
                };

                controlRow.Controls.Add(bt_cap_next);
            }

            Button bt_record = new Button();
            if (config_class.config_bool_read("録画ボタンを有効") == true)
            {

                bt_record.Size = new Size(36, 36);


                bt_record.Image = Resources.bt_ss;

                bt_record.ImageAlign = ContentAlignment.MiddleCenter;
                bt_record.Click += (s, e) => form.record_url();

                controlRow.Controls.Add(bt_record);
            }
            Button bt_ab_loop_a = new Button();
            Button bt_ab_loop_b = new Button();
            Button bt_ab_loop_start = new Button();
            if (config_class.config_bool_read("ABループボタンを有効") == true)
            {

                bt_ab_loop_a.Size = new Size(36, 36);


                bt_ab_loop_a.Text = "A";




                bt_ab_loop_a.Click += (s, e) => form.a_marker_creat();

                controlRow.Controls.Add(bt_ab_loop_a);

                bt_ab_loop_b.Size = new Size(36, 36);


                bt_ab_loop_b.Text = "B";




                bt_ab_loop_b.Click += (s, e) => form.b_marker_creat();

                controlRow.Controls.Add(bt_ab_loop_b);


                bt_ab_loop_start.Size = new Size(36, 36);


                bt_ab_loop_start.Text = "LP";




                bt_ab_loop_start.Click += (s, e) => form.ab_loop_start();

                controlRow.Controls.Add(bt_ab_loop_start);
            }




            form.volume_Slider = new TrackBar();
            if (config_class.config_bool_read("ボリュームスライダーを有効") == true)
            {

                form.volume_Slider.Width = 100;
                form.volume_Slider.Maximum = 100;
                form.volume_Slider.Minimum = 0;
                form.volume_Slider.Value = 100;
                form.volume_Slider.AutoSize = false;

                form.volume_Slider.MouseWheel += (s, e) =>
                {
                    ((HandledMouseEventArgs)e).Handled = true;
                };

                form.volume_Slider.Height = 20;
                form.volume_Slider.TickStyle = TickStyle.None;

                controlRow.Controls.Add(form.volume_Slider);


                form.volume_label = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 10) };

                form.volume_label.Text = "100";

                controlRow.Controls.Add(form.volume_label);
            }
            form.Speed_Slider = new TrackBar();
            if (config_class.config_bool_read("スピードスライダーを有効") == true)
            {


                form.Speed_Slider.Width = 100;
                form.Speed_Slider.Maximum = 30;
                form.Speed_Slider.Minimum = 1;
                form.Speed_Slider.Value = 10;
                form.Speed_Slider.MouseWheel += (s, e) =>
                {
                    ((HandledMouseEventArgs)e).Handled = true;
                };
                form.Speed_Slider.AutoSize = false;

                form.Speed_Slider.Height = 20;

                controlRow.Controls.Add(form.Speed_Slider);

                form.speed_label = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 10) };

                form.speed_label.Text = "1.0";

                controlRow.Controls.Add(form.speed_label);
            }

            form.lbl_category = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12) };



            controlRow.Controls.Add(form.lbl_category);

            //form.loadingGif = new PictureBox();

            //form.loadingGif.Image = Properties.Resources.loading;
            //form.loadingGif.Visible = false;  // 非表示
            // controlRow.Controls.Add(form.loadingGif);

            form.BottomControlPanel.MouseMove += form.PlayerPanel_MouseMove;

            form.BottomControlPanel.Controls.Add(controlRow);

            FlowLayoutPanel descPanel = new FlowLayoutPanel();
            descPanel.Dock = DockStyle.Top;
            descPanel.Height = 20;
            descPanel.FlowDirection = FlowDirection.LeftToRight;
            descPanel.WrapContents = false;
            form.lbl_desc = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 9) };

            descPanel.Controls.Add(form.lbl_desc);
            form.BottomControlPanel.Controls.Add(descPanel);

            FlowLayoutPanel titlePanel = new FlowLayoutPanel();
            titlePanel.Dock = DockStyle.Top;
            titlePanel.Height = 25;
            titlePanel.FlowDirection = FlowDirection.LeftToRight;
            titlePanel.WrapContents = false;

            form.lblFilesize = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12) };
            form.lblResolution = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12) };
            form.lbl_title = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12) };


            titlePanel.Controls.Add(form.lblFilesize);
            titlePanel.Controls.Add(form.lblResolution);
            titlePanel.Controls.Add(form.lbl_title);

            form.BottomControlPanel.Controls.Add(titlePanel);



            Panel ListPanel = new Panel();
            ListPanel.Dock = DockStyle.Top;
            ListPanel.Height = 30;

            form.ListSlider = new TrackBar();

            form.ListSlider.AutoSize = false;

            form.ListSlider.MouseWheel += (s, e) =>
            {
                ((HandledMouseEventArgs)e).Handled = true;
            };

            // Dock を使わなr,

            // 代わりに位置とサイズを指定
            form.ListSlider.Left = 10;
            form.ListSlider.Top = 5;
            form.ListSlider.Width = (int)(form.ClientSize.Width * 0.7);

            form.ListSlider.TickStyle = TickStyle.None;

            form.ListSlider.MouseDown += form.ListSlider_MouseDown;
            form.ListSlider.MouseUp += form.ListSlider_MouseUp;
            form.ListSlider.MouseMove += form.ListSlider_MouseMove;
            ListPanel.Controls.Add(form.ListSlider);

            form.lbl_list_name = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12, FontStyle.Regular) };
            form.lbl_list_name.Left = form.ListSlider.Right + 10;
            form.lbl_list_name.Top = 5;


            form.lbl_Listsize = new Label() { AutoSize = true, Font = new Font("Yu Gothic UI", 12, FontStyle.Regular) };
            form.lbl_Listsize.Left = form.ListSlider.Right + 80;
            form.lbl_Listsize.Top = 5;
            ListPanel.Controls.Add(form.lbl_Listsize);

            ListPanel.Controls.Add(form.lbl_list_name);


            form.BottomControlPanel.Controls.Add(ListPanel);



            Panel posPanel = new Panel();
            posPanel.Dock = DockStyle.Top;
            posPanel.Height = 25;


            form.PositionSlider = new TrackBar();
            form.PositionSlider.AutoSize = false;
            form.PositionSlider.Height = 20;
            form.PositionSlider.MouseWheel += (s, e) =>
            form.PositionSlider.MouseWheel += (s, e) =>
            {
                ((HandledMouseEventArgs)e).Handled = true;
            };

            // 代わりに位置とサイズを指定
            form.PositionSlider.Left = 10;
            form.PositionSlider.Top = 5;

            form.PositionSlider.Width = (int)(form.ClientSize.Width * 0.7);

            form.PositionSlider.MouseDown += form.PositionSlider_MouseDown;
            form.PositionSlider.MouseUp += form.PositionSlider_MouseUp;
            form.PositionSlider.MouseMove += form.PositionSlider_MouseMove;

            form.PositionSlider.TickStyle = TickStyle.None;






            posPanel.Controls.Add(form.PositionSlider);
            form.lblTime = new Label()
            {
                Text = "00:00:00 / 00:00:00",
                AutoSize = true,
                Font = new Font("Yu Gothic UI", 12, FontStyle.Regular)
            };
            form.lblTime.Left = form.PositionSlider.Right + 10;
            form.lblTime.Top = 5;
            posPanel.Controls.Add(form.lblTime);


            form.BottomControlPanel.Controls.Add(posPanel);


            form._mainLayout.Controls.Add(form.BottomControlPanel, 0, 2);

            form.Controls.Add(form._mainLayout);
            form.BackColor = Color.Black;
            form._mainLayout.BackColor = Color.Black;

            if (config_class.config_bool_read("tooltipsを有効") == true)
            {
                ToolTip toolTip1 = new ToolTip();

                toolTip1.SetToolTip(form.ListSlider, "動画リスト切り替え");
                toolTip1.SetToolTip(form.PositionSlider, "シークスライダー");
                toolTip1.SetToolTip(form.volume_Slider, "音量調整");
                toolTip1.SetToolTip(bt_play, "再起動");
                toolTip1.SetToolTip(bt_reload, "リロード");
                toolTip1.SetToolTip(bt_NextSeek, "前へシーク");
                toolTip1.SetToolTip(bt_PrevSeek, "後ろへシーク");
                toolTip1.SetToolTip(bt_next, "次の動画");
                toolTip1.SetToolTip(bt_prev, "前の動画");
                toolTip1.SetToolTip(bt_ss, "スクリーンショット");
                toolTip1.SetToolTip(bt_mute, "ミュート");
                toolTip1.SetToolTip(bt_full, "フルスクリーン");
                toolTip1.SetToolTip(bt_stop, "停止");
                toolTip1.SetToolTip(bt_open, "動画を開く");
                toolTip1.SetToolTip(bt_Pause, "ポーズ");
                toolTip1.SetToolTip(bt_speed_down, "スピードダウン");
                toolTip1.SetToolTip(bt_speed_up, "スピードアップ");
                toolTip1.SetToolTip(bt_speed_normal, "スピードノーマル化");
                toolTip1.SetToolTip(form.Speed_Slider, "スピードスライダー");
                toolTip1.SetToolTip(bt_flame_step, "コマ送り");
                toolTip1.SetToolTip(bt_flame_back_step, "コマ戻り");
                toolTip1.SetToolTip(bt_cap_next, "次のチャプター");
                toolTip1.SetToolTip(bt_cap_back, "前のチャプター");
                toolTip1.SetToolTip(bt_record, "録画");
                toolTip1.SetToolTip(bt_ab_loop_a, "ABループのA設定");
                toolTip1.SetToolTip(bt_ab_loop_b, "ABループのB設定");
                toolTip1.SetToolTip(bt_ab_loop_start, "ABループの開始");
            }


            if (config_class.config_int_read("起動時のウインドウサイズ") == 3)
            {
                form.ToggleFullScreen();
            }
        }
    }
}