public override async Task Run(Command command)
        {
            var dialog = new VistaOpenFileDialog
            {
                Title       = "Resources.OpenFileDialogTitle",
                Multiselect = false,
                Filter      = "All Supported Files|" + string.Join(";", _solutionProviders.SelectMany(p => p.ExtensionTypes)
                                                                   .Select(t => $"*{t.Extension}"))
            };

            // generate filters
            foreach (var provider in _solutionProviders)
            {
                dialog.Filter += $"|{provider.Name}|{string.Join(";", provider.ExtensionTypes.Select(t => $"*{t.Extension}"))}";
            }

            if (dialog.ShowDialog() == true)
            {
                // find provider
                var extension = Path.GetExtension(dialog.FileName);

                var solutionProvider = System.Array.Find(_solutionProviders,
                                                         p => p.ExtensionTypes.Any(
                                                             t => string.Equals(t.Extension, extension, System.StringComparison.InvariantCultureIgnoreCase)));
                if (solutionProvider != null)
                {
                    var solutionInfo = await solutionProvider.Load(new FileFromPath(dialog.FileName)).ConfigureAwait(false);

                    _solutionExplorer.Load(solutionInfo);
                    _shell.ShowTool(_solutionExplorer);
                }
            }
        }
        public override Task Run(Command command)
        {
            var dialog = new VistaOpenFileDialog
            {
                Title       = "Resources.OpenFileDialogTitle",
                Multiselect = false,
                Filter      = "Factorio Modification Info|Info.json"
            };

            if (dialog.ShowDialog() == true)
            {
                // find provider
                var extension = Path.GetExtension(dialog.FileName);

                var projectProvider = System.Array.Find(_projectProviders,
                                                        p => p.ExtensionTypes.Any(
                                                            t => string.Equals(t.Extension, extension, System.StringComparison.InvariantCultureIgnoreCase)));
                if (projectProvider != null)
                {
                    var projectInfo = projectProvider.Load(new FileFromPath(dialog.FileName));
                    _solutionExplorer.Load(projectInfo);
                    _shell.ShowTool(_solutionExplorer);
                }
            }

            /*
             * var dialog = new VistaOpenFileDialog
             * {
             *  Title = "Resources.OpenFileDialogTitle",
             *  Multiselect = false,
             *  Filter = "All Supported Files|" + string.Join(";", _projectProviders.SelectMany(p => p.ExtensionTypes)
             *               .Select(t => $"*{t.Extension}"))
             * };
             *
             * // generate filters
             * foreach (var provider in _projectProviders)
             * {
             *  dialog.Filter += $"|{provider.Name}|{string.Join(";", provider.ExtensionTypes.Select(t => $"*{t.Extension}"))}";
             * }
             *
             * if (dialog.ShowDialog() == true)
             * {
             *  // find provider
             *  var extension = Path.GetExtension(dialog.FileName);
             *  var explorer = IoC.Get<ISolutionExplorer>();
             *
             *  var projectProvider = System.Array.Find(_projectProviders,
             *      p => p.ExtensionTypes.Any(
             *          t => string.Equals(t.Extension, extension, System.StringComparison.InvariantCultureIgnoreCase)));
             *  if (projectProvider != null)
             *  {
             *      explorer.LoadProject(new FileFromPath(dialog.FileName), projectProvider);
             *      _shell.ShowTool(explorer);
             *  }
             * }
             */

            return(Task.CompletedTask);
        }
Beispiel #3
0
        public override async Task Run(Command command)
        {
            if (!(_windowManager.ShowDialog(_newProjectDialog) is bool result) || !result)
            {
                return;
            }

            var root           = new FolderFromPath(_newProjectDialog.RootLocation);
            var solutionName   = _newProjectDialog.SolutionName.TrimStart().TrimEnd();
            var solutionFolder = await root.CreateFolderAsync(_newProjectDialog.SolutionName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);

            var projectName   = _newProjectDialog.ProjectName.TrimStart().TrimEnd();
            var projectFolder = _newProjectDialog.ProjectInRoot
                ? new FolderFromPath(solutionFolder.Path)
                : await solutionFolder.CreateFolderAsync(projectName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);

            var solutionData = new SolutionDataBase()
            {
                Name     = solutionName,
                Projects =
                {
                    new ProjectData()
                    {
                        Name = projectName,
                        Path = solutionFolder.GetProjectPath(projectFolder)
                    }
                }
            };

            var solutionProvider = new FactrIDESolutionProvider();
            var solutioFile      = await solutionProvider.Create(solutionData, solutionFolder).ConfigureAwait(false);

            var solutionInfo = await solutionProvider.Load(solutioFile).ConfigureAwait(false);

            _solutionExplorer.Load(solutionInfo);
        }