public void RemoveItemDetail(ItemDetailViewModel detail) { if (detail == null) { throw new ArgumentNullException(nameof(detail)); } bool updateCurrentChanged = false; if (_currentItemDetails.IndexOf(detail) == _currentItemDetails.Count - 1) { updateCurrentChanged = true; } _currentItemDetails.Remove(detail); if (updateCurrentChanged) { if (_currentItemDetails.Count == 0) { CurrentItemChanged?.Invoke(this, new ItemDetailViewModelEventArgs { Item = null }); } else { ItemDetailViewModel lastItem = _currentItemDetails[_currentItemDetails.Count - 1]; CurrentItemChanged?.Invoke(this, new ItemDetailViewModelEventArgs { Item = lastItem }); } } }
public PlayingQueue(MediaPlayer player, LibraryService libraryService) { this.player = player; this.libraryService = libraryService; player.Source = null; player.AutoPlay = true; queue = new MediaPlaybackList(); items = new TrackList(queue); queue.CurrentItemChanged += (s, a) => { CurrentItemChanged?.Invoke( (Track)a.NewItem?.Source.CustomProperties["track"], (Track)a.OldItem?.Source.CustomProperties["track"]); }; queue.Items.VectorChanged += (sender, a) => { /* If the playbacklist is empty we unset the player source */ if (sender.Count > 0) { if (player.Source == null) { player.Source = queue; } } else { player.Source = null; } }; }
/// <summary> /// Déclenche l'événement <see cref="CurrentItemChanged"/> /// </summary> /// <param name="oldItem">Ancienne valeur</param> protected virtual void OnCurrentItemChanged(T oldItem) { if (CurrentItem != null && !SelectedItems.Contains(CurrentItem)) { _selectedItems.Add(CurrentItem); } if (oldItem != null && SelectedItems.Contains(oldItem)) { _selectedItems.Remove(oldItem); } CurrentItemChanged?.Invoke(this, new CurrentItemChangedEventArgs(oldItem)); if (oldItem is INotifyPropertyChanged npc) { npc.PropertyChanged -= CurrentItem_PropertyChanged; } npc = CurrentItem as INotifyPropertyChanged; if (npc != null) { npc.PropertyChanged += CurrentItem_PropertyChanged; } // TODO :Refresh commands //DetailCommand.RaiseCanExecuteChanged(); }
private void Update() { if (_closestItem != ClosestItemIndex) { CurrentItemChanged.Invoke(ClosestItemIndex); ChangePaginationInfo(ClosestItemIndex); _closestItem = ClosestItemIndex; } }
protected virtual void OnCurrentItemChanged(object sender, EventArgs e) { if (CurrentItem != null) { ((Control)((sbutton)sender).Tag).BringToFront(); } // Invoke. CurrentItemChanged?.Invoke(sender, e); }
private void Update() { if (IsScrollRectAvailable) { if (_closestItem != ClosestItemIndex) { CurrentItemChanged.Invoke(ClosestItemIndex); ChangePaginationInfo(ClosestItemIndex); _closestItem = ClosestItemIndex; } } }
private void RaiseCurrentItemChanged() { CurrentItemChanged?.Invoke(this, CurrentItem); if (dispatcher == null || dispatcher.HasThreadAccess) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentItem))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(NextItem))); } else { var _ = dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentItem))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(NextItem))); }); } }
/*private async void Items_VectorChanged(IObservableVector<MediaPlaybackItem> sender, IVectorChangedEventArgs args) * { * if (disposed) return; * await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => * { * if (disposed) return; * HandlePlaybackListChanges(sender); * }); * }*/ private void SubscribedPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args) { if (disposed) { return; } #if (DEBUG) System.Diagnostics.Debug.WriteLine("SubscribedPlaybackList_CurrentItemChanged " + args.NewItem?.ToString()); #endif CurrentItemChanged?.Invoke(sender, args); if (args.NewItem != null) { loadProperties(args.NewItem); Playing?.Invoke(this, args.NewItem); } }
public void AddItemDetails(IEnumerable <ItemDetailViewModel> details) { if (details == null) { throw new ArgumentNullException(nameof(details)); } foreach (var detail in details) { if (!_currentItemDetails.Contains(detail)) { _currentItemDetails.Add(detail); CurrentItemChanged?.Invoke(this, new ItemDetailViewModelEventArgs { Item = detail }); } } }
private void DataGrid_CurrentCellChanged(object sender, EventArgs e) { DataGrid grid = (DataGrid)sender; NetObject selectedNetObject = null; if (grid.CurrentCell.Item.GetType() == typeof(Project)) { selectedNetObject = selectedProject; } else if (grid.CurrentCell.Item.GetType() == typeof(Todo)) { selectedNetObject = selectedTodo; } else { return; } if (selectedNetObject == null || selectedNetObject.pId != ((NetObject)grid.CurrentCell.Item).pId) { NetObject netObject = (NetObject)grid.CurrentCell.Item; if (netObject.pId != Guid.Empty) { CurrentItemChanged data = new CurrentItemChanged() { PK = netObject.pId, Type = netObject.GetType().ToString() }; tornado14Observer.Send(new Package(SENDERID, 12, (int)EventMapping.CurrentItemChanged_15, Method.PUT, XmlSerializationHelper.Serialize(data))); if (selectedTodo != null) { todoViewSource.View.Refresh(); todoViewSource.View.MoveCurrentTo(selectedTodo.pId); } } selectedNetObject = (NetObject)grid.CurrentCell.Item; } }
private void HandlePUT(Package package) { if (package.Event == (int)EventMapping.DataItemChanged_13) { DataItemChanged putParams = XmlSerializationHelper.Desirialize <DataItemChanged>(package.Data); if (putParams.Type == typeof(Todo).ToString()) { Todo currentTodo = null; foreach (Todo todo in TodoList) { if (todo.pId == putParams.PK) { currentTodo = todo; break; } } Todo.SetPropValue(currentTodo, putParams.PropertyName, putParams.Value); currentTodo.DidNotReadLoL = true; } else if (putParams.Type == typeof(Project).ToString()) { Project currentProject = null; foreach (Project project in ProjectList) { if (project.pId == putParams.PK) { currentProject = project; break; } } Project.SetPropValue(currentProject, putParams.PropertyName, putParams.Value); currentProject.DidNotReadLoL = true; selectedProject = currentProject; } } else if (package.Event == (int)EventMapping.CurrentItemChanged_15) { CurrentItemChanged putParams = XmlSerializationHelper.Desirialize <CurrentItemChanged>(package.Data); if (putParams.Type == typeof(Todo).ToString()) { object pk = TodoList.Where(todo => todo.pId == putParams.PK).First(); SelectedDataItemChanged(pk, putParams.Type); selectedTodo = (Todo)pk; } else if (putParams.Type == typeof(Project).ToString()) { object pk = ProjectList.Where(project => project.pId == putParams.PK).First(); SelectedDataItemChanged(pk, putParams.Type); selectedProject = (Project)pk; } else { throw new Exception("Unknown Type"); } } else if (package.Event == (int)EventMapping.DataItemBeginChanging_16) { DataItemBeginChanging putParams = XmlSerializationHelper.Desirialize <DataItemBeginChanging>(package.Data); DataItemStartChanging(putParams); } else if (package.Event == (int)EventMapping.DataItemEndChanging_17) { DataItemEndChanging putParams = XmlSerializationHelper.Desirialize <DataItemEndChanging>(package.Data); DataItemEndChanging(putParams); } }
private void BindingSource1_CurrentItemChanged(object sender, EventArgs e) { CurrentItemChanged?.Invoke(this, EventArgs.Empty); }
private void OnCurrentItemChanged() { CurrentItemChanged?.Invoke(this, CurrentItem); }
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) { if (context != observerContext) { Log.Debug($"context != observerContext | returning"); base.ObserveValue(keyPath, ofObject, change, context); return; } if (keyPath == null) { return; } if (keyPath == AVUrlAsset_Playable) { Log.Debug($"ObserveValue: {keyPath} | {Asset?.UrlAsset?.Playable}"); if ((Asset?.UrlAsset?.Cache?.IsPlayableOffline ?? false) || (Asset?.UrlAsset?.Playable ?? false)) { PlayerItem = new AVPlayerItem(Asset.UrlAsset); Player.ReplaceCurrentItemWithPlayerItem(PlayerItem); } else { Log.Debug($"FAILED: {Asset?.UrlAsset?.Url}"); } } else if (keyPath == AVPlayerItem_Status) { if (PlayerItem?.Status == AVPlayerItemStatus.ReadyToPlay) { Log.Debug($"PlayerItem.Status = ReadyToPlay | {PlayerItem?.Error}"); if (!readyForPlayback) { readyForPlayback = true; //ReadyToPlay?.Invoke (this, Player); Player.Play(); setupRemoteTransportControls(); } else { if (Player?.Rate == 0) { Player.Play(); } //addPeriodicTimeObserver (); } updateCommandCenterNowPlayingInfo(); } else if (PlayerItem?.Status == AVPlayerItemStatus.Unknown) { //removePeriodicTimeObserver (); Log.Debug($"PlayerItem.Status = Unknown | {PlayerItem?.Error}"); } else if (PlayerItem?.Status == AVPlayerItemStatus.Failed) { Log.Debug($"PlayerItem.Status = Failed | {PlayerItem?.Error}"); } } else if (keyPath == AVPlayer_CurrentItem) { Log.Debug($"ObserveValue: {keyPath} | "); CurrentItemChanged?.Invoke(this, Player); } else { Log.Debug($"ObserveValue: {keyPath} | "); base.ObserveValue(keyPath, ofObject, change, context); } }
void CurrentItemPropertyChanged() { CurrentItemChanged?.Invoke(this, new EventArgs()); }
//private void UpdatePopupSize() //{ // return; // if (_popup == null || lowerThan14393) // { // return; // } // var windowRect = Window.Current.Bounds; // if (DeviceInfo.IsNarrowSrceen) // { // //Gets the visible region of the window (app view). The visible region is the region // //not occluded by chrome such as the status bar and app bar. // windowRect = ApplicationView.GetForCurrentView().VisibleBounds; // } // _popup.Width = windowRect.Width; // _popup.Height = windowRect.Height; //} private void OnCurrentItemChanged(DependencyPropertyChangedEventArgs e) { CurrentItemChanged?.Invoke(this, e); }