예제 #1
0
        private void OnDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var          files  = (string[])e.Data.GetData(DataFormats.FileDrop);
                AskXnbWindow dialog = null;

                foreach (var file in files)
                {
                    var filename = Path.GetFileName(file);

                    dialog = new AskXnbWindow(EDRegistry.ContentTempPath, filename);
                    dialog.TypeSelected += (s, evt) =>
                    {
                        if (evt.Type == typeof(Microsoft.Xna.Framework.Graphics.Effect))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Effects/", filename), true);
                        }

                        else if (evt.Type == typeof(Microsoft.Xna.Framework.Graphics.SpriteFont))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Fonts/", filename), true);
                        }

                        else if (evt.Type == typeof(Microsoft.Xna.Framework.Graphics.Model))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Models/", filename), true);
                            editorGameHost.AddModelFromTemp("Models/" + filename.Replace(".xnb", ""));
                        }

                        else if (evt.Type == typeof(Microsoft.Xna.Framework.Audio.SoundEffect))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Audio/Sounds/", filename), true);
                        }

                        else if (evt.Type == typeof(Microsoft.Xna.Framework.Media.Song))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Audio/Music/", filename), true);
                        }

                        else if (evt.Type == typeof(Microsoft.Xna.Framework.Graphics.Texture2D))
                        {
                            File.Copy(file, Path.Combine(EDRegistry.ContentTempPath + "/Textures/", filename), true);
                        }
                    };
                    dialog.Show();
                }
            }
        }
예제 #2
0
        public static void ImportFiles(string rootFolder, string[] files)
        {
            if (askXnbWindow == null)
            {
                askXnbWindow = new AskXnbWindow();
                askXnbWindow.TypeSelected += OnTypeSelected;
            }

            ActiveRootFolder = rootFolder;

            foreach (var file in files)
            {
                if (file.Contains("xnb"))
                {
                    askXnbWindow.Filepath = file;
                    askXnbWindow.Show();
                }
            }
        }