Beispiel #1
0
        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
     });
 }
Beispiel #11
0
        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());
            }
        }
Beispiel #12
0
 /// <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));
     }
 }
Beispiel #15
0
        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());
        }
Beispiel #17
0
        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);
        }
Beispiel #18
0
 /// <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();
 }
Beispiel #19
0
        private static void Navigate(PubSubEvent <NavigateOrder> @this, string viewName, IDictionary <string, object> prms)
        {
            var order = new NavigateOrder
            {
                ViewName = viewName,
                Prms     = prms,
            };

            @this.Publish(order);
        }
Beispiel #20
0
        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());
        }
Beispiel #21
0
        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();
        }
Beispiel #23
0
        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 { }
        }
Beispiel #25
0
        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));
            }
        }
Beispiel #26
0
        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());
 }
Beispiel #29
0
        public void Publish(TPayload payload)
        {
            var regionPayload = GetRegionEventPayload(payload);

            pubSubEvent.Publish(regionPayload);
        }
Beispiel #30
0
 public void Publish(T args)
 {
     _parent._publishedEvents.Enqueue(args);
     _event.Publish(args);
 }