protected override void UpdateMenu() { _dvdChapters.Clear(); DvdChaptersMenuVisible = false; if (_engine.GraphState != GraphState.Reset) { int ulTitles = _engine.NumberOfTitles; if (ulTitles > 0) { var command = new GenericRelayCommand <TitleChapterMenuItemData>( data => { if (data != null) { _engine.GoTo(data.Title, data.Chapter); } }, data => { return(data != null ? (_engine.UOPS & VALID_UOP_FLAG.UOP_FLAG_Play_Chapter) == 0 : false); }); if (ulTitles == 1) { int nChapters = _engine.GetNumChapters(1); for (int i = 1; i <= nChapters; i++) { _dvdChapters.Add(new LeafItem <TitleChapterMenuItemData>(string.Format(Resources.Resources.mi_chapter_format, i), new TitleChapterMenuItemData(1, i), command)); } } else { for (int title = 1; title <= ulTitles; title++) { var titleItem = new ParentDataItem <TitleChapterMenuItemData>(string.Format(Resources.Resources.mi_title_format, title), new TitleChapterMenuItemData(title, 0)); int nChapters = _engine.GetNumChapters(title); for (int i = 1; i <= nChapters; i++) { titleItem.SubItems.Add(new LeafItem <TitleChapterMenuItemData>(string.Format(Resources.Resources.mi_chapter_format, i), new TitleChapterMenuItemData(title, i), command)); } _dvdChapters.Add(titleItem); } } DvdChaptersMenuVisible = true; } } }
protected override void UpdateMenu() { _filters.Clear(); if (_engine.GraphState == GraphState.Reset) { FiltersMenuVisible = false; } else { var last = _engine.FilterCount; if (last > 15) { last = 15; } var displayPropPageCommand = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { _engine.DisplayFilterPropPage(_windowHandleProvider.Handle, data.Number, true); } }, data => { return(data != null && _engine.DisplayFilterPropPage(_windowHandleProvider.Handle, data.Number, false)); }); var selectStreamCommand = new GenericRelayCommand <SelectableStreamMenuItemData>( data => { if (data != null) { _engine.SelectStream(data.FilterName, data.StreamIndex); } }); for (var i = 0; i < last; i++) { var filterName = _engine.GetFilterName(i); var selectableStreams = _engine.GetSelectableStreams(filterName); var streams = selectableStreams as IList <SelectableStream> ?? selectableStreams.ToList(); if (streams.Any()) { var parentItem = new ParentDataItem <NumberedMenuItemData>(filterName, new NumberedMenuItemData(i)); parentItem.SubItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_properties, new NumberedMenuItemData(i), displayPropPageCommand)); var grouppedStreams = streams.GroupBy(s => s.MajorType); foreach (var group in grouppedStreams) { parentItem.SubItems.Add(new SeparatorItem()); foreach (var stream in group) { var leafItem = new LeafItem <SelectableStreamMenuItemData>(stream.Name, new SelectableStreamMenuItemData(filterName, stream.Index), selectStreamCommand); leafItem.IsChecked = stream.Enabled; parentItem.SubItems.Add(leafItem); } } _filters.Add(parentItem); } else { _filters.Add(new LeafItem <NumberedMenuItemData>(filterName, new NumberedMenuItemData(i), displayPropPageCommand)); } } FiltersMenuVisible = true; } }