public static string ToCsv(VideoClipM vc) =>
 string.Join("|",
             vc.Id.ToString(),
             vc.MediaItem.Id.ToString(),
             vc.TimeStart.ToString(),
             vc.TimeEnd.ToString(),
             vc.Name ?? string.Empty,
             ((int)(vc.Volume * 100)).ToString(),
             ((int)(vc.Speed * 10)).ToString(),
             vc.Rating == 0
   ? string.Empty
   : vc.Rating.ToString(),
             vc.Comment ?? string.Empty,
             vc.People == null
   ? string.Empty
   : string.Join(",", vc.People.Select(x => x.Id)),
             vc.Keywords == null
   ? string.Empty
   : string.Join(",", vc.Keywords.Select(x => x.Id)));
        public override void FromCsv(string csv)
        {
            var props = csv.Split('|');

            if (props.Length != 11)
            {
                throw new ArgumentException("Incorrect number of values.", csv);
            }
            var vc = new VideoClipM(int.Parse(props[0]), null)
            {
                TimeStart = props[2].IntParseOrDefault(0),
                TimeEnd   = props[3].IntParseOrDefault(0),
                Name      = string.IsNullOrEmpty(props[4]) ? null : props[4],
                Csv       = props,
                Volume    = props[5].IntParseOrDefault(50) / 100.0,
                Speed     = props[6].IntParseOrDefault(10) / 10.0,
                Rating    = props[7].IntParseOrDefault(0),
                Comment   = string.IsNullOrEmpty(props[8]) ? null : props[8]
            };

            _model.All.Add(vc);
            _model.AllDic.Add(vc.Id, vc);
        }
Ejemplo n.º 3
0
 public VideoClipDeletedEventArgs(VideoClipM videoClip)
 {
     VideoClip = videoClip;
 }