TreeViewItem renderProperty(string name, object value) { Color color; var item = new TreeViewItem(); var header = item as HeaderedItemsControl; if (value != null && !typeColors.TryGetValue(value.GetType(), out color)) { if (value is CommonObject) { color = typeColors[typeof(CommonObject)]; } else { color = typeColors[typeof(object)]; } } else { color = typeColors[typeof(object)]; } header.Foreground = new SolidColorBrush(color); if (value is CommonObject) { var commonObject = value as CommonObject; item.Header = name + ": " + commonObject.ClassName; if (alreadyRendered.Contains(value)) { item.Header += " <recursive>"; } else { foreach (var property in renderObjectProperties(commonObject)) { item.Items.Add(property); } } } else if (value is string) { item.Header = name + ": \"" + value + "\""; } else { item.Header = name + ": " + TypeConverter.ToString(BoxingUtils.JsBox(value)); } return(item); }
void runSources(Stack <string> sources) { if (jsThread != null) { return; } doWithoutTextChange(() => { inputText.Focusable = false; inputText.Background = Brushes.WhiteSmoke; }); jsThread = new Thread(() => { try { if (sources.Count > 0) { Dispatcher.Invoke(new Action(() => breakPointLabel.Content = "Running...")); var result = context.Execute(sources.Pop()); var resultAsString = TypeConverter.ToString(BoxingUtils.JsBox(result)); Dispatcher.Invoke(new Action(() => consoleOutput.Text += "\r\nLast statement: " + resultAsString)); } } catch (Exception exn) { Dispatcher.Invoke(new Action(() => printException(exn))); } finally { Dispatcher.Invoke(new Action(() => { doWithoutTextChange(() => { inputText.Focusable = true; inputText.Background = Brushes.Transparent; }); displayGlobalVariables(context.Globals); })); jsThread = null; if (sources.Count > 0) { Dispatcher.Invoke(new Action(() => { runSources(sources); })); } else { Dispatcher.Invoke(new Action(() => breakPointLabel.Content = "")); } } }); jsThread.Start(); }