private void Process(UIVisual visual, PhotoshopDocument.Layer layer) { System.Drawing.Rectangle parentBounds = System.Drawing.Rectangle.Empty; if (layer.Group != null) { parentBounds = layer.Group.ComputeUnionRectangle(); } System.Drawing.Rectangle bounds = layer.ComputeUnionRectangle(); bounds.X -= parentBounds.X; bounds.Y -= parentBounds.Y; visual.SetAbsoluteBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height); visual.Opacity = (float)layer.Opacity / (float)byte.MaxValue; if (ForceShowAll) { visual.Visibility = UIVisibility.Visible; } else { visual.Visibility = layer.Visible ? UIVisibility.Visible : UIVisibility.Invisible; } BlendMode blendMode = ConvertToBlendMode(layer.BlendMode); if (blendMode != BlendMode.Normal) { visual.EffectMap = new UIEffectMap(); visual.EffectMap.Insert(new UIBlendingEffect(blendMode)); } }
private static void WriteVisual(AssetStreamWriter writer, UIVisual o, List <object> objectDictionary) { if (WriteElement(writer, o, objectDictionary) == false) { return; } Type t = o.GetType(); if (t == typeof(UIVisual)) { Write(writer, (UIVisual)o, objectDictionary); } else if (t == typeof(UIImage)) { Write(writer, (UIImage)o, objectDictionary); } else if (t == typeof(UILabel)) { Write(writer, (UILabel)o, objectDictionary); } else if (t == typeof(UIEditText)) { Write(writer, (UIEditText)o, objectDictionary); } else if (t == typeof(UIPanel)) { Write(writer, (UIPanel)o, objectDictionary); } else if (t == typeof(UIButton)) { Write(writer, (UIButton)o, objectDictionary); } else if (t == typeof(UICheckBox)) { Write(writer, (UICheckBox)o, objectDictionary); } else if (t == typeof(UIRadioButton)) { Write(writer, (UIRadioButton)o, objectDictionary); } else if (t == typeof(UIDocument)) { Write(writer, (UIDocument)o, objectDictionary); } else if (t == typeof(UIScrollablePanel)) { Write(writer, (UIScrollablePanel)o, objectDictionary); } else if (t == typeof(UIWindow)) { Write(writer, (UIWindow)o, objectDictionary); } else { throw new NotSupportedException(t.ToString()); } }
private static void CollectObjects(UIVisual visual, List <UIImage> images, List <UILabel> labels) { if (visual is UIImage) { images.Add((UIImage)visual); } else if (visual is UILabel) { labels.Add((UILabel)visual); } else if (visual is UIPanel) { foreach (UIVisual item in ((UIPanel)visual).Children) { CollectObjects(item, images, labels); } } }
private static void Write(AssetStreamWriter writer, UIVisual o, List <object> objectDictionary) { Write(writer, (UIElement)o, objectDictionary); writer.Write((byte)o.XMode); writer.Write((byte)o.YMode); writer.Write((byte)o.WidthMode); writer.Write((byte)o.HeightMode); writer.Write(o.X); writer.Write(o.Y); writer.Write(o.Width); writer.Write(o.Height); writer.Write(o.Origin); writer.Write((byte)o.AnchorPoint); writer.Write((byte)(o.Opacity * 255.0f)); writer.Write((byte)o.Visibility); writer.Write((byte)o.ZOrder); writer.Write(o.IsPickable); writer.Write(o.IsFocusable); writer.Write(o.IsDraggable); WriteEventMap(writer, o.EventMap, objectDictionary); WriteEffectMap(writer, o.EffectMap, objectDictionary); WriteTransform(writer, o.Transform, objectDictionary); }
public UILayout(UIVisual root) { Root = root; }