Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Jul 27, 2023
1 parent 8244797 commit 7d29c27
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 61 deletions.
8 changes: 8 additions & 0 deletions SuperGrate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperGrate", "SuperGrate\Su
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperGrateProfileDelete", "SuperGrateProfileDelete\SuperGrateProfileDelete.csproj", "{600B0D09-F639-4603-A9A9-EA4132CCECA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperGrateTests", "SuperGrateTests\SuperGrateTests.csproj", "{411BCED0-F354-4F62-9B12-1042CA095892}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,6 +28,12 @@ Global
{600B0D09-F639-4603-A9A9-EA4132CCECA5}.Release_64|Any CPU.Build.0 = Release|Any CPU
{600B0D09-F639-4603-A9A9-EA4132CCECA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{600B0D09-F639-4603-A9A9-EA4132CCECA5}.Release|Any CPU.Build.0 = Release|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Debug|Any CPU.Build.0 = Debug|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Release_64|Any CPU.ActiveCfg = Release|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Release_64|Any CPU.Build.0 = Release|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Release|Any CPU.ActiveCfg = Release|Any CPU
{411BCED0-F354-4F62-9B12-1042CA095892}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion SuperGrate/Classes/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SuperGrate.Classes
{
internal static class Language
public static class Language
{
/// <summary>
/// The default language type Super Grate uses if the specified language isn't found.
Expand Down
2 changes: 0 additions & 2 deletions SuperGrate/Controls/License.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion SuperGrate/Controls/License.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using SuperGrate.Classes;
using System;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
Expand All @@ -11,6 +12,8 @@ public License()
{
InitializeComponent();
Icon = Properties.Resources.check_ico;
Height = Screen.FromControl(this).WorkingArea.Height;
Text = Application.ProductName + " " + Language.Get("Control/License/License");
}
private void License_Load(object sender, EventArgs e)
{
Expand Down
52 changes: 26 additions & 26 deletions SuperGrate/Controls/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public Main()
listUsers.Tag = new string[0];
Icon = Properties.Resources.supergrate_ico;
Text = About.AssemblyTitle;
btnListSource.Text = Language.Get("ListSource");
btnListStore.Text = Language.Get("ListStore");
btnDelete.Text = Language.Get("Delete");
lblSourceComputer.Text = Language.Get("SourceComputer");
lblDestinationComputer.Text = Language.Get("DestinationComputer");
btnListSource.Text = Language.Get("Control/Main/ListSource");
btnListStore.Text = Language.Get("Control/Main/ListStore");
btnDelete.Text = Language.Get("Control/Main/Delete");
lblSourceComputer.Text = Language.Get("Control/Main/SourceComputer");
lblDestinationComputer.Text = Language.Get("Control/Main/DestinationComputer");
/*
btnListSource.SetSystemIcon(Properties.Resources.users_ico);
btnListStore.SetSystemIcon(Properties.Resources.usercheck);
Expand Down Expand Up @@ -87,8 +87,8 @@ private void Main_Load(object sender, EventArgs e)
{
TaskbarList = (ITaskbarList3)new TaskbarList();
TaskbarList.HrInit();
Logger.Success(Language.Get("WelcomeTo", Application.ProductName, Application.ProductVersion));
Logger.Information(Language.Get("EnterSomeInfoToGetStarted"));
Logger.Success(Language.Get("Control/Main/WelcomeTo", Application.ProductName, Application.ProductVersion));
Logger.Information(Language.Get("Control/Main/Log/EnterSomeInfoToGetStarted"));
UpdateSecurityProtocolType();
UpdateFormRestrictions();
BindHelp(this);
Expand Down Expand Up @@ -160,7 +160,7 @@ public static bool Canceled
storeCanceled = value;
if (value)
{
if (storeRunningTask != RunningTask.None) Logger.Warning(Language.Get("CancelingCurrentTask"));
if (storeRunningTask != RunningTask.None) Logger.Warning(Language.Get("Control/Main/Log/CancelingCurrentTask"));
if (storeRunningTask == RunningTask.USMT) USMT.Cancel();
if (storeRunningTask == RunningTask.RemoteProfileDelete) Misc.CancelRemoteProfileDelete(SourceComputer);
}
Expand All @@ -177,7 +177,7 @@ public RunningTask Running {
if (value != RunningTask.None)
{
Logger.UpdateProgress(0);
btnStartStop.Text = Language.Get("Stop");
btnStartStop.Text = Language.Get("Control/Main/Stop");
btnStartStop.SetSystemIcon(Properties.Resources.cancel_ico);
Cursor = Cursors.AppStarting;
Misc.MainMenuSetState(MainMenu, false, new string[] { "&View" });
Expand All @@ -201,7 +201,7 @@ public RunningTask Running {
else
{
Logger.UpdateProgress(-1);
btnStartStop.Text = Language.Get("Start");
btnStartStop.Text = Language.Get("Control/Main/Start");
btnStartStop.SetSystemIcon(Properties.Resources.go_ico);
Cursor = Cursors.Default;
Misc.MainMenuSetState(MainMenu, true);
Expand Down Expand Up @@ -276,7 +276,7 @@ private async void BtnListSource_Click(object sender, EventArgs e)
miConRename.Visible = false;
listUsers.SetViewMode(Config.Settings["ULViewMode"]);
listUsers.SetColumns(ULControl.HeaderRowComputerSource, Config.Settings["ULSourceColumns"]);
lblUserList.Text = Language.Get("UsersOnSourceComputer");
lblUserList.Text = Language.Get("Control/Main/UsersOnSourceComputer");
CurrentUserRows = await Misc.GetUsersFromHost(tbSourceComputer.Text);
listUsers.SetRows(CurrentUserRows, CurrentSortColumn[ListSources.SourceComputer], CurrentSortDirection[ListSources.SourceComputer]);
CurrentListSource = ListSources.SourceComputer;
Expand All @@ -290,7 +290,7 @@ private async void BtnListStore_Click(object sender, EventArgs e)
Running = RunningTask.Unknown;
miAddRemoveCol.Enabled = true;
miConRename.Visible = true;
lblUserList.Text = Language.Get("UsersInMigrationStore");
lblUserList.Text = Language.Get("Control/Main/UsersInMigrationStore");
listUsers.SetViewMode(Config.Settings["ULViewMode"]);
listUsers.SetColumns(ULControl.HeaderRowStoreSource, Config.Settings["ULStoreColumns"]);
CurrentUserRows = await Misc.GetUsersFromStore();
Expand All @@ -306,12 +306,12 @@ private void LogBox_DoubleClick(object sender, EventArgs e)
if(Logger.VerboseEnabled)
{
Logger.VerboseEnabled = false;
Logger.Information(Language.Get("VerboseModeDisabled"));
Logger.Information(Language.Get("Control/Main/Log/VerboseModeDisabled"));
}
else
{
Logger.VerboseEnabled = true;
Logger.Information(Language.Get("VerboseModeEnabled"));
Logger.Information(Language.Get("Control/Main/Log/VerboseModeEnabled"));
}
}
/// <summary>
Expand Down Expand Up @@ -379,11 +379,11 @@ private async void BtnDelete_Click(object sender, EventArgs e)
ConfirmDialog confirm;
if (selectedCount == 1)
{
confirm = new ConfirmDialog(Language.Get("DeleteUser"), Language.Get("AreYouSureDeleteUser"), Properties.Resources.trash_16_32_ico);
confirm = new ConfirmDialog(Language.Get("Control/Main/DeleteUser"), Language.Get("Control/Main/AreYouSureDeleteUser"), Properties.Resources.trash_16_32_ico);
}
else
{
confirm = new ConfirmDialog(Language.Get("DeleteUsers"), Language.Get("AreYouSureDeleteUsers", selectedCount.ToString()), Properties.Resources.trash_16_32_ico);
confirm = new ConfirmDialog(Language.Get("Control/Main/DeleteUsers"), Language.Get("Control/Main/AreYouSureDeleteUsers", selectedCount.ToString()), Properties.Resources.trash_16_32_ico);
}
confirm.ShowDialog();
if (confirm.DialogResult != DialogResult.OK) return;
Expand Down Expand Up @@ -456,9 +456,9 @@ private async void MiSaveLog_Click(object sender, EventArgs e)
DateTime.Now.ToLongTimeString().Replace(':', '-');
if (dialogSaveLog.ShowDialog() == DialogResult.OK)
{
Logger.Information(Language.Get("WritingLogTo", dialogSaveLog.FileName));
Logger.Information(Language.Get("Control/Main/Log/WritingLogTo", dialogSaveLog.FileName));
await Logger.WriteLogToFile(dialogSaveLog.OpenFile());
Logger.Success(Language.Get("LogWrittenSuccessfully"));
Logger.Success(Language.Get("Control/Main/Log/LogWrittenSuccessfully"));
}
}
/// <summary>
Expand All @@ -476,7 +476,7 @@ private async void Main_FormClosing(object sender, FormClosingEventArgs e)
else if(Config.Settings["DumpLogHereOnExit"] != "")
{
e.Cancel = true;
Logger.Information(Language.Get("WritingLogTo", Config.Settings["DumpLogHereOnExit"]));
Logger.Information(Language.Get("Control/Main/Log/WritingLogTo", Config.Settings["DumpLogHereOnExit"]));
string fileName =
"SuperGrate_" +
Environment.UserName + "_" +
Expand All @@ -495,10 +495,10 @@ private async void Main_FormClosing(object sender, FormClosingEventArgs e)
}
catch(Exception exc)
{
Logger.Exception(exc, Language.Get("FailedToWriteLogToDisk"));
Logger.Exception(exc, Language.Get("Class/Logger/Log/Failed/WriteLogToDisk"));
}
}
Logger.Warning(Language.Get("ThisProgramIsAttemptingToClose", CloseAttempts.ToString(), "3"));
Logger.Warning(Language.Get("Control/Main/Log/ThisProgramIsAttemptingToClose", CloseAttempts.ToString(), "3"));
}
/// <summary>
/// This event will fire when the miAbout menu item is clicked, and will open the about dialog box.
Expand Down Expand Up @@ -635,7 +635,7 @@ private async void OpenUserProperties_Event(object sender, EventArgs e)
if(listUsers.SelectedItems.Count == 1)
{
Running = RunningTask.Unknown;
Logger.Information(Language.Get("GatheringUserProperties"));
Logger.Information(Language.Get("Control/Main/Log/GatheringUserProperties"));
UserRow row = null;
UserRow template = null;
if (CurrentListSource == ListSources.MigrationStore)
Expand All @@ -655,13 +655,13 @@ await WMI.GetInstance(tbSourceComputer.Text, "Win32_UserProfile.SID=\"" + (strin
if (Canceled)
{
Running = RunningTask.None;
Logger.Information(Language.Get("Canceled"));
Logger.Information(Language.Get("Control/Main/Log/Canceled"));
return;
}
Running = RunningTask.None;
if (row == null)
{
Logger.Error(Language.Get("FailedToGatherUserProperties"));
Logger.Error(Language.Get("Control/Main/Log/Failed/GatherUserProperties"));
}
else
{
Expand Down Expand Up @@ -769,7 +769,7 @@ private async void MiConRename_Click(object sender, EventArgs e)
if (listUsers.SelectedItems.Count == 1)
{
Running = RunningTask.Unknown;
Logger.Information(Language.Get("GatheringUserProperties"));
Logger.Information(Language.Get("Control/Main/Log/GatheringUserProperties"));
string storeID = (string)listUsers.SelectedItems[0].Tag;
UserRow row = await Misc.GetUserFromStore(new UserRow() {
{ ULColumnType.Tag, string.Empty },
Expand All @@ -779,7 +779,7 @@ private async void MiConRename_Click(object sender, EventArgs e)
Running = RunningTask.None;
if (row == null)
{
Logger.Error(Language.Get("FailedToGatherUserProperties"));
Logger.Error(Language.Get("Control/Main/Log/Failed/GatherUserProperties"));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions SuperGrate/Controls/RenameStoreUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private async void btnSave_Click(object sender, EventArgs e)
try
{
Enabled = false;
Logger.Information(Language.Get("SavingDataToMigrationStore"));
Logger.Information(Language.Get("Control/Main/Log/SavingDataToMigrationStore"));
string destination = Path.Combine(Config.Settings["MigrationStorePath"], StoreID);
string destinationUser = tbDestUser.Text;
await Task.Run(() => {
Expand All @@ -35,7 +35,7 @@ await Task.Run(() => {
}
catch(Exception exc)
{
Logger.Exception(exc, Language.Get("FailedToWriteStoreParameterTo", StoreID));
Logger.Exception(exc, Language.Get("Class/USMT/Log/Failed/WriteStoreParameterTo", StoreID));
}
}
}
Expand Down
65 changes: 36 additions & 29 deletions SuperGrate/Localization/en-US.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
<SGLanguage DisplayName="English (United States)">
<WelcomeTo>Welcome to {0}! v{1}</WelcomeTo>
<EnterSomeInfoToGetStarted>Enter some information to get started!</EnterSomeInfoToGetStarted>
<CancelingCurrentTask>Canceling current task...</CancelingCurrentTask>
<UsersOnSourceComputer>Users on source computer:</UsersOnSourceComputer>
<UsersInMigrationStore>Users in migration store:</UsersInMigrationStore>
<VerboseModeDisabled>Verbose mode disabled.</VerboseModeDisabled>
<VerboseModeEnabled>Verbose mode enabled.</VerboseModeEnabled>
<Start>Start</Start>
<Stop>Stop</Stop>
<Done>Done.</Done>
<OK>OK</OK>
<Cancel>Cancel</Cancel>
<Canceled>Canceled.</Canceled>
<DeleteUser>Delete user</DeleteUser>
<DeleteUsers>Delete users</DeleteUsers>
<AreYouSureDeleteUser>Are you sure you want to delete this user?</AreYouSureDeleteUser>
<AreYouSureDeleteUsers>Are you sure you want to delete these {0} users?</AreYouSureDeleteUsers>
<WritingLogTo>Writing log to {0}...</WritingLogTo>
<LogWrittenSuccessfully>Log written successfully.</LogWrittenSuccessfully>
<ListSource>List source</ListSource>
<ListStore>List store</ListStore>
<Delete>Delete</Delete>
<Store>store</Store>
<SourceComputer>Source computer</SourceComputer>
<DestinationComputer>Destination computer</DestinationComputer>
<FailedToGatherUserProperties>Failed to gather user properties.</FailedToGatherUserProperties>


<GatheringUserProperties>Gathering user properties...</GatheringUserProperties>
<ThisProgramIsAttemptingToClose>This program is attempting to close, attempt {0}/{1}.</ThisProgramIsAttemptingToClose>
<SavingDataToMigrationStore>Saving user data to migration store...</SavingDataToMigrationStore>
<Class>
<Config>
<Log>
Expand Down Expand Up @@ -154,8 +127,8 @@
<ImportedOn>Imported on</ImportedOn>
<ExportedBy>Exported by</ExportedBy>
<ExportedOn>Exported on</ExportedOn>
<SourceComputer>{SourceComputer}</SourceComputer>
<DestinationComputer>{DestinationComputer}</DestinationComputer>
<SourceComputer>Source computer</SourceComputer>
<DestinationComputer>Destination computer</DestinationComputer>
</Column>
</UserList>
<USMT>
Expand Down Expand Up @@ -238,5 +211,39 @@
</Failed>
</Log>
</DirectorySearch>
<License>
<License>license</License>
</License>
<Main>
<WelcomeTo>Welcome to {0}! v{1}</WelcomeTo>
<ListSource>List source</ListSource>
<ListStore>List store</ListStore>
<SourceComputer>Source computer</SourceComputer>
<DestinationComputer>Destination computer</DestinationComputer>
<Start>Start</Start>
<Stop>Stop</Stop>
<UsersOnSourceComputer>Users on source computer:</UsersOnSourceComputer>
<UsersInMigrationStore>Users in migration store:</UsersInMigrationStore>
<DeleteUser>Delete user</DeleteUser>
<DeleteUsers>Delete users</DeleteUsers>
<AreYouSureDeleteUser>Are you sure you want to delete this user?</AreYouSureDeleteUser>
<AreYouSureDeleteUsers>Are you sure you want to delete these {0} users?</AreYouSureDeleteUsers>
<Delete>Delete</Delete>
<Log>
<EnterSomeInfoToGetStarted>Enter some information to get started!</EnterSomeInfoToGetStarted>
<CancelingCurrentTask>Canceling current task...</CancelingCurrentTask>
<VerboseModeDisabled>Verbose mode disabled.</VerboseModeDisabled>
<VerboseModeEnabled>Verbose mode enabled.</VerboseModeEnabled>
<WritingLogTo>Writing log to {0}...</WritingLogTo>
<LogWrittenSuccessfully>Log written successfully.</LogWrittenSuccessfully>
<ThisProgramIsAttemptingToClose>This program is attempting to close, attempt {0}/{1}.</ThisProgramIsAttemptingToClose>
<GatheringUserProperties>Gathering user properties...</GatheringUserProperties>
<Canceled>Canceled.</Canceled>
<SavingDataToMigrationStore>Saving user data to migration store...</SavingDataToMigrationStore>
<Failed>
<GatherUserProperties>Failed to gather user properties.</GatherUserProperties>
</Failed>
</Log>
</Main>
</Control>
</SGLanguage>
27 changes: 27 additions & 0 deletions SuperGrateTests/Classes/LanguageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Text.RegularExpressions;

namespace SuperGrate.Classes.Tests
{
[TestClass()]
public class LanguageTests
{
[TestMethod()]
public void GetTest()
{
string[] files = Directory.GetFiles("..\\..\\..\\", "*.cs", SearchOption.AllDirectories);
foreach (string file in files)
{
StreamReader reader = File.OpenText(file);
MatchCollection matches = Regex.Matches(reader.ReadToEnd(), "Language\\.Get\\(\"([a-z,A-Z,/]*)\".*\\)");
reader.Close();
foreach (Match match in matches)
{
if (Language.Get(match.Groups[1].Value).Contains("???")) throw new Exception("Language string missing for \"" + match.Groups[1].Value + "\" at: " + file + ".");
}
}
}
}
}
20 changes: 20 additions & 0 deletions SuperGrateTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("SuperGrateTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SuperGrateTests")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("411bced0-f354-4f62-9b12-1042ca095892")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 7d29c27

Please sign in to comment.