Ejemplo n.º 1
0
        public FinalPageViewModel(IProgramWindow progWindow, IConfigurationProvider configurationProvider, IToInstallProvider toInstallProvider)
            : base("Finish", "")
        {
            vsCodeInstalled = toInstallProvider.Model.InstallVsCode;
            if (vsCodeInstalled)
            {
                if (OperatingSystem.IsMacOS())
                {
                    FinishText = "Clicking finish will open the VS Code folder.\nPlease drag this to your dock.";
                }
                else
                {
                    FinishText = "Use the WPILib VS Code desktop icon to start VS Code.";
                }
            }
            else
            {
                FinishText = "";
            }

            this.progWindow            = progWindow;
            this.configurationProvider = configurationProvider;
        }
        public InstallPageViewModel(IViewModelResolver viewModelResolver, IToInstallProvider toInstallProvider, IConfigurationProvider configurationProvider, IVsCodeInstallLocationProvider vsInstallProvider,
                                    IProgramWindow programWindow, ICatchableButtonFactory buttonFactory)
            : base("", "")
        {
            this.viewModelResolver     = viewModelResolver;
            this.toInstallProvider     = toInstallProvider;
            this.configurationProvider = configurationProvider;
            this.vsInstallProvider     = vsInstallProvider;
            this.programWindow         = programWindow;
            CancelInstall  = buttonFactory.CreateCatchableButton(CancelInstallFunc);
            runInstallTask = installFunc();

            async Task installFunc()
            {
                try
                {
                    await RunInstall();
                }
                catch (Exception e)
                {
                    viewModelResolver.ResolveMainWindow().HandleException(e);
                }
            }
        }
Ejemplo n.º 3
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
        public StartPageViewModel(IMainWindowViewModel mainRefresher, IProgramWindow mainWindow, IViewModelResolver viewModelResolver,
                                  ICatchableButtonFactory buttonFactory)
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
            : base("Start", "")
        {
            try
            {
                var rootDirectory = Directory.GetDirectoryRoot(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

                var driveInfo = new DriveInfo(rootDirectory);

                if (driveInfo.AvailableFreeSpace < 3L * 1000L * 1000L * 1000L)
                {
                    ;
                    // Fail
                }
            }
            catch
            {
                // Do nothing if we couldn't determine the drive
            }

            SelectSupportFiles  = buttonFactory.CreateCatchableButton(SelectSupportFilesFunc);
            SelectResourceFiles = buttonFactory.CreateCatchableButton(SelectResourceFilesFunc);

            this.programWindow     = mainWindow;
            this.viewModelResolver = viewModelResolver;
            refresher = mainRefresher;

            var baseDir = AppContext.BaseDirectory;

            try
            {
                verString = File.ReadAllText(Path.Join(baseDir, "WPILibInstallerVersion.txt")).Trim();
            }
            catch
            {
            }

            var extension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "zip" : "tar.gz";

            bool foundResources = false;
            bool foundSupport   = false;

            // Enumerate all files in base dir
            foreach (var file in Directory.EnumerateFiles(baseDir))
            {
                if (file.EndsWith($"{verString}-resources.zip"))
                {
                    _ = SelectResourceFilesWithFile(file);
                    foundResources = true;
                }
                else if (file.EndsWith($"{verString}-artifacts.{extension}"))
                {
                    _            = SelectSupportFilesWithFile(file);
                    foundSupport = true;
                }
            }

            // Assume app is running in a translocated process.
            if ((!foundResources || !foundSupport) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
                Directory.Exists("/Volumes/WPILibInstaller"))
            {
                baseDir = Path.GetFullPath("/Volumes/WPILibInstaller");
                foreach (var file in Directory.EnumerateFiles(baseDir))
                {
                    if (!foundResources && file.EndsWith($"{verString}-resources.zip"))
                    {
                        _ = SelectResourceFilesWithFile(file);
                        foundResources = true;
                    }
                    else if (!foundSupport && file.EndsWith($"{verString}-artifacts.{extension}"))
                    {
                        _            = SelectSupportFilesWithFile(file);
                        foundSupport = true;
                    }
                }
            }

            // Look beside the .app
            if ((!foundResources || !foundSupport) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                // Go back 3 directories to back out of mac package
                baseDir = Path.GetFullPath(Path.Join(baseDir, "..", "..", ".."));
                foreach (var file in Directory.EnumerateFiles(baseDir))
                {
                    if (!foundResources && file.EndsWith($"{verString}-resources.zip"))
                    {
                        _ = SelectResourceFilesWithFile(file);
                        foundResources = true;
                    }
                    else if (!foundSupport && file.EndsWith($"{verString}-artifacts.{extension}"))
                    {
                        _            = SelectSupportFilesWithFile(file);
                        foundSupport = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public FailedPageViewModel(IProgramWindow progWindow)
     : base("Finish", "")
 {
     this.progWindow = progWindow;
 }