private void DeleteNotes(DateTime?date) { var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = date.HasValue ? string.Format(CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteNotesMessage"), date.Value) : CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteAllNotesMessage") }; confirmationViewModel.OnYesAction = () => { StartAsyncOperation(() => { Progress = 0; ProgressEnabled = true; var noteProcessingService = ServiceLocator.Current.GetInstance <INoteProcessingService>(); noteProcessingService.ProgressChanged += (s, e) => { Progress = e.Progress; }; noteProcessingService.DeletesNotes(date); }, () => { ProgressEnabled = false; Progress = 0; }); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteTitle"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void AddProfile() { var addNoteViewModel = new AddEditNoteViewModel(); addNoteViewModel.OnSaveAction = () => { var profile = new ProfileObject { Name = addNoteViewModel.Name, }; profiles.Add(profile); SelectedProfile = profile; NoteService.SaveAppSettings(); eventAggregator.GetEvent <RefreshSettingsEvent>().Publish(new RefreshSettingsEventArgs()); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_AddProfileTitle"), Content = new AddEditNoteView(addNoteViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void EditProfile() { var addNoteViewModel = new AddEditNoteViewModel { Name = SelectedProfile.Name }; addNoteViewModel.OnSaveAction = () => { if (NoteService.CurrentNotesAppSettings.AutoNoteProfile == SelectedProfile.Name) { NoteService.CurrentNotesAppSettings.AutoNoteProfile = addNoteViewModel.Name; } SelectedProfile.Name = addNoteViewModel.Name; NoteService.SaveAppSettings(); eventAggregator.GetEvent <RefreshSettingsEvent>().Publish(new RefreshSettingsEventArgs()); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_EditProfileTitle"), Content = new AddEditNoteView(addNoteViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
public override bool OnClosing() { if (isClosing) { return(true); } var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_ExitText"), OnYesAction = () => { isClosing = true; OnClosed(); } }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_Exit"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); return(isClosing); }
private void EditNote() { var treeEditableObject = SelectedStage as NoteTreeEditableObject; if (treeEditableObject == null) { return; } var addNoteViewModel = new AddEditNoteViewModel { Name = treeEditableObject.Name }; addNoteViewModel.OnSaveAction = () => { treeEditableObject.Name = addNoteViewModel.Name; SaveNote(); }; var popupEventArgs = new RaisePopupEventArgs() { Title = treeEditableObject is NoteObject? CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_EditNoteTitle") : CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_EditNoteGroup"), Content = new AddEditNoteView(addNoteViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void RaisePopup(RaisePopupEventArgs e) { var containerView = e.Content as IPopupContainerView; if (containerView != null && containerView.ViewModel != null) { containerView.ViewModel.FinishInteraction = () => ClosePopup(); } PopupTitle = e.Title; PopupContent = containerView; PopupIsOpen = true; }
private void GenerateNetLog() { StartAsyncOperation(() => { var processStartInfo = new ProcessStartInfo("netstat", "-ano") { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; var process = Process.Start(processStartInfo); var result = process.StandardOutput.ReadToEnd(); process.WaitForExit(5000); File.WriteAllText("Logs\\pk-netstat.log", result); }, ex => { string message; string title; if (ex != null) { LogProvider.Log.Error(CustomModulesNames.PKCatcher, "Failed to create PK netstat log.", ex); message = CommonResourceManager.Instance.GetResourceString("PKC_GenerateLogView_FailMessage"); title = CommonResourceManager.Instance.GetResourceString("PKC_GenerateLogView_FailTitle"); } else { message = CommonResourceManager.Instance.GetResourceString("PKC_GenerateLogView_SuccessMessage"); title = CommonResourceManager.Instance.GetResourceString("PKC_GenerateLogView_SuccessTitle"); } var generateLogViewModel = new GenerateLogViewModel { Message = message }; var popupEventArgs = new RaisePopupEventArgs() { Title = title, Content = new GenerateLogView(generateLogViewModel) }; RaisePopup(popupEventArgs); }); }
private void RemoveNote() { var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteItemMessage") }; confirmationViewModel.OnYesAction = () => { foreach (var stage in Stages) { if (SelectedStage is NoteObject) { var noteToRemove = SelectedStage as NoteObject; stage.Notes.Remove(noteToRemove); foreach (var group in stage.InnerGroups) { group.Notes.Remove(noteToRemove); } noteToRemove.TrackChanges(false); } else if (SelectedStage is InnerGroupObject) { var groupToRemove = SelectedStage as InnerGroupObject; stage.InnerGroups.Remove(groupToRemove); } SaveNote(); } }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteTitle"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void RestoreDefaults() { var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_RestoreDefaultsText") }; confirmationViewModel.OnYesAction = () => { NoteService.InitializeDefaultNotes(); eventAggregator.GetEvent <RestoreDefaultsEvent>().Publish(new RestoreDefaultsEventArgs()); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_RestoreDefaults"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void RaiseRegistrationPopup(bool showRegister) { var registrationViewModel = new RegistrationViewModel(showRegister) { Callback = () => { var licenseService = ServiceLocator.Current.GetInstance <ILicenseService>(); Initialize(licenseService); this.RaisePropertyChanged(nameof(LicenseType)); } }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("PMC_RegistrationView_Title"), Content = new RegistrationView(registrationViewModel) }; RaisePopup(popupEventArgs); }
private void RemoveProfile() { var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteItemMessage") }; confirmationViewModel.OnYesAction = () => { profiles.Remove(SelectedProfile); SelectedProfile = profiles.FirstOrDefault(); NoteService.SaveAppSettings(); eventAggregator.GetEvent <RefreshSettingsEvent>().Publish(new RefreshSettingsEventArgs()); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_DeleteTitle"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void ShowPendingChangedPopup(NoteObject noteObject) { var confirmationViewModel = new YesNoConfirmationViewModel { ConfirmationMessage = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_SavePendingChangesText"), OnYesAction = () => { if (selectedNote != null) { selectedNote.Modified = false; } SaveNote(); SelectedNote = noteObject; }, OnNoAction = () => { if (selectedNote != null) { noteCopy?.CopyTo(selectedNote); selectedNote.Modified = false; } SelectedNote = noteObject; } }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_YesNoConfirmationView_SavePendingChanges"), Content = new YesNoConfirmationView(confirmationViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
private void AddNote() { var addNoteViewModel = new AddEditNoteViewModel { IsGroupPossible = SelectedStage is StageObject }; addNoteViewModel.OnSaveAction = () => { ReactiveList <NoteObject> noteList = null; if (SelectedStage is StageObject) { if (addNoteViewModel.IsGroup) { var group = new InnerGroupObject { Name = addNoteViewModel.Name, IsSelected = true }; (SelectedStage as StageObject).InnerGroups.Add(group); SaveNote(); return; } noteList = (SelectedStage as StageObject).Notes; } else if (SelectedStage is InnerGroupObject) { noteList = (SelectedStage as InnerGroupObject).Notes; } else { foreach (var stage in stages) { if (stage.Notes.Contains(SelectedStage)) { noteList = stage.Notes; break; } foreach (var group in stage.InnerGroups) { if (group.Notes.Contains(SelectedStage)) { noteList = group.Notes; break; } } } } if (noteList == null) { return; } var note = new NoteObject { ID = ObjectsHelper.GetNextID(NoteService.CurrentNotesAppSettings.AllNotes), ParentStageType = NoteStageType, Name = addNoteViewModel.Name, DisplayedNote = addNoteViewModel.Name, IsSelected = true }; note.TrackChanges(true); noteList.Add(note); SaveNote(); }; var popupEventArgs = new RaisePopupEventArgs() { Title = CommonResourceManager.Instance.GetResourceString("XRay_AddEditNoteView_AddTitle"), Content = new AddEditNoteView(addNoteViewModel) }; eventAggregator.GetEvent <RaisePopupEvent>().Publish(popupEventArgs); }
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); } }); }