Inheritance: System.Windows.Forms.Panel
コード例 #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());
            }
        }
コード例 #2
0
 public void AddImage(Frame frame)
 {
     FramePanel panel = new FramePanel(frame, _sprite, _parent_editor.Settings);
     panel.Zoom = _zoom;
     ImagesPanel.Controls.Add(panel);
     panel.BringToFront();
     panel.MouseClick += new MouseEventHandler(Panel_MouseClick);
     panel.MouseEnter += new System.EventHandler(Panel_MouseEnter);
     Invalidate(true);
     if (Modified != null) Modified(this, new EventArgs());
 }
コード例 #3
0
 private void Panel_MouseClick(object sender, MouseEventArgs e)
 {
     if (SelectedFrame != null)
     {
         SelectedFrame.Selected = false;
     }
     SelectedFrame          = (FramePanel)sender;
     SelectedFrame.Selected = true;
     if (OnFrameClick != null)
     {
         OnFrameClick(this, new EventArgs());
     }
 }
コード例 #4
0
 public void Select(int index)
 {
     index = ImagesPanel.Controls.Count - 1 - index;
     if (ImagesPanel.Controls[index] is FramePanel)
     {
         if (SelectedFrame != null)
         {
             SelectedFrame.Selected = false;
         }
         SelectedFrame          = (FramePanel)ImagesPanel.Controls[index];
         SelectedFrame.Selected = true;
     }
 }
コード例 #5
0
        public void AddImage(Frame frame)
        {
            FramePanel panel = new FramePanel(frame, _sprite, _parent_editor.Settings);

            panel.Zoom = _zoom;
            ImagesPanel.Controls.Add(panel);
            panel.BringToFront();
            panel.MouseClick += new MouseEventHandler(Panel_MouseClick);
            panel.MouseEnter += new System.EventHandler(Panel_MouseEnter);
            Invalidate(true);
            if (Modified != null)
            {
                Modified(this, new EventArgs());
            }
        }
コード例 #6
0
        private void DirectionLayout_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;

            if (e.Data.GetDataPresent("Frame"))
            {
                _panel_to_add = (FramePanel)e.Data.GetData("Frame");
            }
            else if (e.Data.GetDataPresent("ImageFrame"))
            {
                Frame      frame = (Frame)e.Data.GetData("ImageFrame");
                FramePanel panel = new FramePanel(frame, _sprite, _parent_editor.Settings);
                panel.Zoom        = _zoom;
                panel.MouseClick += new MouseEventHandler(Panel_MouseClick);
                panel.MouseEnter += new System.EventHandler(Panel_MouseEnter);
                _panel_to_add     = panel;
            }
            else
            {
                _panel_to_add = null;
            }
        }
コード例 #7
0
 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);
 }
コード例 #8
0
 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];
 }
コード例 #9
0
 private void Panel_MouseEnter(object sender, EventArgs e)
 {
     _hovered_frame = (FramePanel)sender;
 }
コード例 #10
0
        private void DirectionLayout_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;

            if (e.Data.GetDataPresent("Frame"))
                _panel_to_add = (FramePanel)e.Data.GetData("Frame");
            else if (e.Data.GetDataPresent("ImageFrame"))
            {
                Frame frame = (Frame)e.Data.GetData("ImageFrame");
                FramePanel panel = new FramePanel(frame, _sprite, _parent_editor.Settings);
                panel.Zoom = _zoom;
                panel.MouseClick += new MouseEventHandler(Panel_MouseClick);
                panel.MouseEnter += new System.EventHandler(Panel_MouseEnter);
                _panel_to_add = panel;
            }
            else
                _panel_to_add = null;
        }
コード例 #11
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);
                if (Modified != null) Modified(this, new EventArgs());
            }
        }
コード例 #12
0
 private void Panel_MouseEnter(object sender, EventArgs e)
 {
     _hovered_frame = (FramePanel)sender;
 }