This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cbc5ab
commit e3e346f
Showing
7 changed files
with
140 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
using System; | ||
using System.IO; | ||
using System.Windows.Forms; | ||
using SheasCore; | ||
|
||
namespace Sheas_Unlocker | ||
{ | ||
public partial class MainForm : Form | ||
internal partial class MainForm : Form | ||
{ | ||
public MainForm() | ||
internal MainForm() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void UnlockButton_Click(object sender, EventArgs e) | ||
{ | ||
if (System.IO.Directory.Exists(PathTextBox.Text)) | ||
Text = "解锁中..."; | ||
else | ||
try | ||
{ | ||
Text = "文件路径错误"; | ||
return; | ||
} | ||
if (!Directory.Exists(PathBox.Text)) | ||
throw new Exception("文件路径错误"); | ||
|
||
string feedBack = "未知错误"; | ||
if (RecurseCheckBox.Checked) | ||
feedBack = PowerShell.PowerShellRun(PathTextBox.Text, @"Get-ChildItem -Recurse | Unblock-File"); | ||
else | ||
feedBack = PowerShell.PowerShellRun(PathTextBox.Text, @"Get-ChildItem | Unblock-File"); | ||
Text = "解锁中..."; | ||
|
||
if (feedBack == "") | ||
Text = "解锁成功"; | ||
else | ||
Text = "解锁失败"; //feedBack | ||
PowerShell powerShell = new(this); | ||
if (RecurseCheckBox.Checked) | ||
powerShell.ShellRun(PathBox.Text, @"Get-ChildItem -Recurse | Unblock-File"); | ||
else | ||
powerShell.ShellRun(PathBox.Text, @"Get-ChildItem | Unblock-File"); | ||
} | ||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); Text = "解锁失败"; return; } | ||
} | ||
private void NavigateButton_Click(object sender, EventArgs e) | ||
{ | ||
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); | ||
try | ||
{ | ||
FolderBrowserDialog folderBrowserDialog = new(); | ||
|
||
#region 配置folderBrowserDialog的参数 | ||
folderBrowserDialog.Description = "Sheath Importer"; | ||
folderBrowserDialog.UseDescriptionForTitle = true; //修改标题 | ||
folderBrowserDialog.AutoUpgradeEnabled = true; //自动升级对话框样式 | ||
#endregion | ||
#region 配置folderBrowserDialog的参数 | ||
folderBrowserDialog.Description = "Sheath Importer"; | ||
folderBrowserDialog.UseDescriptionForTitle = true; //修改标题 | ||
folderBrowserDialog.AutoUpgradeEnabled = true; //自动升级对话框样式 | ||
#endregion 配置folderBrowserDialog的参数 | ||
|
||
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) | ||
PathTextBox.Text = folderBrowserDialog.SelectedPath; //路径 | ||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK) | ||
PathBox.Text = folderBrowserDialog.SelectedPath; //路径 | ||
} | ||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); Text = "浏览失败"; return; } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Windows.Forms; | ||
|
||
namespace Sheas_Unlocker | ||
{ | ||
internal class PowerShell : SheasCore.Proc | ||
{ | ||
private readonly MainForm MAIN_FORM; | ||
private bool IS_SUCCESSFUL = true; | ||
|
||
internal PowerShell(MainForm mainForm) : base("powershell") | ||
{ | ||
Control.CheckForIllegalCrossThreadCalls = false; | ||
MAIN_FORM = mainForm; | ||
} | ||
|
||
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) | ||
{ | ||
OutputError(e); | ||
} | ||
|
||
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) | ||
{ | ||
OutputError(e); | ||
} | ||
|
||
public override void Process_Exited(object sender, EventArgs e) | ||
{ | ||
if (IS_SUCCESSFUL) | ||
MAIN_FORM.Text = "解锁成功"; | ||
} | ||
|
||
private void OutputError(DataReceivedEventArgs e) | ||
{ | ||
if (!string.IsNullOrEmpty(e.Data) && !string.IsNullOrWhiteSpace(e.Data)) | ||
{ | ||
IS_SUCCESSFUL = false; | ||
MAIN_FORM.Text = "解锁失败"; | ||
|
||
if (!MAIN_FORM.IgnoreCheckBox.Checked) | ||
MessageBox.Show("Error: " + e.Data); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ private static void Main() | |
Application.Run(new MainForm()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters