Esempio n. 1
0
File: Map.cs Progetto: nistck/Jx
            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);
            }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
File: Map.cs Progetto: nistck/Jx
            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);
            }
Esempio n. 4
0
File: Map.cs Progetto: nistck/Jx
            public EditorLayer Create(string name = "New Layer_")
            {
                EditorLayer layer = new EditorLayer(name, this);

                children.Add(layer);
                return(layer);
            }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 public static void EndDrag(ref EditorScene scene, EditorLayer layer)
 {
     if (layer != null)
     {
         int index = scene.Layers.IndexOf(layer);
         scene.Layers[index].EndDrag();
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
File: Map.cs Progetto: nistck/Jx
 public void Create(EditorLayer layer)
 {
     if (layer == null)
     {
         return;
     }
     children.Add(layer);
 }
Esempio n. 9
0
File: Map.cs Progetto: nistck/Jx
            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));
            }
Esempio n. 10
0
 private void SetCurrentLayer(EditorLayer value)
 {
     if (OutsideOfLayerBounds)
     {
         return;
     }
     else
     {
         Layers[SelectedLayerIndex] = value;
     }
 }
Esempio n. 11
0
File: Map.cs Progetto: nistck/Jx
            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);
            }
Esempio n. 12
0
File: Map.cs Progetto: nistck/Jx
            private bool RemoveChild(EditorLayer layerChild)
            {
                if (layerChild == null || !children.Contains(layerChild))
                {
                    return(false);
                }

                bool result = children.Remove(layerChild);

                return(result);
            }
Esempio n. 13
0
 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);
         }
     }
 }
Esempio n. 14
0
File: Map.cs Progetto: nistck/Jx
            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);
            }
Esempio n. 15
0
File: Map.cs Progetto: nistck/Jx
            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);
            }
Esempio n. 16
0
File: Map.cs Progetto: nistck/Jx
 public EditorLayer(string name, EditorLayer parent)
 {
     this.Name   = name;
     this.Parent = parent;
 }
Esempio n. 17
0
File: Map.cs Progetto: nistck/Jx
 public EditorLayer(EditorLayer parent)
 {
     this.Parent = parent;
 }