/// <summary> /// Create an image from an existing texture. /// </summary> /// <param name="rect">position and size</param> /// <param name="texture">texture, call<see cref="CreateTexture"/>to create it.</param> public static void Image(Rect rect, ITexture texture) { var window = GetCurrentWindow(); if (window.SkipItems) { return; } var id = window.GetID(texture.GetHashCode()); var container = window.AbsoluteVisualList; var node = (Node)container.Find(visual => visual.Id == id); if (node == null) { //create node node = new Node(id, $"{nameof(Image)}<Native_{texture.GetNativeTextureId()}>"); node.UseBoxModel = true; node.RuleSet.Replace(GUISkin.Current[GUIControlName.Image]); container.Add(node); } node.ActiveSelf = true; // rect node.Rect = window.GetRect(rect); // draw using (var dc = node.RenderOpen()) { dc.DrawBoxModel(texture, node.RuleSet, node.Rect); } }
public static void Image(ITexture texture) { var window = GetCurrentWindow(); if (window.SkipItems) { return; } var id = window.GetID(texture.GetHashCode()); var container = window.RenderTree.CurrentContainer; var node = container.GetNodeById(id); if (node == null) { //create node node = new Node(id, $"{nameof(Image)}<Native_{texture.GetNativeTextureId()}>"); node.UseBoxModel = true; node.RuleSet.Replace(GUISkin.Current[GUIControlName.Image]); node.AttachLayoutEntry(texture.Size); } container.AppendChild(node); node.ActiveSelf = true; // rect node.Rect = window.GetRect(id); // draw using (var dc = node.RenderOpen()) { dc.DrawBoxModel(texture, node.RuleSet, node.Rect); } }
public int GetID(ITexture texture) { int seed = this.IDStack.Peek(); int int_id = texture.GetHashCode(); var id = this.Hash(seed, int_id); GUIContext g = Form.current.uiContext; g.KeepAliveID(id); return(id); }
public override int GetHashCode() { unchecked { var hashCode = DiffuseColor.GetHashCode(); hashCode = (hashCode * 397) ^ (DiffuseMap != null ? DiffuseMap.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NormalMap != null ? NormalMap.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SpecularMap != null ? SpecularMap.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DisplacementMap != null ? DisplacementMap.GetHashCode() : 0); return(hashCode); } }