Newer
Older
Launcheroid / V3 / Form1.cs
@Ivan Dominguez Ivan Dominguez 11 days ago 2 KB Lancheroid 3 to 4
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using XWolf.Aero;

namespace Launcheroid
{
    public partial class Form1 : XGlassForm
    {
        private const int WM_NCHITTEST = 0x0084;
        private static IntPtr HTCAPTION = (IntPtr)2;

        private LRD3 lib = new LRD3();
        private string libPath;

        public Form1()
        {
            InitializeComponent();
            FullGlass = true;
            GoToCursor();
            libPath = Program.ArgumentFile;
            if (string.IsNullOrEmpty(libPath))
                libPath = Program.DefaultFile;
            lib.Load(libPath);
        }

        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);
            if (message.Msg == WM_NCHITTEST)
            {
                int r = message.Result.ToInt32();
                if (r >= 10 && r <= 18)
                    message.Result = HTCAPTION;
            }
        }

        private void GoToCursor()
        {
            Point c = Cursor.Position;
            c.X -= Width / 2;
            if (c.X < 0)
                c.X = 0;
            c.Y -= Height / 2;
            if (c.Y < 0)
                c.Y = 0;
            Location = c;
        }

        private void UpdateLibrary()
        {

        }

        private void Add(LRD3.Item item)
        {
            lib.Items.Add(item);
            lib.Save(libPath);
            UpdateLibrary();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void AddItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LRD3.Item item = new LRD3.Item();
            if (FItem.Execute(item))
                Add(item);
        }

        private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
        }

        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files.Length != 1)
                return;
            LRD3.Item item = FItem.Import(files[0]);
            if (item != null)
                Add(item);
        }
    }
}