Esempio n. 1
0
        public MirakurunChannel(Ch2 ch)
        {
            this.Name      = ch.Name;
            this.Type      = ch.Type;
            this.Channel   = ch.Channel.ToString();
            this.ServiceID = ch.ServiceID;
            this.Space     = ch.TuningSpace;
            if (!ch.Enabled)
            {
                this.IsDisabled = true;
            }
            switch (this.Type)
            {
            case CHType.BS:
            case CHType.SKY:
                this.Satelite = "0";
                break;

            case CHType.CS:
                this.Satelite = "1";
                break;

            default:
                this.Satelite = null;
                break;
            }
        }
Esempio n. 2
0
        private void Open()
        {
            var mdlg = new OpenFileDialog();

            mdlg.CheckFileExists = true;
            mdlg.Multiselect     = false;
            mdlg.Filter          = "Tvtest channel file(*.ch2)|*.ch2|All file(*.*)|*.*";
            if (mdlg.ShowDialog() == true)
            {
                foreach (var item in Ch2.ReadChe2File(mdlg.FileName))
                {
                    switch (item.Type)
                    {
                    case CHType.GR:
                        if (!GRList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            GRList.Add(new ChannelViewModel(item));
                        }
                        break;

                    case CHType.BS:
                        if (!BSList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            BSList.Add(new ChannelViewModel(item));
                        }
                        break;

                    case CHType.CS:
                        if (!CSList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            CSList.Add(new ChannelViewModel(item));
                        }
                        break;

                    default:
                        if (!SKList.Any(x => x.ServiceID == item.ServiceID))
                        {
                            SKList.Add(new ChannelViewModel(item));
                        }
                        break;
                    }
                }
                GRList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                BSList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                CSList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                SKList.Sort((x, y) => x.Channel == y.Channel ? x.ServiceID.CompareTo(y.ServiceID) : x.Channel.CompareTo(y.Channel));
                ChannelList  = new ObservableCollection <ChannelViewModel>(GRList.Concat(BSList).Concat(CSList).Concat(SKList));
                this.isSaved = false;
                this.NotifyPropertyChanged(nameof(this.Caption));
            }
            else
            {
                return;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Read a *.Ch2 file.
        /// </summary>
        /// <param name="fullPath"></param>
        /// <returns></returns>
        public static IEnumerable <Ch2> ReadChe2File(string fullPath)
        {
            if (!System.IO.File.Exists(fullPath))
            {
                yield break;
            }
            using (var reader = new System.IO.StreamReader(fullPath, Encoding.GetEncoding("Shift-JIS")))
            {
                string line;
                CHType mType = CHType.BS;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith(";"))
                    {
                        if (line.Contains(";#SPACE"))
                        {
                            switch (line)
                            {
                            case string x when x.Contains("BS"):
                                mType = CHType.BS;

                                break;

                            case string x when x.Contains("CS"):
                                mType = CHType.CS;

                                break;

                            case string x when x.Contains("UHF"):
                                mType = CHType.GR;

                                break;

                            default:
                                mType = CHType.SKY;
                                break;
                            }
                        }
                    }
                    else
                    {
                        var tmp  = line.Split(',');
                        var item = new Ch2();
                        item.Name = tmp[0];
                        item.Type = mType;
                        if (byte.TryParse(tmp[1], out var valTuningSpace))
                        {
                            item.TuningSpace = valTuningSpace;
                        }
                        if (byte.TryParse(tmp[2], out var valChannel))
                        {
                            item.Channel = valChannel;
                        }
                        if (ushort.TryParse(tmp[3], out var valRemoteNumber))
                        {
                            item.RemoteNumber = valRemoteNumber;
                        }
                        if (int.TryParse(tmp[4], out var valServiceType))
                        {
                            item.ServiceType = valServiceType;
                        }
                        if (ushort.TryParse(tmp[5], out var valServiceID))
                        {
                            item.ServiceID = valServiceID;
                        }
                        if (byte.TryParse(tmp[6], out var valNetworkID))
                        {
                            item.NetworkID = valNetworkID;
                        }
                        if (short.TryParse(tmp[7], out var valTSID))
                        {
                            item.TSID = valTSID;
                        }
                        if (int.TryParse(tmp[8], out var valStatus))
                        {
                            item.Status = valStatus != 0;
                        }
                        yield return(item);
                    }
                }
            }
        }