Skip to content

Commit

Permalink
Added UI element remove thread safe code
Browse files Browse the repository at this point in the history
Localization plugins updated to v4.7.1 .NET
corrected typo in sample plugin project
  • Loading branch information
John H. Freeman committed Apr 3, 2024
1 parent 2fcfa70 commit 205b312
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 16 deletions.
13 changes: 10 additions & 3 deletions Localization/en-US/ActLocalization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ActLocalization</RootNamespace>
<AssemblyName>ActLocalization_en-US</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -20,6 +21,7 @@
<DefineConstants>TRACE;DEBUG;XMLINCLUDED</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,10 +30,11 @@
<DefineConstants>TRACE;XMLINCLUDED</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Advanced Combat Tracker">
<HintPath>C:\Program Files (x86)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
<HintPath>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -71,4 +74,8 @@
<EmbeddedResource Include="Advanced Combat Tracker.exe.InternalStrings.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<PropertyGroup>
<PostBuildEvent>IF NOT EXIST "$(APPDATA)\Advanced Combat Tracker\Plugins" mkdir "$(APPDATA)\Advanced Combat Tracker\Plugins"
IF Debug==$(ConfigurationName) copy /Y $(TargetPath) "$(APPDATA)\Advanced Combat Tracker\Plugins"</PostBuildEvent>
</PropertyGroup>
</Project>
35 changes: 32 additions & 3 deletions Localization/en-US/ActLocalizationPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@

[assembly: AssemblyTitle("ActLocalization en-US")]
[assembly: AssemblyDescription("A sample of an ACT plugin that changes localization strings using XML resources.")]
[assembly: AssemblyVersion("276.0.0.0")]
[assembly: AssemblyVersion("276.0.1.0")]

namespace ActLocalization
{
class ActLocalizationPlugin : IActPluginV1
{
void pluginScreenSpaceRemove(TabPage screenSpace)
{
Action removeControl = new Action(() => { screenSpace.Parent.Controls.Remove(screenSpace); });
if (screenSpace.InvokeRequired)
{
screenSpace.Invoke(removeControl);
}
else
removeControl.Invoke();
}
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
{
//ActLocalization.InternalStrings.EditLocalizations();
Expand Down Expand Up @@ -74,8 +84,8 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
using (Stream s = asm.GetManifestResourceStream("ActLocalization.Advanced Combat Tracker.exe.FormXmlSettingsIO.xml"))
ActGlobals.oFormXmlSettingsIO.ImportControlTextXML(s);
}
pluginStatusText.Text = "Localization Complete";
pluginScreenSpace.Parent.Controls.Remove(pluginScreenSpace);
ChangeLblStatus(pluginStatusText, "Localization Complete");
pluginScreenSpaceRemove(pluginScreenSpace);
}
internal static bool TryEditLocalization(string Key, string Value)
{
Expand All @@ -91,5 +101,24 @@ internal static bool TryEditLocalization(string Key, string Value)
public void DeInitPlugin()
{
}

void ChangeLblStatus(Label label, String status)
{

switch (label.InvokeRequired)
{
case true:
label.Invoke(new Action(() =>
{
label.Text = status;
}));
break;
case false:
label.Text = status;
break;
default:
break;
}
}
}
}
18 changes: 13 additions & 5 deletions Localization/ja-JP/ActLocalization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
<ProjectGuid>{E8253A9D-199D-46A9-A017-572CD97701A0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ActLocalization</RootNamespace>
<AssemblyName>ActLocalization</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<RootNamespace>ActLocalization_ja_JP</RootNamespace>
<AssemblyName>ActLocalization_ja_JP</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -20,6 +21,7 @@
<DefineConstants>TRACE;DEBUG;XMLINCLUDED</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
Expand All @@ -28,10 +30,12 @@
<DefineConstants>TRACE;XMLINCLUDED</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Advanced Combat Tracker">
<HintPath>.\Advanced Combat Tracker.exe</HintPath>
<Reference Include="Advanced Combat Tracker, Version=3.7.0.280, Culture=neutral, PublicKeyToken=a946b61e93d97868, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -73,4 +77,8 @@
<EmbeddedResource Include="Advanced Combat Tracker.exe.InternalStrings.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>IF NOT EXIST "$(APPDATA)\Advanced Combat Tracker\Plugins" mkdir "$(APPDATA)\Advanced Combat Tracker\Plugins"
IF Debug==$(ConfigurationName) copy /Y $(TargetPath) "$(APPDATA)\Advanced Combat Tracker\Plugins"</PostBuildEvent>
</PropertyGroup>
</Project>
37 changes: 34 additions & 3 deletions Localization/ja-JP/ActLocalizationPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Advanced_Combat_Tracker;
Expand All @@ -7,6 +8,17 @@ namespace ActLocalization
{
internal class ActLocalizationPlugin : IActPluginV1
{
void pluginScreenSpaceRemove(TabPage screenSpace)
{
Action removeControl = new Action(() => { screenSpace.Parent.Controls.Remove(screenSpace); });
if (screenSpace.InvokeRequired)
{
screenSpace.Invoke(removeControl);
}
else
removeControl.Invoke();
}

public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
{
ActLocalization.InternalStrings.EditLocalizations();
Expand Down Expand Up @@ -57,12 +69,31 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
ActGlobals.oFormXmlSettingsIO.ImportControlTextXML(s);
}

pluginStatusText.Text = "Localization Complete";
pluginScreenSpace.Parent.Controls.Remove(pluginScreenSpace);
ChangeLblStatus(pluginStatusText, "Localization Complete");
pluginScreenSpaceRemove(pluginScreenSpace);
}

public void DeInitPlugin()
{
}

void ChangeLblStatus(Label label, String status)
{

switch (label.InvokeRequired)
{
case true:
label.Invoke(new Action(() =>
{
label.Text = status;
}));
break;
case false:
label.Text = status;
break;
default:
break;
}
}
}
}
4 changes: 2 additions & 2 deletions Plugins/ACT_Plugin_Sample/ACT_Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<StartAction>Program</StartAction>
<StartProgram>>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</StartProgram>
<StartProgram>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</StartProgram>
<StartWorkingDirectory>>$(MSBuildProgramFiles32)\Advanced Combat Tracker\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -52,7 +52,7 @@
-->
<ItemGroup>
<Reference Include="Advanced Combat Tracker">
<HintPath>>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
<HintPath>$(MSBuildProgramFiles32)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand Down

0 comments on commit 205b312

Please sign in to comment.