Skip to content

Commit 700782a

Browse files
committed
Update shared files.
1 parent e9e2249 commit 700782a

36 files changed

+1315
-731
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
/.vs/JocysCom.TextToSpeech/v14/*.suo
1313
/TextToSpeech/.vs
1414
/.vs/JocysCom.TextToSpeech
15+
Files

TextToSpeech/Common/Options.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public partial class Options : INotifyPropertyChanged
1212
{
1313
public Options()
1414
{
15-
JocysCom.ClassLibrary.Runtime.RuntimeHelper.ResetPropertiesToDefault(this, false);
15+
JocysCom.ClassLibrary.Runtime.Attributes.ResetPropertiesToDefault(this, false);
1616
}
1717

1818
/// <summary>
1919
/// Avoid deserialization duplicates by using separate method.
2020
/// </summary>
2121
public void InitDefaults(bool onlyIfNull = false)
2222
{
23-
JocysCom.ClassLibrary.Runtime.RuntimeHelper.ResetPropertiesToDefault(this, onlyIfNull);
23+
JocysCom.ClassLibrary.Runtime.Attributes.ResetPropertiesToDefault(this, onlyIfNull);
2424
}
2525

2626
[DefaultValue("")]
@@ -163,34 +163,34 @@ public string AmazonSecretKey
163163
[DefaultValue(null), XmlElement(ElementName = nameof(AmazonSecretKey))]
164164
public string _AmazonSecretKeyEncrypted { get; set; }
165165

166-
#endregion
166+
#endregion
167167

168-
#region Voices: ElevenLabs
168+
#region Voices: ElevenLabs
169169

170-
[DefaultValue(null)]
171-
public bool ElevenLabsEnabled { get { return _ElevenLabsEnabled; } set { _ElevenLabsEnabled = value; OnPropertyChanged(); } }
172-
bool _ElevenLabsEnabled;
170+
[DefaultValue(null)]
171+
public bool ElevenLabsEnabled { get { return _ElevenLabsEnabled; } set { _ElevenLabsEnabled = value; OnPropertyChanged(); } }
172+
bool _ElevenLabsEnabled;
173173

174-
[XmlIgnore]
175-
public string ElevenLabsApiKey
176-
{
177-
get { return UserDecrypt(_ElevenLabsApiKeyEncrypted); }
178-
set { _ElevenLabsApiKeyEncrypted = UserEncrypt(value); OnPropertyChanged(); }
179-
}
180-
[DefaultValue(null), XmlElement(ElementName = nameof(ElevenLabsApiKey))]
181-
public string _ElevenLabsApiKeyEncrypted { get; set; }
174+
[XmlIgnore]
175+
public string ElevenLabsApiKey
176+
{
177+
get { return UserDecrypt(_ElevenLabsApiKeyEncrypted); }
178+
set { _ElevenLabsApiKeyEncrypted = UserEncrypt(value); OnPropertyChanged(); }
179+
}
180+
[DefaultValue(null), XmlElement(ElementName = nameof(ElevenLabsApiKey))]
181+
public string _ElevenLabsApiKeyEncrypted { get; set; }
182182

183-
#endregion
183+
#endregion
184184

185-
#region Encrypt Settings
185+
#region Encrypt Settings
186186

187-
static string UserEncrypt(string text)
187+
static string UserEncrypt(string text)
188188
{
189189
try
190190
{
191191
//var user = System.Security.Principal.WindowsIdentity.GetCurrent().User.Value;
192192
var user = "AppContext";
193-
return JocysCom.ClassLibrary.Security.Encryption.ProtectWithMachineKey(text, user);
193+
return JocysCom.ClassLibrary.Security.Encryption.Encrypt(text, user);
194194
}
195195
catch (Exception ex)
196196
{
@@ -205,7 +205,7 @@ static string UserDecrypt(string base64)
205205
{
206206
//var user = System.Security.Principal.WindowsIdentity.GetCurrent().User.Value;
207207
var user = "AppContext";
208-
return JocysCom.ClassLibrary.Security.Encryption.UnProtectWithMachineKey(base64, user);
208+
return JocysCom.ClassLibrary.Security.Encryption.Decrypt(base64, user);
209209
}
210210
catch (Exception ex)
211211
{

TextToSpeech/JocysCom.TextToSpeech.Monitor.csproj

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
<UpdatePeriodically>false</UpdatePeriodically>
2828
<UpdateRequired>false</UpdateRequired>
2929
<MapFileExtensions>true</MapFileExtensions>
30-
<ApplicationRevision>0</ApplicationRevision>
30+
<ApplicationRevision>1</ApplicationRevision>
3131
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
3232
<UseApplicationTrust>false</UseApplicationTrust>
33+
<PublishWizardCompleted>true</PublishWizardCompleted>
3334
<BootstrapperEnabled>true</BootstrapperEnabled>
3435
</PropertyGroup>
3536
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@@ -42,8 +43,10 @@
4243
<ErrorReport>prompt</ErrorReport>
4344
<WarningLevel>4</WarningLevel>
4445
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
45-
<RunCodeAnalysis>true</RunCodeAnalysis>
46+
<RunCodeAnalysis>false</RunCodeAnalysis>
4647
<Prefer32Bit>false</Prefer32Bit>
48+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
49+
<CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>
4750
</PropertyGroup>
4851
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
4952
<PlatformTarget>x86</PlatformTarget>
@@ -84,6 +87,27 @@
8487
<ApplicationIcon>app.ico</ApplicationIcon>
8588
</PropertyGroup>
8689
<PropertyGroup />
90+
<PropertyGroup>
91+
<ManifestCertificateThumbprint>60F171B9DDEC11957D89324C5D05AC78A912399A</ManifestCertificateThumbprint>
92+
</PropertyGroup>
93+
<PropertyGroup>
94+
<ManifestKeyFile>JocysCom.TextToSpeech.Monitor_TemporaryKey.pfx</ManifestKeyFile>
95+
</PropertyGroup>
96+
<PropertyGroup>
97+
<GenerateManifests>true</GenerateManifests>
98+
</PropertyGroup>
99+
<PropertyGroup>
100+
<SignManifests>false</SignManifests>
101+
</PropertyGroup>
102+
<PropertyGroup>
103+
<SignAssembly>false</SignAssembly>
104+
</PropertyGroup>
105+
<PropertyGroup>
106+
<DelaySign>false</DelaySign>
107+
</PropertyGroup>
108+
<PropertyGroup>
109+
<AssemblyOriginatorKeyFile>JocysCom.TextToSpeech.Monitor_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
110+
</PropertyGroup>
87111
<ItemGroup>
88112
<Reference Include="AWSSDK.Core">
89113
<HintPath>Resources\Amazon\AWSSDK.Core.dll</HintPath>
@@ -132,12 +156,15 @@
132156
<Reference Include="System.Design" />
133157
<Reference Include="System.DirectoryServices.AccountManagement" />
134158
<Reference Include="System.Management" />
159+
<Reference Include="System.Memory" />
135160
<Reference Include="System.Net.Http" />
136161
<Reference Include="System.Runtime.Serialization" />
137162
<Reference Include="System.Security" />
138163
<Reference Include="System.Speech" />
139-
<Reference Include="System.Text.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
140-
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
164+
<Reference Include="System.Text.Json">
165+
<SpecificVersion>False</SpecificVersion>
166+
</Reference>
167+
<Reference Include="System.Threading.Tasks.Extensions" />
141168
<Reference Include="System.Web" />
142169
<Reference Include="System.Windows.Forms.DataVisualization.Design" />
143170
<Reference Include="System.Xaml" />
@@ -284,7 +311,10 @@
284311
<Compile Include="Controls\VoicesUserControl.Designer.cs">
285312
<DependentUpon>VoicesUserControl.cs</DependentUpon>
286313
</Compile>
314+
<Compile Include="JocysCom\Collections\CollectionsHelper.cs" />
315+
<Compile Include="JocysCom\Collections\IKeyValue.cs" />
287316
<Compile Include="JocysCom\Configuration\AssemblyInfo.Ext1.cs" />
317+
<Compile Include="JocysCom\Configuration\ISettingsItemFile.cs" />
288318
<Compile Include="JocysCom\Configuration\SettingsParser.cs" />
289319
<Compile Include="JocysCom\Controls\ControlsHelper.Windows.cs" />
290320
<Compile Include="JocysCom\Data\SqlHelper.Types.cs" />
@@ -511,6 +541,8 @@
511541
<EmbeddedResource Include="Resources\Icons\Information.png" />
512542
<EmbeddedResource Include="Resources\Documents\JocysCom.TextToSpeech.Monitor.rtf" />
513543
<None Include=".editorconfig" />
544+
<None Include="Evaldas_Jocys.PublicKey.cer" />
545+
<None Include="JocysCom.TextToSpeech.Monitor_TemporaryKey.pfx" />
514546
<None Include="Resources\Images\JocysCom_TTS_Monitor.psd" />
515547
<None Include="Resources\Images\JocysCom_TTS_Monitor_IntroSounds.psd" />
516548
<None Include="Resources\Images\JocysCom_TTS_Monitor_Voices.psd" />
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace JocysCom.ClassLibrary.Collections
5+
{
6+
public static partial class CollectionsHelper
7+
{
8+
9+
/// <summary>
10+
/// Synchronize source collection to destination.
11+
/// </summary>
12+
public static void Synchronize<T>(IList<T> source, IList<T> target, IEqualityComparer<T> comparer = null)
13+
{
14+
comparer = comparer ?? EqualityComparer<T>.Default;
15+
// Create a dictionary for fast lookup in source list
16+
var sourceSet = new Dictionary<T, int>();
17+
for (int i = 0; i < source.Count; i++)
18+
sourceSet[source[i]] = i;
19+
// Iterate over the target, remove items not in source
20+
for (int i = target.Count - 1; i >= 0; i--)
21+
if (!sourceSet.Keys.Contains(target[i], comparer))
22+
target.RemoveAt(i);
23+
// Iterate over source
24+
for (int si = 0; si < source.Count; si++)
25+
{
26+
// If item is not present in target, insert it.
27+
// Note: Only check items that have not been synchornized in the target.
28+
if (!target.Skip(si).Contains(source[si], comparer))
29+
{
30+
target.Insert(si, source[si]);
31+
continue;
32+
}
33+
// If item is present in target but not at the right position, move it.
34+
int ti = -1;
35+
// Note: Only check items that have not been synchornized in the target.
36+
for (int i = si; i < target.Count; i++)
37+
{
38+
if (comparer.Equals(target[i], source[si]))
39+
{
40+
ti = i;
41+
break;
42+
}
43+
}
44+
if (ti != si)
45+
{
46+
T temp = target[si];
47+
target[si] = target[ti];
48+
target[ti] = temp;
49+
}
50+
}
51+
// Remove items at the end of target that exceed source's length
52+
while (target.Count > source.Count)
53+
target.RemoveAt(target.Count - 1);
54+
}
55+
56+
}
57+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace JocysCom.ClassLibrary.Collections
2+
{
3+
public interface IKeyValue<TKey, TValue>
4+
{
5+
TKey Key { get; set; }
6+
TValue Value { get; set; }
7+
8+
}
9+
}

0 commit comments

Comments
 (0)