private XmlDocument CreateXml(string value, ViewContentType contentType) { XmlDocument result = new XmlDocument(); if (contentType == ViewContentType.Xml) { // Xml result.XmlResolver = null; result.LoadXml(value); } else { // Json JSON.JSONParseErrors oErrors; object o = JSON.JsonDecode(value, out oErrors); if (o != null) { XmlElement root = result.CreateElement("JSON"); result.AppendChild(root); uint nodeCount = 0; CreateNodes(result, root, o, false, ref nodeCount); } } return(result); }
void ReleaseDesignerOutlets() { if (ImageViewMenuIcon != null) { ImageViewMenuIcon.Dispose(); ImageViewMenuIcon = null; } if (LabelContentType != null) { LabelContentType.Dispose(); LabelContentType = null; } if (LabelTitle != null) { LabelTitle.Dispose(); LabelTitle = null; } if (RootView != null) { RootView.Dispose(); RootView = null; } if (ViewBackground != null) { ViewBackground.Dispose(); ViewBackground = null; } if (ViewContentType != null) { ViewContentType.Dispose(); ViewContentType = null; } if (ViewMenuIcon != null) { ViewMenuIcon.Dispose(); ViewMenuIcon = null; } if (ViewOverlay != null) { ViewOverlay.Dispose(); ViewOverlay = null; } }
void OnValidate() { if (viewContentDelegation == null) { viewContentDelegation = GetComponentInChildren <PanoramaBlock>(); } if (viewContentDelegation) { sceneViewCenter = viewContentDelegation.transform; sceneViewContentType = ViewContentType.PanoramaView; } if (sceneViewCenter == null) { sceneViewCenter = transform; } if (string.IsNullOrEmpty(specialSceneName)) { specialSceneName = name; } }
protected override bool SetViewContentInternal(ViewContentType contentType, ViewNode target, object content) { if (this.settingContentReentranceDepth > 1) { return(false); } if (contentType == ViewContentType.Error) { FormattedException formattedException = content as FormattedException; if (formattedException != null) { content = (object)this.FilterCatastrophicFailure(formattedException); } } try { ++this.settingContentReentranceDepth; return(this.SetViewContentWorker(contentType, target, content)); } finally { --this.settingContentReentranceDepth; } }
protected override bool SetViewContentInternal(ViewContentType contentType, ViewNode target, object content) { FrameworkElement frameworkElement = (FrameworkElement)null; object obj = content; bool flag = false; if (contentType == ViewContentType.Content) { if (this.currentScopedInstance == content && this.currentContentType == ViewContentType.Content) { this.UpdateViewContentIfNecessary(false); return(false); } if (target != null && content != null) { ViewContent viewContent = this.ProvideViewContent(target, content); contentType = viewContent.ViewContentType; content = viewContent.Content; flag = viewContent.IsSizeFixed; frameworkElement = content as FrameworkElement; } else { contentType = ViewContentType.DefaultMessage; } if (this.currentScopedInstance == null && content == null && this.currentContentType == ViewContentType.DefaultMessage) { return(false); } } if (contentType == ViewContentType.Content) { this.currentScopedInstance = obj; } else { this.currentScopedInstance = (object)null; frameworkElement = (FrameworkElement)null; } this.currentContentType = contentType; this.ClearAdornerSets(); if (flag && contentType == ViewContentType.Content && (!double.IsNaN(frameworkElement.Width) && !double.IsNaN(frameworkElement.Height)) || this.ViewModel.PreferredSize == Size.Empty) { this.Artboard.ContentArea.MinWidth = 20.0; this.Artboard.ContentArea.MinHeight = 20.0; } else { this.Artboard.ContentArea.MinWidth = this.ViewModel.PreferredSize.Width; this.Artboard.ContentArea.MinHeight = this.ViewModel.PreferredSize.Height; } if (frameworkElement != null) { this.Artboard.EditableContent = (FrameworkElement)null; this.SetApplicationResourceDictionary((ResourceDictionary)null); this.Artboard.EditableContent = frameworkElement; } else { this.Artboard.SafelyRemoveEditableContent(); } this.Artboard.ContentArea.SetValue(TextElement.FontFamilyProperty, TextElement.FontFamilyProperty.DefaultMetadata.DefaultValue); this.Artboard.ContentArea.SetValue(TextElement.FontSizeProperty, TextElement.FontSizeProperty.DefaultMetadata.DefaultValue); switch (contentType) { case ViewContentType.DefaultMessage: this.IsDefaultMessageDisplayed = true; this.MessageContent = (object)null; break; case ViewContentType.Content: this.IsDefaultMessageDisplayed = false; this.MessageContent = (object)null; NameScope.SetNameScope((DependencyObject)frameworkElement, this.rootNameScope); break; default: this.IsDefaultMessageDisplayed = false; this.MessageContent = content; break; } return(true); }
private bool SetViewContentWorker(ViewContentType contentType, ViewNode target, object content) { object obj = content; if (contentType == ViewContentType.Content) { if (!this.isRootInstanceKnownInvalid && this.postponedUpdate == SceneView.PostponedUpdate.None && (this.currentScopedInstance == content && this.currentContentType == ViewContentType.Content)) { this.ApplyNameScope(this.rootNameScope as SilverlightNameScope); this.UpdateViewContentIfNecessary(false); return(false); } if (content != null) { ViewContent viewContent = this.ProvideViewContent(target, content); contentType = viewContent.ViewContentType; content = viewContent.Content; if (content != null && contentType == ViewContentType.Content && !this.Document.ProjectContext.ResolveType(PlatformTypes.FrameworkElement).RuntimeType.IsAssignableFrom(content.GetType())) { contentType = ViewContentType.DefaultMessage; } } else { contentType = ViewContentType.DefaultMessage; } if (!this.isRootInstanceKnownInvalid && this.currentScopedInstance == null && (content == null && this.currentContentType == ViewContentType.DefaultMessage)) { return(false); } } ViewContentType viewContentType = this.currentContentType; this.currentContentType = contentType; if (contentType == ViewContentType.Content) { this.currentScopedInstance = obj; this.imageHost.RootInstance = content; this.hitTestRoot = this.Platform.ViewObjectFactory.Instantiate(this.imageHost.HitTestRoot) as IViewVisual; if (this.currentContentType != contentType) { return(true); } this.isRootInstanceKnownInvalid = false; if (viewContentType != ViewContentType.Content) { this.imageHost.Redraw(true); } this.UpdateRootBounds(); this.UpdateLayout(); this.disposedExceptionCaught = false; this.catastrohpicFailureCaught = false; } else { this.imageHost.RootInstance = (object)null; this.currentScopedInstance = (object)null; } this.ClearAdornerSets(); bool flag = false; if (contentType == ViewContentType.Content) { ReferenceStep referenceStep1 = this.ProjectContext.ResolveProperty(BaseFrameworkElement.ActualWidthProperty) as ReferenceStep; ReferenceStep referenceStep2 = this.ProjectContext.ResolveProperty(BaseFrameworkElement.ActualHeightProperty) as ReferenceStep; double num1 = (double)referenceStep1.GetValue(content); double num2 = (double)referenceStep2.GetValue(content); if (!double.IsNaN(num1) && !double.IsNaN(num2)) { this.SetContentSize(new Size(num1, num2)); flag = true; } } if (!flag) { if (this.ViewModel.PreferredSize != Size.Empty) { this.SetContentSize(new Size(this.ViewModel.PreferredSize.Width, this.ViewModel.PreferredSize.Height)); } else { this.SetContentSize(new Size(20.0, 20.0)); } } switch (contentType) { case ViewContentType.DefaultMessage: this.IsDefaultMessageDisplayed = true; this.MessageContent = (object)null; break; case ViewContentType.Content: this.IsDefaultMessageDisplayed = false; this.MessageContent = (object)null; this.ApplyNameScope(this.rootNameScope as SilverlightNameScope); break; default: this.IsDefaultMessageDisplayed = false; this.MessageContent = content; break; } return(true); }