public PostsynapticViewModel(IAvatarViewer host, string tag, Node <Neuron, int> node, SourceCache <Neuron, int> cache, NeuronViewModelBase parent = null,
                              INeuronApplicationService neuronApplicationService = null, INeuronQueryService neuronQueryService = null, ITerminalApplicationService terminalApplicationService = null,
                              IExtendedSelectionService selectionService         = null) :
     base(host, node, cache, parent, neuronApplicationService, neuronQueryService, terminalApplicationService, selectionService)
 {
     this.Tag = tag;
 }
Пример #2
0
        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";
        }
Пример #3
0
        public PropertyGridViewModel(IExtendedSelectionService selectionService = null) : base("Properties")
        {
            this.selectionService = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Select.ToString());

            this.selectionService.WhenPropertyChanged(a => a.SelectedComponents)
            .Subscribe(p => this.SelectedObject = p.Sender.PrimarySelection);

            this.IconSourcePath = @"pack://application:,,,/d23-wpf;component/images/wrench.ico";
        }
Пример #4
0
        public PropertyGridViewModel(IExtendedSelectionService selectionService = null) : base("Properties")
        {
            this.selectionService = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>();

            this.selectionService.WhenPropertyChanged(a => a.SelectedComponents)
            .Subscribe(p =>
            {
                this.SelectedObject = p.Sender.PrimarySelection;
            }
                       );
        }
Пример #5
0
        public NeuronGraphViewModel(IExtendedSelectionService selectionService = null, IExtendedSelectionService highlightService = null) : base("Graph")
        {
            this.selectionService = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Select.ToString());
            this.highlightService = highlightService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Highlight.ToString());

            this.LayoutOptions = new string[] { "Top to bottom", "Left to right", "Bottom to top", "Right to left" };

            this.SelectCommand = ReactiveCommand.Create(() => this.UpdateHighlightService());

            this.selectionService.WhenPropertyChanged(a => a.SelectedComponents)
            .Subscribe(p =>
            {
                if (p.Sender.PrimarySelection is NeuronViewModelBase)
                {
                    this.ExternallySelectedNeuron = (NeuronViewModelBase)p.Sender.PrimarySelection;
                    this.InternallySelectNeuronAndTerminal(null, null);

                    this.UpdateHighlightService();
                }
            });

            this.IconSourcePath = @"pack://application:,,,/d23-wpf;component/images/graph.ico";
        }
Пример #6
0
        protected NeuronViewModelBase(Node <NeuronDto, int> node, SourceCache <NeuronDto, int> cache, NeuronViewModelBase parent = null, IExtendedSelectionService selectionService = null)
        {
            this.Id       = node.Key;
            this.NeuronId = node.Item.NeuronId;
            this.Data     = node.Item.Data;
            this.Parent   = parent;
            this.Dto      = node.Item;

            this.ReloadCommand          = ReactiveCommand.Create(() => this.neuronService.Reload(cache, this.Dto));
            this.AddPostsynapticCommand = ReactiveCommand.Create(() => this.neuronService.AddPostsynaptic(cache, this.Dto));
            this.AddPresynapticCommand  = ReactiveCommand.Create(() => this.neuronService.AddPresynaptic(cache, this.Dto));
            this.DeleteCommand          = ReactiveCommand.Create(() => this.neuronService.Delete(cache, this.Dto));

            this.neuronService    = neuronService ?? Locator.Current.GetService <INeuronService>();
            this.selectionService = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>();

            var childrenLoader = new Lazy <IDisposable>(() => node.Children.Connect()
                                                        .Transform(e =>
                                                                   e.Item.Type == ChildType.Postsynaptic ?
                                                                   (NeuronViewModelBase)(new PostsynapticViewModel(e.Item.Data, e, cache, this)) :
                                                                   (NeuronViewModelBase)(new PresynapticViewModel(e.Item.Data, e, cache, this)))
                                                        .Bind(out this.children)
                                                        .DisposeMany()
                                                        .Subscribe()
                                                        );

            var shouldExpand = node.IsRoot ?
                               Observable.Return(true) :
                               Parent.Value.WhenValueChanged(t => t.IsExpanded);

            var expander = shouldExpand
                           .Where(isExpanded => isExpanded)
                           .Take(1)
                           .Subscribe(_ =>
            {
                var x = childrenLoader.Value;
            });

            var childrenCount = node.Children.CountChanged
                                .Select(count =>
            {
                if (count == 0)
                {
                    return("0 Synapses");
                }
                else
                {
                    return($"{node.Children.Items.Count(n => n.Item.Type == ChildType.Postsynaptic)} Postsynaptic; " +
                           $"{node.Children.Items.Count(n => n.Item.Type == ChildType.Presynaptic)} Presynaptic");
                }
            })
                                .Subscribe(text => this.ChildrenCountText = text);

            var changeData = this.WhenPropertyChanged(p => p.Data, false)
                             .Subscribe(x => this.neuronService.ChangeData(cache, this.Dto, x.Value));

            var selector = this.WhenPropertyChanged(p => p.IsSelected)
                           .Where(p => p.Value)
                           .Subscribe(x => this.selectionService.SetSelectedComponents(new object[] { x.Sender }));

            this.cleanUp = Disposable.Create(() =>
            {
                expander.Dispose();
                childrenCount.Dispose();
                if (childrenLoader.IsValueCreated)
                {
                    childrenLoader.Value.Dispose();
                }
                selector.Dispose();
            });
        }
Пример #7
0
 public PresynapticViewModel(string data, Node <NeuronDto, int> node, SourceCache <NeuronDto, int> cache, NeuronViewModelBase parent = null, IExtendedSelectionService selectionService = null) : base(node, cache, parent, selectionService)
 {
     this.Data = data;
 }
Пример #8
0
        protected NeuronViewModelBase(IAvatarViewer host, Node <Neuron, int> node, SourceCache <Neuron, int> cache, NeuronViewModelBase parent = null, INeuronApplicationService neuronApplicationService = null,
                                      INeuronQueryService neuronQueryService = null, ITerminalApplicationService terminalApplicationService = null, IExtendedSelectionService selectionService = null, IExtendedSelectionService highlightService = null, IStatusService statusService = null, IDialogService dialogService = null)
        {
            this.host   = host;
            this.Id     = node.Key;
            this.Parent = parent;
            this.SetNeuron(node.Item);

            this.ReloadCommand       = ReactiveCommand.Create(async() => await this.OnReload(cache));
            this.ReloadExpandCommand = ReactiveCommand.Create(async() =>
            {
                await this.OnReload(cache);
                this.IsExpanded = true;
            });
            this.AddPostsynapticCommand = ReactiveCommand.Create <object>(async(parameter) => await this.OnAddPostsynaptic(cache, parameter));
            this.AddPresynapticCommand  = ReactiveCommand.Create <object>(async(parameter) => await this.OnAddPresynaptic(cache, parameter));
            this.DeleteCommand          = ReactiveCommand.Create <object>(async(parameter) => await this.OnDeleteClicked(cache, parameter));

            this.neuronApplicationService   = neuronApplicationService ?? Locator.Current.GetService <INeuronApplicationService>();
            this.neuronQueryService         = neuronQueryService ?? Locator.Current.GetService <INeuronQueryService>();
            this.terminalApplicationService = terminalApplicationService ?? Locator.Current.GetService <ITerminalApplicationService>();
            this.selectionService           = selectionService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Select.ToString());
            this.highlightService           = highlightService ?? Locator.Current.GetService <IExtendedSelectionService>(SelectionContract.Highlight.ToString());
            this.statusService = statusService ?? Locator.Current.GetService <IStatusService>();
            this.dialogService = dialogService ?? Locator.Current.GetService <IDialogService>();

            var childrenLoader = new Lazy <IDisposable>(() => node.Children.Connect()
                                                        .Transform(e =>
                                                                   e.Item.Type == RelativeType.Postsynaptic ?
                                                                   (NeuronViewModelBase)(new PostsynapticViewModel(this.host, e.Item.Tag, e, cache, this)) :
                                                                   (NeuronViewModelBase)(new PresynapticViewModel(this.host, e.Item.Tag, e, cache, this)))
                                                        .Bind(out this.children)
                                                        .DisposeMany()
                                                        .Subscribe()
                                                        );

            var shouldExpand = node.IsRoot ?
                               Observable.Return(true) :
                               Parent.Value.WhenValueChanged(t => t.IsExpanded);

            var expander = shouldExpand
                           .Where(isExpanded => isExpanded)
                           .Take(1)
                           .Subscribe(_ =>
            {
                var x = childrenLoader.Value;
            });

            var childrenCount = node.Children.CountChanged
                                .Select(count =>
            {
                if (count == 0)
                {
                    return("0 Synapses");
                }
                else
                {
                    return($"{node.Children.Items.Count(n => n.Item.Type == RelativeType.Postsynaptic)} Postsynaptic; " +
                           $"{node.Children.Items.Count(n => n.Item.Type == RelativeType.Presynaptic)} Presynaptic");
                }
            })
                                .Subscribe(text => this.ChildrenCountText = text);

            var changeTag = this.WhenPropertyChanged(p => p.Tag, false)
                            .Subscribe(async(x) => await this.OnNeuronTagChanged(cache, x));

            var selector = this.WhenPropertyChanged(p => p.IsSelected)
                           .Where(p => p.Value)
                           .Subscribe(x =>
            {
                this.selectionService.SetSelectedComponents(new object[] { x.Sender });
                this.host.Target = NeuronViewModelBase.ConvertNeuronViewModelToEditorNeuron((NeuronViewModelBase)x.Sender);
            });

            var highlighter = this.highlightService.WhenPropertyChanged(a => a.SelectedComponents)
                              .Subscribe(p =>
            {
                if (p.Sender.SelectedComponents != null)
                {
                    var selection = p.Sender.SelectedComponents.OfType <object>().ToArray();
                    if (selection.Count() > 0 && selection[0] is string)
                    {
                        if (selection.Count() < 2)
                        {
                            this.IsHighlighted = this.NeuronId == p.Sender.PrimarySelection.ToString();
                        }
                        else
                        {
                            this.IsHighlighted =
                                this.NeuronId == p.Sender.PrimarySelection.ToString() &&
                                this.TerminalId == selection[1].ToString();
                        }
                    }
                }
            }
                                         );

            this.cleanUp = Disposable.Create(() =>
            {
                expander.Dispose();
                childrenCount.Dispose();
                if (childrenLoader.IsValueCreated)
                {
                    childrenLoader.Value.Dispose();
                }
                changeTag.Dispose();
                selector.Dispose();
                highlighter.Dispose();
            });
        }