private void ApplyToken(OAuthToken token) { if (token != null && token.Equals(State.Token)) { return; } ; State.Token = token; var fileInfo = new FileInfo(OAUTHTOKEN_FILENAME); try { if (State.Token is null) { _loginStateEvent.Publish(new AppMessages.LoginState(false)); File.Delete(fileInfo.FullName); } else { _loginStateEvent.Publish(new AppMessages.LoginState(true)); var encrypted = ProtectedData.Protect(Encoding.UTF8.GetBytes(token.ToJson()), null, DataProtectionScope.CurrentUser); File.WriteAllBytes(fileInfo.FullName, encrypted); } } catch (Exception e) { _logger.LogError(e, "Error saving OAuthToken to File"); } }
public void AddDeliveryPoint(StoragePoint deliveryPoint) { DeliveryPoints.Add(deliveryPoint); _addDeliveryPointEvent.Publish(new AddDeliveryPointEvent { DeliveryPoint = deliveryPoint }); }
public void AddShelfToStore(Store store, Shelf shelf) { store.Shelves.Add(shelf); _addShelfEvent.Publish(new AddShelfEvent { Shelf = shelf, Store = store }); }
public void RemovePartFromShelf(Shelf shelf, Part part) { shelf.Parts.Remove(part); _removePartFromShelfEvent.Publish(new RemovePartFromShelfEvent { Part = part, Shelf = shelf }); }
public void AddPartToStoragePoint(StoragePoint storagePoint, Part part) { storagePoint.Parts.Add(part); _insertPartEvent.Publish(new InsertPartEvent { Part = part, StoragePoint = storagePoint.Name }); }
public void AddPartToShelf(Shelf shelf, Part part) { shelf.Parts.Add(part); _addPartEvent.Publish(new AddPartEvent { Part = part, Shelf = shelf }); }
public void AddStoragePoint(StoragePoint storagePoint) { StoragePoints.Add(storagePoint); _addStoragePointEvent.Publish(new AddStoragePointEvent { StoragePoint = storagePoint }); }
public void AddStore(Store store) { Stores.Add(store); _addStoreEvent.Publish(new AddStoreEvent { Store = store }); }
public void AddPartToDeliveryPoint(StoragePoint deliveryPoint, Part part) { deliveryPoint.Parts.Add(part); _insertPartToDeliveryPointEvent.Publish(new InsertPartToDeliveryEvent { DeliveryPoint = deliveryPoint, Part = part }); }
public void RemovePartFromStoragePoint(StoragePoint storagePoint, Part part) { storagePoint.Parts.Remove(part); _removePartFromStoragePointEvent.Publish(new RemovePartFromStoragePointEvent { Part = part, StoragePoint = storagePoint }); }
public void OnSelectDownloadFolder() { var dialog = new CommonOpenFileDialog { IsFolderPicker = true }; CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { _appConfiguration.CloudDownloadDirectory = dialog.FileName; CloudDownloadDirectory = dialog.FileName; _cloudFolderChanged.Publish(new AppMessages.CloudFolderChanged()); } }
/// <summary> /// Load settings from <see cref="RawSettings"/> to this service. /// </summary> /// <remarks>This method should be invoked after <see cref="RawSettings"/> has been changed.</remarks> public void RefreshSettings() { { // Associates language settings with wiki ContentModels. _LanguageSettings.Clear(); _WikiContentModelLanguageSettings.Clear(); var defaultLanguageSettings = _RawSettings.TextEditor.LanguageSettings[""]; foreach (var p in _RawSettings.TextEditor.LanguageSettings) { var settings = new RuntimeTextEditorLanguageSettings(p.Key, p.Value, defaultLanguageSettings); _LanguageSettings[p.Key] = settings; if (p.Key == "") { _WikiContentModelLanguageSettings[""] = settings; } else { foreach (var model in p.Value.WikiContentModels) { _WikiContentModelLanguageSettings[model] = settings; } } } } // Notify about the changes. SettingsChangedEvent.Publish(); }
private void OnAcceptEditingDialog() { if (CustomCpuDescription == null || CustomGpuDescription == null || CustomRamDescription == null || CustomGameName == null || CustomComment == null || _selectedRecordInfo == null) { return; } // hint: _selectedRecordInfo must not be uptated, because after reload // it will be set to null RecordManager.UpdateCustomData(_selectedRecordInfo, CustomCpuDescription, CustomGpuDescription, CustomRamDescription, CustomGameName, CustomComment); _recordDataProvider.AddGameNameToMatchingList(_selectedRecordInfo.ProcessName, CustomGameName); var id = SelectedRecordInfo.Id; ReloadRecordList(); // Get recordInfo after update via id var updatedRecordInfo = RecordInfoList.FirstOrDefault(info => info.Id == id); if (updatedRecordInfo != null) { SelectedRecordInfo = updatedRecordInfo; _updateRecordInfosEvent.Publish(new ViewMessages.UpdateRecordInfos(updatedRecordInfo)); } }
public void OnRecordSelectByDoubleClick() { if (SelectedRecordInfo != null && _selectSessionEvent != null) { var session = RecordManager.LoadData(SelectedRecordInfo.FullPath); _selectSessionEvent.Publish(new ViewMessages.SelectSession(session, SelectedRecordInfo)); } }
public static IMaybe <TReturn> Get <TReturn>(this PubSubEvent <Action <TReturn> > @this) { var v = default(TReturn); var isCallback = false; var callback = Act.New((TReturn x) => { v = x; isCallback = true; }); @this.Publish(callback); return(v.ToMaybe().Where(_ => isCallback)); }
private void OnOpenEditingDialog() { if (!RecordInfoList.Any()) { return; } _showOverlayEvent.Publish(new ViewMessages.ShowOverlay()); }
public static void Publish <T, With>(this PubSubEvent <AddOrder <T, With> > @this, T model, With with) { var order = new AddOrder <T, With> { Model = model, WithIn = with, }; @this.Publish(order); }
/// <summary> /// Invalidates the current <see cref="Site"/> instance maintined /// by the view model. /// </summary> public void InvalidateSite() { _GetSiteTaskCts?.Cancel(); if (_Site == null) { return; } _Site = null; SiteInvalidatedEvent.Publish(); }
private static void Navigate(PubSubEvent <NavigateOrder> @this, string viewName, IDictionary <string, object> prms) { var order = new NavigateOrder { ViewName = viewName, Prms = prms, }; @this.Publish(order); }
public void OnSwitchToDownloadDirectory() { string downloadDirectory = CloudDownloadDirectory; if (downloadDirectory.Contains(@"MyDocuments\CapFrameX\Captures\Cloud")) { downloadDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"CapFrameX\Captures\Cloud"); } _appConfiguration.ObservedDirectory = downloadDirectory; _selectCloudFolder.Publish(new AppMessages.SelectCloudFolder()); }
public static IUser Get(this PubSubEvent <AuthOrder> @this, IUser authUser) { var v = null as IUser; var callback = Act.New((IUser x) => { v = x; }); var order = new AuthOrder { AuthUser = authUser, Callback = callback, }; @this.Publish(order); return(v); }
private void OnAddToIgnoreList() { if (!RecordInfoList.Any()) { return; } CaptureServiceConfiguration.AddProcessToIgnoreList(SelectedRecordInfo.GameName); _updateProcessIgnoreListEvent.Publish(new ViewMessages.UpdateProcessIgnoreList()); SelectedRecordInfo = null; RecordInfoList.Clear(); LoadRecordList(); }
private async Task <Site> InitializeSiteAsync(CancellationToken ct) { try { Debug.Assert(_Site == null); var s = await _SessionService.CreateSiteAsync(_Model.ApiEndpoint); ct.ThrowIfCancellationRequested(); Debug.Assert(_Site == null); _Site = s; PullSiteInfo(); // Publish events. SiteRefreshedEvent.Publish(); AccountRefreshedEvent.Publish(); return(_Site); } finally { _GetSiteTaskCts.Dispose(); _GetSiteTaskCts = null; _GetSiteTask = null; } }
private void OnDeleteRecordFile() { if (!RecordInfoList.Any()) { return; } try { if (_selectedRecordings?.Count > 1) { _recordDeleteStreamActive = false; foreach (var item in _selectedRecordings) { File.Delete(item.FullPath); } _ = _recordObserver.RecordingFileWatcher .WaitForChanged(WatcherChangeTypes.Deleted, 1000); _recordDeleteStreamActive = true; _recordDeleteSubStream.OnNext(null); } else { File.Delete(SelectedRecordInfo.FullPath); } SelectedRecordInfo = null; _selectedRecordings = null; ResetInfoEditBoxes(); _updateSessionEvent.Publish(new ViewMessages.UpdateSession(null, null)); } catch { } }
private void OnSelectObeservedFolder() { var dialog = new CommonOpenFileDialog { IsFolderPicker = true }; CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { _appConfiguration.ObservedDirectory = dialog.FileName; _recordDirectoryObserver.UpdateObservedDirectory(dialog.FileName); ObservedDirectory = dialog.FileName; _updateObservedFolder.Publish(new AppMessages.UpdateObservedDirectory(dialog.FileName)); } }
public static IEnumerable <TReturn> Get <TReturn>(this PubSubEvent <GetOrder <TReturn> > @this, Func <TReturn, bool> predicate) { var v = Enumerable.Empty <TReturn>(); var isCallback = false; var callback = Act.New((IEnumerable <TReturn> x) => { v = x; isCallback = true; }); var order = new GetOrder <TReturn> { Callback = callback, Predicate = predicate }; @this.Publish(order); return (isCallback ? v : Enumerable.Empty <TReturn>()); }
private void OnMouseDown() => _setFileRecordInfoExternalEvent .Publish(new ViewMessages .SetFileRecordInfoExternal(WrappedRecordInfo.FileRecordInfo));
private void OnCancelEditingDialog() { IsEditingDialogOpen = false; _hideOverlayEvent.Publish(new ViewMessages.HideOverlay()); }
public void Publish(TPayload payload) { var regionPayload = GetRegionEventPayload(payload); pubSubEvent.Publish(regionPayload); }
public void Publish(T args) { _parent._publishedEvents.Enqueue(args); _event.Publish(args); }