Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
irusanov committed Nov 23, 2023
1 parent 780f965 commit b4448c8
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 69 deletions.
Binary file modified Common/ZenStates-Core.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions WPF-no-themes/Properties/BuildNumberTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

using System.Reflection;

[assembly: AssemblyVersion("1.30.1177")]
[assembly: AssemblyFileVersion("1.30.1177")]
[assembly: AssemblyVersion("1.30.1178")]
[assembly: AssemblyFileVersion("1.30.1178")]
72 changes: 30 additions & 42 deletions WPF/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@ namespace ZenTimings
[Serializable]
public sealed class AppSettings
{
private const int VERSION_MAJOR = 1;
private const int VERSION_MINOR = 1;
public const int VersionMajor = 1;
public const int VersionMinor = 2;

private const string filename = "settings.xml";
private static readonly string Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.xml");

public enum THEME : int
public enum Theme : int
{
LIGHT,
DARK,
DARK_MINT,
Light,
Dark,
DarkMint,
}

public AppSettings Create()
{
Version = $"{VERSION_MAJOR}.{VERSION_MINOR}";
AppTheme = THEME.LIGHT;
Version = $"{VersionMajor}.{VersionMinor}";
AppTheme = Theme.Light;
AutoRefresh = true;
AutoRefreshInterval = 2000;
AdvancedMode = true;
// DarkMode = false;
CheckForUpdates = true;
SaveWindowPosition = false;
WindowLeft = 0;
Expand All @@ -48,46 +47,43 @@ public AppSettings Create()

public AppSettings Load()
{
if (File.Exists(filename))
try
{
using (StreamReader sr = new StreamReader(filename))
if (File.Exists(Filename))
{
try
using (StreamReader sr = new StreamReader(Filename))
{
XmlSerializer xmls = new XmlSerializer(typeof(AppSettings));
return xmls.Deserialize(sr) as AppSettings;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
sr.Close();
MessageBox.Show(
"Invalid settings file!\nSettings will be reset to defaults.",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
return Create();
}
}
}
else
catch (Exception ex)
{
return Create();
Console.WriteLine(ex.Message);
MessageBox.Show(
"Invalid or outdated settings file!\nSettings will be reset to defaults.",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}

return Create();
}

public void Save()
{
try
{
using (StreamWriter sw = new StreamWriter(filename))
using (StreamWriter sw = new StreamWriter(Filename))
{
XmlSerializer xmls = new XmlSerializer(typeof(AppSettings));
xmls.Serialize(sw, this);
}
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine(ex.Message);
AdonisUI.Controls.MessageBox.Show(
"Could not save settings to file!",
"Error",
Expand All @@ -98,29 +94,21 @@ public void Save()

public void ChangeTheme()
{
Uri[] ThemeUri = new Uri[]
Uri[] themeUri = new Uri[]
{
new Uri("pack://application:,,,/ZenTimings;component/Themes/Light.xaml", UriKind.Absolute),
new Uri("pack://application:,,,/ZenTimings;component/Themes/Dark.xaml", UriKind.Absolute),
new Uri("pack://application:,,,/ZenTimings;component/Themes/DarkMint.xaml", UriKind.Absolute),
new Uri("pack://application:,,,/ZenTimings;component/Themes/Light.xaml", UriKind.Absolute),
};

if (AppTheme == THEME.DARK)
ResourceLocator.SetColorScheme(Application.Current.Resources, ThemeUri[0]);
else if (AppTheme == THEME.DARK_MINT)
ResourceLocator.SetColorScheme(Application.Current.Resources, ThemeUri[1]);
else
ResourceLocator.SetColorScheme(Application.Current.Resources, ThemeUri[ThemeUri.Length - 1]);

//DarkMode = !DarkMode;
ResourceLocator.SetColorScheme(Application.Current.Resources, themeUri[(int)AppTheme]);
}

public string Version { get; set; } = $"{VERSION_MAJOR}.{VERSION_MINOR}";
public string Version { get; set; } = $"{VersionMajor}.{VersionMinor}";
public bool AutoRefresh { get; set; } = true;
public int AutoRefreshInterval { get; set; } = 2000;
public bool AdvancedMode { get; set; } = true;
// public bool DarkMode { get; set; }
public THEME AppTheme { get; set; } = THEME.LIGHT;
public Theme AppTheme { get; set; } = Theme.Light;
public bool CheckForUpdates { get; set; } = true;
public string UpdaterSkippedVersion { get; set; } = "";
public string UpdaterRemindLaterAt { get; set; } = "";
Expand All @@ -135,4 +123,4 @@ public void ChangeTheme()
public string NotifiedChangelog { get; set; } = "";
public string NotifiedRembrandt { get; set; } = "";
}
}
}
21 changes: 19 additions & 2 deletions WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,25 @@ private void Window_Initialized(object sender, EventArgs e)
if (settings.SaveWindowPosition)
{
WindowStartupLocation = WindowStartupLocation.Manual;
Left = settings.WindowLeft;
Top = settings.WindowTop;

// Get the current screen bounds
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
System.Drawing.Rectangle screenBounds = screen.Bounds;

// Check if the saved window position is outside the screen bounds
if (settings.WindowLeft < screenBounds.Left || settings.WindowLeft + Width > screenBounds.Right ||
settings.WindowTop < screenBounds.Top || settings.WindowTop + Height > screenBounds.Bottom)
{
// Reset the window position to a default value
Left = (screenBounds.Width - Width) / 2 + screenBounds.Left;
Top = (screenBounds.Height - Height) / 2 + screenBounds.Top;
}
else
{
// Set the window position to the saved values
Left = settings.WindowLeft;
Top = settings.WindowTop;
}
}

SetWindowTitle();
Expand Down
47 changes: 30 additions & 17 deletions WPF/Plugin/SVI2Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ namespace ZenTimings.Plugin
{
public class SVI2Plugin : IPlugin
{
internal Cpu _cpu;
internal int timeout = 20;
internal const string VERSION = "1.1";
private int timeout = 20;
private const string VERSION = "1.1";

public string Name => "SVI2 Sensors";

Expand All @@ -21,7 +20,14 @@ public class SVI2Plugin : IPlugin

public List<Sensor> Sensors { get; private set; }

private Cpu _cpu;

public SVI2Plugin(Cpu cpu)
{
InitializeSensors(cpu);
}

private void InitializeSensors(Cpu cpu)
{
if (cpu != null && cpu.Status == IOModule.LibStatus.OK)
{
Expand All @@ -36,34 +42,41 @@ public SVI2Plugin(Cpu cpu)

public bool Update()
{
if (Sensors?.Count > 0)
if (Sensors?.Count > 0 && _cpu != null)
{
uint soc_plane_value;
uint vcore_plane_value;
uint socPlaneValue;
uint vcorePlaneValue;
do
{
soc_plane_value = _cpu.ReadDword(_cpu.info.svi2.socAddress);
vcore_plane_value = _cpu.ReadDword(_cpu.info.svi2.coreAddress);
} while ((soc_plane_value & 0xFF00) != 0 && (vcore_plane_value & 0xFF00) != 0 && --timeout > 0);
ReadSensorValues(out socPlaneValue, out vcorePlaneValue);
} while ((socPlaneValue & 0xFF00) != 0 && (vcorePlaneValue & 0xFF00) != 0 && --timeout > 0);

if (timeout > 0)
{
uint socVid = (soc_plane_value >> 16) & 0xFF;
Sensors[0].Value = Convert.ToSingle(Utils.VidToVoltage(socVid));
UpdateSensorValue(socPlaneValue, Sensors[0]);
UpdateSensorValue(vcorePlaneValue, Sensors[1]);

Console.WriteLine("Vsoc: " + Sensors[0].Min + " " + Sensors[0].Max);

uint coreVid = (vcore_plane_value >> 16) & 0xFF;
Sensors[1].Value = Convert.ToSingle(Utils.VidToVoltage(coreVid));

Console.WriteLine("Vcore: " + Sensors[1].Min + " " + Sensors[1].Max);
return true;
}
}

return false;
}

private void ReadSensorValues(out uint socPlaneValue, out uint vcorePlaneValue)
{
socPlaneValue = _cpu.ReadDword(_cpu.info.svi2.socAddress);
vcorePlaneValue = _cpu.ReadDword(_cpu.info.svi2.coreAddress);
}

private void UpdateSensorValue(uint planeValue, Sensor sensor)
{
uint vid = (planeValue >> 16) & 0xFF;
sensor.Value = Convert.ToSingle(Utils.VidToVoltage(vid));

Console.WriteLine($"{sensor.Name}: {sensor.Min} {sensor.Max}");
}

public void Open()
{
throw new NotImplementedException();
Expand Down
4 changes: 2 additions & 2 deletions WPF/Properties/BuildNumberTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

using System.Reflection;

[assembly: AssemblyVersion("1.30.1177")]
[assembly: AssemblyFileVersion("1.30.1177")]
[assembly: AssemblyVersion("1.30.1178")]
[assembly: AssemblyFileVersion("1.30.1178")]
3 changes: 2 additions & 1 deletion WPF/Windows/Changelog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Margin="15" Grid.ColumnSpan="2">
<!-- TextBlock Text="Changelog" FontSize="14" FontWeight="Bold" Style="{DynamicResource ValueStyles}" Height="auto" HorizontalAlignment="Left" /-->
<TextBlock Text="v1.30 Nov 22, 2023" FontSize="13" Style="{DynamicResource ValueStyles}" Height="auto" HorizontalAlignment="Left" />
<TextBlock Text="v1.30 Nov 23, 2023" FontSize="13" Style="{DynamicResource ValueStyles}" Height="auto" HorizontalAlignment="Left" />
<TextBlock Text="" />
<TextBlock Text=" - Enhanced compatibility with StormPeak and Genoa, offering partial support." />
<TextBlock Text=" - Introduced initial support for Mendocino and Phoenix." />
<TextBlock Text=" - Optimized the refresh process for power management tables, enhancing efficiency." />
<TextBlock Text=" - Improved support for Dali cores." />
<TextBlock Text=" - Addressed and fixed issues with the PM table of Picasso." />
<TextBlock Text=" - Fix saved window position out of bounds." />
<TextBlock Text=" - Simplified the versioning scheme for better clarity." />
<TextBlock Text="" />
<StackPanel Orientation="Horizontal">
Expand Down
4 changes: 2 additions & 2 deletions WPF/Windows/OptionsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class OptionsDialog
internal readonly AppSettings appSettings = (Application.Current as App)?.settings;
private readonly DispatcherTimer timerInstance;
private DispatcherTimer notificationTimer;
private THEME _Theme;
private Theme _Theme;
private readonly bool _AdvancedMode;

public OptionsDialog(DispatcherTimer timer)
Expand Down Expand Up @@ -136,7 +136,7 @@ private void OptionsWindow_Closing(object sender, System.ComponentModel.CancelEv

private void ComboBoxTheme_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
appSettings.AppTheme = (THEME)comboBoxTheme.SelectedIndex;
appSettings.AppTheme = (Theme)comboBoxTheme.SelectedIndex;
appSettings.ChangeTheme();
}
}
Expand Down
2 changes: 1 addition & 1 deletion WPF/Windows/SplashWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void Start()
{
splash.Show();

if (appSettings.AppTheme != AppSettings.THEME.LIGHT)
if (appSettings.AppTheme != AppSettings.Theme.Light)
appSettings.ChangeTheme();

if (appSettings.CheckForUpdates) updater.CheckForUpdate();
Expand Down

0 comments on commit b4448c8

Please sign in to comment.