78 lines
2.3 KiB
C#
78 lines
2.3 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);
|
|
|
|
e.Effect = (e.Data.GetDataPresent(DataFormats.FileDrop)) ? DragDropEffects.Link : 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 (e.Button == MouseButtons.Right)
|
|
{
|
|
this.DoDragDrop(this, DragDropEffects.Move);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |