Ejemplo n.º 1
0
        internal string ImportProject(string importFrom)
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Title  = TextHelper.GetString("Title.ImportProject");
                dialog.Filter = TextHelper.GetString("Info.ImportProjectFilter");
                if (importFrom == "hxml")
                {
                    dialog.FilterIndex = 3;
                }
                if (dialog.ShowDialog() == DialogResult.OK && File.Exists(dialog.FileName))
                {
                    string fileName         = dialog.FileName;
                    string currentDirectory = Directory.GetCurrentDirectory();
                    try
                    {
                        if (FileInspector.IsHxml(Path.GetExtension(fileName).ToLower()))
                        {
                            var project = HaxeProject.Load(fileName);
                            var path    = Path.GetDirectoryName(project.ProjectPath);
                            var name    = Path.GetFileNameWithoutExtension(project.OutputPath);
                            var newPath = Path.Combine(path, $"{name}.hxproj");
                            PatchProject(project);
                            PatchHxmlProject(project);
                            project.SaveAs(newPath);
                            return(newPath);
                        }
                        if (FileInspector.IsFlexBuilderPackagedProject(fileName))
                        {
                            fileName = ExtractPackagedProject(fileName);
                        }
                        if (FileInspector.IsFlexBuilderProject(fileName))
                        {
                            AS3Project imported = AS3Project.Load(fileName);
                            string     path     = Path.GetDirectoryName(imported.ProjectPath);
                            string     name     = Path.GetFileNameWithoutExtension(imported.OutputPath);
                            string     newPath  = Path.Combine(path, name + ".as3proj");
                            PatchProject(imported);
                            PatchFbProject(imported);
                            imported.SaveAs(newPath);

                            return(newPath);
                        }
                        ErrorManager.ShowInfo(TextHelper.GetString("Info.NotValidFlashBuilderProject"));
                    }
                    catch (Exception exception)
                    {
                        Directory.SetCurrentDirectory(currentDirectory);
                        string msg = TextHelper.GetString("Info.CouldNotOpenProject");
                        ErrorManager.ShowInfo(msg + " " + exception.Message);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public string ImportProject()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title  = TextHelper.GetString("Title.ImportProject");
            dialog.Filter = TextHelper.GetString("Info.ImportProjectFilter");
            if (dialog.ShowDialog() == DialogResult.OK && File.Exists(dialog.FileName))
            {
                string fbProject        = dialog.FileName;
                string currentDirectory = Directory.GetCurrentDirectory();

                try
                {
                    if (FileInspector.IsFlexBuilderPackagedProject(fbProject))
                    {
                        fbProject = ExtractPackagedProject(fbProject);
                    }

                    if (FileInspector.IsFlexBuilderProject(fbProject))
                    {
                        AS3Project imported = AS3Project.Load(fbProject);
                        string     path     = Path.GetDirectoryName(imported.ProjectPath);
                        string     name     = Path.GetFileNameWithoutExtension(imported.OutputPath);
                        string     newPath  = Path.Combine(path, name + ".as3proj");
                        PatchProject(imported);
                        PatchFbProject(imported);
                        imported.SaveAs(newPath);

                        return(newPath);
                    }
                    else
                    {
                        ErrorManager.ShowInfo(TextHelper.GetString("Info.NotValidFlashBuilderProject"));
                    }
                }
                catch (Exception exception)
                {
                    Directory.SetCurrentDirectory(currentDirectory);
                    string msg = TextHelper.GetString("Info.CouldNotOpenProject");
                    ErrorManager.ShowInfo(msg + " " + exception.Message);
                }
            }
            return(null);
        }