private void LoadNote() { if (SelectedNote != null) { HoleCardsCollection.ForEach(x => x.IsChecked = !SelectedNote.Settings.ExcludedCardsList.Contains(x.Name)); } noteCopy = SelectedNote?.CopyTo(); RefreshCurrentActionSettings(); RefreshFiltersSettings(); RefreshCurrentHandValuesSettings(); RaiseFilterBasedPropertyChanged(); }
private void InitializeCommands() { var canAdd = this.WhenAny(x => x.SelectedStage, x => x.Value != null); AddNoteCommand = ReactiveCommand.Create(AddNote, canAdd); var canEdit = this.WhenAny(x => x.SelectedStage, x => x.Value != null && x.Value is NoteTreeEditableObject); EditNoteCommand = ReactiveCommand.Create(EditNote, canEdit); var canRemove = this.WhenAny(x => x.SelectedStage, x => (x.Value is InnerGroupObject) || (x.Value is NoteObject)); RemoveNoteCommand = ReactiveCommand.Create(RemoveNote, canRemove); SwitchModeCommand = ReactiveCommand.Create(() => IsAdvancedMode = !IsAdvancedMode); HoleCardsLeftClickCommand = ReactiveCommand.Create <HoleCardsViewModel>(x => x.IsChecked = true); HoleCardsDoubleLeftClickCommand = ReactiveCommand.Create <HoleCardsViewModel>(x => x.IsChecked = false); HoleCardsMouseEnterCommand = ReactiveCommand.Create <HoleCardsViewModel>(x => x.IsChecked = true); HoleCardsSelectAllCommand = ReactiveCommand.Create(() => HoleCardsCollection.ForEach(x => x.IsChecked = true)); HoleCardsSelectNoneCommand = ReactiveCommand.Create(() => HoleCardsCollection.ForEach(x => x.IsChecked = false)); HoleCardsSelectSuitedGappersCommand = ReactiveCommand.Create(SelectSuitedGappers); HoleCardsSelectSuitedConnectorsCommand = ReactiveCommand.Create(SelectedSuitedConnectors); HoleCardsSelectPocketPairsCommand = ReactiveCommand.Create(SelectPocketPairs); HoleCardsSelectOffSuitedGappersCommand = ReactiveCommand.Create(SelectOffSuitedGappers); HoleCardsSelectOffSuitedConnectorsCommand = ReactiveCommand.Create(SelectOffSuitedConnectors); AddToSelectedFiltersCommand = ReactiveCommand.Create(() => { var selectedItem = filters.FirstOrDefault(f => f.IsSelected); if (selectedItem != null && !selectedFilters.Any(f => f.Filter == selectedItem.Filter)) { var filterToAdd = selectedItem.Clone(); filterToAdd.IsSelected = false; // if filter requires value if (FiltersHelper.FiltersWithValueRequired.Contains(filterToAdd.Filter)) { var setFilterValueViewModel = new SetFilterValueViewModel { Filter = filterToAdd.Filter }; setFilterValueViewModel.OnSaveAction = () => { filterToAdd.Value = setFilterValueViewModel.FilterValue; selectedFilters.Add(filterToAdd); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_SetFilterValueView_Title"), Content = new SetFilterValueView(setFilterValueViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); } else { selectedFilters.Add(filterToAdd); } } }); RemoveFromSelectedFiltersCommand = ReactiveCommand.Create(() => { var selectedItem = selectedFilters.FirstOrDefault(f => f.IsSelected); if (selectedItem != null) { selectedFilters.Remove(selectedItem); } }); NoteDragDropCommand = ReactiveCommand.Create <DragDropDataObject>(dataObject => { if (dataObject == null) { return; } var note = dataObject.DropData as NoteObject; if (note == null || ReferenceEquals(note, dataObject.Source)) { return; } var noteParent = FindNoteParent(note); if (dataObject.Source is InnerGroupObject) { (dataObject.Source as InnerGroupObject).Notes.Add(note); } else if (dataObject.Source is NoteObject) { var sourceNoteParent = FindNoteParent(dataObject.Source as NoteObject); if (ReferenceEquals(sourceNoteParent, noteParent)) { return; } if (sourceNoteParent is InnerGroupObject) { (sourceNoteParent as InnerGroupObject).Notes.Add(note); } else if (sourceNoteParent is StageObject) { (sourceNoteParent as StageObject).Notes.Add(note); } } // remove note from parent object if (noteParent is InnerGroupObject) { (noteParent as InnerGroupObject).Notes.Remove(note); } else if (noteParent is StageObject) { (noteParent as StageObject).Notes.Remove(note); } }); }