Inheritance: ToolViewModel, IExtension, IWatchList
示例#1
0
        public ObjectValueViewModel(WatchListViewModel watchList, ObjectValue model)
            : base(model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            this.watchList = watchList;

            model.ValueChanged += (sender, e) =>
            {
                this.RaisePropertyChanged(nameof(Value));
            };

            DeleteCommand = ReactiveCommand.Create(() => IoC.Get <IWatchList>().Remove(Model));

            if (model.HasChildren)
            {
                children = new ObservableCollection <ObjectValueViewModel>();
                children.Add(DummyChild);
            }

            AddWatchPointCommand = ReactiveCommand.Create(() =>
            {
                IoC.Get <IDebugManager2>().Breakpoints.Add(new WatchPoint(Model.Name));
            });

            DisplayFormatCommand = ReactiveCommand.Create <string>(s =>
            {
                /*var format = s as string;
                 *
                 *              switch (format)
                 *              {
                 *                      case "hex":
                 *                              await Model.SetFormat(WatchFormat.Hexadecimal);
                 *                              break;
                 *
                 *                      case "dec":
                 *                              await Model.SetFormat(WatchFormat.Decimal);
                 *                              break;
                 *
                 *                      case "bin":
                 *                              await Model.SetFormat(WatchFormat.Binary);
                 *                              break;
                 *
                 *                      case "nat":
                 *                              await Model.SetFormat(WatchFormat.Natural);
                 *                              break;
                 *
                 *                      case "oct":
                 *                              await Model.SetFormat(WatchFormat.Octal);
                 *                              break;
                 * }
                 *
                 *              await Invalidate(debugger);*/
            });
        }
示例#2
0
        public WatchViewModel(WatchListViewModel watchList, IDebugger debugger, VariableObject model)
            : base(model)
        {
            this.watchList = watchList;
            this.debugger  = debugger;

            Value = model.Value;

            DeleteCommand = ReactiveCommand.Create();
            DeleteCommand.Subscribe(_ => { IoC.Get <IWatchList>().RemoveWatch(this); });


            DisplayFormatCommand = ReactiveCommand.Create();
            DisplayFormatCommand.Subscribe(async s =>
            {
                var format = s as string;

                switch (format)
                {
                case "hex":
                    await Model.SetFormat(WatchFormat.Hexadecimal);
                    break;

                case "dec":
                    await Model.SetFormat(WatchFormat.Decimal);
                    break;

                case "bin":
                    await Model.SetFormat(WatchFormat.Binary);
                    break;

                case "nat":
                    await Model.SetFormat(WatchFormat.Natural);
                    break;

                case "oct":
                    await Model.SetFormat(WatchFormat.Octal);
                    break;
                }

                await Invalidate(debugger);
            });
        }