public NotificationsPaneViewModel(INotificationApplicationService neuronApplicationService = null, INeuronQueryClient neuronGraphQueryClient = null, IExtendedSelectionService selectionService = null, IStatusService statusService = null, IDialogService dialogService = null) { this.notificationApplicationService = neuronApplicationService ?? Locator.Current.GetService <INotificationApplicationService>(); this.neuronGraphQueryClient = neuronGraphQueryClient ?? Locator.Current.GetService <INeuronQueryClient>(); this.selectionService = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Select.ToString()); this.statusService = statusService ?? Locator.Current.GetService <IStatusService>(); this.dialogService = dialogService ?? Locator.Current.GetService <IDialogService>(); var selector = this.WhenPropertyChanged(p => p.SelectedNotification) .Where(p => p != null) .Subscribe(x => { this.selectionService.SetSelectedComponents(new object[] { x.Value }); if (x.Value != null && Array.IndexOf(new string[] { EventTypeNames.NeuronCreated.ToString(), EventTypeNames.NeuronTagChanged.ToString() }, x.Value.Type) > -1) { this.Target = NotificationsPaneViewModel.ConvertNotificationViewModelToEditorNeuron(x.Value); } }); this.statusService.WhenPropertyChanged(s => s.Message) .Subscribe(s => this.StatusMessage = s.Sender.Message); this.LoadCommand = ReactiveCommand.Create(async() => await this.OnLoadClicked()); var canMore = this.WhenAnyValue <NotificationsPaneViewModel, bool, NotificationLog>(x => x.NotificationLog, nl => nl != null && nl.PreviousNotificationLogId != null); this.MoreCommand = ReactiveCommand.Create(async() => await this.OnMoreClicked(), canMore); this.SetRegionCommand = ReactiveCommand.Create <object>(async(parameter) => await this.OnSetRegionIdClicked(parameter)); this.Loading = false; this.IconSourcePath = @"pack://application:,,,/d23-wpf;component/images/notification.ico"; }
public NeuronTreePaneViewModel(INeuronApplicationService neuronApplicationService = null, INeuronQueryService neuronQueryService = null, INotificationApplicationService notificationApplicationService = null, IStatusService statusService = null, IDialogService dialogService = null, IOriginService originService = null) { this.dialogService = dialogService ?? Locator.Current.GetService <IDialogService>(); this.neuronApplicationService = neuronApplicationService ?? Locator.Current.GetService <INeuronApplicationService>(); this.neuronQueryService = neuronQueryService ?? Locator.Current.GetService <INeuronQueryService>(); this.notificationApplicationService = notificationApplicationService ?? Locator.Current.GetService <INotificationApplicationService>(); this.statusService = statusService ?? Locator.Current.GetService <IStatusService>(); this.originService = originService ?? Locator.Current.GetService <IOriginService>(); this.statusService.WhenPropertyChanged(s => s.Message) .Subscribe(s => this.StatusMessage = s.Sender.Message); bool DefaultPredicate(Node <Neuron, int> node) => node.IsRoot; var cache = new SourceCache <Neuron, int>(x => x.UIId); this.AddCommand = ReactiveCommand.Create <object>(async(parameter) => await this.OnAddClicked(cache, parameter)); this.SetRegionCommand = ReactiveCommand.Create <object>(async(parameter) => await this.OnSetRegionIdClicked(parameter)); this.ReloadCommand = ReactiveCommand.Create(async() => await this.OnReloadClicked(cache)); this.cleanUp = cache.AsObservableCache().Connect() .TransformToTree(child => child.CentralUIId, Observable.Return((Func <Node <Neuron, int>, bool>)DefaultPredicate)) .Transform(e => e.Item.Type == RelativeType.Postsynaptic ? (NeuronViewModelBase)(new PostsynapticViewModel(this, e.Item.Tag, e, cache)) : (NeuronViewModelBase)(new PresynapticViewModel(this, e.Item.Tag, e, cache))) .Bind(out this.children) .DisposeMany() .Subscribe(); this.Target = null; this.Loading = false; this.IconSourcePath = @"pack://application:,,,/d23-wpf;component/images/hierarchy.ico"; }
public NotificationModule(INotificationApplicationService notificationService) : base("/nuclei/d23/notifications") { this.Get("/", async(parameters) => new TextResponse(JsonConvert.SerializeObject( await notificationService.GetNotificationLog(string.Empty) )) ); this.Get("/{logid}", async(parameters) => new TextResponse(JsonConvert.SerializeObject( await notificationService.GetNotificationLog(parameters.logid) )) ); }
public NotificationModule(INotificationApplicationService notificationService) : base("/eventsourcing/notifications") { this.Get("/", async(parameters) => this.ProcessLog( await notificationService.GetCurrentNotificationLog(), this.Request.Url.ToString() ) ); this.Get("/{logid}", async(parameters) => this.ProcessLog( await notificationService.GetNotificationLog(parameters.logid), this.Request.Url.ToString().Substring( 0, this.Request.Url.ToString().Length - parameters.logid.ToString().Length - 1 ) ) ); }
internal async static Task <Neuron> CreateNeuron(Func <Task <string> > tagRetriever, object owner, IDialogService dialogService, INeuronQueryService neuronQueryService, INeuronApplicationService neuronApplicationService, INotificationApplicationService notificationApplicationService, IStatusService statusService, string avatarUrl, string regionId) { Neuron result = null; await Neurons.Helper.SetStatusOnComplete(async() => { bool stat = false; bool addingOwner = false; var shouldAddOwner = (await notificationApplicationService.GetNotificationLog(avatarUrl, string.Empty)).NotificationList.Count == 0; if (shouldAddOwner && (await dialogService.ShowDialogYesNo("This Avatar needs to be initialized with an Owner Neuron. Do you wish to continue by creating one?", owner, out DialogResult yesno)).GetValueOrDefault()) { addingOwner = true; } if (!shouldAddOwner || addingOwner) { string tag = await tagRetriever(); if (!string.IsNullOrEmpty(tag) && await Neurons.Helper.PromptSimilarExists(neuronQueryService, dialogService, avatarUrl, owner, tag) ) { Neuron n = new Neuron { Tag = tag, UIId = Guid.NewGuid().GetHashCode(), Id = Guid.NewGuid().ToString(), Version = 1, }; await neuronApplicationService.CreateNeuron( avatarUrl, n.Id, n.Tag, regionId ); result = n; stat = true; } } return(stat); }, "Neuron created successfully.", statusService, "Neuron creation cancelled." ); return(result); }
public NotificationController(INotificationApplicationService notificationApplicationService) { _notificationApplicationService = notificationApplicationService; }
public EditorToolViewModel(Workspace workspace = null, INeuronApplicationService neuronApplicationService = null, INeuronQueryService neuronQueryService = null, INotificationApplicationService notificationApplicationService = null, ITerminalApplicationService terminalApplicationService = null, IStatusService statusService = null, IDialogService dialogService = null) : base("Editor") { this.dialogService = dialogService ?? Locator.Current.GetService <IDialogService>(); this.neuronApplicationService = neuronApplicationService ?? Locator.Current.GetService <INeuronApplicationService>(); this.neuronQueryService = neuronQueryService ?? Locator.Current.GetService <INeuronQueryService>(); this.notificationApplicationService = notificationApplicationService ?? Locator.Current.GetService <INotificationApplicationService>(); this.terminalApplicationService = terminalApplicationService ?? Locator.Current.GetService <ITerminalApplicationService>(); this.statusService = statusService ?? Locator.Current.GetService <IStatusService>(); this.workspace = workspace ?? Locator.Current.GetService <Workspace>(); this.EditorState = EditorStateValue.Browse; this.TargetDraft = new EditorNeuronViewModel(); this.Target = null; this.InitDetailsSection(); this.NewCommand = ReactiveCommand.Create( () => this.OnNewClicked(), this.WhenAnyValue( vm => vm.EditorState, vm => vm.AvatarUrl, vm => vm.RegionName, (esv, au, ln) => esv == EditorStateValue.Browse && !string.IsNullOrEmpty(au) && !string.IsNullOrEmpty(ln) ) ); this.SaveCommand = ReactiveCommand.Create <object>( async(parameter) => await this.OnSaveClicked(parameter), Observable.CombineLatest( this.WhenAnyValue( vm => vm.EditorState, es => es == EditorStateValue.New || es == EditorStateValue.Edit ), this.IsValid(), (esValid, dataValid) => esValid && dataValid ) ); this.CancelCommand = ReactiveCommand.Create( () => this.OnCancelClicked(), this.WhenAnyValue( vm => vm.EditorState, es => es == EditorStateValue.New || es == EditorStateValue.Edit ) ); this.EditCommand = ReactiveCommand.Create( () => this.OnEditClicked(), this.WhenAnyValue( vm => vm.EditorState, vm => vm.AvatarUrl, vm => vm.RegionName, vm => vm.Target, (esv, au, ln, t) => esv == EditorStateValue.Browse && !string.IsNullOrEmpty(au) && !string.IsNullOrEmpty(ln) && t != null ) ); this.SelectCommand = ReactiveCommand.Create <object>( async(parameter) => await this.OnSelectClicked(parameter), this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, (es, nm) => es == EditorStateValue.New && nm == NewModeValue.Link ) ); this.WhenAnyValue(vm => vm.statusService.Message) .Subscribe(m => this.StatusMessage = m); this.WhenAnyValue(vm => vm.workspace.ActiveDocument) .Where(ad => ad is IAvatarViewer) .Subscribe(ad => this.AvatarViewer = (IAvatarViewer)ad); (this).WhenAnyValue(vm => vm.AvatarViewer) .Where(av => this.EditorState == EditorStateValue.Browse) .Subscribe(av => this.UpdateFromViewer(av)); this.WhenAnyValue(vm => vm.AvatarViewer.Target) .Where(lt => this.EditorState == EditorStateValue.Browse) .Subscribe(lt => this.Target = lt); this.WhenAnyValue(vm => vm.Target) .Subscribe(t => { if (t == null) { this.TargetDraft.Init(); } else { this.TargetDraft.Id = t.Id; this.TargetDraft.Tag = t.Tag; this.TargetDraft.Effect = t.Effect; this.TargetDraft.Strength = t.Strength; this.TargetDraft.RelativeType = t.RelativeType; this.TargetDraft.RegionId = t.RegionId; this.TargetDraft.RegionName = t.RegionName; this.TargetDraft.Version = t.Version; } }); this.WhenAnyValue(vm => vm.TargetDraft.RelativeType) .Where(rt => rt == null) .Subscribe(rt => this.TargetDraft.Effect = (NeurotransmitterEffect?)(this.TargetDraft.Strength = null)); this.WhenAnyValue(vm => vm.AvatarViewer.AvatarUrl) .Where(au => this.EditorState == EditorStateValue.Browse) .Subscribe(au => this.AvatarUrl = au); this.WhenAnyValue(vm => vm.AvatarViewer.RegionId) .Where(li => this.EditorState == EditorStateValue.Browse) .Subscribe(li => this.RegionId = li); this.WhenAnyValue(vm => vm.AvatarViewer.RegionName) .Where(ln => this.EditorState == EditorStateValue.Browse) .Subscribe(ln => this.RegionName = ln); this.WhenAnyValue(vm => vm.EditorState, vm => vm.TargetDraft.RelativeType) .Select(x => x.Item1 == EditorStateValue.New && x.Item2 != null) .ToPropertyEx(this, vm => vm.AreTerminalParametersEditable); this.WhenAnyValue(vm => vm.EditorState, vm => vm.NewMode) .Select(x => x.Item2 != ViewModels.NewModeValue.NotSet && x.Item2 != ViewModels.NewModeValue.Neuron && x.Item1 == ViewModels.EditorStateValue.New) .ToPropertyEx(this, vm => vm.IsRelativeTypeEditable); this.WhenAnyValue(vm => vm.EditorState) .Where(es => es == EditorStateValue.Browse) .Subscribe(es => { this.NewModes = new NewModeValue[0]; this.NewMode = NewModeValue.NotSet; this.UpdateFromViewer(this.AvatarViewer); }); this.WhenAnyValue(vm => vm.NewMode) .Subscribe(nm => { if (nm == NewModeValue.Neuron) { this.TargetDraft.RelativeType = null; } if (nm != NewModeValue.Link) { this.TargetDraft.LinkCandidates = null; } else { this.TargetDraft.Tag = string.Empty; } }); this.NewEditTagRule = this.ValidationRule( _ => this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, vm => vm.TargetDraft.Tag, (es, nm, t) => es == EditorStateValue.Browse || nm == NewModeValue.Link || !string.IsNullOrWhiteSpace(t) ), (vm, state) => !state ? "Tag must neither be null, empty, nor consist of white-space characters." : string.Empty ); this.NewLinkLinkCandidatesRule = this.ValidationRule( _ => this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, vm => vm.TargetDraft.LinkCandidates, (es, nm, lcs) => es != EditorStateValue.New || nm != NewModeValue.Link || (lcs != null && lcs.Count() > 0) ), (vm, state) => !state ? "Must select at least one Link Candidate." : string.Empty ); this.NewRelativeTypeRule = this.ValidationRule( _ => this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, vm => vm.TargetDraft.RelativeType, (es, nm, rt) => es != EditorStateValue.New || nm == NewModeValue.Neuron || (rt != null && rt != RelativeType.NotSet) ), (vm, state) => !state ? "Relative Type must be either Postsynaptic or Presynaptic." : string.Empty ); this.RelativeEffectRule = this.ValidationRule( _ => this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, vm => vm.TargetDraft.Effect, (es, nm, e) => es != EditorStateValue.New || nm == NewModeValue.Neuron || (e != null && e != NeurotransmitterEffect.NotSet) ), (vm, state) => !state ? "Effect must be either Excite or Inhibit." : string.Empty ); this.RelativeStrengthRule = this.ValidationRule( _ => this.WhenAnyValue( vm => vm.EditorState, vm => vm.NewMode, vm => vm.TargetDraft.Strength, (es, nm, s) => es != EditorStateValue.New || nm == NewModeValue.Neuron || (s != null && s > 0) ), (vm, state) => !state ? "Strength must be greater than zero." : string.Empty ); // TODO: this.IconSourcePath = @"pack://application:,,,/d23-wpf;component/images/wrench.ico"; }