コード例 #1
0
        public void SelectEditor(ItemEditor editor)
        {
            LayerEditor parentLayer = editor.ParentLayer;

            editor.IsSelected = true;

            ActiveLayer = parentLayer;
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void MoveItemToLayer(ItemEditor itemToMove, LayerEditor layer, ItemEditor itemToMoveNewItemUnder)
        {
            int insertPosition = itemToMoveNewItemUnder == null ? 0 : layer.Items.IndexOf(itemToMoveNewItemUnder);

            itemToMove.ParentLayer.Items.Remove(itemToMove);

            layer.Items.Insert(insertPosition, itemToMove);

            itemToMove.ParentLayer = layer;
        }
コード例 #3
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void SelectLayer(LayerEditor layer)
        {
            if (Level.SelectedEditors.Any( ))
            {
                Level.ClearSelectedEditors( );
            }

            setActiveLayerIfItsDifferent(layer);

            tryFire(() => SelectionChanged, (ITreeItem)layer);
        }
コード例 #4
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
 public void MoveLayerDown(LayerEditor layer)
 {
     _memento.Record(@"Move Up Layer '{0}'".FormatWith(layer.Name), () =>
     {
         int index               = Level.Layers.IndexOf(layer);
         Level.Layers[index]     = Level.Layers[index + 1];
         Level.Layers[index + 1] = layer;
         tryFire(() => ItemsRearrangedInLayer, (ITreeItem)layer);
         SelectLayer(layer);
     });
 }
コード例 #5
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void DeleteLayer(LayerEditor layer)
        {
            _memento.Record(@"Delete Layer '{0}'".FormatWith(layer.Name), () => Level.Layers.Remove(layer));

            tryFire(() => ItemsAddedOrRemoved, (ITreeItem)layer);

            LayerEditor nextChoiceOfLayerToSelect = Level.Layers.Count > 0 ? Level.Layers.Last( ) : null;

            if (nextChoiceOfLayerToSelect != null)
            {
                setActiveLayerIfItsDifferent(nextChoiceOfLayerToSelect);
            }
        }
コード例 #6
0
        public void MoveSelectedIditorsToLayer(LayerEditor chosenLayer)
        {
            var selected = SelectedEditors.ToList(  );

            foreach (var eachSelectedEditor in selected)
            {
                ActiveLayer.RemoveEditor(eachSelectedEditor);

                eachSelectedEditor.ParentLayer = chosenLayer;

                chosenLayer.AddEditor(eachSelectedEditor);
            }
        }
コード例 #7
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void MoveSelectedItemsToLayer(LayerEditor chosenLayer)
        {
            if (chosenLayer == Level.ActiveLayer)
            {
                return;
            }

            _memento.BeginCommand(@"Move Item(s) To Layer '{0}'".FormatWith(chosenLayer.Name));

            Level.MoveSelectedIditorsToLayer(chosenLayer);

            tryFire(() => ItemsMoved, Level.SelectedEditors);
        }
コード例 #8
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void CopySelectedItemsToLayer(LayerEditor layer)
        {
            if (layer == ActiveLayer)
            {
                return;
            }

            List <ItemEditor> clonedEditors = null;

            _memento.Record(@"Copy Item(s) To Layer '{0}'".FormatWith(layer.Name), () => { clonedEditors = Level.CopySelectedEditorsToLayer(layer).ToList( ); });

            Level.SelectEditors(new SelectedEditors(clonedEditors));

            tryFire(() => ItemsAddedOrRemoved, clonedEditors);
        }
コード例 #9
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void AddNewLayer(LayerEditor layer)
        {
            layer.ParentLevel = Level;

            Level.Layers.Add(layer);

            tryFire(
                () => ItemsAddedOrRemoved,
                new[]
            {
                layer
            });

            SelectLayer(layer);
        }
コード例 #10
0
ファイル: LayerEditor.cs プロジェクト: xubingyue/Gleed2D-1
        public static LayerEditor FromXml(LevelEditor level, XElement xml)
        {
            var layerProperties = xml.CertainElement(@"LayerProperties").DeserializedAs <LayerProperties>( );
            var layer           = new LayerEditor(level, xml.CertainAttribute(@"Name").Value)
            {
                _properties = layerProperties,
                _behaviours = new BehaviourCollection(layerProperties, xml)
            };

            layer.Items =
                new List <ItemEditor>(
                    xml.CertainElement(@"Editors").Elements(@"Editor").Select(x => createEditor(layer, x)));

            return(layer);
        }
コード例 #11
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        void setActiveLayerIfItsDifferent(LayerEditor layer)
        {
            if (ActiveLayer == layer)
            {
                return;
            }

            Level.SelectLayer(layer);

            var eventHandler = ActiveLayerChanged;

            if (eventHandler != null)
            {
                eventHandler(this, EventArgs.Empty);
            }
        }
コード例 #12
0
        LayerEditor copyLayer(Legacy.Layer oldLayer)
        {
            var newLayer = new LayerEditor(null, oldLayer.Name)
            {
                Visible     = oldLayer.Visible,
                ScrollSpeed = oldLayer.ScrollSpeed
            };

            convertCustomProperties(oldLayer.CustomProperties, newLayer.ItemProperties.CustomProperties);

            newLayer.Items.AddRange(oldLayer.Items.Select(convertItem));

            newLayer.Items.ForEach(i => i.ParentLayer = newLayer);

            return(newLayer);
        }
コード例 #13
0
        public IEnumerable <ItemEditor> CopySelectedEditorsToLayer(LayerEditor destinationLayer)
        {
            var selectedEditors = SelectedEditors.ToList(  );

            foreach (ItemEditor eachEditor in selectedEditors)
            {
                ItemEditor clonedEditor = eachEditor.Clone( );

                clonedEditor.ParentLayer         = destinationLayer;
                clonedEditor.ItemProperties.Name = destinationLayer.ParentLevel.GetUniqueNameBasedOn(clonedEditor.ItemProperties.Name);

                destinationLayer.AddEditor(clonedEditor);

                clonedEditor.ItemProperties.Id = generateId( );

                yield return(clonedEditor);
            }
        }
コード例 #14
0
ファイル: LayerEditor.cs プロジェクト: xubingyue/Gleed2D-1
        static ItemEditor createEditor(LayerEditor layer, XElement xml)
        {
            string typeName = xml.CertainAttribute(@"ClrTypeOfEditor").Value;

            Type type = Type.GetType(typeName);

            if (type == null)
            {
                throw new InvalidOperationException(
                          @"Cannot construct an editor from the XML as the type '{0}' cannot be created.".FormatWith(typeName));
            }

            var editor = (ItemEditor)Activator.CreateInstance(type);

            editor.RecreateFromXml(layer, xml);

            return(editor);
        }
コード例 #15
0
ファイル: Model.cs プロジェクト: xubingyue/Gleed2D-1
        public void DuplicateLayer(LayerEditor layer)
        {
            LayerEditor copiedLayer = layer.Clone( );

            copiedLayer.Name = layer.ParentLevel.GetUniqueNameBasedOn(copiedLayer.Name);

            foreach (ItemEditor eachCopiedItem in copiedLayer.Items)
            {
                eachCopiedItem.ItemProperties.Name = layer.ParentLevel.GetUniqueNameBasedOn(eachCopiedItem.ItemProperties.Name);
            }

            IMainForm mainForm = IoC.MainForm;

            _memento.Record(@"Duplicate Layer '{0}'".FormatWith(layer.Name), () => AddNewLayer(copiedLayer));

            tryFire(() => ItemsAddedOrRemoved, (ITreeItem)copiedLayer);

            mainForm.LevelExplorer.Rebuild( );
        }
コード例 #16
0
ファイル: ItemEditor.cs プロジェクト: xubingyue/Gleed2D-1
 public virtual void RecreateFromXml(LayerEditor parentLayer, XElement xml)
 {
     Behaviours = new BehaviourCollection(ItemProperties, xml);
 }
コード例 #17
0
        public void SelectLayer(LayerEditor value)
        {
            clearAllSelections( );

            ActiveLayer = value;
        }
コード例 #18
0
        public LevelEditor(XElement xml)
        {
            TypeLookup.Rehydrate(xml);

            _properties = xml.Element(@"LevelProperties").DeserializedAs <LevelProperties>( );

            _previousContentRootFolder = _properties.ContentRootFolder;

            if (!Directory.Exists(_properties.ContentRootFolder))
            {
                string message = @"The level file has a content root folder that does not exist.
It says the content root is at ""{0}"". Images specified in this level file are relative to this folder so you should change it in order to load this level file correctly.
Would you like to change it?".FormatWith(_properties.ContentRootFolder);

                if (MessageBox.Show(message, @"Content root folder not found.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var folderBrowserDialog = new Ookii.Dialogs.VistaFolderBrowserDialog( );

                    DialogResult dialogResult = folderBrowserDialog.ShowDialog( );

                    if (dialogResult == DialogResult.OK)
                    {
                        _properties.ContentRootFolder = folderBrowserDialog.SelectedPath;
                    }
                }
            }

            if (_properties.ContentRootFolder != _previousContentRootFolder)
            {
                //ObjectFactory.GetInstance<IEventHub>().Publish(new ContentRootChanged(_previousContentRootFolder, _properties.ContentRootFolder));
            }

            Behaviours = new BehaviourCollection(_properties, xml);

            Layers = new List <LayerEditor>(xml.CertainElement(@"Layers").Elements(@"Layer").Select(x => LayerEditor.FromXml(this, x)));

            ActiveLayer = Layers.FirstOrDefault( );
        }
コード例 #19
0
ファイル: ItemEditor.cs プロジェクト: xubingyue/Gleed2D-1
 /// <summary>
 /// Called when the user starts creating something, e.g. a Rectangle will have a position but no height or width as this is
 /// set when the user moves the pointer around.
 /// Another example is the Path object.  This initially just has 1 point (that start point) and
 /// the user add points by clicking around.
 /// </summary>
 /// <param name="parentLayer"></param>
 /// <param name="creationProperties"></param>
 public abstract void CreateInDesignMode(LayerEditor parentLayer, IEntityCreationProperties creationProperties);