public void AddMap(object dataContext) { var mapViewModel = ((MapAddViewModel)dataContext); m_Repository.Maps.Add(mapViewModel.Model); NotifyOfPropertyChange(() => Maps); CloseEditor(); Save(); SelectedMap = m_Maps.LastOrDefault(); }
/// <summary> /// Удалить выбранный адрес /// </summary> public void RemoveAddress() { if (CanRemoveAddress is false) { return; } for (var i = 0; i < SelectedAddresses.Count; i++) { FullyAddressInfoDeleting(SelectedAddresses[i]); } Addresses = new BindableCollection <AddressInfo>(CurrentEpisode.AddressInfoList); SelectedAddressInfo = Addresses.LastOrDefault(); }
/// <summary> /// Удалить выбранные сезоны /// </summary> public void DeleteSelectedSeasons() { if (CanDeleteSelectedSeasons is false) { return; } for (var i = 0; i < SelectedSeasons.Count; i++) { FullySeasonDeleting(SelectedSeasons[i]); } Seasons = new BindableCollection <Season>(CurrentFilm.Seasons); SelectedSeason = Seasons.LastOrDefault(); }
/// <summary> /// Удалить выбранный эпизод /// </summary> public void DeleteSelectedEpisodes() { if (CanDeleteSelectedEpisodes is false) { return; } for (var i = 0; i < SelectedEpisodes.Count; i++) { FullyEpisodeDeleting(SelectedEpisodes[i]); } Episodes = new BindableCollection <Episode>(CurrentSeason.Episodes); SelectedEpisode = Episodes.LastOrDefault(); }
/// <summary> /// Добавить эпизоды /// </summary> public void AddEpisodes() { var number = Episodes.Count; var lastNumber = Episodes.LastOrDefault()?.Number ?? 0; var episodes = new List <Episode>(); var name = $"{TranslateFileName(ESVM.SelectedFilm.Name)}_S{CurrentSeason.Number}_E"; for (var i = 0; i < AddingEpisodeValue; i++) { if (number > 0 && number != lastNumber) { for (var j = 1; j <= lastNumber; j++) { if (Episodes.Any(e => e.Number == j) || episodes.Any(e => e.Number == j)) { continue; } episodes.Add(new Episode { Name = name + j, Number = j, Season = CurrentSeason, Film = ESVM.SelectedFilm }); lastNumber++; break; } continue; } episodes.Add(new Episode { Name = name + ++number, Number = number, Season = CurrentSeason, Film = ESVM.SelectedFilm, }); lastNumber++; } InsertEntityListToDb(episodes); Episodes = new BindableCollection <Episode>(CurrentSeason.Episodes); SelectedEpisode = Episodes.LastOrDefault(); }
private void GroupLaps() { if (isUpdating) { return; } foreach (var group in groups) { group.Clear(); } var groupings = laps.GroupByPresented(); TimeSpan?previousTime = null; for (var i = 0; i < groupings.Count; i++) { var grouping = groupings[i]; var group = GetOrAddGroup(i); if (grouping.Key != null) { grouping.Key.PreviousTime = previousTime; group.Presented = grouping.Key; } foreach (var notPresented in grouping) { notPresented.PreviousTime = previousTime; group.NotPresented.Add(notPresented); } if (grouping.Key != null) { previousTime = grouping.Key.Time; } } TrimGroups(); groups.Refresh(); LastPresented = groups.LastOrDefault(g => g.Presented != null); }
/// <summary> /// Добавить джампер /// </summary> public void AddJumper() { var startTime = Jumpers.Count == 0 ? new TimeSpan() : Jumpers.Last().EndTime + new TimeSpan(1000); var jumper = new Jumper { JumperMode = JumperModes.First(), Number = Jumpers.Count + 1, StartTime = startTime, EndTime = startTime + new TimeSpan(1000), Film = EEVM.ESVM.SelectedFilm, Season = EEVM.ESVM.SelectedSeason, Episode = EEVM.CurrentEpisode, AddressInfo = EEVM.SelectedAddressInfo }; InsertEntityToDb(jumper); Jumpers = new BindableCollection <Jumper>(CurrentAddressInfo.Jumpers); SelectedJumper = Jumpers.LastOrDefault(); }
public void LoadNextSlice() { if (!string.IsNullOrEmpty(Text)) { return; } if (!_secondSliceLoaded) { return; } var maxSliceCount = int.MaxValue; var index = 0; var lastRow = Rows.LastOrDefault(); if (lastRow != null) { var lastDialogItem = lastRow.GetLast(); if (lastDialogItem != null) { index = DialogsSource.IndexOf(lastDialogItem); } } var currentRow = lastRow; if (currentRow != null && currentRow.HasEmptyItem()) { for (index = index + 1; index < DialogsSource.Count; index++) { if (!currentRow.HasEmptyItem()) { break; } var d = DialogsSource[index]; d.Row = currentRow; currentRow.Add(d, true); } } else { index++; } _lastSlice = new List <DialogRow>(); for (var count = 0; index < DialogsSource.Count && count < maxSliceCount; index++, count++) { if (currentRow == null || !currentRow.HasEmptyItem()) { currentRow = new DialogRow(); _lastSlice.Add(currentRow); } var d = DialogsSource[index]; d.Row = currentRow; currentRow.Add(d); } if (_lastSlice.Count > 0 && Rows.Count < 10) { for (var i = 0; i < 10 - Rows.Count; i++) { var row = _lastSlice.FirstOrDefault(); if (row != null) { _lastSlice.RemoveAt(0); Rows.Add(row); } else { return; } } } }