Beispiel #1
0
        private void DirectionLayout_DragDrop(object sender, DragEventArgs e)
        {
            if (_panel_to_add == null)
            {
                return;
            }
            if (e.Data.GetDataPresent("Frame") || e.Data.GetDataPresent("ImageFrame"))
            {
                // commit to the removal of the frame from the dragged_from direction:
                if (_panel_to_add.Parent != null)
                {
                    DirectionLayout last_dir = ((DirectionLayout)_panel_to_add.Parent.Parent);
                    last_dir._direction.Frames.RemoveAt(last_dir._direction.Frames.IndexOf(_panel_to_add.Frame));
                }

                ImagesPanel.Controls.Add(_panel_to_add);

                Point      Location    = ImagesPanel.PointToClient(new Point(e.X, e.Y));
                FramePanel place_panel = (FramePanel)ImagesPanel.GetChildAtPoint(Location);
                ImagesPanel.Controls.SetChildIndex(_panel_to_add, ImagesPanel.Controls.IndexOf(place_panel));

                // and add the frame to the dragged_to direction:
                int pos = _direction.Frames.Count - (ImagesPanel.Controls.IndexOf(_panel_to_add));
                _direction.Frames.Insert(pos, _panel_to_add.Frame);

                _panel_to_add = null;
                Invalidate(true);
                Modified?.Invoke(this, new EventArgs());
            }
        }
 public void RemoveDirection(DirectionLayout layout)
 {
     _sprite.Directions.Remove(layout.Direction);
     DirectionHolder.Controls.Remove(layout);
     UpdateControls();
     IsDirty = true;
 }
 public void AddNewDirection()
 {
     Direction d = new Direction("Direction_" + DirectionHolder.Controls.Count);
     d.Frames.Add(new Frame());
     _sprite.Directions.Add(d);
     DirectionLayout layout = new DirectionLayout(_sprite, d, this);
     layout.OnFrameClick += layout_OnFrameClick;
     layout.Modified += Modified;
     layout.Zoom = _zoom;
     DirectionHolder.Controls.Add(layout);
     layout.Location = new Point(2, DirectionHolder.Controls.Count - 1 * (layout.Height + 2) + 2);
     IsDirty = true;
 }
 private void layout_OnFrameClick(object sender, EventArgs e)
 {
     if (_selectedFrame != null) _selectedFrame.Selected = false;
     _selectedDirection = (DirectionLayout)sender;
     _selectedFrame = _selectedDirection.SelectedFrame;
     SpriteDrawer.Content = (Bitmap)_sprite.GetImage(_selectedFrame.Index);
     FrameBaseEditor.Frame = _selectedFrame.Frame;
     DirectionAnim.Direction = _selectedDirection.Direction;
     DirectionAnim.Invalidate(true);
 }
 public void Init()
 {
     int i = 0;
     foreach (Direction d in _sprite.Directions)
     {
         DirectionLayout layout = new DirectionLayout(_sprite, d, this);
         layout.OnFrameClick += layout_OnFrameClick;
         layout.Modified += Modified;
         layout.Zoom = _zoom;
         DirectionHolder.Controls.Add(layout);
         layout.Location = new Point(2, i++ * (layout.Height + 2) + 2);
     }
     ((DirectionLayout)DirectionHolder.Controls[0]).Select(0);
     _selectedFrame = ((DirectionLayout)DirectionHolder.Controls[0]).SelectedFrame;
     SpriteDrawer.Content = (Bitmap)_sprite.GetImage((((DirectionLayout)DirectionHolder.Controls[0]).SelectedFrame.Index));
     SpriteDrawer.ZoomIn();
     SpriteDrawer.ZoomIn();
     _tilesetCtrl = new TilesetControl2 { Tileset = Sphere.Core.Tileset.FromSpriteset(_sprite), CanInsert = false };
     _tilesetCtrl.ZoomIn();
     _tilesetCtrl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
     _tilesetCtrl.TileSelected += _tileset_ctrl_TileSelected;
     _tilesetCtrl.TileAdded += _tileset_ctrl_TileAdded;
     _tilesetCtrl.TileRemoved += _tileset_ctrl_TileRemoved;
     ImageHolder.Controls.Add(_tilesetCtrl);
     _tilesetCtrl.Width = ImageHolder.Width - 6;
     DirectionAnim.Sprite = _sprite;
     DirectionAnim.Direction = _sprite.Directions[0];
     FrameBaseEditor.Frame = _sprite.Directions[0].Frames[0];
 }