Пример #1
0
        public void CustomizeView(Watch nodeModel, NodeView nodeView)
        {
            this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel;
            this.watch           = nodeModel;
            this.syncContext     = new DispatcherSynchronizationContext(nodeView.Dispatcher);

            var watchTree = new WatchTree();

            watchTree.BorderThickness = new Thickness(1, 1, 1, 1);
            watchTree.BorderBrush     = new SolidColorBrush(Color.FromRgb(220, 220, 220));

            watchTree.SetWatchNodeProperties();

            // make empty watchViewModel
            rootWatchViewModel = new WatchViewModel(dynamoViewModel.BackgroundPreviewViewModel.AddLabelForPath);

            nodeView.PresentationGrid.Children.Add(watchTree);
            nodeView.PresentationGrid.Visibility = Visibility.Visible;
            // disable preview control
            nodeView.TogglePreviewControlAllowance();

            Bind(watchTree, nodeView);

            Subscribe();
            ResetWatch();
        }
Пример #2
0
        private void HandleItemChanged(TreeViewItem tvi, WatchViewModel node)
        {
            if (tvi == null || node == null)
            {
                return;
            }

            // checks to see if the node to be selected is the same as the currently selected node
            // if so, then de-select the currently selected node.

            if (node == prevWatchViewModel)
            {
                this.prevWatchViewModel = null;
                if (tvi.IsSelected)
                {
                    tvi.IsSelected = false;
                    tvi.Focus();
                }
            }
            else
            {
                this.prevWatchViewModel = node;
            }

            if (_vm.FindNodeForPathCommand.CanExecute(node.Path))
            {
                _vm.FindNodeForPathCommand.Execute(node.Path);
            }
        }
Пример #3
0
        public void WatchLiterals()
        {
            var model = Controller.DynamoModel;

            string openPath = Path.Combine(GetTestDirectory(), @"core\watch\WatchLiterals.dyn");

            model.Open(openPath);

            Assert.DoesNotThrow(() => Controller.RunExpression(null));

            dynSettings.Controller.PreferenceSettings.NumberFormat = "f0";

            // get count node
            Watch watchNumber  = model.CurrentWorkspace.NodeFromWorkspace("eed0b6aa-0d82-44c5-aab6-2bf131044940") as Watch;
            Watch watchBoolean = model.CurrentWorkspace.NodeFromWorkspace("8c5a87db-2d6a-4d3c-8c01-5ff326aef321") as Watch;
            Watch watchPoint   = model.CurrentWorkspace.NodeFromWorkspace("f1581148-9318-40fa-9402-61557255162a") as Watch;

            WatchViewModel node = watchNumber.GetWatchNode();

            Assert.AreEqual("5", node.NodeLabel);

            node = watchBoolean.GetWatchNode();
            Assert.AreEqual("False", node.NodeLabel);

            node = watchPoint.GetWatchNode();
            var pointNode = model.CurrentWorkspace.NodeFromWorkspace("64f10a92-3297-448b-be7a-03dbe1e8a90a");

            //Validate using the point node connected to watch node.
            AssertWatchContent(node, pointNode);
        }
Пример #4
0
        /// <summary>
        /// Update the watch content from the given MirrorData and returns WatchNode.
        /// </summary>
        /// <param name="data">The Mirror data for which watch content is needed.</param>
        /// <param name="prefix">Prefix string used for formatting the content.</param>
        /// <param name="index">Index of input data if it is a part of a collection.</param>
        /// <param name="isListMember">Specifies if this data belongs to a collection.</param>
        /// <returns>WatchNode</returns>
        public WatchViewModel Process(MirrorData data, string path, bool showRawData = true)
        {
            WatchViewModel node = null;

            if (data == null || data.IsNull)
            {
                node = new WatchViewModel(nullString, path);
            }
            else if (data.IsCollection)
            {
                var list = data.GetElements();

                node = new WatchViewModel(list.Count == 0 ? "Empty List" : "List", path, true);

                foreach (var e in list.Select((x, i) => new { Element = x, Index = i }))
                {
                    node.Children.Add(Process(e.Element, path + ":" + e.Index, showRawData));
                }
            }
            else
            {
                node = dynSettings.Controller.WatchHandler.Process(data as dynamic, path, showRawData);
            }

            return(node ?? (new WatchViewModel("null", path)));
        }
Пример #5
0
        private void RefreshExpandedDisplay()
        {
            // The preview control will not have its content refreshed unless
            // the content is null. In order to perform real refresh, new data
            // source needs to be rebound to the preview control by calling
            // BindToDataSource method.
            //
            if (this.cachedLargeContent != null)
            {
                return;
            }

            if (largeContentGrid.Children.Count <= 0)
            {
                var newWatchTree = new WatchTree();
                newWatchTree.DataContext = new WatchViewModel();
                largeContentGrid.Children.Add(newWatchTree);
            }

            var watchTree       = largeContentGrid.Children[0] as WatchTree;
            var rootDataContext = watchTree.DataContext as WatchViewModel;

            // Associate the data context to the view before binding.
            cachedLargeContent = Watch.Process(mirrorData, string.Empty, false);
            rootDataContext.Children.Add(cachedLargeContent);

            // Establish data binding between data context and the view.
            watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty,
                                           new Binding("Children")
            {
                Mode   = BindingMode.TwoWay,
                Source = rootDataContext
            });
        }
Пример #6
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(!list.Any() ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }
            else if (data.IsPointer && data.Data is DesignScript.Builtin.Dictionary)
            {
                var dict   = data.Data as DesignScript.Builtin.Dictionary;
                var keys   = dict.Keys;
                var values = dict.Values;

                var node = new WatchViewModel(keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true);

                foreach (var e in keys.Zip(values, (key, value) => new { key, value }))
                {
                    node.Children.Add(ProcessThing(e.value, runtimeCore, tag + ":" + e.key.ToString(), showRawData, callback));
                }

                return(node);
            }

            if (data.Data is Enum)
            {
                return(new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry));
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(Resources.NullString, tag, RequestSelectGeometry));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, runtimeCore, tag, showRawData));
        }
Пример #7
0
        /// <summary>
        ///     Obtain the expanded preview values for this control.  Must not be called from
        ///     Scheduler thread or this could cause a live-lock.
        /// </summary>
        ///
        private void RefreshExpandedDisplay(Action refreshDisplay)
        {
            // The preview control will not have its content refreshed unless
            // the content is null. In order to perform real refresh, new data
            // source needs to be rebound to the preview control by calling
            // BindToDataSource method.
            //
            if (this.cachedLargeContent != null)
            {
                // If there are cached contents, simply update the UI and return
                if (refreshDisplay != null)
                {
                    refreshDisplay();
                }
                return;
            }

            WatchViewModel newViewModel = null;

            RunOnSchedulerSync(
                () =>
            {
                newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData(
                    mirrorData, null, string.Empty, false);
            },
                (m) =>
            {
                if (largeContentGrid.Children.Count == 0)
                {
                    var tree = new WatchTree
                    {
                        Margin      = (System.Windows.Thickness) this.Resources["PreviewContentMargin"],
                        DataContext = new WatchViewModel()
                    };
                    largeContentGrid.Children.Add(tree);
                }

                var watchTree       = largeContentGrid.Children[0] as WatchTree;
                var rootDataContext = watchTree.DataContext as WatchViewModel;

                cachedLargeContent = newViewModel;

                rootDataContext.Children.Clear();
                rootDataContext.Children.Add(cachedLargeContent);

                watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty,
                                               new Binding("Children")
                {
                    Mode   = BindingMode.TwoWay,
                    Source = rootDataContext
                });
                if (refreshDisplay != null)
                {
                    refreshDisplay();
                }
            }
                );
        }
Пример #8
0
        public async Task <IActionResult> Watched([FromBody] WatchViewModel watch)
        {
            var news = await db.Posts.FirstOrDefaultAsync(x => x.Id == watch.Id);

            news.watch++;
            await db.SaveChangesAsync();

            return(Json(Ok()));
        }
Пример #9
0
        /// <summary>
        /// Validates the watch content with the source nodes output.
        /// </summary>
        /// <param name="watch">WatchViewModel of the watch node</param>
        /// <param name="sourceNode">NodeModel for source to watch node</param>
        public void AssertWatchContent(WatchViewModel watch, NodeModel sourceNode)
        {
            string        var    = sourceNode.GetAstIdentifierForOutputIndex(0).Name;
            RuntimeMirror mirror = null;

            Assert.DoesNotThrow(() => mirror = ViewModel.Model.EngineController.GetMirror(var));
            Assert.IsNotNull(mirror);
            AssertWatchContent(watch, mirror.GetData());
        }
Пример #10
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            this.dynamoViewModel = nodeUI.ViewModel.DynamoViewModel;
            watchTree            = new WatchTree();

            // MAGN-2446: Fixes the maximum width/height of watch node so it won't
            // go too crazy on us. Note that this is only applied to regular watch
            // node so it won't be limiting the size of image/3D watch nodes.
            //
            nodeUI.PresentationGrid.MaxWidth  = Configurations.MaxWatchNodeWidth;
            nodeUI.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight;
            nodeUI.PresentationGrid.Children.Add(watchTree);
            nodeUI.PresentationGrid.Visibility = Visibility.Visible;

            if (Root == null)
            {
                Root = new WatchViewModel(this.dynamoViewModel.VisualizationManager);
            }

            watchTree.DataContext = Root;

            RequestBindingUnhook += delegate
            {
                BindingOperations.ClearAllBindings(watchTree.treeView1);
            };

            RequestBindingRehook += delegate
            {
                var sourceBinding = new Binding("Children")
                {
                    Mode   = BindingMode.TwoWay,
                    Source = Root,
                };
                watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding);
            };

            var checkedBinding = new Binding("ShowRawData")
            {
                Mode   = BindingMode.TwoWay,
                Source = Root
            };

            var rawDataMenuItem = new MenuItem
            {
                Header      = "Show Raw Data",
                IsCheckable = true,
            };

            rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding);

            nodeUI.MainContextMenu.Items.Add(rawDataMenuItem);

            ((PreferenceSettings)this.Workspace.DynamoModel.PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;

            Root.PropertyChanged += Root_PropertyChanged;
        }
Пример #11
0
        public async Task <IActionResult> Watch(FilterViewModel filter)
        {
            var phones = await db.GetProducts("Watch");

            var model = new WatchViewModel {
                Products = phones, Filter = filter
            };

            return(View(model));
        }
Пример #12
0
        internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData = true)
        {
            var id = element.Id;

            var node = new WatchViewModel(element.ToString(dynSettings.Controller.PreferenceSettings.NumberFormat, CultureInfo.InvariantCulture), tag);

            node.Clicked += () => DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement);
            node.Link     = id.ToString(CultureInfo.InvariantCulture);

            return(node);
        }
Пример #13
0
        public IActionResult Watch(string id)
        {
            var workout   = this.workoutsService.GetWorkoutById(id);
            var viewModel = new WatchViewModel()
            {
                WorkoutName = workout.Name,
                VideoUrl    = workout.VideoUrl,
            };

            return(this.View(viewModel));
        }
    public MainPage()
    {
        InitializeComponent();
        watch = new WatchViewModel();
        watch.GetWatchRows();

        watch.AddWatchRow(132, "green");
        watch.AddWatchRow(123, "red");
        base.DataContext      = watch;
        listWatch.ItemsSource = watch.WatchRows;
    }
Пример #15
0
        private void ResetWatch()
        {
            // When the node has no input connected, the preview should be empty
            // Without doing this, the preview would say "null"
            if (watch.IsPartiallyApplied)
            {
                rootWatchViewModel.Children.Clear();
                rootWatchViewModel.IsCollection = false;
                return;
            }

            // If the node hasn't been evaluated, no need to update the UI
            if (!watch.HasRunOnce)
            {
                return;
            }

            var s = dynamoViewModel.Model.Scheduler;

            WatchViewModel wvm = null;

            // prevent data race by running on scheduler
            var t = new DelegateBasedAsyncTask(s, () =>
            {
                wvm = GetWatchViewModel();
            });

            // then update on the ui thread
            t.ThenPost((_) =>
            {
                //If wvm is not computed successfully then don't post.
                if (wvm == null)
                {
                    return;
                }

                // store in temp variable to silence binding
                var temp = rootWatchViewModel.Children;


                rootWatchViewModel.Children = null;
                temp.Clear();
                temp.Add(wvm);

                // rebind
                rootWatchViewModel.Children = temp;
                rootWatchViewModel.CountNumberOfItems();
                rootWatchViewModel.CountLevels();
                rootWatchViewModel.Children[0].IsTopLevel = true;
            }, syncContext);

            s.ScheduleForExecution(t);
        }
Пример #16
0
        private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (value is DesignScript.Builtin.Dictionary)
            {
                var dict   = value as DesignScript.Builtin.Dictionary;
                var keys   = dict.Keys;
                var values = dict.Values;

                var node = new WatchViewModel(keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true);

                foreach (var e in keys.Zip(values, (key, val) => new { key, val }))
                {
                    node.Children.Add(ProcessThing(e.val, runtimeCore, tag + ":" + e.key.ToString(), showRawData, callback));
                }

                return(node);
            }
            else if (!(value is string) && value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast <dynamic>().ToList();

                var node = new WatchViewModel(list.Count == 0 ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, runtimeCore, tag + ":" + e.idx, showRawData));
                }

                return(node);
            }
            else if (runtimeCore != null && value is StackValue)
            {
                StackValue stackValue  = (StackValue)value;
                string     stringValue = string.Empty;

                if (stackValue.IsFunctionPointer)
                {
                    stringValue = StringUtils.GetStringValue(stackValue, runtimeCore);
                }
                else
                {
                    int typeId = runtimeCore.DSExecutable.TypeSystem.GetType(stackValue);
                    stringValue = runtimeCore.DSExecutable.classTable.ClassNodes[typeId].Name;
                }
                return(new WatchViewModel(stringValue, tag, RequestSelectGeometry));
            }
            else if (value is Enum)
            {
                return(new WatchViewModel(((Enum)value).GetDescription(), tag, RequestSelectGeometry));
            }

            return(new WatchViewModel(ToString(value), tag, RequestSelectGeometry));
        }
Пример #17
0
        private WatchViewModel ProcessThing(Account account, List <string> preferredDictionaryOrdering, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            var node = new WatchViewModel(account.userInfo.email, tag, RequestSelectGeometry);

            node.Clicked += () =>
            {
                System.Diagnostics.Process.Start(account.serverInfo.url);
            };

            node.Link = account.serverInfo.url;

            return(node);
        }
Пример #18
0
        public IActionResult Index(string watchId)
        {
            WatchVM = new WatchViewModel(DB.Watches.Where(watch => watch.Id.Equals(int.Parse(watchId))).First());
            InitWatch();
            FillUpParts();
            WatchVM.fillWatch();



            System.IO.File.WriteAllText("./wwwroot/js/WatchPartsJSON.js", JsonConvert.SerializeObject(WatchVM.WatchInitModel, Formatting.Indented));
            Console.WriteLine("CAME FROM ANOTHER VIEW: " + WatchVM);
            ViewBag.BGNames = GetaBackgrounds();

            return(View(WatchVM));
        }
Пример #19
0
 /// <summary>
 /// Validates the watch content with given mirror data.
 /// </summary>
 /// <param name="watch">WatchViewModel of the watch node</param>
 /// <param name="mirrorData">MirrorData to be shown in watch</param>
 private void AssertWatchContent(WatchViewModel watch, MirrorData mirrorData)
 {
     Assert.IsNotNull(mirrorData);
     if (mirrorData.IsCollection)
     {
         AssertWatchTreeBranchContent(watch.Children, mirrorData.GetElements());
     }
     else if (mirrorData.IsNull)
     {
         Assert.AreEqual("null", watch.NodeLabel);
     }
     else
     {
         string nodeLabel = string.Format("{0}", mirrorData.Data);
         Assert.AreEqual(nodeLabel, watch.NodeLabel);
     }
 }
Пример #20
0
 public IActionResult Index(string watchId)
 {
     if (watchId.Length == 1)
     {
         WatchVM = new WatchViewModel(DB.Watches.Where(watch => watch.Id.Equals(int.Parse(watchId))).First());
         WatchCreation.InitWatch(WatchVM.Watch);
         WatchVM.GenerateSelectedItemIds();
         return(View(WatchVM));
     }
     else
     {
         var ids = watchId.Split("-");
         WatchVM = new WatchViewModel(DB.Watches.Where(watch => watch.Id.Equals(int.Parse(ids[0]))).First());
         WatchCreation.InitBuiltWatch(WatchVM.Watch, ids);
         WatchVM.GenerateSelectedItemIds();
         return(View(WatchVM));
     }
 }
Пример #21
0
        private WatchViewModel ProcessThing(Element element, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            var id = element.Id;

            var node = new WatchViewModel(element.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag, RequestSelectGeometry);

            node.Clicked += () =>
            {
                if (element.InternalElement.IsValidObject)
                {
                    DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement);
                }
            };

            node.Link = id.ToString(CultureInfo.InvariantCulture);

            return(node);
        }
Пример #22
0
        internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData)
        {
            var id = element.Id;

            var node = new WatchViewModel(visualizationManager,
                                          element.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag);

            node.Clicked += () =>
            {
                if (element.InternalElement.IsValidObject)
                {
                    DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement);
                }
            };
            node.Link = id.ToString(CultureInfo.InvariantCulture);

            return(node);
        }
Пример #23
0
        public void WatchCAD()
        {
            _watchViewModel = new WatchViewModel();
            //создаем окно
            MainWatchCADWindow mainWindow = new MainWatchCADWindow
            {
                DataContext = _watchViewModel
            };

            try
            {
                //запускаем как модальное окно
                Autodesk.AutoCAD.ApplicationServices.Application.ShowModalWindow(mainWindow);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Пример #24
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }
            if (data.Data is Enum)
            {
                return(new WatchViewModel(((Enum)data.Data).GetDescription(), tag));
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(NULL_STRING, tag));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, runtimeCore, tag, showRawData));
        }
Пример #25
0
        /// <summary>
        ///     Obtain the expanded preview values for this control.  Must not be called from
        ///     Scheduler thread or this could cause a live-lock.
        /// </summary>
        private void RefreshExpandedDisplay()
        {
            // The preview control will not have its content refreshed unless
            // the content is null. In order to perform real refresh, new data
            // source needs to be rebound to the preview control by calling
            // BindToDataSource method.
            //
            if (this.cachedLargeContent != null)
            {
                return;
            }

            WatchViewModel newViewModel = null;

            RunOnSchedulerSync(() =>
            {
                newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData(
                    mirrorData, null, string.Empty, false);
            });

            if (largeContentGrid.Children.Count == 0)
            {
                var tree = new WatchTree();
                tree.DataContext = new WatchViewModel(nodeViewModel.DynamoViewModel.VisualizationManager);
                largeContentGrid.Children.Add(tree);
            }

            var watchTree       = largeContentGrid.Children[0] as WatchTree;
            var rootDataContext = watchTree.DataContext as WatchViewModel;

            cachedLargeContent = newViewModel;

            rootDataContext.Children.Clear();
            rootDataContext.Children.Add(cachedLargeContent);

            watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty,
                                           new Binding("Children")
            {
                Mode   = BindingMode.TwoWay,
                Source = rootDataContext
            });
        }
Пример #26
0
        public void CustomizeView(Watch nodeModel, NodeView nodeView)
        {
            this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel;
            this.watch           = nodeModel;

            var watchTree = new WatchTree();

            // make empty watchViewModel
            rootWatchViewModel = new WatchViewModel(this.dynamoViewModel.VisualizationManager);

            // Fix the maximum width/height of watch node.
            nodeView.PresentationGrid.MaxWidth  = Configurations.MaxWatchNodeWidth;
            nodeView.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight;
            nodeView.PresentationGrid.Children.Add(watchTree);
            nodeView.PresentationGrid.Visibility = Visibility.Visible;

            Bind(watchTree, nodeView);

            Subscribe();
        }
Пример #27
0
        /// <summary>
        /// Bind a mirror data to the preview control for display, this call
        /// unbinds the internal data structure from the view that it was
        /// originally bound to and resets the data structure. If this call is
        /// made while the preview control is in condensed or expanded state,
        /// the display will immediately be refreshed. Since this method deals
        /// with UI elements internally, it must be called from the UI thread.
        /// </summary>
        /// <param name="mirrorData">The mirror data to bind the preview control
        /// to. This value can be null to reset the preview control to its
        /// initial state.</param>
        ///
        internal void BindToDataSource(MirrorData mirrorData)
        {
            // First detach the bound data from its view.
            ResetContentViews();

            this.mirrorData         = mirrorData;
            this.cachedLargeContent = null; // Reset expanded content.
            this.cachedSmallContent = null; // Reset condensed content.

            // If at the time of data binding the preview control is within the
            // following states, then its contents need to be updated immediately.
            if (this.IsCondensed)
            {
                RefreshCondensedDisplay(delegate { BeginViewSizeTransition(ComputeSmallContentSize()); });
            }
            else if (this.IsExpanded)
            {
                RefreshExpandedDisplay(delegate { BeginViewSizeTransition(ComputeLargeContentSize()); });
            }
        }
Пример #28
0
        private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast <dynamic>().ToList();

                node = new WatchViewModel(list.Count == 0 ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, runtimeCore, tag + ":" + e.idx, showRawData));
                }
            }
            else if (runtimeCore != null && value is StackValue)
            {
                StackValue stackValue  = (StackValue)value;
                string     stringValue = string.Empty;

                if (stackValue.IsFunctionPointer)
                {
                    stringValue = StringUtils.GetStringValue(stackValue, runtimeCore);
                }
                else
                {
                    int typeId = runtimeCore.DSExecutable.TypeSystem.GetType(stackValue);
                    stringValue = runtimeCore.DSExecutable.classTable.ClassNodes[typeId].Name;
                }
                node = new WatchViewModel(stringValue, tag, RequestSelectGeometry);
            }
            else if (value is Enum)
            {
                return(new WatchViewModel(((Enum)value).GetDescription(), tag, RequestSelectGeometry));
            }
            else
            {
                node = new WatchViewModel(ToString(value), tag, RequestSelectGeometry);
            }

            return(node);
        }
Пример #29
0
        internal WatchViewModel ProcessThing(object value, string tag, bool showRawData = true)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                node = new WatchViewModel("List", tag);

                var enumerable = value as IEnumerable;
                foreach (var obj in enumerable)
                {
                    node.Children.Add(ProcessThing(obj, tag));
                }
            }
            else
            {
                node = new WatchViewModel(ToString(value), tag);
            }

            return(node);
        }
Пример #30
0
        private WatchViewModel ProcessThing(object value, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast <dynamic>().ToList();

                node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, tag + ":" + e.idx, showRawData));
                }
            }
            else
            {
                node = new WatchViewModel(visualizationManager, ToString(value), tag);
            }

            return(node);
        }
		public async void Add(VariableObject model)
		{
			var newWatch = new WatchViewModel(this, _debugManager.CurrentDebugger, model);

			await newWatch.Evaluate(_debugManager.CurrentDebugger);

			Dispatcher.UIThread.InvokeAsync(() => { Children.Add(newWatch); });

			//InvalidateColumnWidths();
		}
		public async void RemoveWatch(WatchViewModel watch)
		{
			if (watch != null)
			{
				Dispatcher.UIThread.InvokeAsync(() => { Children.Remove(watch); });

				await _debugManager.CurrentDebugger.DeleteWatchAsync(watch.Model.Id);
			}
		}