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 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()); }
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()); } }
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; } }
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()); } }
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; } }
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]; }
private void Panel_MouseEnter(object sender, EventArgs e) { _hovered_frame = (FramePanel)sender; }
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; }
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()); } }