protected override void UpdateMenu() { _dvdAngles.Clear(); DvdAnglesMenuVisible = false; if (_engine.GraphState != GraphState.Reset) { int ulAngles = _engine.AnglesAvailable; if (ulAngles > 1) { var command = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { _engine.CurrentAngle = data.Number; } }, data => { return(data != null && (_engine.UOPS & VALID_UOP_FLAG.UOP_FLAG_Select_Angle) == 0); }); for (int i = 0; i < ulAngles; i++) { _dvdAngles.Add(new LeafItem <NumberedMenuItemData>(string.Format(Resources.Resources.mi_angle_format, i + 1), new NumberedMenuItemData(i + 1), command)); } DvdAnglesMenuVisible = true; } } }
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; } } }
/// <summary> /// Constructor. /// </summary> public MainViewModel() { TreeviewLeftDoubleClickCommand = new GenericRelayCommand <NodeTree>( param => TreeviewLeftDoubleClickCommand_Execute(param), param => TreeviewLeftDoubleClickCommand_CanExecute()); ListviewLeftDoubleClickCommand = new GenericRelayCommand <EntryItem>( param => ListviewLeftDoubleClickCommand_Execute(param), param => ListviewLeftDoubleClickCommand_CanExecute()); OpenEditorCommand = new GenericRelayCommand <EntryItem>( param => OpenEditorCommand_Execute(param), param => OpenEditorCommand_CanExecute()); DeleteEntryCommand = new GenericRelayCommand <EntryItem>( param => DeleteEntryCommand_Execute(param), param => DeleteEntryCommand_CanExecute()); OpenInBrowserCommand = new GenericRelayCommand <EntryItem>( param => OpenInBrowserCommand_Execute(param), param => OpenInBrowserCommand_CanExecute()); ListviewEnterKeyCommand = new GenericRelayCommand <EntryItem>( param => ListviewEnterKeyCommand_Execute(param), param => ListviewEnterKeyCommand_CanExecute()); ServiceAddCommand = new RelayCommand(ServiceAddCommand_Execute, ServiceAddCommand_CanExecute); OpenEditorAsNewCommand = new RelayCommand(OpenEditorAsNewCommand_Execute, OpenEditorAsNewCommand_CanExecute); RefreshEntriesCommand = new RelayCommand(RefreshEntriesCommand_Execute, RefreshEntriesCommand_CanExecute); WindowClosingCommand = new RelayCommand(WindowClosingCommand_Execute, WindowClosingCommand_CanExecute); ShowSettingsCommand = new RelayCommand(ShowSettingsCommand_Execute, ShowSettingsCommand_CanExecute); // Upgrade settings. Properties.Settings.Default.Upgrade(); // Load settings. if (Properties.Settings.Default.Profiles != null) { // Must be the first time. _services.LoadXmlDoc(Properties.Settings.Default.Profiles.Profiles); } else { //TODO: } //Task.Run(() => Do()); }
protected override void UpdateMenu() { _audioStreams.Clear(); AudioStreamsMenuVisible = false; if (_engine.GraphState != GraphState.Reset) { int nStreams = _engine.AudioStreams; if (nStreams > 0) { var command = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { _engine.CurrentAudioStream = data.Number; } }, data => { return(data != null && (_engine.SourceType != SourceType.Dvd || ((_engine.IsAudioStreamEnabled(data.Number)) && (_engine.UOPS & VALID_UOP_FLAG.UOP_FLAG_Select_Audio_Stream) == 0))); }); if (nStreams > 8) { nStreams = 8; } for (int i = 0; i < nStreams; i++) { _audioStreams.Add(new LeafItem <NumberedMenuItemData>(_engine.GetAudioStreamName(i), new NumberedMenuItemData(i), command)); } AudioStreamsMenuVisible = true; } } }
protected override void UpdateMenu() { _dvdMenuLanguages.Clear(); DvdMenuLanguagesMenuVisible = false; if (_engine.GraphState != GraphState.Reset) { var nLang = _engine.MenuLangCount; if (nLang > 0) { if (nLang > 10) { nLang = 10; } var command = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { _engine.SetMenuLang(data.Number); } }, data => { return(data != null && _engine.MenuLangCount > 1); }); for (int i = 0; i < nLang; i++) { _dvdMenuLanguages.Add(new LeafItem <NumberedMenuItemData>(_engine.GetMenuLangName(i), new NumberedMenuItemData(i), command)); } DvdMenuLanguagesMenuVisible = true; } } }
protected override void UpdateMenu() { _subpictureStreams.Clear(); SubpictureStreamsMenuVisible = false; if (IsInPlayingMode) { int nStreams = _engine.NumberOfSubpictureStreams; if (nStreams > 0) { var command = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { if (data.Number == -1) { _engine.EnableSubpicture(!_engine.IsSubpictureEnabled()); } else { _engine.CurrentSubpictureStream = data.Number; } } }, data => { var enabled = false; if (data != null) { if (data.Number == -1) { enabled = (_engine.UOPS & VALID_UOP_FLAG.UOP_FLAG_Select_SubPic_Stream) == 0; } else { enabled = _engine.SourceType != SourceType.Dvd ? _engine.IsSubpictureStreamEnabled(data.Number) : (_engine.UOPS & VALID_UOP_FLAG.UOP_FLAG_Select_SubPic_Stream) == 0 && _engine.IsSubpictureStreamEnabled(data.Number); } } return(enabled); }); if (_engine.SourceType == SourceType.Dvd) { _subpictureStreams.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_display_subpictures, new NumberedMenuItemData(-1), command)); } for (int i = 0; i < nStreams; i++) { _subpictureStreams.Add(new LeafItem <NumberedMenuItemData>(_engine.GetSubpictureStreamName(i), new NumberedMenuItemData(i), command)); } SubpictureStreamsMenuVisible = true; } } }
private void RegistCommands() { ShowBaseCommand = new GenericRelayCommand <TypeViewModel>(OnShowBaseCommandExecute, OnShowBaseCommandCanExecute); ShowInterfacesCommand = new GenericRelayCommand <TypeViewModel>(OnShowInterfacesCommandExecute); }
public ConfirmationDialogViewModel(string title, string message) : base(title, message) { YesCommand = new GenericRelayCommand <IDialogWindow>(Yes); NoCommand = new GenericRelayCommand <IDialogWindow>(No); }
public ViewModel() { Comment = "Hello World!"; SubmitComment1Command = new GenericRelayCommand <string>(OnSubmitComment1); SubmitComment2Command = new RelayCommand(OnSubmitComment2); }
protected override void UpdateMenu() { _engineReady = true; _dvdMenuItems.Clear(); DvdMenuVisible = false; if (_engine.SourceType == SourceType.Dvd) { var command = new GenericRelayCommand <NumberedMenuItemData>( data => { if (data != null) { _engine.ShowMenu((DVD_MENU_ID)data.Number); } }, data => { var enabled = false; if (data != null) { VALID_UOP_FLAG uops = _engine.UOPS; DVD_MENU_ID id = (DVD_MENU_ID)data.Number; switch (id) { case DVD_MENU_ID.DVD_MENU_Title: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_Title) == 0; break; case DVD_MENU_ID.DVD_MENU_Root: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_Root) == 0; break; case DVD_MENU_ID.DVD_MENU_Subpicture: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_SubPic) == 0; break; case DVD_MENU_ID.DVD_MENU_Audio: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_Audio) == 0; break; case DVD_MENU_ID.DVD_MENU_Angle: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_Angle) == 0; break; case DVD_MENU_ID.DVD_MENU_Chapter: enabled = (uops & VALID_UOP_FLAG.UOP_FLAG_ShowMenu_Chapter) == 0; break; } } return(enabled); }); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_title_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Title), command)); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_root_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Root), command)); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_subpicture_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Subpicture), command)); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_audio_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Audio), command)); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_angle_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Angle), command)); _dvdMenuItems.Add(new LeafItem <NumberedMenuItemData>(Resources.Resources.mi_chapter_menu, new NumberedMenuItemData((int)DVD_MENU_ID.DVD_MENU_Chapter), command)); DvdMenuVisible = true; } }
//public Action CloseAction { get; set; } #endregion public RentLivingBuildingViewModel(string id) { _id = id; #region == コマンド初期化 == // 建物情報の保存・更新 SaveCommand = new RelayCommand(SaveCommand_Execute, SaveCommand_CanExecute); // 画像の追加 PictureAddCommand = new RelayCommand(PictureAddCommand_Execute, PictureAddCommand_CanExecute); // 画像の編集 PictureEditCommand = new RelayCommand(PictureEditCommand_Execute, PictureEditCommand_CanExecute); // 画像の削除 PictureDeleteCommand = new RelayCommand(PictureDeleteCommand_Execute, PictureDeleteCommand_CanExecute); // 画像の編集(Listview) PictureEditListviewCommand = new GenericRelayCommand <object>( param => PictureEditListviewCommand_Execute(param), param => PictureEditListviewCommand_CanExecute()); // 画像の削除(Listview) PictureDeleteListviewCommand = new GenericRelayCommand <object>( param => PictureDeleteListviewCommand_Execute(param), param => PictureDeleteListviewCommand_CanExecute()); // 画像の差替え(Listview) PictureChangeListviewCommand = new GenericRelayCommand <object>( param => PictureChangeListviewCommand_Execute(param), param => PictureChangeListviewCommand_CanExecute()); // PDFの追加 PdfAddCommand = new RelayCommand(PdfAddCommand_Execute, PdfAddCommand_CanExecute); // PDFの編集 PdfEditCommand = new RelayCommand(PdfEditCommand_Execute, PdfEditCommand_CanExecute); // PDFの削除 PdfDeleteCommand = new RelayCommand(PdfDeleteCommand_Execute, PdfDeleteCommand_CanExecute); // PDFの削除 RentLivingEditZumenPdfDeleteCommand = new GenericRelayCommand <object>( param => RentLivingEditZumenPdfDeleteCommand_Execute(param), param => RentLivingEditZumenPdfDeleteCommand_CanExecute()); // PDFの表示 RentLivingEditZumenPdfShowCommand = new GenericRelayCommand <object>( param => RentLivingEditZumenPdfShowCommand_Execute(param), param => RentLivingEditZumenPdfShowCommand_CanExecute()); // PDFの RentLivingEditZumenPdfEnterCommand = new GenericRelayCommand <RentPdf>( param => RentLivingEditZumenPdfEnterCommand_Execute(param), param => RentLivingEditZumenPdfEnterCommand_CanExecute()); // 部屋の追加 SectionNewCommand = new RelayCommand(SectionNewCommand_Execute, SectionNewCommand_CanExecute); // 部屋の編集 SectionEditCommand = new RelayCommand(SectionEditCommand_Execute, SectionEditCommand_CanExecute); // 部屋の複製 SectionDuplicateCommand = new RelayCommand(SectionDuplicateCommand_Execute, SectionDuplicateCommand_CanExecute); // 部屋の削除 SectionDeleteCommand = new RelayCommand(SectionDeleteCommand_Execute, SectionDeleteCommand_CanExecute); // /* * // RL 管理新規 新規部屋の画像追加と削除 * RentLivingNewSectionNewPictureAddCommand = new RelayCommand(RentLivingNewSectionNewPictureAddCommand_Execute, RentLivingNewSectionNewPictureAddCommand_CanExecute); * RentLivingNewSectionNewPictureDeleteCommand = new GenericRelayCommand<object>( * param => RentLivingNewSectionNewPictureDeleteCommand_Execute(param), * param => RentLivingNewSectionNewPictureDeleteCommand_CanExecute()); * // RL 管理新規 編集部屋の画像追加と削除 * RentLivingNewSectionEditPictureAddCommand = new RelayCommand(RentLivingNewSectionEditPictureAddCommand_Execute, RentLivingNewSectionEditPictureAddCommand_CanExecute); * RentLivingNewSectionEditPictureDeleteCommand = new GenericRelayCommand<object>( * param => RentLivingNewSectionEditPictureDeleteCommand_Execute(param), * param => RentLivingNewSectionEditPictureDeleteCommand_CanExecute()); */ #endregion #region == イベントへのサブスクライブ == ErrorOccured += new MyErrorEvent(OnError); #endregion }
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; } }
private void SetupCommands() { PlaySongCommand = new AsyncCommand( execute: (s) => { UIEnabled = false; if(s as Song != null) { Playlist.SelectFirstMatch((Song)s); if(SongPlayer.PlayerState != PlayerState.Playing) { SongPlayer.PlayerState = PlayerState.Playing; } } }, continueWith: t => UIEnabled = true, canExecute: (s) => SongPlayer != null && s as Song != null ); ReverseSortCommand = new RelayCommand((o) => Playlist.Reverse(), (o) => Playlist != null); SortByCommand = new RelayCommand( (o) => { var pi = o as PropertyInfo; if(pi.DeclaringType == typeof(Song)) { Playlist.Order((s) => pi.GetValue(s)); } else if(pi.DeclaringType == typeof(SongFile)) { Playlist.Order((s) => pi.GetValue(s.File)); } }, (o) => o as PropertyInfo != null && (((PropertyInfo)o).DeclaringType == typeof(Song) || ((PropertyInfo)o).DeclaringType == typeof(SongFile)) ); SortBySearchCommand = new RelayCommand( _ => { var reg = new Regex(SearchText, RegexOptions.IgnoreCase); SearchText = string.Empty; Playlist.Order(s => { var res = 0; res += (reg.IsMatch(s.Title ?? string.Empty) ? 0 : 3); res += (reg.IsMatch(s.Artist ?? string.Empty) ? 0 : 2); res += (reg.IsMatch(s.Album ?? string.Empty) ? 0 : 1); return res; }); }, _ => !string.IsNullOrEmpty(SearchText) ); RemoveSongsCommand = new RelayCommand((o) => { Playlist.Remove(((IEnumerable<SongViewModel>)o).Select(svm => svm.Song)); }, (o) => { var songs = o as IEnumerable<SongViewModel>; return songs != null && songs.Count() > 0; }); SearchCommand = new RelayCommand((o) => FillPlaylist(o as string)); AddFilesCommand = new AsyncCommand(async (dyn) => { dynamic input = dyn; UIEnabled = false; var paths = input.Paths as string[]; Song position = (input.Position as Song) ?? Playlist.LastOrDefault(); if(paths != null) { var addFiles = await SongFileReader.ReadFilePathsAsync(paths); var added = Playlist.AddSong(addFiles); Playlist.MoveTo(position, added.ToArray()); } }, (t) => { UIEnabled = true; if(t.IsFaulted) Application.Current.Dispatcher.BeginInvoke((Action)(() => new ExceptionWindow(t.Exception).Show())); }); MovePlaylistSongsCommand = new GenericRelayCommand<Tuple<SongViewModel[], SongViewModel>>(inp => { Playlist.MoveTo(inp.Item2.Song, inp.Item1.Select(svm => svm.Song).ToArray()); }, (inp) => { return (inp.Item1?.Length ?? 0) > 0 && inp.Item2?.Song != null; }); }