private void DistroPropertiesForm_Load(object sender, EventArgs e) { var model = Model; if (model == null) { return; } DistroNameText.Text = model.DistroName; DistroIcon.Image = ImageList.Images[SharedRoutines.GetImageKey(model.DistroName)]; DistroLocation.Text = model.BasePath; State.Text = model.DistroName; IsDefaultDistro.Text = model.IsDefaultDistro ? "Yes" : "No"; WSLVersion.Text = model.WslVersion.ToString(); var dictionary = new Dictionary <string, object>(); dictionary.Add("Append NT Path", (model.AppendNtPath ? "Yes" : "No")); dictionary.Add("Enable Drive Mounting", (model.EnableDriveMounting ? "Yes" : "No")); dictionary.Add("Enable Interop", (model.EnableInterop ? "Yes" : "No")); dictionary.Add("Kernel Command Line", model.KernelCommandLine); dictionary.Add("Default Environment Variables", model.DefaultEnvironment); dictionary.Add("Default User ID", model.DefaultUid.ToString()); dictionary.Add("Distro Unique ID", model.DistroId); DistroPropertyGrid.SelectedObject = new DictionaryPropertyGridAdapter(dictionary); var ext4VhdxPath = Path.Combine( Path.GetFullPath(model.BasePath), "ext4.vhdx"); if (model.WslVersion < 2 || !File.Exists(ext4VhdxPath)) { DistroSizeCalculator.RunWorkerAsync(DistroLocation.Text); } else { DistroSize.Text = $"{(new FileInfo(ext4VhdxPath).Length / 1024 / 1024)} MiB"; } Text = $"{model.DistroName} Properties"; }
private bool CreateDistroShortcut(DistroProperties selectedDistro, string targetFilePath) { var shortcut = (IWshShortcut)wscriptShellType.InvokeMember( "CreateShortcut", BindingFlags.InvokeMethod, null, shellObject, new object[] { targetFilePath }); shortcut.Description = selectedDistro.DistroName; shortcut.TargetPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), "wsl.exe"); shortcut.WorkingDirectory = Environment.GetFolderPath( Environment.SpecialFolder.UserProfile); shortcut.Arguments = $@"-d {selectedDistro.DistroName}"; shortcut.IconLocation = Path.Combine( SharedRoutines.GetIconDirectoryPath(), SharedRoutines.GetImageKey(selectedDistro.DistroName) + ".ico"); shortcut.Save(); return(File.Exists(targetFilePath)); }