public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null || Instance == null) { return(null); } string valueString = Convert.ToString(value); if (string.IsNullOrEmpty(valueString)) { return(Instance.RootEditorLayer); } string[] dirs = valueString.Split(Path.AltDirectorySeparatorChar); EditorLayer layer = Instance.RootEditorLayer; for (int i = 1; i < dirs.Length; i++) { layer = layer.FindChild(dirs[i]); if (layer == null) { return(Instance.RootEditorLayer); } } return(layer); }
public static void SelectRegion(ref EditorScene scene, EditorLayer layer, System.Drawing.Point SelectionXY_1, System.Drawing.Point SelectionXY_2, bool addSelection = false, bool deselectIfSelected = false) { if (layer != null) { int index = scene.Layers.IndexOf(layer); int x1 = SelectionXY_1.X, x2 = SelectionXY_2.X; int y1 = SelectionXY_1.Y, y2 = SelectionXY_2.Y; if (x1 != x2 && y1 != y2) { if (x1 > x2) { x1 = SelectionXY_2.X; x2 = SelectionXY_1.X; } if (y1 > y2) { y1 = SelectionXY_2.Y; y2 = SelectionXY_1.Y; } } scene.Layers[index].Select(new System.Drawing.Rectangle(x1, y1, x2 - x1, y2 - y1), addSelection, deselectIfSelected); } }
internal bool OnLoad(TextBlock block) { if (block == null) { return(false); } if (block.IsAttributeExist("name")) { this.Name = block.GetAttribute("name"); } if (block.IsAttributeExist("visible")) { this.Visible = bool.Parse(block.GetAttribute("visible")); } if (block.IsAttributeExist("allowSelect")) { this.AllowSelect = bool.Parse(block.GetAttribute("allowSelect")); } if (block.IsAttributeExist("allowEdit")) { this.AllowEdit = bool.Parse(block.GetAttribute("allowEdit")); } foreach (TextBlock child in block.Children) { EditorLayer layer = new EditorLayer(this); if (!layer.OnLoad(child)) { return(false); } children.Add(layer); } return(true); }
public EditorLayer Create(string name = "New Layer_") { EditorLayer layer = new EditorLayer(name, this); children.Add(layer); return(layer); }
public static void MoveSelection(ref EditorScene scene, EditorLayer layer, System.Drawing.Point OldPos, System.Drawing.Point NewPos, bool duplicate = false, bool chunkAlign = false) { if (layer != null) { int index = scene.Layers.IndexOf(layer); scene.Layers[index].MoveSelected(OldPos, NewPos, duplicate, chunkAlign); } }
public static void EndDrag(ref EditorScene scene, EditorLayer layer) { if (layer != null) { int index = scene.Layers.IndexOf(layer); scene.Layers[index].EndDrag(); } }
public static void Select(ref EditorScene scene, EditorLayer layer, System.Drawing.Point pos, bool addSelection = false, bool deselectIfSelected = false) { if (layer != null) { int index = scene.Layers.IndexOf(layer); scene.Layers[index].Select(pos, addSelection, deselectIfSelected); } }
public void Create(EditorLayer layer) { if (layer == null) { return; } children.Add(layer); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { EditorLayer layer = value as EditorLayer; return(layer == null? "" : layer.Path); } return(base.ConvertTo(context, culture, value, destinationType)); }
private void SetCurrentLayer(EditorLayer value) { if (OutsideOfLayerBounds) { return; } else { Layers[SelectedLayerIndex] = value; } }
public override bool Equals(object obj) { EditorLayer layer = obj as EditorLayer; if (layer == null || layer.Path == null || Path == null) { return(false); } return(layer.Path == Path); }
private bool RemoveChild(EditorLayer layerChild) { if (layerChild == null || !children.Contains(layerChild)) { return(false); } bool result = children.Remove(layerChild); return(result); }
public static void Deselect(ref EditorScene scene, EditorLayer layer) { if (layer != null) { int index = scene.Layers.IndexOf(layer); bool wasMoved = scene.Layers[index].SelectionMoved; scene.Layers[index].Deselect(); if (wasMoved) { UndoRedo.UpdateLayerStack(ref scene.Parent); UndoRedo.UpdateUndoRedoButtons(ref scene.Parent); } } }
public bool HasChild(string name, EditorLayer excludeLayer = null) { if (string.IsNullOrEmpty(name)) { return(false); } foreach (EditorLayer layer in children) { if (excludeLayer != null && excludeLayer == layer) { continue; } if (name == layer.Name) { return(true); } } return(false); }
public EditorLayer Find(string p) { if (p == null) { return(null); } string[] ps = p.Split('\\'); EditorLayer editorLayer = Instance.RootEditorLayer; for (int i = 1; i < ps.Length && editorLayer != null; i++) { string psi = ps[i]; EditorLayer layer = editorLayer.FindChild(psi); if (layer == null) { editorLayer = null; break; } editorLayer = layer; } return(editorLayer); }
public EditorLayer(string name, EditorLayer parent) { this.Name = name; this.Parent = parent; }
public EditorLayer(EditorLayer parent) { this.Parent = parent; }