Exemple #1
0
        public SetBasicView()
        {
            InitializeComponent();

            IsChangeSettingPath = false;

            listBox_Button_Set();

            try
            {
                // tabItem1 - 保存フォルダ
                // 保存できない項目は IsEnabled = false にする
                if (CommonManager.Instance.NWMode == true)
                {
                    group_setPath.IsEnabled       = false; // 設定関係保存フォルダ
                    group_exePath.IsEnabled       = false; // 録画用アプリのexe
                    group_recInfoFolder.IsEnabled = false; // 録画情報保存フォルダ
                    label4.IsEnabled             = false;  //※ 録画中やEPG取得中に設定を変更すると正常動作しなくなる可能性があります。
                    button_shortCutSrv.IsEnabled = false;
                }
                group_recFolder.IsEnabled = IniFileHandler.CanUpdateInifile; // 録画保存フォルダ

                // 読める設定のみ項目に反映させる
                if (IniFileHandler.CanReadInifile)
                {
                    textBox_setPath.Text = SettingPath.SettingFolderPath;
                    textBox_exe.Text     = SettingPath.EdcbExePath;

                    textBox_recInfoFolder.Text = IniFileHandler.GetPrivateProfileString("SET", "RecInfoFolder", "", SettingPath.CommonIniPath);

                    Settings.Instance.DefRecFolders.ForEach(folder => listBox_recFolder.Items.Add(new UserCtrlView.BGBarListBoxItem(folder)));
                }
                if (CommonManager.Instance.NWMode == false)
                {
                    string viewAppIniPath = SettingPath.ModulePath.TrimEnd('\\') + "\\ViewApp.ini";
                    textBox_cmdBon.Text     = IniFileHandler.GetPrivateProfileString("APP_CMD_OPT", "Bon", "-d", viewAppIniPath);
                    textBox_cmdMin.Text     = IniFileHandler.GetPrivateProfileString("APP_CMD_OPT", "Min", "-min", viewAppIniPath);
                    textBox_cmdViewOff.Text = IniFileHandler.GetPrivateProfileString("APP_CMD_OPT", "ViewOff", "-noview", viewAppIniPath);
                }

                // tabItem2 - チューナー
                // 保存できない項目は IsEnabled = false にする
                if (IniFileHandler.CanUpdateInifile == false)
                {
                    ViewUtil.DisableControlChildren(tabItem2);
                    grid_tuner.IsEnabled = true;
                    ViewUtil.ChangeChildren(grid_tuner, false);
                }
                listBox_bon.IsEnabled = IniFileHandler.CanUpdateInifile;

                // 読める設定のみ項目に反映させる
                if (IniFileHandler.CanReadInifile)
                {
                    SortedList <Int32, TunerInfo> tunerInfo = new SortedList <Int32, TunerInfo>();
                    foreach (string fileName in CommonManager.Instance.GetBonFileList())
                    {
                        try
                        {
                            TunerInfo item = new TunerInfo(fileName);
                            item.TunerNum = IniFileHandler.GetPrivateProfileInt(item.BonDriver, "Count", 0, SettingPath.TimerSrvIniPath).ToString();
                            item.IsEpgCap = (IniFileHandler.GetPrivateProfileInt(item.BonDriver, "GetEpg", 1, SettingPath.TimerSrvIniPath) != 0);
                            item.EPGNum   = IniFileHandler.GetPrivateProfileInt(item.BonDriver, "EPGCount", 0, SettingPath.TimerSrvIniPath).ToString();
                            int priority = IniFileHandler.GetPrivateProfileInt(item.BonDriver, "Priority", 0xFFFF, SettingPath.TimerSrvIniPath);
                            while (true)
                            {
                                if (tunerInfo.ContainsKey(priority) == true)
                                {
                                    priority++;
                                }
                                else
                                {
                                    tunerInfo.Add(priority, item);
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
                        }
                    }
                    foreach (TunerInfo info in tunerInfo.Values)
                    {
                        listBox_bon.Items.Add(info);
                    }
                    if (listBox_bon.Items.Count > 0)
                    {
                        listBox_bon.SelectedIndex = 0;
                    }
                }
                button_shortCut.Content = SettingPath.ModuleName + ".exe" + (File.Exists(
                                                                                 System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), SettingPath.ModuleName + ".lnk")) ? "を解除" : "");
                button_shortCutSrv.Content = (string)button_shortCutSrv.Content + (File.Exists(
                                                                                       System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EpgTimerSrv.lnk")) ? "を解除" : "");

                // tabItem3 - EPG取得
                // 保存できない項目は IsEnabled = false にする
                if (IniFileHandler.CanUpdateInifile == false)
                {
                    ViewUtil.DisableControlChildren(tabItem3);
                }
                listView_service.IsEnabled = IniFileHandler.CanUpdateInifile;

                // 読める設定のみ項目に反映させる
                serviceList = new List <ServiceViewItem>();
                if (IniFileHandler.CanReadInifile)
                {
                    comboBox_HH.DataContext   = CommonManager.Instance.HourDictionary.Values;
                    comboBox_HH.SelectedIndex = 0;
                    comboBox_MM.DataContext   = CommonManager.Instance.MinDictionary.Values;
                    comboBox_MM.SelectedIndex = 0;

                    try
                    {
                        foreach (ChSet5Item info in ChSet5.ChList.Values)
                        {
                            ServiceViewItem item = new ServiceViewItem(info);
                            if (info.EpgCapFlag == 1)
                            {
                                item.IsSelected = true;
                            }
                            else
                            {
                                item.IsSelected = false;
                            }
                            serviceList.Add(item);
                        }
                    }
                    catch
                    {
                    }
                    listView_service.DataContext = serviceList;

                    if (IniFileHandler.GetPrivateProfileInt("SET", "BSBasicOnly", 1, SettingPath.CommonIniPath) == 1)
                    {
                        checkBox_bs.IsChecked = true;
                    }
                    else
                    {
                        checkBox_bs.IsChecked = false;
                    }
                    if (IniFileHandler.GetPrivateProfileInt("SET", "CS1BasicOnly", 1, SettingPath.CommonIniPath) == 1)
                    {
                        checkBox_cs1.IsChecked = true;
                    }
                    else
                    {
                        checkBox_cs1.IsChecked = false;
                    }
                    if (IniFileHandler.GetPrivateProfileInt("SET", "CS2BasicOnly", 1, SettingPath.CommonIniPath) == 1)
                    {
                        checkBox_cs2.IsChecked = true;
                    }
                    else
                    {
                        checkBox_cs2.IsChecked = false;
                    }
                    if (IniFileHandler.GetPrivateProfileInt("SET", "CS3BasicOnly", 0, SettingPath.CommonIniPath) == 1)
                    {
                        checkBox_cs3.IsChecked = true;
                    }
                    else
                    {
                        checkBox_cs3.IsChecked = false;
                    }

                    int capCount = IniFileHandler.GetPrivateProfileInt("EPG_CAP", "Count", 0, SettingPath.TimerSrvIniPath);
                    if (capCount == 0)
                    {
                        EpgCaptime item = new EpgCaptime();
                        item.IsSelected   = true;
                        item.Time         = "23:00";
                        item.BSBasicOnly  = checkBox_bs.IsChecked == true;
                        item.CS1BasicOnly = checkBox_cs1.IsChecked == true;
                        item.CS2BasicOnly = checkBox_cs2.IsChecked == true;
                        item.CS3BasicOnly = checkBox_cs3.IsChecked == true;
                        timeList.Add(item);
                    }
                    else
                    {
                        for (int i = 0; i < capCount; i++)
                        {
                            EpgCaptime item = new EpgCaptime();
                            item.Time = IniFileHandler.GetPrivateProfileString("EPG_CAP", i.ToString(), "", SettingPath.TimerSrvIniPath);
                            if (IniFileHandler.GetPrivateProfileInt("EPG_CAP", i.ToString() + "Select", 0, SettingPath.TimerSrvIniPath) == 1)
                            {
                                item.IsSelected = true;
                            }
                            else
                            {
                                item.IsSelected = false;
                            }
                            // 取得種別(bit0(LSB)=BS,bit1=CS1,bit2=CS2,bit3=CS3)。負値のときは共通設定に従う
                            int flags = IniFileHandler.GetPrivateProfileInt("EPG_CAP", i.ToString() + "BasicOnlyFlags", -1, SettingPath.TimerSrvIniPath);
                            if (flags >= 0)
                            {
                                item.BSBasicOnly  = (flags & 1) != 0;
                                item.CS1BasicOnly = (flags & 2) != 0;
                                item.CS2BasicOnly = (flags & 4) != 0;
                                item.CS3BasicOnly = (flags & 8) != 0;
                            }
                            else
                            {
                                item.BSBasicOnly  = checkBox_bs.IsChecked == true;
                                item.CS1BasicOnly = checkBox_cs1.IsChecked == true;
                                item.CS2BasicOnly = checkBox_cs2.IsChecked == true;
                                item.CS3BasicOnly = checkBox_cs3.IsChecked == true;
                            }
                            timeList.Add(item);
                        }
                    }
                    ListView_time.DataContext = timeList;

                    textBox_ngCapMin.Text   = IniFileHandler.GetPrivateProfileInt("SET", "NGEpgCapTime", 20, SettingPath.TimerSrvIniPath).ToString();
                    textBox_ngTunerMin.Text = IniFileHandler.GetPrivateProfileInt("SET", "NGEpgCapTunerTime", 20, SettingPath.TimerSrvIniPath).ToString();
                }

                SetBasicView_tabItem4();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }