Skip to content

application config persists on relaunch #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions GmodAddonCompressor/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="GmodAddonCompressor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<GmodAddonCompressor.Properties.Settings>
<setting name="_imageWidthLimitIndex" serializeAs="String">
<value>10</value>
</setting>
<setting name="_imageHeightLimitIndex" serializeAs="String">
<value>10</value>
</setting>
<setting name="_useFFMpegForCompress" serializeAs="String">
<value>False</value>
</setting>
<setting name="_unlockedUI" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressVTF" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressWAV" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressMP3" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressOGG" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressJPG" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressPNG" serializeAs="String">
<value>True</value>
</setting>
<setting name="_compressLUA" serializeAs="String">
<value>False</value>
</setting>
<setting name="_changeOriginalCodeToMinimalistic" serializeAs="String">
<value>False</value>
</setting>
<setting name="_reduceExactlyToLimits" serializeAs="String">
<value>False</value>
</setting>
<setting name="_reduceExactlyToResolution" serializeAs="String">
<value>True</value>
</setting>
<setting name="_keepImageAspectRatio" serializeAs="String">
<value>True</value>
</setting>
<setting name="_imageMagickVTFCompress" serializeAs="String">
<value>False</value>
</setting>
<setting name="_imageSkipWidth" serializeAs="String">
<value>0</value>
</setting>
<setting name="_imageSkipHeight" serializeAs="String">
<value>0</value>
</setting>
<setting name="_wavRate" serializeAs="String">
<value>22050</value>
</setting>
<setting name="_wavRateListIndex" serializeAs="String">
<value>0</value>
</setting>
<setting name="_imageReducingResolutionListIndex" serializeAs="String">
<value>0</value>
</setting>
</GmodAddonCompressor.Properties.Settings>
</userSettings>
</configuration>
66 changes: 45 additions & 21 deletions GmodAddonCompressor/DataContexts/MainWindowContext.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using GmodAddonCompressor.Properties;

namespace GmodAddonCompressor.DataContexts
{
internal class MainWindowContext : INotifyPropertyChanged
{
private static Settings Set => Settings.Default;
private string _addonDirectoryPath = string.Empty;
private string _progressBarText = string.Empty;
private int _progressBarMinValue = 0;
private int _progressBarMaxValue = 100;
private int _progressBarValue = 0;
private bool _unlockedUI = true;
private bool _compressVTF = true;
private bool _compressWAV = true;
private bool _compressMP3 = true;
private bool _compressOGG = true;
private bool _compressJPG = true;
private bool _compressPNG = true;
private bool _compressLUA = false;
private bool _useFFMpegForCompress = false;
private bool _changeOriginalCodeToMinimalistic = false;
private bool _reduceExactlyToLimits = false;
private bool _reduceExactlyToResolution = true;
private bool _keepImageAspectRatio = true;
private bool _imageMagickVTFCompress = false;
private uint _imageSkipWidth = 0;
private uint _imageSkipHeight = 0;
private int _wavRate = 22050;
private int _wavRateListIndex = 0;
private int _imageReducingResolutionListIndex = 0;
private int _imageWidthLimitIndex = 10;
private int _imageHeightLimitIndex = 10;
private bool _unlockedUI = Set._unlockedUI;
private bool _compressVTF = Set._compressVTF;
private bool _compressWAV = Set._compressWAV;
private bool _compressMP3 = Set._compressMP3;
private bool _compressOGG = Set._compressOGG;
private bool _compressJPG = Set._compressJPG;
private bool _compressPNG = Set._compressPNG;
private bool _compressLUA = Set._compressLUA;
private bool _useFFMpegForCompress = Set._useFFMpegForCompress;
private bool _changeOriginalCodeToMinimalistic = Set._changeOriginalCodeToMinimalistic;
private bool _reduceExactlyToLimits = Set._reduceExactlyToLimits;
private bool _reduceExactlyToResolution = Set._reduceExactlyToResolution;
private bool _keepImageAspectRatio = Set._keepImageAspectRatio;
private bool _imageMagickVTFCompress = Set._imageMagickVTFCompress;
private uint _imageSkipWidth = Set._imageSkipWidth;
private uint _imageSkipHeight = Set._imageSkipHeight;
private int _wavRate = Set._wavRate;
private int _wavRateListIndex = Set._wavRateListIndex;
private int _imageReducingResolutionListIndex = Set._imageReducingResolutionListIndex;
private int _imageWidthLimitIndex = Set._imageWidthLimitIndex;
private int _imageHeightLimitIndex = Set._imageHeightLimitIndex;
private int[] _imageReducingResolutionList = new int[]
{
2,
Expand Down Expand Up @@ -69,6 +71,7 @@ public uint ImageSkipHeight
set
{
_imageSkipHeight = value;
Set._imageSkipHeight = value;
OnPropertyChanged();
}
}
Expand All @@ -79,6 +82,7 @@ public uint ImageSkipWidth
set
{
_imageSkipWidth = value;
Set._imageSkipWidth = value;
OnPropertyChanged();
}
}
Expand All @@ -99,6 +103,7 @@ public int ImageWidthLimitIndex
set
{
_imageWidthLimitIndex = value;
Set._imageWidthLimitIndex = value;
OnPropertyChanged();
}
}
Expand All @@ -109,6 +114,7 @@ public int ImageHeightLimitIndex
set
{
_imageHeightLimitIndex = value;
Set._imageHeightLimitIndex = value;
OnPropertyChanged();
}
}
Expand All @@ -119,6 +125,7 @@ public int ImageReducingResolutionListIndex
set
{
_imageReducingResolutionListIndex = value;
Set._imageReducingResolutionListIndex = value;
OnPropertyChanged();
}
}
Expand All @@ -139,6 +146,7 @@ public int WavRateListIndex
set
{
_wavRateListIndex = value;
Set._wavRateListIndex = value;
OnPropertyChanged();
}
}
Expand All @@ -159,6 +167,7 @@ public int WavRate
set
{
_wavRate = value;
Set._wavRate = value;
OnPropertyChanged();
}
}
Expand All @@ -169,6 +178,7 @@ public bool ImageMagickVTFCompress
set
{
_imageMagickVTFCompress = value;
Set._imageMagickVTFCompress = value;
OnPropertyChanged();
}
}
Expand All @@ -179,6 +189,7 @@ public bool KeepImageAspectRatio
set
{
_keepImageAspectRatio = value;
Set._keepImageAspectRatio = value;
OnPropertyChanged();
}
}
Expand All @@ -189,6 +200,7 @@ public bool ReduceExactlyToResolution
set
{
_reduceExactlyToResolution = value;
Set._reduceExactlyToResolution = value;
OnPropertyChanged();
}
}
Expand All @@ -199,6 +211,7 @@ public bool ReduceExactlyToLimits
set
{
_reduceExactlyToLimits = value;
Set._reduceExactlyToLimits = value;
ReduceExactlyToResolution = !_reduceExactlyToLimits;
OnPropertyChanged();
}
Expand All @@ -210,6 +223,7 @@ public bool ChangeOriginalCodeToMinimalistic
set
{
_changeOriginalCodeToMinimalistic = value;
Set._changeOriginalCodeToMinimalistic = value;
OnPropertyChanged();
}
}
Expand All @@ -220,6 +234,7 @@ public bool UseFFMpegForCompress
set
{
_useFFMpegForCompress = value;
Set._useFFMpegForCompress = value;
OnPropertyChanged();
}
}
Expand All @@ -230,6 +245,7 @@ public bool CompressLUA
set
{
_compressLUA = value;
Set._compressLUA = value;
OnPropertyChanged();
}
}
Expand All @@ -240,6 +256,7 @@ public bool CompressPNG
set
{
_compressPNG = value;
Set._compressPNG = value;
OnPropertyChanged();
}
}
Expand All @@ -250,6 +267,7 @@ public bool CompressJPG
set
{
_compressJPG = value;
Set._compressJPG = value;
OnPropertyChanged();
}
}
Expand All @@ -260,6 +278,7 @@ public bool CompressVTF
set
{
_compressVTF = value;
Set._compressVTF = value;
OnPropertyChanged();
}
}
Expand All @@ -270,6 +289,7 @@ public bool CompressOGG
set
{
_compressOGG = value;
Set._compressOGG = value;
OnPropertyChanged();
}
}
Expand All @@ -280,6 +300,7 @@ public bool CompressMP3
set
{
_compressMP3 = value;
Set._compressMP3 = value;
OnPropertyChanged();
}
}
Expand All @@ -290,6 +311,7 @@ public bool CompressWAV
set
{
_compressWAV = value;
Set._compressWAV = value;
OnPropertyChanged();
}
}
Expand All @@ -300,6 +322,7 @@ public bool UnlockedUI
set
{
_unlockedUI = value;
Set._unlockedUI = value;
OnPropertyChanged();
}
}
Expand Down Expand Up @@ -359,6 +382,7 @@ public void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
if (PropertyChanged != null && propertyName != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
Set.Save();
}
}
}
12 changes: 12 additions & 0 deletions GmodAddonCompressor/GmodAddonCompressor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
Expand All @@ -40,4 +45,11 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

</Project>
Loading