diff --git a/src/ScoopBoxManager.sln b/src/ScoopBoxManager.sln new file mode 100644 index 0000000..317ae6d --- /dev/null +++ b/src/ScoopBoxManager.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScoopBoxManager", "ScoopBoxManager\ScoopBoxManager.csproj", "{4A83E129-7251-4DBC-B842-B651CF093166}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A83E129-7251-4DBC-B842-B651CF093166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A83E129-7251-4DBC-B842-B651CF093166}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A83E129-7251-4DBC-B842-B651CF093166}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A83E129-7251-4DBC-B842-B651CF093166}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + VisualSVNWorkingCopyRoot = . + SolutionGuid = {71F77405-635E-4E47-A6D3-FB470BEE105C} + EndGlobalSection +EndGlobal diff --git a/src/ScoopBoxManager/Enums/PackageManager.cs b/src/ScoopBoxManager/Enums/PackageManager.cs new file mode 100644 index 0000000..fb31bc8 --- /dev/null +++ b/src/ScoopBoxManager/Enums/PackageManager.cs @@ -0,0 +1,7 @@ +namespace ScoopBoxManager.Enums; + +public enum PackageManagerType +{ + Scoop, + Chocolatey +} \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/AddApplication.Designer.cs b/src/ScoopBoxManager/Forms/AddApplication.Designer.cs new file mode 100644 index 0000000..75e3198 --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddApplication.Designer.cs @@ -0,0 +1,125 @@ +namespace ScoopBoxManager.Forms +{ + partial class AddApplication + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddApplication)); + this.BtnSave = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.TbApplication = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.CbPackageManager = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // BtnSave + // + this.BtnSave.Dock = System.Windows.Forms.DockStyle.Bottom; + this.BtnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnSave.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnSave.Image = global::ScoopBoxManager.Properties.Resources.save_32; + this.BtnSave.Location = new System.Drawing.Point(0, 147); + this.BtnSave.Name = "BtnSave"; + this.BtnSave.Size = new System.Drawing.Size(312, 45); + this.BtnSave.TabIndex = 2; + this.BtnSave.UseVisualStyleBackColor = true; + this.BtnSave.Click += new System.EventHandler(this.BtnSave_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(23, 77); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(101, 15); + this.label2.TabIndex = 13; + this.label2.Text = "package manager"; + // + // TbApplication + // + this.TbApplication.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbApplication.ForeColor = System.Drawing.Color.Black; + this.TbApplication.Location = new System.Drawing.Point(23, 40); + this.TbApplication.Name = "TbApplication"; + this.TbApplication.Size = new System.Drawing.Size(266, 23); + this.TbApplication.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(23, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 15); + this.label1.TabIndex = 11; + this.label1.Text = "application"; + // + // CbPackageManager + // + this.CbPackageManager.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbPackageManager.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbPackageManager.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbPackageManager.ForeColor = System.Drawing.Color.Black; + this.CbPackageManager.FormattingEnabled = true; + this.CbPackageManager.Location = new System.Drawing.Point(23, 95); + this.CbPackageManager.Name = "CbPackageManager"; + this.CbPackageManager.Size = new System.Drawing.Size(158, 23); + this.CbPackageManager.TabIndex = 1; + // + // AddApplication + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94))))); + this.ClientSize = new System.Drawing.Size(312, 192); + this.Controls.Add(this.CbPackageManager); + this.Controls.Add(this.BtnSave); + this.Controls.Add(this.label2); + this.Controls.Add(this.TbApplication); + this.Controls.Add(this.label1); + this.DoubleBuffered = true; + this.ForeColor = System.Drawing.Color.White; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AddApplication"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Application"; + this.Load += new System.EventHandler(this.Application_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal Button BtnSave; + private Label label2; + internal TextBox TbApplication; + private Label label1; + internal ComboBox CbPackageManager; + } +} \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/AddApplication.cs b/src/ScoopBoxManager/Forms/AddApplication.cs new file mode 100644 index 0000000..c2fe306 --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddApplication.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ScoopBoxManager.Enums; +using ScoopBoxManager.Models; + +namespace ScoopBoxManager.Forms +{ + public partial class AddApplication : Form + { + public PackageManagerApplication Application { get; set; } = null; + public int ListviewIndex { get; set; } = -1; + + public AddApplication(PackageManagerApplication application, int listviewIndex) + { + Application = application; + ListviewIndex = listviewIndex; + + InitializeComponent(); + } + + public AddApplication() + { + InitializeComponent(); + } + + /// + /// Optionally loads the provided application + /// + /// + /// + private void Application_Load(object sender, EventArgs e) + { + // load enum + CbPackageManager.DataSource = Enum.GetValues(typeof(PackageManagerType)); + + if (Application == null) return; + + // load linked application + CbPackageManager.Text = Application.PackageManager.ToString(); + TbApplication.Text = Application.Package; + } + + /// + /// Converts the settings to a PackageManagerApplication object + /// + /// + /// + private void BtnSave_Click(object sender, EventArgs e) + { + // get values + var app = TbApplication.Text.Trim(); + var manager = Enum.Parse(CbPackageManager.SelectedValue.ToString() ?? "Scoop"); + + // basic checks + if (string.IsNullOrEmpty(app)) + { + MessageBox.Show("Enter an application.", "ScoopBoxManager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ActiveControl = TbApplication; + return; + } + + // optionally create new obj + Application ??= new PackageManagerApplication(); + + // map values + Application.Package = app; + Application.PackageManager = manager; + + // done! + DialogResult = DialogResult.OK; + } + } +} diff --git a/src/ScoopBoxManager/Forms/AddApplication.resx b/src/ScoopBoxManager/Forms/AddApplication.resx new file mode 100644 index 0000000..fd6616d --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddApplication.resx @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIADVBAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAgAAAAIAgGAAAAc3p69AAAAAFz + UkdCAK7OHOkAAAAEZ0FNQQAAsY8L/GEFAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEaklEQVRYR+1WfUyV + VRx+CvCDUjPJO76CvLvMYCZJMWk6zKyGimsR2togR6lRm4ymJmMWuO6iYjgamkU6dX1YbY4tN6GWdZcK + QRRKOLQwCYFAviEEEeo8v73v5YX7XrhrFX/Us92d95z7nvf3nOc8v985N90Xl/wHphA3a+2U4X8CkxKI + iVqE3du2IPreCG1kYtw2exYy01Kwcf1abWRieGxC35kzMHPGdDy07H7ELl2C0GB/zPe7Xf5r7+xGQ1ML + TlecRYmjDM0tbTLuCTwiMOsWX6Q8uQ7r41dh2jQfXLz0K6prf0ZHZw98fLxhDQ3CooVWWf3w8DBOnDyD + gkOfCrHJMCmBu213IXfXVlntl6cqsFd9mEqQBIl5eXmhq6cXkRFhaGnrQGpSAuJWPoDe3/uRmbMPpZXV + 2pfMMSEB7n/urjT0Dwwgp+CwECC4x5HhYbINBFda+t05ZO95T/pUg++EBvnLvKISh4ybwa0J/S1+sO98 + HpevNCNxc4Yz+PLoSMSvWuYMTsybO0dWvSImSvpcPbeD6mxPTRIV3cEtgVfSN8FXSZ2dVygSE/xg+uan + pB2Prp4+RbZJiO3PyZCxlBd3Cxn7S6mmcwhTApQ+6p6FOHj0M9lrHeG2UAQHWLTeKLgFz+18TZ714OxX + 19Yh/8BRmfPYo7EyPh6mHthr3yFbkLglQ1ytg1IbpdfR0NSq0nT6mOCXG5rlmSh8M1PmPv7sDm1kFC4K + MN/p6M8d38qK9YBsxwcfHh5B5blal+CD14fkOWzBnVI3ir8qFRXM1PPWWicWh9sk1x1l36NVpVX8w8ux + YEOgGMlIgMpkvv62jBmDW0OCJAOOf/ENmlvbpdXnRUdGSMEywkUBi6G68Xfok+N4OfcdpxEJPXhd/RWX + 4DRcX18/8t79EB8VlYgJ6+ob5Z075s2V1ggXAsbyagQ/REwW3Mzt/dcGRE2LnwcE+CJhDQmUVkd3d6/H + wY1q6aAJW9o6td4oXAiwnBLhWvGgKRNWr0SYNcTjlVPFtco79BKhF6Wr7R4QOHv+J1xXLrYpB9M8W5/Z + oGpBPZLTsjyWvajYgfaOLqmCzIQVMUtkvLyqRlojXAhwv6pqLsqkViUZazkLSnDAfI/3/OTpCjmE7PkH + xYDrVBGi+8dnAOFCgHj/2AmRMfmJNdI3SzV3wVkXjNUzYfWDcjh9cKxYGxkLUwJkzw8lJcTJ4WMMHuxv + cRucmcKU1cFq+sLGRFm5uxPRlACRvacQg0NDyMtKlz6Ds7xWVtfijMkZz/82bbM7s4jm5YHmrYjSvMaS + boRXgG1xlvY8BiMjI6i5cElKKdPqB+WLxt+uYujGDZR8XYYflS+a1NXrl4ZGkfctdejowXmQFby6Xd2U + AvHGviM4VV4l42ZweyF5JHapOg/KxtyI2M8/8LEz0HjwnacT18jVjdvBG1F51Xk5U2hkM/ylOyEJXFBG + q1eyXxsYxJzZt0q68RCj1H/rndAIVrMpuRX/k3CbBf8W/usEgD8B3es0Hn532FcAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/AddMappedFolder.Designer.cs b/src/ScoopBoxManager/Forms/AddMappedFolder.Designer.cs new file mode 100644 index 0000000..c2bbe67 --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddMappedFolder.Designer.cs @@ -0,0 +1,152 @@ +namespace ScoopBoxManager.Forms +{ + partial class AddMappedFolder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddMappedFolder)); + this.TbSandboxFolder = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.TbHostFolder = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.CbReadOnly = new System.Windows.Forms.CheckBox(); + this.BtnSave = new System.Windows.Forms.Button(); + this.label15 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // TbSandboxFolder + // + this.TbSandboxFolder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbSandboxFolder.ForeColor = System.Drawing.Color.Black; + this.TbSandboxFolder.Location = new System.Drawing.Point(13, 96); + this.TbSandboxFolder.Name = "TbSandboxFolder"; + this.TbSandboxFolder.Size = new System.Drawing.Size(378, 23); + this.TbSandboxFolder.TabIndex = 1; + this.TbSandboxFolder.Text = "C:\\Users\\WDAGUtilityAccount\\Desktop"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 78); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(86, 15); + this.label2.TabIndex = 6; + this.label2.Text = "sandbox folder"; + // + // TbHostFolder + // + this.TbHostFolder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbHostFolder.ForeColor = System.Drawing.Color.Black; + this.TbHostFolder.Location = new System.Drawing.Point(12, 35); + this.TbHostFolder.Name = "TbHostFolder"; + this.TbHostFolder.Size = new System.Drawing.Size(378, 23); + this.TbHostFolder.TabIndex = 0; + this.TbHostFolder.TextChanged += new System.EventHandler(this.TbHostFolder_TextChanged); + this.TbHostFolder.DoubleClick += new System.EventHandler(this.TbHostFolder_DoubleClick); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(64, 15); + this.label1.TabIndex = 4; + this.label1.Text = "host folder"; + // + // CbReadOnly + // + this.CbReadOnly.AutoSize = true; + this.CbReadOnly.Checked = true; + this.CbReadOnly.CheckState = System.Windows.Forms.CheckState.Checked; + this.CbReadOnly.Location = new System.Drawing.Point(13, 137); + this.CbReadOnly.Name = "CbReadOnly"; + this.CbReadOnly.Size = new System.Drawing.Size(72, 19); + this.CbReadOnly.TabIndex = 8; + this.CbReadOnly.Text = "readonly"; + this.CbReadOnly.UseVisualStyleBackColor = true; + // + // BtnSave + // + this.BtnSave.Dock = System.Windows.Forms.DockStyle.Bottom; + this.BtnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnSave.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnSave.Image = global::ScoopBoxManager.Properties.Resources.save_32; + this.BtnSave.Location = new System.Drawing.Point(0, 185); + this.BtnSave.Name = "BtnSave"; + this.BtnSave.Size = new System.Drawing.Size(403, 45); + this.BtnSave.TabIndex = 2; + this.BtnSave.UseVisualStyleBackColor = true; + this.BtnSave.Click += new System.EventHandler(this.BtnSave_Click); + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(189, 17); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(201, 15); + this.label15.TabIndex = 10; + this.label15.Text = "tip: double-click to open a file dialog"; + // + // AddMappedFolder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94))))); + this.ClientSize = new System.Drawing.Size(403, 230); + this.Controls.Add(this.label15); + this.Controls.Add(this.BtnSave); + this.Controls.Add(this.CbReadOnly); + this.Controls.Add(this.TbSandboxFolder); + this.Controls.Add(this.label2); + this.Controls.Add(this.TbHostFolder); + this.Controls.Add(this.label1); + this.DoubleBuffered = true; + this.ForeColor = System.Drawing.Color.White; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AddMappedFolder"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Mapped Folder"; + this.Load += new System.EventHandler(this.MappedFolder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal TextBox TbSandboxFolder; + private Label label2; + internal TextBox TbHostFolder; + private Label label1; + private CheckBox CbReadOnly; + internal Button BtnSave; + private Label label15; + } +} \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/AddMappedFolder.cs b/src/ScoopBoxManager/Forms/AddMappedFolder.cs new file mode 100644 index 0000000..67b76bd --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddMappedFolder.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ScoopBox; + +namespace ScoopBoxManager.Forms +{ + public partial class AddMappedFolder : Form + { + public MappedFolder MappedFolder { get; set; } = null; + public int ListviewIndex { get; set; } = -1; + + public AddMappedFolder(MappedFolder mappedFolder, int listviewIndex) + { + MappedFolder = mappedFolder; + ListviewIndex = listviewIndex; + + InitializeComponent(); + } + + public AddMappedFolder() + { + InitializeComponent(); + } + + /// + /// Optionally loads the provided mapped folder + /// + /// + /// + private void MappedFolder_Load(object sender, EventArgs e) + { + TbSandboxFolder.Text = Variables.SandboxRoot; + + if (MappedFolder == null) return; + + // load linked mapped folder + TbHostFolder.Text = MappedFolder.HostFolder; + TbSandboxFolder.Text = MappedFolder.SandboxFolder; + CbReadOnly.Checked = MappedFolder.ReadOnly == "true"; + } + + /// + /// Converts the settings to a MappedFolder object + /// + /// + /// + private void BtnSave_Click(object sender, EventArgs e) + { + // get values + var hostFolder = TbHostFolder.Text.Trim(); + var sandboxFolder = TbSandboxFolder.Text.Trim(); + var ro = CbReadOnly.Checked ? "true" : "false"; + + // basic checks + if (string.IsNullOrEmpty(hostFolder)) + { + MessageBox.Show("Enter a host folder (or doubleclick to select one).", "ScoopBoxManager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ActiveControl = TbHostFolder; + return; + } + + if (string.IsNullOrEmpty(sandboxFolder)) + { + MessageBox.Show("Enter a sandbox folder (or doubleclick to select one).", "ScoopBoxManager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ActiveControl = TbSandboxFolder; + return; + } + + // optionally create new obj + MappedFolder ??= new MappedFolder(); + + // map values + MappedFolder.HostFolder = hostFolder; + MappedFolder.SandboxFolder = sandboxFolder; + MappedFolder.ReadOnly = ro; + + // done! + DialogResult = DialogResult.OK; + } + + private void TbHostFolder_DoubleClick(object sender, EventArgs e) + { + using var dialog = new FolderBrowserDialog(); + + dialog.ShowNewFolderButton = true; + dialog.RootFolder = Environment.SpecialFolder.MyComputer; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + TbHostFolder.Text = dialog.SelectedPath; + + // if sandbox folder starts with root, modify accordinly + if (!TbSandboxFolder.Text.StartsWith(Variables.SandboxRoot)) return; + var lastPart = Path.GetFileName(dialog.SelectedPath); + TbSandboxFolder.Text = $"{Variables.SandboxRoot}\\{lastPart}"; + } + + private void TbHostFolder_TextChanged(object sender, EventArgs e) + { + // if sandbox folder starts with root, modify accordinly + if (!TbSandboxFolder.Text.StartsWith(Variables.SandboxRoot)) return; + + // get the host folder, check for empty + var hostfolder = TbHostFolder.Text.Trim(); + if (string.IsNullOrEmpty(hostfolder)) + { + TbSandboxFolder.Text = $"{Variables.SandboxRoot}\\"; + return; + } + + // set corresponding value + var lastPart = hostfolder.Split('\\').Last(); + TbSandboxFolder.Text = $"{Variables.SandboxRoot}\\{lastPart}\\"; + } + } +} diff --git a/src/ScoopBoxManager/Forms/AddMappedFolder.resx b/src/ScoopBoxManager/Forms/AddMappedFolder.resx new file mode 100644 index 0000000..fd6616d --- /dev/null +++ b/src/ScoopBoxManager/Forms/AddMappedFolder.resx @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIADVBAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAgAAAAIAgGAAAAc3p69AAAAAFz + UkdCAK7OHOkAAAAEZ0FNQQAAsY8L/GEFAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEaklEQVRYR+1WfUyV + VRx+CvCDUjPJO76CvLvMYCZJMWk6zKyGimsR2togR6lRm4ymJmMWuO6iYjgamkU6dX1YbY4tN6GWdZcK + QRRKOLQwCYFAviEEEeo8v73v5YX7XrhrFX/Us92d95z7nvf3nOc8v985N90Xl/wHphA3a+2U4X8CkxKI + iVqE3du2IPreCG1kYtw2exYy01Kwcf1abWRieGxC35kzMHPGdDy07H7ELl2C0GB/zPe7Xf5r7+xGQ1ML + TlecRYmjDM0tbTLuCTwiMOsWX6Q8uQ7r41dh2jQfXLz0K6prf0ZHZw98fLxhDQ3CooVWWf3w8DBOnDyD + gkOfCrHJMCmBu213IXfXVlntl6cqsFd9mEqQBIl5eXmhq6cXkRFhaGnrQGpSAuJWPoDe3/uRmbMPpZXV + 2pfMMSEB7n/urjT0Dwwgp+CwECC4x5HhYbINBFda+t05ZO95T/pUg++EBvnLvKISh4ybwa0J/S1+sO98 + HpevNCNxc4Yz+PLoSMSvWuYMTsybO0dWvSImSvpcPbeD6mxPTRIV3cEtgVfSN8FXSZ2dVygSE/xg+uan + pB2Prp4+RbZJiO3PyZCxlBd3Cxn7S6mmcwhTApQ+6p6FOHj0M9lrHeG2UAQHWLTeKLgFz+18TZ714OxX + 19Yh/8BRmfPYo7EyPh6mHthr3yFbkLglQ1ytg1IbpdfR0NSq0nT6mOCXG5rlmSh8M1PmPv7sDm1kFC4K + MN/p6M8d38qK9YBsxwcfHh5B5blal+CD14fkOWzBnVI3ir8qFRXM1PPWWicWh9sk1x1l36NVpVX8w8ux + YEOgGMlIgMpkvv62jBmDW0OCJAOOf/ENmlvbpdXnRUdGSMEywkUBi6G68Xfok+N4OfcdpxEJPXhd/RWX + 4DRcX18/8t79EB8VlYgJ6+ob5Z075s2V1ggXAsbyagQ/REwW3Mzt/dcGRE2LnwcE+CJhDQmUVkd3d6/H + wY1q6aAJW9o6td4oXAiwnBLhWvGgKRNWr0SYNcTjlVPFtco79BKhF6Wr7R4QOHv+J1xXLrYpB9M8W5/Z + oGpBPZLTsjyWvajYgfaOLqmCzIQVMUtkvLyqRlojXAhwv6pqLsqkViUZazkLSnDAfI/3/OTpCjmE7PkH + xYDrVBGi+8dnAOFCgHj/2AmRMfmJNdI3SzV3wVkXjNUzYfWDcjh9cKxYGxkLUwJkzw8lJcTJ4WMMHuxv + cRucmcKU1cFq+sLGRFm5uxPRlACRvacQg0NDyMtKlz6Ds7xWVtfijMkZz/82bbM7s4jm5YHmrYjSvMaS + boRXgG1xlvY8BiMjI6i5cElKKdPqB+WLxt+uYujGDZR8XYYflS+a1NXrl4ZGkfctdejowXmQFby6Xd2U + AvHGviM4VV4l42ZweyF5JHapOg/KxtyI2M8/8LEz0HjwnacT18jVjdvBG1F51Xk5U2hkM/ylOyEJXFBG + q1eyXxsYxJzZt0q68RCj1H/rndAIVrMpuRX/k3CbBf8W/usEgD8B3es0Hn532FcAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/Main.Designer.cs b/src/ScoopBoxManager/Forms/Main.Designer.cs new file mode 100644 index 0000000..7111d49 --- /dev/null +++ b/src/ScoopBoxManager/Forms/Main.Designer.cs @@ -0,0 +1,722 @@ +namespace ScoopBoxManager.Forms +{ + partial class Main + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); + this.BtnLaunch = new System.Windows.Forms.Button(); + this.GpGeneralConfig = new System.Windows.Forms.GroupBox(); + this.label12 = new System.Windows.Forms.Label(); + this.NumMemory = new System.Windows.Forms.NumericUpDown(); + this.label11 = new System.Windows.Forms.Label(); + this.CbVgpu = new System.Windows.Forms.ComboBox(); + this.label10 = new System.Windows.Forms.Label(); + this.CbClipboardRedirection = new System.Windows.Forms.ComboBox(); + this.label9 = new System.Windows.Forms.Label(); + this.CbPrinterRedirection = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.CbProtectedClient = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.CbNetworking = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.CbVideoInput = new System.Windows.Forms.ComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.CbAudioInput = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.TbRootSandboxFilesDirectory = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.TbRootfilesDirectory = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.TbSandboxConfigurationFile = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.GpMappedFolders = new System.Windows.Forms.GroupBox(); + this.BtnRemoveMappedFolder = new System.Windows.Forms.Button(); + this.BtnAddMappedFolder = new System.Windows.Forms.Button(); + this.LvMappedFolders = new System.Windows.Forms.ListView(); + this.ClmHostFolder = new System.Windows.Forms.ColumnHeader(); + this.ClmSandboxFolder = new System.Windows.Forms.ColumnHeader(); + this.ClmReadonly = new System.Windows.Forms.ColumnHeader(); + this.label13 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.BtnRemoveApplication = new System.Windows.Forms.Button(); + this.BtnAddApplication = new System.Windows.Forms.Button(); + this.LvApplications = new System.Windows.Forms.ListView(); + this.ClmApplication = new System.Windows.Forms.ColumnHeader(); + this.ClmPackageManager = new System.Windows.Forms.ColumnHeader(); + this.label14 = new System.Windows.Forms.Label(); + this.BtnSaveSettings = new System.Windows.Forms.Button(); + this.BtnLoadSettings = new System.Windows.Forms.Button(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.LblScoopBox = new System.Windows.Forms.Label(); + this.LblSettingsStored = new System.Windows.Forms.Label(); + this.LblSettingsLoaded = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label18 = new System.Windows.Forms.Label(); + this.GpGeneralConfig.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NumMemory)).BeginInit(); + this.GpMappedFolders.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // BtnLaunch + // + this.BtnLaunch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnLaunch.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnLaunch.Location = new System.Drawing.Point(713, 534); + this.BtnLaunch.Name = "BtnLaunch"; + this.BtnLaunch.Size = new System.Drawing.Size(330, 55); + this.BtnLaunch.TabIndex = 8; + this.BtnLaunch.Text = "LAUNCH SANDBOX"; + this.BtnLaunch.UseVisualStyleBackColor = true; + this.BtnLaunch.Click += new System.EventHandler(this.BtnLaunch_Click); + // + // GpGeneralConfig + // + this.GpGeneralConfig.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94))))); + this.GpGeneralConfig.Controls.Add(this.label12); + this.GpGeneralConfig.Controls.Add(this.NumMemory); + this.GpGeneralConfig.Controls.Add(this.label11); + this.GpGeneralConfig.Controls.Add(this.CbVgpu); + this.GpGeneralConfig.Controls.Add(this.label10); + this.GpGeneralConfig.Controls.Add(this.CbClipboardRedirection); + this.GpGeneralConfig.Controls.Add(this.label9); + this.GpGeneralConfig.Controls.Add(this.CbPrinterRedirection); + this.GpGeneralConfig.Controls.Add(this.label8); + this.GpGeneralConfig.Controls.Add(this.CbProtectedClient); + this.GpGeneralConfig.Controls.Add(this.label7); + this.GpGeneralConfig.Controls.Add(this.CbNetworking); + this.GpGeneralConfig.Controls.Add(this.label6); + this.GpGeneralConfig.Controls.Add(this.CbVideoInput); + this.GpGeneralConfig.Controls.Add(this.label5); + this.GpGeneralConfig.Controls.Add(this.CbAudioInput); + this.GpGeneralConfig.Controls.Add(this.label4); + this.GpGeneralConfig.Location = new System.Drawing.Point(12, 12); + this.GpGeneralConfig.Name = "GpGeneralConfig"; + this.GpGeneralConfig.Size = new System.Drawing.Size(433, 261); + this.GpGeneralConfig.TabIndex = 1; + this.GpGeneralConfig.TabStop = false; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(6, 1); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(121, 15); + this.label12.TabIndex = 22; + this.label12.Text = "general configuration"; + // + // NumMemory + // + this.NumMemory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.NumMemory.ForeColor = System.Drawing.Color.Black; + this.NumMemory.Location = new System.Drawing.Point(247, 157); + this.NumMemory.Maximum = new decimal(new int[] { + 262144, + 0, + 0, + 0}); + this.NumMemory.Name = "NumMemory"; + this.NumMemory.Size = new System.Drawing.Size(158, 23); + this.NumMemory.TabIndex = 5; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(247, 139); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(81, 15); + this.label11.TabIndex = 20; + this.label11.Text = "memory (mb)"; + // + // CbVgpu + // + this.CbVgpu.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbVgpu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbVgpu.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbVgpu.ForeColor = System.Drawing.Color.Black; + this.CbVgpu.FormattingEnabled = true; + this.CbVgpu.Location = new System.Drawing.Point(27, 157); + this.CbVgpu.Name = "CbVgpu"; + this.CbVgpu.Size = new System.Drawing.Size(158, 23); + this.CbVgpu.TabIndex = 4; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(27, 139); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(34, 15); + this.label10.TabIndex = 18; + this.label10.Text = "vgpu"; + // + // CbClipboardRedirection + // + this.CbClipboardRedirection.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbClipboardRedirection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbClipboardRedirection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbClipboardRedirection.ForeColor = System.Drawing.Color.Black; + this.CbClipboardRedirection.FormattingEnabled = true; + this.CbClipboardRedirection.Location = new System.Drawing.Point(247, 212); + this.CbClipboardRedirection.Name = "CbClipboardRedirection"; + this.CbClipboardRedirection.Size = new System.Drawing.Size(158, 23); + this.CbClipboardRedirection.TabIndex = 7; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(247, 194); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(117, 15); + this.label9.TabIndex = 16; + this.label9.Text = "clipboard redirection"; + // + // CbPrinterRedirection + // + this.CbPrinterRedirection.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbPrinterRedirection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbPrinterRedirection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbPrinterRedirection.ForeColor = System.Drawing.Color.Black; + this.CbPrinterRedirection.FormattingEnabled = true; + this.CbPrinterRedirection.Location = new System.Drawing.Point(247, 102); + this.CbPrinterRedirection.Name = "CbPrinterRedirection"; + this.CbPrinterRedirection.Size = new System.Drawing.Size(158, 23); + this.CbPrinterRedirection.TabIndex = 3; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(247, 84); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(102, 15); + this.label8.TabIndex = 14; + this.label8.Text = "printer redirection"; + // + // CbProtectedClient + // + this.CbProtectedClient.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbProtectedClient.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbProtectedClient.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbProtectedClient.ForeColor = System.Drawing.Color.Black; + this.CbProtectedClient.FormattingEnabled = true; + this.CbProtectedClient.Location = new System.Drawing.Point(27, 102); + this.CbProtectedClient.Name = "CbProtectedClient"; + this.CbProtectedClient.Size = new System.Drawing.Size(158, 23); + this.CbProtectedClient.TabIndex = 2; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(27, 84); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(90, 15); + this.label7.TabIndex = 12; + this.label7.Text = "protected client"; + // + // CbNetworking + // + this.CbNetworking.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbNetworking.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbNetworking.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbNetworking.ForeColor = System.Drawing.Color.Black; + this.CbNetworking.FormattingEnabled = true; + this.CbNetworking.Location = new System.Drawing.Point(27, 212); + this.CbNetworking.Name = "CbNetworking"; + this.CbNetworking.Size = new System.Drawing.Size(158, 23); + this.CbNetworking.TabIndex = 6; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(27, 194); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(67, 15); + this.label6.TabIndex = 10; + this.label6.Text = "networking"; + // + // CbVideoInput + // + this.CbVideoInput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbVideoInput.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbVideoInput.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbVideoInput.ForeColor = System.Drawing.Color.Black; + this.CbVideoInput.FormattingEnabled = true; + this.CbVideoInput.Location = new System.Drawing.Point(247, 47); + this.CbVideoInput.Name = "CbVideoInput"; + this.CbVideoInput.Size = new System.Drawing.Size(158, 23); + this.CbVideoInput.TabIndex = 1; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(247, 29); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(67, 15); + this.label5.TabIndex = 8; + this.label5.Text = "video input"; + // + // CbAudioInput + // + this.CbAudioInput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.CbAudioInput.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbAudioInput.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CbAudioInput.ForeColor = System.Drawing.Color.Black; + this.CbAudioInput.FormattingEnabled = true; + this.CbAudioInput.Location = new System.Drawing.Point(27, 47); + this.CbAudioInput.Name = "CbAudioInput"; + this.CbAudioInput.Size = new System.Drawing.Size(158, 23); + this.CbAudioInput.TabIndex = 0; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(27, 29); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(68, 15); + this.label4.TabIndex = 6; + this.label4.Text = "audio input"; + // + // TbRootSandboxFilesDirectory + // + this.TbRootSandboxFilesDirectory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbRootSandboxFilesDirectory.ForeColor = System.Drawing.Color.Black; + this.TbRootSandboxFilesDirectory.Location = new System.Drawing.Point(27, 168); + this.TbRootSandboxFilesDirectory.Name = "TbRootSandboxFilesDirectory"; + this.TbRootSandboxFilesDirectory.Size = new System.Drawing.Size(378, 23); + this.TbRootSandboxFilesDirectory.TabIndex = 5; + this.TbRootSandboxFilesDirectory.DoubleClick += new System.EventHandler(this.TbRootSandboxFilesDirectory_DoubleClick); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(27, 150); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(194, 15); + this.label3.TabIndex = 4; + this.label3.Text = "root sandboxfiles directory location"; + // + // TbRootfilesDirectory + // + this.TbRootfilesDirectory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbRootfilesDirectory.ForeColor = System.Drawing.Color.Black; + this.TbRootfilesDirectory.Location = new System.Drawing.Point(27, 113); + this.TbRootfilesDirectory.Name = "TbRootfilesDirectory"; + this.TbRootfilesDirectory.Size = new System.Drawing.Size(378, 23); + this.TbRootfilesDirectory.TabIndex = 3; + this.TbRootfilesDirectory.DoubleClick += new System.EventHandler(this.TbRootfilesDirectory_DoubleClick); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(27, 95); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(146, 15); + this.label2.TabIndex = 2; + this.label2.Text = "rootfiles directory location"; + // + // TbSandboxConfigurationFile + // + this.TbSandboxConfigurationFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.TbSandboxConfigurationFile.ForeColor = System.Drawing.Color.Black; + this.TbSandboxConfigurationFile.Location = new System.Drawing.Point(27, 58); + this.TbSandboxConfigurationFile.Name = "TbSandboxConfigurationFile"; + this.TbSandboxConfigurationFile.Size = new System.Drawing.Size(378, 23); + this.TbSandboxConfigurationFile.TabIndex = 1; + this.TbSandboxConfigurationFile.DoubleClick += new System.EventHandler(this.TbSandboxConfigurationFile_DoubleClick); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(27, 40); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(146, 15); + this.label1.TabIndex = 0; + this.label1.Text = "sandbox configuration file"; + // + // GpMappedFolders + // + this.GpMappedFolders.Controls.Add(this.BtnRemoveMappedFolder); + this.GpMappedFolders.Controls.Add(this.BtnAddMappedFolder); + this.GpMappedFolders.Controls.Add(this.LvMappedFolders); + this.GpMappedFolders.Controls.Add(this.label13); + this.GpMappedFolders.Location = new System.Drawing.Point(466, 12); + this.GpMappedFolders.Name = "GpMappedFolders"; + this.GpMappedFolders.Size = new System.Drawing.Size(577, 240); + this.GpMappedFolders.TabIndex = 2; + this.GpMappedFolders.TabStop = false; + // + // BtnRemoveMappedFolder + // + this.BtnRemoveMappedFolder.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnRemoveMappedFolder.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnRemoveMappedFolder.Image = global::ScoopBoxManager.Properties.Resources.remove_24; + this.BtnRemoveMappedFolder.Location = new System.Drawing.Point(6, 202); + this.BtnRemoveMappedFolder.Name = "BtnRemoveMappedFolder"; + this.BtnRemoveMappedFolder.Size = new System.Drawing.Size(69, 32); + this.BtnRemoveMappedFolder.TabIndex = 26; + this.BtnRemoveMappedFolder.UseVisualStyleBackColor = true; + this.BtnRemoveMappedFolder.Click += new System.EventHandler(this.BtnRemoveMappedFolder_Click); + // + // BtnAddMappedFolder + // + this.BtnAddMappedFolder.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnAddMappedFolder.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnAddMappedFolder.Image = global::ScoopBoxManager.Properties.Resources.add_24; + this.BtnAddMappedFolder.Location = new System.Drawing.Point(502, 202); + this.BtnAddMappedFolder.Name = "BtnAddMappedFolder"; + this.BtnAddMappedFolder.Size = new System.Drawing.Size(69, 32); + this.BtnAddMappedFolder.TabIndex = 25; + this.BtnAddMappedFolder.UseVisualStyleBackColor = true; + this.BtnAddMappedFolder.Click += new System.EventHandler(this.BtnAddMappedFolder_Click); + // + // LvMappedFolders + // + this.LvMappedFolders.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.LvMappedFolders.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.ClmHostFolder, + this.ClmSandboxFolder, + this.ClmReadonly}); + this.LvMappedFolders.Dock = System.Windows.Forms.DockStyle.Top; + this.LvMappedFolders.ForeColor = System.Drawing.Color.Black; + this.LvMappedFolders.FullRowSelect = true; + this.LvMappedFolders.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.LvMappedFolders.Location = new System.Drawing.Point(3, 19); + this.LvMappedFolders.MultiSelect = false; + this.LvMappedFolders.Name = "LvMappedFolders"; + this.LvMappedFolders.Size = new System.Drawing.Size(571, 177); + this.LvMappedFolders.TabIndex = 24; + this.LvMappedFolders.UseCompatibleStateImageBehavior = false; + this.LvMappedFolders.View = System.Windows.Forms.View.Details; + this.LvMappedFolders.DoubleClick += new System.EventHandler(this.LvMappedFolders_DoubleClick); + // + // ClmHostFolder + // + this.ClmHostFolder.Text = "host folder"; + this.ClmHostFolder.Width = 240; + // + // ClmSandboxFolder + // + this.ClmSandboxFolder.Text = "sandbox folder"; + this.ClmSandboxFolder.Width = 240; + // + // ClmReadonly + // + this.ClmReadonly.Text = "readonly"; + this.ClmReadonly.Width = 70; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(6, 1); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(90, 15); + this.label13.TabIndex = 23; + this.label13.Text = "mapped folders"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.BtnRemoveApplication); + this.groupBox1.Controls.Add(this.BtnAddApplication); + this.groupBox1.Controls.Add(this.LvApplications); + this.groupBox1.Controls.Add(this.label14); + this.groupBox1.Location = new System.Drawing.Point(466, 261); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(577, 240); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + // + // BtnRemoveApplication + // + this.BtnRemoveApplication.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnRemoveApplication.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnRemoveApplication.Image = global::ScoopBoxManager.Properties.Resources.remove_24; + this.BtnRemoveApplication.Location = new System.Drawing.Point(6, 202); + this.BtnRemoveApplication.Name = "BtnRemoveApplication"; + this.BtnRemoveApplication.Size = new System.Drawing.Size(69, 32); + this.BtnRemoveApplication.TabIndex = 26; + this.BtnRemoveApplication.UseVisualStyleBackColor = true; + this.BtnRemoveApplication.Click += new System.EventHandler(this.BtnRemoveApplication_Click); + // + // BtnAddApplication + // + this.BtnAddApplication.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnAddApplication.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnAddApplication.Image = global::ScoopBoxManager.Properties.Resources.add_24; + this.BtnAddApplication.Location = new System.Drawing.Point(502, 202); + this.BtnAddApplication.Name = "BtnAddApplication"; + this.BtnAddApplication.Size = new System.Drawing.Size(69, 32); + this.BtnAddApplication.TabIndex = 25; + this.BtnAddApplication.UseVisualStyleBackColor = true; + this.BtnAddApplication.Click += new System.EventHandler(this.BtnAddApplication_Click); + // + // LvApplications + // + this.LvApplications.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.LvApplications.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.ClmApplication, + this.ClmPackageManager}); + this.LvApplications.Dock = System.Windows.Forms.DockStyle.Top; + this.LvApplications.ForeColor = System.Drawing.Color.Black; + this.LvApplications.FullRowSelect = true; + this.LvApplications.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.LvApplications.Location = new System.Drawing.Point(3, 19); + this.LvApplications.MultiSelect = false; + this.LvApplications.Name = "LvApplications"; + this.LvApplications.Size = new System.Drawing.Size(571, 177); + this.LvApplications.TabIndex = 24; + this.LvApplications.UseCompatibleStateImageBehavior = false; + this.LvApplications.View = System.Windows.Forms.View.Details; + this.LvApplications.DoubleClick += new System.EventHandler(this.LvApplications_DoubleClick); + // + // ClmApplication + // + this.ClmApplication.Text = "application"; + this.ClmApplication.Width = 430; + // + // ClmPackageManager + // + this.ClmPackageManager.Text = "package manager"; + this.ClmPackageManager.Width = 120; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(6, 1); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(71, 15); + this.label14.TabIndex = 23; + this.label14.Text = "applications"; + // + // BtnSaveSettings + // + this.BtnSaveSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnSaveSettings.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnSaveSettings.Image = global::ScoopBoxManager.Properties.Resources.save_32; + this.BtnSaveSettings.Location = new System.Drawing.Point(12, 534); + this.BtnSaveSettings.Name = "BtnSaveSettings"; + this.BtnSaveSettings.Size = new System.Drawing.Size(127, 55); + this.BtnSaveSettings.TabIndex = 4; + this.BtnSaveSettings.UseVisualStyleBackColor = true; + this.BtnSaveSettings.Click += new System.EventHandler(this.BtnSaveSettings_Click); + // + // BtnLoadSettings + // + this.BtnLoadSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BtnLoadSettings.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.BtnLoadSettings.Image = global::ScoopBoxManager.Properties.Resources.open_32; + this.BtnLoadSettings.Location = new System.Drawing.Point(145, 534); + this.BtnLoadSettings.Name = "BtnLoadSettings"; + this.BtnLoadSettings.Size = new System.Drawing.Size(127, 55); + this.BtnLoadSettings.TabIndex = 5; + this.BtnLoadSettings.UseVisualStyleBackColor = true; + this.BtnLoadSettings.Click += new System.EventHandler(this.BtnLoadSettings_Click); + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(278, 534); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(316, 15); + this.label15.TabIndex = 9; + this.label15.Text = "tip: double-click on a location textbox to open a file dialog"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(278, 559); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(367, 30); + this.label16.TabIndex = 10; + this.label16.Text = "tip: your last launched settings are stored (and loaded) as the default\r\n u" + + "se the save/load buttons to use other settings"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(713, 516); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(171, 15); + this.label17.TabIndex = 11; + this.label17.Text = "powered by @hasan-hasanov\'s"; + // + // LblScoopBox + // + this.LblScoopBox.AutoSize = true; + this.LblScoopBox.Cursor = System.Windows.Forms.Cursors.Hand; + this.LblScoopBox.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point); + this.LblScoopBox.Location = new System.Drawing.Point(885, 516); + this.LblScoopBox.Name = "LblScoopBox"; + this.LblScoopBox.Size = new System.Drawing.Size(60, 15); + this.LblScoopBox.TabIndex = 12; + this.LblScoopBox.Text = "ScoopBox"; + this.LblScoopBox.Click += new System.EventHandler(this.LblScoopBox_Click); + // + // LblSettingsStored + // + this.LblSettingsStored.AutoSize = true; + this.LblSettingsStored.ForeColor = System.Drawing.Color.GreenYellow; + this.LblSettingsStored.Location = new System.Drawing.Point(12, 516); + this.LblSettingsStored.Name = "LblSettingsStored"; + this.LblSettingsStored.Size = new System.Drawing.Size(87, 15); + this.LblSettingsStored.TabIndex = 13; + this.LblSettingsStored.Text = "settings stored!"; + this.LblSettingsStored.Visible = false; + // + // LblSettingsLoaded + // + this.LblSettingsLoaded.AutoSize = true; + this.LblSettingsLoaded.ForeColor = System.Drawing.Color.GreenYellow; + this.LblSettingsLoaded.Location = new System.Drawing.Point(145, 516); + this.LblSettingsLoaded.Name = "LblSettingsLoaded"; + this.LblSettingsLoaded.Size = new System.Drawing.Size(90, 15); + this.LblSettingsLoaded.TabIndex = 14; + this.LblSettingsLoaded.Text = "settings loaded!"; + this.LblSettingsLoaded.Visible = false; + // + // groupBox2 + // + this.groupBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94))))); + this.groupBox2.Controls.Add(this.label18); + this.groupBox2.Controls.Add(this.TbSandboxConfigurationFile); + this.groupBox2.Controls.Add(this.TbRootSandboxFilesDirectory); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Controls.Add(this.TbRootfilesDirectory); + this.groupBox2.Controls.Add(this.label2); + this.groupBox2.Controls.Add(this.label1); + this.groupBox2.Location = new System.Drawing.Point(12, 283); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(433, 218); + this.groupBox2.TabIndex = 15; + this.groupBox2.TabStop = false; + // + // label18 + // + this.label18.AutoSize = true; + this.label18.Location = new System.Drawing.Point(6, 1); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(126, 15); + this.label18.TabIndex = 22; + this.label18.Text = "optional configuration"; + // + // Main + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94))))); + this.ClientSize = new System.Drawing.Size(1052, 598); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.LblSettingsLoaded); + this.Controls.Add(this.LblSettingsStored); + this.Controls.Add(this.LblScoopBox); + this.Controls.Add(this.label17); + this.Controls.Add(this.label16); + this.Controls.Add(this.label15); + this.Controls.Add(this.BtnLoadSettings); + this.Controls.Add(this.BtnSaveSettings); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.GpMappedFolders); + this.Controls.Add(this.GpGeneralConfig); + this.Controls.Add(this.BtnLaunch); + this.DoubleBuffered = true; + this.ForeColor = System.Drawing.Color.White; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.Name = "Main"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ScoopBox Manager | LAB02 Research"; + this.Load += new System.EventHandler(this.Main_Load); + this.GpGeneralConfig.ResumeLayout(false); + this.GpGeneralConfig.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NumMemory)).EndInit(); + this.GpMappedFolders.ResumeLayout(false); + this.GpMappedFolders.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private GroupBox GpGeneralConfig; + private Label label3; + private Label label2; + private Label label1; + private Label label4; + private Label label6; + private Label label5; + private Label label8; + private Label label7; + private Label label9; + private Label label10; + private Label label11; + private Label label12; + private GroupBox GpMappedFolders; + private Label label13; + private ColumnHeader ClmHostFolder; + private ColumnHeader ClmSandboxFolder; + private ColumnHeader ClmReadonly; + private GroupBox groupBox1; + private ColumnHeader ClmApplication; + private ColumnHeader ClmPackageManager; + private Label label14; + private Label label15; + private Label label16; + private Label label17; + private Label LblScoopBox; + internal Button BtnLaunch; + internal TextBox TbRootSandboxFilesDirectory; + internal TextBox TbRootfilesDirectory; + internal TextBox TbSandboxConfigurationFile; + internal ComboBox CbAudioInput; + internal ComboBox CbNetworking; + internal ComboBox CbVideoInput; + internal ComboBox CbPrinterRedirection; + internal ComboBox CbProtectedClient; + internal ComboBox CbClipboardRedirection; + internal ComboBox CbVgpu; + internal NumericUpDown NumMemory; + internal ListView LvMappedFolders; + internal Button BtnAddMappedFolder; + internal Button BtnRemoveMappedFolder; + internal Button BtnRemoveApplication; + internal Button BtnAddApplication; + internal ListView LvApplications; + internal Button BtnSaveSettings; + internal Button BtnLoadSettings; + internal Label LblSettingsStored; + internal Label LblSettingsLoaded; + private GroupBox groupBox2; + private Label label18; + } +} \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/Main.cs b/src/ScoopBoxManager/Forms/Main.cs new file mode 100644 index 0000000..d2a3770 --- /dev/null +++ b/src/ScoopBoxManager/Forms/Main.cs @@ -0,0 +1,411 @@ +using Newtonsoft.Json; +using ScoopBox; +using ScoopBoxManager.Enums; +using ScoopBoxManager.Functions; +using ScoopBoxManager.Models; + +namespace ScoopBoxManager.Forms +{ + public partial class Main : Form + { + public Main() + { + InitializeComponent(); + } + + /// + /// Starting point + /// + /// + /// + private void Main_Load(object sender, EventArgs e) + { + // load enums + CbAudioInput.DataSource = Enum.GetValues(typeof(AudioInputOptions)); + CbVideoInput.DataSource = Enum.GetValues(typeof(VideoInputOptions)); + CbProtectedClient.DataSource = Enum.GetValues(typeof(ProtectedClientOptions)); + CbPrinterRedirection.DataSource = Enum.GetValues(typeof(PrinterRedirectionOptions)); + CbVgpu.DataSource = Enum.GetValues(typeof(VGpuOptions)); + CbNetworking.DataSource = Enum.GetValues(typeof(NetworkingOptions)); + CbClipboardRedirection.DataSource = Enum.GetValues(typeof(ClipboardRedirectionOptions)); + + // set defaults + CbAudioInput.Text = "Default"; + CbVideoInput.Text = "Default"; + CbProtectedClient.Text = "Default"; + CbPrinterRedirection.Text = "Default"; + CbVgpu.Text = "Enabled"; + CbNetworking.Text = "Default"; + CbClipboardRedirection.Text = "Default"; + + // load last-stored settings (if any) + Task.Run(SettingsManager.LoadSettings); + } + + /// + /// Opens the ScoopBox URL + /// + /// + /// + private void LblScoopBox_Click(object sender, EventArgs e) => HelperFunctions.LaunchUrl("https://github.com/hasan-hasanov/ScoopBox"); + + /// + /// Saves the current settings + /// + /// + /// + private void BtnSaveSettings_Click(object sender, EventArgs e) + { + var q = MessageBox.Show("Do you want to save it as the default settings?\r\n\r\nClick 'no' to provide a custom filename.", "ScoopBoxManager", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (q != DialogResult.Yes && q != DialogResult.No) return; + + if (q == DialogResult.Yes) + { + // store as default + SettingsManager.StoreCurrentSettings(); + InterfaceManager.ShowSettingsStored(); + return; + } + + // let the user pick a filename + if (!Directory.Exists(Variables.ConfigPath)) Directory.CreateDirectory(Variables.ConfigPath); + + using var dialog = new OpenFileDialog(); + + dialog.CheckFileExists = false; + dialog.Multiselect = false; + dialog.InitialDirectory = Variables.ConfigPath; + dialog.DefaultExt = "json"; + dialog.Filter = "JSON files (*.json)|*.json"; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + // force .json + var filename = dialog.FileName; + if (!filename.ToLower().EndsWith("json")) filename = $"{filename}.json"; + + // store settings + SettingsManager.StoreCurrentSettings(dialog.FileName); + + // done + InterfaceManager.ShowSettingsStored(); + } + + /// + /// Loads the selected settings + /// + /// + /// + private void BtnLoadSettings_Click(object sender, EventArgs e) + { + // let the user pick a filename + if (!Directory.Exists(Variables.ConfigPath)) Directory.CreateDirectory(Variables.ConfigPath); + + using var dialog = new OpenFileDialog(); + + dialog.CheckFileExists = true; + dialog.Multiselect = false; + dialog.InitialDirectory = Variables.ConfigPath; + dialog.DefaultExt = "json"; + dialog.Filter = "JSON files (*.json)|*.json"; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + // force .json + var filename = dialog.FileName; + if (!filename.ToLower().EndsWith("json")) + { + MessageBox.Show("Only .json files are supported.", "ScoopBoxManager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + // load settings + SettingsManager.LoadSettings(filename); + + // done + InterfaceManager.ShowSettingsLoaded(); + } + + /// + /// Stores the current configuration, and launches a new sandbox with them + /// + /// + /// + private async void BtnLaunch_Click(object sender, EventArgs e) + { + BtnLaunch.Text = "LAUNCHING .."; + + // lock ui + InterfaceManager.LockUi(); + + try + { + // store current settings and get the appSettings object + var appSettings = SettingsManager.StoreCurrentSettings(); + + // prepare options + var options = appSettings.ConvertToScoopBoxOptions(); + + // prepare chocolatey packages + var choco = appSettings.ConvertToChocolateyPackageManagerScript(); + + // prepare scoop packages + var scoop = appSettings.ConvertToScoopPackageManagerScript(); + + // check for conflicting settings + if (options.Networking == NetworkingOptions.Disable && (choco.Applications.Any() || scoop.Applications.Any())) + { + // without networking, no packages will get downloaded .. + var q = MessageBox.Show("You've disabled networking, but added packages. They won't be able to download.\r\n\r\nAre you sure you want to continue?", "ScoopBoxManager", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); + if (q != DialogResult.Yes) return; + } + + // prepare sandbox + ISandboxConfigurationBuilder configurationBuilder = new SandboxConfigurationBuilder(options); + var sandbox = new Sandbox(options, configurationBuilder); + + // launch according to packages + if (choco == null && scoop == null) + { + // scoopbox will get pissed if we don't provide at lease one script :( + await sandbox.Run(new ScoopPackageManagerScript(new List { "curl" })); + } + + // both choco & scoop + else if (choco != null && scoop != null) + { + await sandbox.Run(new List { choco, scoop }); + } + + // only choco + else if (choco != null) await sandbox.Run(new List { choco }); + + // only scoop + else await sandbox.Run(new List { scoop }); + + // it's launching + BtnLaunch.Text = "LAUNCHED!"; + BtnLaunch.ForeColor = Color.GreenYellow; + + // wait 3 sec so user won't spam + await Task.Delay(TimeSpan.FromSeconds(3)); + } + catch (Exception ex) + { + // show error + MessageBox.Show($"Something went wrong while trying to launch your sandbox:\r\n\r\n{ex.Message}", "ScoopBoxManager", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + // unlock ui + InterfaceManager.UnlockUi(); + + // done + BtnLaunch.ForeColor = Color.White; + BtnLaunch.Text = "LAUNCH SANDBOX"; + } + } + + /// + /// Lets the user select a root files directory + /// + /// + /// + private void TbRootfilesDirectory_DoubleClick(object sender, EventArgs e) + { + using var dialog = new FolderBrowserDialog(); + + dialog.ShowNewFolderButton = true; + dialog.RootFolder = Environment.SpecialFolder.MyComputer; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + TbRootfilesDirectory.Text = dialog.SelectedPath; + } + + /// + /// Lets the user select a rootdirectory for the sandbox files + /// + /// + /// + private void TbRootSandboxFilesDirectory_DoubleClick(object sender, EventArgs e) + { + using var dialog = new FolderBrowserDialog(); + + dialog.ShowNewFolderButton = true; + dialog.RootFolder = Environment.SpecialFolder.MyComputer; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + TbRootSandboxFilesDirectory.Text = dialog.SelectedPath; + } + + /// + /// Lets the user select a sandbox configuration file + /// + /// + /// + private void TbSandboxConfigurationFile_DoubleClick(object sender, EventArgs e) + { + using var dialog = new OpenFileDialog(); + + dialog.CheckFileExists = true; + dialog.Multiselect = false; + + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + + TbSandboxConfigurationFile.Text = dialog.FileName; + } + + /// + /// Opens a 'add mapped folder' window + /// + /// + /// + private void BtnAddMappedFolder_Click(object sender, EventArgs e) => ProcessAddMappedFolder(); + + /// + /// Removes the selected mapped folder + /// + /// + /// + private void BtnRemoveMappedFolder_Click(object sender, EventArgs e) + { + if (LvMappedFolders.SelectedItems.Count == 0) return; + LvMappedFolders.Items[LvMappedFolders.SelectedItems[0].Index].Remove(); + } + + /// + /// Opens a 'add application' window + /// + /// + /// + private void BtnAddApplication_Click(object sender, EventArgs e) => ProcessAddApplication(); + + /// + /// Removes the selected application + /// + /// + /// + private void BtnRemoveApplication_Click(object sender, EventArgs e) + { + if (LvApplications.SelectedItems.Count == 0) return; + LvApplications.Items[LvApplications.SelectedItems[0].Index].Remove(); + } + + /// + /// Opens the selected mapped folder for updating + /// + /// + /// + private void LvMappedFolders_DoubleClick(object sender, EventArgs e) + { + if (LvMappedFolders.SelectedItems.Count == 0) return; + var index = LvMappedFolders.SelectedItems[0].Index; + + // prepare the mapped folder + var mappedFolder = new MappedFolder + { + HostFolder = LvMappedFolders.SelectedItems[0].Text, + SandboxFolder = LvMappedFolders.SelectedItems[0].SubItems[1].Text, + ReadOnly = LvMappedFolders.SelectedItems[0].SubItems[2].Text + }; + + // open for update + ProcessAddMappedFolder(mappedFolder, index); + } + + /// + /// Opens the selected application for updating + /// + /// + /// + private void LvApplications_DoubleClick(object sender, EventArgs e) + { + if (LvApplications.SelectedItems.Count == 0) return; + var index = LvApplications.SelectedItems[0].Index; + + // prepare the application + var app = new PackageManagerApplication + { + Package = LvApplications.SelectedItems[0].Text, + PackageManager = Enum.Parse(LvApplications.SelectedItems[0].SubItems[1].Text ?? "Scoop") + }; + + // open for update + ProcessAddApplication(app, index); + } + + /// + /// Lets the user add or update a mapped folder + /// + /// + /// + private void ProcessAddMappedFolder(MappedFolder currentMappedFolder = null, int listviewIndex = -1) + { + // show the add mapped folder dialog + using var addMapped = new AddMappedFolder(currentMappedFolder, listviewIndex); + var result = addMapped.ShowDialog(); + if (result != DialogResult.OK) return; + + var mappedFolder = addMapped.MappedFolder; + + // are we updating? + if (currentMappedFolder != null) + { + // jep, set new values + LvMappedFolders.Items[listviewIndex].Text = mappedFolder.HostFolder; + LvMappedFolders.Items[listviewIndex].SubItems[1].Text = mappedFolder.SandboxFolder; + LvMappedFolders.Items[listviewIndex].SubItems[2].Text = mappedFolder.ReadOnly; + LvMappedFolders.Refresh(); + return; + } + + // prepare new listview item + var mappedItem = new ListViewItem(mappedFolder.HostFolder); + mappedItem.SubItems.Add(mappedFolder.SandboxFolder); + mappedItem.SubItems.Add(mappedFolder.ReadOnly); + + // add to the list + LvMappedFolders.Items.Add(mappedItem); + } + + /// + /// Lets the user add or update an application + /// + /// + /// + private void ProcessAddApplication(PackageManagerApplication currentApplication = null, int listviewIndex = -1) + { + // show the add application folder dialog + using var addApplication = new AddApplication(currentApplication, listviewIndex); + var result = addApplication.ShowDialog(); + if (result != DialogResult.OK) return; + + var app = addApplication.Application; + + // are we updating? + if (currentApplication != null) + { + // jep, set new values + LvApplications.Items[listviewIndex].Text = app.Package; + LvApplications.Items[listviewIndex].SubItems[1].Text = app.PackageManager.ToString(); + LvApplications.Refresh(); + return; + } + + // nope, prepare new listview item + var appItem = new ListViewItem(app.Package); + appItem.SubItems.Add(app.PackageManager.ToString()); + + // add to the list + LvApplications.Items.Add(appItem); + + } + } +} \ No newline at end of file diff --git a/src/ScoopBoxManager/Forms/Main.resx b/src/ScoopBoxManager/Forms/Main.resx new file mode 100644 index 0000000..fd6616d --- /dev/null +++ b/src/ScoopBoxManager/Forms/Main.resx @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIADVBAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAgAAAAIAgGAAAAc3p69AAAAAFz + UkdCAK7OHOkAAAAEZ0FNQQAAsY8L/GEFAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEaklEQVRYR+1WfUyV + VRx+CvCDUjPJO76CvLvMYCZJMWk6zKyGimsR2togR6lRm4ymJmMWuO6iYjgamkU6dX1YbY4tN6GWdZcK + QRRKOLQwCYFAviEEEeo8v73v5YX7XrhrFX/Us92d95z7nvf3nOc8v985N90Xl/wHphA3a+2U4X8CkxKI + iVqE3du2IPreCG1kYtw2exYy01Kwcf1abWRieGxC35kzMHPGdDy07H7ELl2C0GB/zPe7Xf5r7+xGQ1ML + TlecRYmjDM0tbTLuCTwiMOsWX6Q8uQ7r41dh2jQfXLz0K6prf0ZHZw98fLxhDQ3CooVWWf3w8DBOnDyD + gkOfCrHJMCmBu213IXfXVlntl6cqsFd9mEqQBIl5eXmhq6cXkRFhaGnrQGpSAuJWPoDe3/uRmbMPpZXV + 2pfMMSEB7n/urjT0Dwwgp+CwECC4x5HhYbINBFda+t05ZO95T/pUg++EBvnLvKISh4ybwa0J/S1+sO98 + HpevNCNxc4Yz+PLoSMSvWuYMTsybO0dWvSImSvpcPbeD6mxPTRIV3cEtgVfSN8FXSZ2dVygSE/xg+uan + pB2Prp4+RbZJiO3PyZCxlBd3Cxn7S6mmcwhTApQ+6p6FOHj0M9lrHeG2UAQHWLTeKLgFz+18TZ714OxX + 19Yh/8BRmfPYo7EyPh6mHthr3yFbkLglQ1ytg1IbpdfR0NSq0nT6mOCXG5rlmSh8M1PmPv7sDm1kFC4K + MN/p6M8d38qK9YBsxwcfHh5B5blal+CD14fkOWzBnVI3ir8qFRXM1PPWWicWh9sk1x1l36NVpVX8w8ux + YEOgGMlIgMpkvv62jBmDW0OCJAOOf/ENmlvbpdXnRUdGSMEywkUBi6G68Xfok+N4OfcdpxEJPXhd/RWX + 4DRcX18/8t79EB8VlYgJ6+ob5Z075s2V1ggXAsbyagQ/REwW3Mzt/dcGRE2LnwcE+CJhDQmUVkd3d6/H + wY1q6aAJW9o6td4oXAiwnBLhWvGgKRNWr0SYNcTjlVPFtco79BKhF6Wr7R4QOHv+J1xXLrYpB9M8W5/Z + oGpBPZLTsjyWvajYgfaOLqmCzIQVMUtkvLyqRlojXAhwv6pqLsqkViUZazkLSnDAfI/3/OTpCjmE7PkH + xYDrVBGi+8dnAOFCgHj/2AmRMfmJNdI3SzV3wVkXjNUzYfWDcjh9cKxYGxkLUwJkzw8lJcTJ4WMMHuxv + cRucmcKU1cFq+sLGRFm5uxPRlACRvacQg0NDyMtKlz6Ds7xWVtfijMkZz/82bbM7s4jm5YHmrYjSvMaS + boRXgG1xlvY8BiMjI6i5cElKKdPqB+WLxt+uYujGDZR8XYYflS+a1NXrl4ZGkfctdejowXmQFby6Xd2U + AvHGviM4VV4l42ZweyF5JHapOg/KxtyI2M8/8LEz0HjwnacT18jVjdvBG1F51Xk5U2hkM/ylOyEJXFBG + q1eyXxsYxJzZt0q68RCj1H/rndAIVrMpuRX/k3CbBf8W/usEgD8B3es0Hn532FcAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/src/ScoopBoxManager/Functions/HelperFunctions.cs b/src/ScoopBoxManager/Functions/HelperFunctions.cs new file mode 100644 index 0000000..2a22303 --- /dev/null +++ b/src/ScoopBoxManager/Functions/HelperFunctions.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.VisualBasic.Logging; + +namespace ScoopBoxManager.Functions +{ + internal static class HelperFunctions + { + /// + /// Launches the url with the system's default browser + /// + /// + internal static void LaunchUrl(string url) + { + using (_ = Process.Start(new ProcessStartInfo(url) { UseShellExecute = true })) + { + // + } + } + } +} diff --git a/src/ScoopBoxManager/Functions/InterfaceManager.cs b/src/ScoopBoxManager/Functions/InterfaceManager.cs new file mode 100644 index 0000000..b96c140 --- /dev/null +++ b/src/ScoopBoxManager/Functions/InterfaceManager.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ScoopBoxManager.Models; + +namespace ScoopBoxManager.Functions +{ + internal static class InterfaceManager + { + /// + /// Shows the provided AppSettings in the GUI + /// + /// + internal static void ShowAppSettings(AppSettings appSettings) + { + Variables.MainForm.Invoke(delegate + { + // set IO locations + Variables.MainForm.TbSandboxConfigurationFile.Text = appSettings.SandboxConfigurationFile; + Variables.MainForm.TbRootfilesDirectory.Text = appSettings.RootfilesDirectoryLocation; + Variables.MainForm.TbRootSandboxFilesDirectory.Text = appSettings.RootfilesDirectoryLocation; + + // set comboboxes + Variables.MainForm.CbAudioInput.Text = appSettings.AudioInput.ToString(); + Variables.MainForm.CbVideoInput.Text = appSettings.VideoInput.ToString(); + Variables.MainForm.CbProtectedClient.Text = appSettings.ProtectedClient.ToString(); + Variables.MainForm.CbPrinterRedirection.Text = appSettings.PrinterRedirection.ToString(); + Variables.MainForm.CbVgpu.Text = appSettings.VGpu.ToString(); + Variables.MainForm.CbNetworking.Text = appSettings.Networking.ToString(); + Variables.MainForm.CbClipboardRedirection.Text = appSettings.ClipboardRedirection.ToString(); + + // set memory + Variables.MainForm.NumMemory.Value = appSettings.MemoryMb; + + // set mapped folders + Variables.MainForm.LvMappedFolders.BeginUpdate(); + foreach (var mappedFolder in appSettings.MappedFolders) + { + var mappedFolderItem = new ListViewItem(mappedFolder.HostFolder); + mappedFolderItem.SubItems.Add(mappedFolder.SandboxFolder); + mappedFolderItem.SubItems.Add(mappedFolder.ReadOnly); + + Variables.MainForm.LvMappedFolders.Items.Add(mappedFolderItem); + } + Variables.MainForm.LvMappedFolders.EndUpdate(); + + // set apps + Variables.MainForm.LvApplications.BeginUpdate(); + foreach (var app in appSettings.Applications) + { + var appItem = new ListViewItem(app.Package); + appItem.SubItems.Add(app.PackageManager.ToString()); + + Variables.MainForm.LvApplications.Items.Add(appItem); + } + Variables.MainForm.LvApplications.EndUpdate(); + + // done + }); + } + + /// + /// Sets all interface elements enabled to false + /// + internal static void LockUi() + { + Variables.MainForm.Invoke(delegate + { + foreach (var textBox in Variables.MainForm.Controls.OfType()) textBox.Enabled = false; + foreach (var button in Variables.MainForm.Controls.OfType