Setup project added and tool updated to include an installer and better handling of user settings.

This commit is contained in:
Kay Unkroth 2021-02-25 15:37:31 -08:00
parent 8ec484fc17
commit 6353066423
14 changed files with 1461 additions and 79 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata Translator", "Metadata Translator\Metadata Translator.csproj", "{CB7D493C-B67E-4438-B304-EFE5D418ADDF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata Translator", "Metadata Translator\Metadata Translator.csproj", "{CB7D493C-B67E-4438-B304-EFE5D418ADDF}"
EndProject EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Metadata Translator Setup", "Metadata Translator Setup\Metadata Translator Setup.vdproj", "{FC353DA7-B669-4EDF-B465-CB9827C7F035}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,8 @@ Global
{CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Release|Any CPU.Build.0 = Release|Any CPU {CB7D493C-B67E-4438-B304-EFE5D418ADDF}.Release|Any CPU.Build.0 = Release|Any CPU
{FC353DA7-B669-4EDF-B465-CB9827C7F035}.Debug|Any CPU.ActiveCfg = Debug
{FC353DA7-B669-4EDF-B465-CB9827C7F035}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,13 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Metadata_Translator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup> </startup>
<appSettings> <userSettings>
<add key="SubscriptionKey" value="" /> <Metadata_Translator.Properties.Settings>
<add key="TranslatorEndpoint" value="https://api.cognitive.microsofttranslator.com/" /> <setting name="SubscriptionKey" serializeAs="String">
<add key="TranslatorLocation" value="" /> <value />
<add key="OverwriteTranslation" value="false" /> </setting>
<add key="LastUsedExportFolder" value="" /> <setting name="TranslatorEndpoint" serializeAs="String">
</appSettings> <value>https://api.cognitive.microsofttranslator.com/</value>
</setting>
<setting name="TranslatorLocation" serializeAs="String">
<value />
</setting>
<setting name="OverwriteTranslation" serializeAs="String">
<value>False</value>
</setting>
<setting name="LastUsedExportFolder" serializeAs="String">
<value />
</setting>
</Metadata_Translator.Properties.Settings>
</userSettings>
</configuration> </configuration>

View File

@ -0,0 +1,37 @@

namespace Metadata_Translator
{
partial class Installer1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Security.Permissions;
using System.Windows;
using System.IO;
namespace Metadata_Translator
{
[RunInstaller(true)]
public partial class Installer1 : System.Configuration.Install.Installer
{
public Installer1()
{
InitializeComponent();
}
[SecurityPermission(SecurityAction.Demand)]
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
MessageBox.Show("Commit");
}
[SecurityPermission(SecurityAction.Demand)]
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string exeName = Context.Parameters["assemblypath"];
string appDir = Path.GetDirectoryName(exeName);
string pbiSharedDir = Environment.ExpandEnvironmentVariables(@"%CommonProgramFiles%\microsoft shared\Power BI Desktop\External Tools\");
string pbiToolsJsonTemplate = $"{appDir}\\metadata-translator.pbitool.json";
if (File.Exists(pbiToolsJsonTemplate))
{
string pbiToolsJson = File.ReadAllText(pbiToolsJsonTemplate).Replace("<METADATA_TRANSLATOR_PATH>", exeName.Replace("\\", "\\\\"));
File.WriteAllText($"{pbiSharedDir}\\metadata-translator.pbitool.json", pbiToolsJson);
}
}
[SecurityPermission(SecurityAction.Demand)]
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
string pbiSharedDir = Environment.ExpandEnvironmentVariables(@"%CommonProgramFiles%\microsoft shared\Power BI Desktop\External Tools\");
string pbiToolFile = $"{pbiSharedDir}\\metadata-translator.pbitool.json";
if (File.Exists(pbiToolFile))
{
File.Delete(pbiToolFile);
}
}
}
}

View File

@ -14,6 +14,21 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,33 +48,42 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon> <ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>MetadataTranslator.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.AnalysisServices, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.AnalysisServices.AdomdClient, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices.AdomdClient, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.AdomdClient.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.AdomdClient.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.AdomdClient.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.AdomdClient.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.AnalysisServices.Core, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices.Core, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.Core.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.AnalysisServices.SPClient.Interfaces, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices.SPClient.Interfaces, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.SPClient.Interfaces.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.SPClient.Interfaces.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices.Tabular, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.Tabular.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.Tabular.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular.Json, Version=19.16.3.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"> <Reference Include="Microsoft.AnalysisServices.Tabular.Json, Version=19.16.3.4, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3\lib\net45\Microsoft.AnalysisServices.Tabular.Json.dll</HintPath> <HintPath>..\packages\Microsoft.AnalysisServices.retail.amd64.19.16.3.4\lib\net45\Microsoft.AnalysisServices.Tabular.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
@ -89,6 +113,12 @@
<Compile Include="Helpers\Hourglass.cs" /> <Compile Include="Helpers\Hourglass.cs" />
<Compile Include="Helpers\ListExtensions.cs" /> <Compile Include="Helpers\ListExtensions.cs" />
<Compile Include="Helpers\ObservableCollectionExtensions.cs" /> <Compile Include="Helpers\ObservableCollectionExtensions.cs" />
<Compile Include="Installer1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Installer1.Designer.cs">
<DependentUpon>Installer1.cs</DependentUpon>
</Compile>
<Compile Include="UI\ImportExportPanel.xaml.cs"> <Compile Include="UI\ImportExportPanel.xaml.cs">
<DependentUpon>ImportExportPanel.xaml</DependentUpon> <DependentUpon>ImportExportPanel.xaml</DependentUpon>
</Compile> </Compile>
@ -161,7 +191,10 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="metadata-translator.pbitool.json" /> <None Include="metadata-translator.pbitool.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MetadataTranslator.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -175,7 +208,21 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="icon.ico" /> <Resource Include="icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>

View File

@ -8,9 +8,9 @@ using System.Windows;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Metadata Translator")] [assembly: AssemblyTitle("Metadata Translator")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("Metadata Translator can translate the names and descriptions of the metadata objects in your semantic model by using Azure Cognitive Services.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Metadata Translator")] [assembly: AssemblyProduct("Metadata Translator")]
[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]

View File

@ -8,22 +8,79 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Metadata_Translator.Properties {
namespace Metadata_Translator.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default public static Settings Default {
{ get {
get
{
return defaultInstance; return defaultInstance;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string SubscriptionKey {
get {
return ((string)(this["SubscriptionKey"]));
}
set {
this["SubscriptionKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://api.cognitive.microsofttranslator.com/")]
public string TranslatorEndpoint {
get {
return ((string)(this["TranslatorEndpoint"]));
}
set {
this["TranslatorEndpoint"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TranslatorLocation {
get {
return ((string)(this["TranslatorLocation"]));
}
set {
this["TranslatorLocation"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool OverwriteTranslation {
get {
return ((bool)(this["OverwriteTranslation"]));
}
set {
this["OverwriteTranslation"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastUsedExportFolder {
get {
return ((string)(this["LastUsedExportFolder"]));
}
set {
this["LastUsedExportFolder"] = value;
}
}
} }
} }

View File

@ -1,7 +1,21 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Metadata_Translator.Properties" GeneratedClassName="Settings">
<Profiles> <Profiles />
<Profile Name="(Default)" /> <Settings>
</Profiles> <Setting Name="SubscriptionKey" Type="System.String" Scope="User">
<Settings /> <Value Profile="(Default)" />
</Setting>
<Setting Name="TranslatorEndpoint" Type="System.String" Scope="User">
<Value Profile="(Default)">https://api.cognitive.microsofttranslator.com/</Value>
</Setting>
<Setting Name="TranslatorLocation" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="OverwriteTranslation" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="LastUsedExportFolder" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile> </SettingsFile>

View File

@ -6,7 +6,8 @@
xmlns:local="clr-namespace:Metadata_Translator" xmlns:local="clr-namespace:Metadata_Translator"
mc:Ignorable="d" mc:Ignorable="d"
x:Name="main" x:Name="main"
Title="Metadata Translator" Height="450" Width="800"> Title="Metadata Translator" Height="450" Width="800"
Closing="OnMainWindow_Closing">
<Window.Resources> <Window.Resources>
<local:TrueFalseVisibilityConverter x:Key="TrueFalseVisibilityConverter" /> <local:TrueFalseVisibilityConverter x:Key="TrueFalseVisibilityConverter" />
<local:FalseTrueVisibilityConverter x:Key="FalseTrueVisibilityConverter" /> <local:FalseTrueVisibilityConverter x:Key="FalseTrueVisibilityConverter" />

View File

@ -32,13 +32,10 @@ namespace Metadata_Translator
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
Configuration AppConfig { get; set; }
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
AppConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
SetDependencyProperty("SubscriptionKey"); SetDependencyProperty("SubscriptionKey");
SetDependencyProperty("TranslatorEndpoint"); SetDependencyProperty("TranslatorEndpoint");
SetDependencyProperty("TranslatorLocation"); SetDependencyProperty("TranslatorLocation");
@ -102,20 +99,19 @@ namespace Metadata_Translator
switch (parameterName) switch (parameterName)
{ {
case "SubscriptionKey": case "SubscriptionKey":
SubscriptionKey = AppConfig.AppSettings.Settings[parameterName].Value; SubscriptionKey = Properties.Settings.Default.SubscriptionKey;
break; break;
case "TranslatorEndpoint": case "TranslatorEndpoint":
TranslatorEndpoint = AppConfig.AppSettings.Settings[parameterName].Value; TranslatorEndpoint = Properties.Settings.Default.TranslatorEndpoint;
break; break;
case "TranslatorLocation": case "TranslatorLocation":
TranslatorLocation = AppConfig.AppSettings.Settings[parameterName].Value; TranslatorLocation = Properties.Settings.Default.TranslatorLocation;
break; break;
case "OverwriteTranslation": case "OverwriteTranslation":
string configSetting = AppConfig.AppSettings.Settings[parameterName].Value; OverwriteTranslation = Properties.Settings.Default.OverwriteTranslation;
OverwriteTranslation = bool.TryParse(configSetting, out bool value) && value;
break; break;
case "LastUsedExportFolder": case "LastUsedExportFolder":
LastUsedExportFolder = AppConfig.AppSettings.Settings[parameterName].Value; LastUsedExportFolder = Properties.Settings.Default.LastUsedExportFolder;
break; break;
case "Languages": case "Languages":
Languages = new ObservableCollection<Language>(); Languages = new ObservableCollection<Language>();
@ -245,18 +241,6 @@ namespace Metadata_Translator
return GetMainWindow(parentObject); return GetMainWindow(parentObject);
} }
} }
/// <summary>
/// Save app settings to the application config file.
/// </summary>
/// <param name="settingName"></param>
/// <param name="newValue"></param>
private void OnAppSettingChanged(string settingName, string newValue)
{
AppConfig.AppSettings.Settings[settingName].Value = newValue;
AppConfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
#endregion #endregion
#region Dependency Properties #region Dependency Properties
@ -390,8 +374,7 @@ namespace Metadata_Translator
private static void OnSubscriptionKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnSubscriptionKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
(d as MainWindow)?.OnAppSettingChanged("SubscriptionKey", (string)e.NewValue); Properties.Settings.Default.SubscriptionKey = (string)e.NewValue;
} }
/// <summary> /// <summary>
@ -409,8 +392,7 @@ namespace Metadata_Translator
private static void OnTranslatorEndpointChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnTranslatorEndpointChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
(d as MainWindow)?.OnAppSettingChanged("TranslatorEndpoint", (string)e.NewValue); Properties.Settings.Default.TranslatorEndpoint = (string)e.NewValue;
} }
/// <summary> /// <summary>
@ -428,8 +410,7 @@ namespace Metadata_Translator
private static void OnTranslatorLocationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnTranslatorLocationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
(d as MainWindow)?.OnAppSettingChanged("TranslatorLocation", (string)e.NewValue); Properties.Settings.Default.TranslatorLocation = (string)e.NewValue;
} }
/// <summary> /// <summary>
@ -447,8 +428,7 @@ namespace Metadata_Translator
private static void OnOverwriteTranslationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnOverwriteTranslationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
(d as MainWindow)?.OnAppSettingChanged("OverwriteTranslation", e.NewValue.ToString()); Properties.Settings.Default.OverwriteTranslation = (bool)e.NewValue;
} }
/// <summary> /// <summary>
@ -466,8 +446,7 @@ namespace Metadata_Translator
private static void OnLastUsedExportFolderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnLastUsedExportFolderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
(d as MainWindow)?.OnAppSettingChanged("LastUsedExportFolder", (string)e.NewValue); Properties.Settings.Default.LastUsedExportFolder = (string)e.NewValue;
} }
/// <summary> /// <summary>
@ -633,6 +612,16 @@ namespace Metadata_Translator
{ {
DataModel.Update(); DataModel.Update();
} }
/// <summary>
/// Saves modified user settings.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnMainWindow_Closing(object sender, CancelEventArgs e)
{
Properties.Settings.Default.Save();
}
#endregion #endregion
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Microsoft.AnalysisServices.AdomdClient.retail.amd64" version="19.16.3" targetFramework="net472" /> <package id="Microsoft.AnalysisServices.AdomdClient.retail.amd64" version="19.16.3.4" targetFramework="net472" />
<package id="Microsoft.AnalysisServices.retail.amd64" version="19.16.3" targetFramework="net472" /> <package id="Microsoft.AnalysisServices.retail.amd64" version="19.16.3.4" targetFramework="net472" />
</packages> </packages>