public override void PropsToCsv()
 {
     TableProps.Clear();
     TableProps.Add(nameof(_model.SegmentSize), _model.SegmentSize.ToString());
     TableProps.Add(nameof(_model.CompareSegmentSize), _model.CompareSegmentSize.ToString());
     TableProps.Add(nameof(_model.SimilarityLimit), _model.SimilarityLimit.ToString());
     TableProps.Add(nameof(_model.SimilarityLimitMin), _model.SimilarityLimitMin.ToString());
     TableProps.Add(nameof(_model.SegmentsDrawer), string.Join(",", _model.SegmentsDrawer.Select(x => x.Id)));
 }
        public override void LinkReferences()
        {
            var withoutMediaItem = new List <SegmentM>();

            foreach (var segment in _model.All)
            {
                if (_mediaItemsM.AllDic.TryGetValue(int.Parse(segment.Csv[1]), out var mi))
                {
                    segment.MediaItem = mi;
                    mi.Segments ??= new();
                    mi.Segments.Add(segment);

                    if (segment.PersonId > 0 && _peopleM.AllDic.TryGetValue(segment.PersonId, out var person))
                    {
                        segment.Person = person;
                        person.Segment ??= segment;
                    }
                }
                else
                {
                    withoutMediaItem.Add(segment);
                }

                // reference to Keywords
                if (!string.IsNullOrEmpty(segment.Csv[4]))
                {
                    var ids = segment.Csv[4].Split(',');
                    segment.Keywords = new(ids.Length);
                    foreach (var keywordId in ids)
                    {
                        var k = _keywordsM.AllDic[int.Parse(keywordId)];
                        segment.Keywords.Add(k);
                    }
                }

                // CSV array is not needed any more
                segment.Csv = null;
            }

            // in case MediaItem was deleted
            foreach (var segment in withoutMediaItem)
            {
                _ = _model.All.Remove(segment);
            }

            // Table Properties
            if (TableProps == null)
            {
                return;
            }
            if (TableProps.TryGetValue(nameof(_model.SegmentSize), out var segmentSize))
            {
                _model.SegmentSize = int.Parse(segmentSize);
            }
            if (TableProps.TryGetValue(nameof(_model.CompareSegmentSize), out var compareSegmentSize))
            {
                _model.CompareSegmentSize = int.Parse(compareSegmentSize);
            }
            if (TableProps.TryGetValue(nameof(_model.SimilarityLimit), out var similarityLimit))
            {
                _model.SimilarityLimit = int.Parse(similarityLimit);
            }
            if (TableProps.TryGetValue(nameof(_model.SimilarityLimitMin), out var similarityLimitMin))
            {
                _model.SimilarityLimitMin = int.Parse(similarityLimitMin);
            }
            if (TableProps.TryGetValue(nameof(_model.SegmentsDrawer), out var segmentsDrawer) && !string.IsNullOrEmpty(segmentsDrawer))
            {
                foreach (var segmentId in segmentsDrawer.Split(','))
                {
                    _model.SegmentsDrawer.Add(_model.AllDic[int.Parse(segmentId)]);
                }
            }

            // table props are not needed any more
            TableProps.Clear();
        }