roketto-launch/source/Windows/Forms/TilePanel.cs
Ray 7b73a8098b Changed to update nupkg
Changed folder structure
Added readme
2026-07-07 14:01:21 +01:00

85 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RokettoLaunch.Windows.Forms
{
public partial class TilePanel : RyzStudio.Windows.TileForms.Tile
{
public delegate Task OnFileDropEvent(TilePanel sender, Keys keys, List<string> paths);
public TilePanel()
{
InitializeComponent();
this.AllowDrop = true;
this.Font = new Font(this.Font.FontFamily, 8.25F);
this.Size = new Size(70, 70);
this.AutoScaleMode = AutoScaleMode.None;
this.EnableMovable = false;
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Guid TileId { get; set; } = Guid.Empty;
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsGroup { get; set; } = false;
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ContextMenuStrip TileContextMenu { get; set; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public OnFileDropEvent OnFileDrop { get; set; }
protected override void OnDragOver(DragEventArgs e)
{
base.OnDragDrop(e);
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) ? DragDropEffects.Copy : DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
protected override void OnDragDrop(DragEventArgs e)
{
var fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
if (fileList == null)
{
return;
}
if (fileList.Length <= 0)
{
return;
}
if (this.OnFileDrop != null)
{
this.OnFileDrop(this, Control.ModifierKeys, fileList.ToList());
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (Control.ModifierKeys == Keys.Control && e.Button == MouseButtons.Right)
{
this.DoDragDrop(this, DragDropEffects.Move);
}
}
}
}