Exemplo n.º 1
0
        private void Button_Drop(object sender, System.Windows.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(MButton)))
            {
                var origin = e.Data.GetData(typeof(MButton)) as MButton;
                var btn    = sender as MButton;

                if (origin.Col != btn.Col || origin.Row != btn.Row)
                {
                    string path  = origin.Path;
                    string bpath = btn.Path;

                    if (!File.Exists(path) && !Directory.Exists(path))
                    {
                        return;
                    }

                    if (PathManager.GetType(path) == PathManager.PathType.Shotcut)
                    {
                        path = PathManager.AbsolutePath(path);
                    }

                    InsertButton(btn, path);
                    DeleteButton(origin);

                    if (!string.IsNullOrWhiteSpace(bpath))
                    {
                        InsertButton(origin, bpath);
                    }
                }
            }
            else
            {
                string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);

                string path = files.AsEnumerable().First();;
                if (!File.Exists(path) && !Directory.Exists(path))
                {
                    return;
                }

                if (PathManager.GetType(path) == PathManager.PathType.Shotcut)
                {
                    path = PathManager.AbsolutePath(path);
                }

                var btn = sender as MButton;
                InsertButton(btn, path);
            }
        }
Exemplo n.º 2
0
        private void Button_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(mButton)))
            {
                var origin = e.Data.GetData(typeof(mButton)) as mButton;
                var btn    = sender as mButton;
                if (origin.Name != btn.Name)
                {
                    string oriPath = DB.ExecuteValue <string>(string.Format("SELECT Path FROM Buttons WHERE ID = '{0}'", origin.Name));

                    string path = oriPath;
                    if (!File.Exists(path) && !Directory.Exists(path))
                    {
                        return;
                    }

                    if (PathManager.GetType(oriPath) == PathManager.PathType.Shotcut)
                    {
                        path = PathManager.AbsolutePath(oriPath);
                    }

                    InsertButton(btn, path);
                    DeleteButton(origin);
                }
            }
            else
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                foreach (string file in files)
                {
                    string path = file;
                    if (!File.Exists(path) && !Directory.Exists(path))
                    {
                        return;
                    }

                    if (PathManager.GetType(file) == PathManager.PathType.Shotcut)
                    {
                        path = PathManager.AbsolutePath(file);
                    }

                    var btn = sender as mButton;

                    InsertButton(btn, path);
                }
            }
        }