コード例 #1
0
        /// <summary>
        /// Drag&Drop
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Drop(object sender, DragEventArgs e)
        {
            DroppedFiles list = this.DataContext as DroppedFiles;

            string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
            if (files != null)
            {
                if (checkFileNmae(files[0]))
                {
                    BuiFile buiFile = new BuiFile();
                    buiFile.Load(files[0]);
                    convertBuiToDot(buiFile);
                }
                else
                {
                    this.Activate(); //  bring the window to the foreground.
                    var msg = "Non-bui file was dropped. Please drop the Bui file here.";
                    MessageBox.Show(this, msg, "Non-bui file", MessageBoxButton.OK);
                    this.txtBox.Text = "Error !!\n" + msg;
                }
            }
        }
コード例 #2
0
        void DragDrop_DragDrop(object sender, DragEventArgs e)
        {
            string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            if (paths.Length > 1)
            {
                MessageBox.Show("Error, only single folders are supported.  We'll traverse the tree and add all files under it.", "Error", MessageBoxButtons.OK);
                return;
            }
            string path = paths[0];

            RelativePath = Path.GetFullPath(path) + Path.DirectorySeparatorChar;

            FileAttributes attr = File.GetAttributes(path);

            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
            {
                AddFiles(path);
            }

            if (DroppedFiles != null)
            {
                DroppedFiles.Invoke(this, new EventArgs());
            }
        }