Skip to content

Commit 1d60783

Browse files
committed
* Integration of Syncfusion controls
* Added ram percentage gauge control * Design changes for Syncfusion theme
1 parent a70a2ac commit 1d60783

13 files changed

+302
-62
lines changed

MemPlus/App.config

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
3+
<configSections>
4+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="MemPlus.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
38
<startup>
49
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
510
</startup>
11+
<userSettings>
12+
<MemPlus.Properties.Settings>
13+
<setting name="VisualStyle" serializeAs="String">
14+
<value>Metro</value>
15+
</setting>
16+
<setting name="MetroColor" serializeAs="String">
17+
<value>#FF07779C</value>
18+
</setting>
19+
<setting name="BorderThickness" serializeAs="String">
20+
<value>3</value>
21+
</setting>
22+
</MemPlus.Properties.Settings>
23+
</userSettings>
624
</configuration>

MemPlus/Classes/RamMonitor.cs

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using System.Timers;
4+
using System.Windows.Threading;
5+
using Microsoft.VisualBasic.Devices;
6+
using Syncfusion.UI.Xaml.Gauges;
7+
8+
namespace MemPlus.Classes
9+
{
10+
internal sealed class RamMonitor
11+
{
12+
private readonly ComputerInfo _info;
13+
private readonly SfCircularGauge _gauge;
14+
private readonly Dispatcher _dispatcher;
15+
16+
private readonly Timer _ramTimer;
17+
18+
internal RamMonitor(Dispatcher dispatcher, SfCircularGauge gauge)
19+
{
20+
_info = new ComputerInfo();
21+
_dispatcher = dispatcher;
22+
_gauge = gauge;
23+
24+
_ramTimer = new Timer();
25+
_ramTimer.Elapsed += OnTimedEvent;
26+
_ramTimer.Interval = 5000;
27+
}
28+
29+
internal void SetTimerInterval(double interval)
30+
{
31+
if (interval <= 0) throw new ArgumentException("Interval cannot be less than or equal to zero!");
32+
_ramTimer.Interval = interval;
33+
}
34+
35+
internal void Start()
36+
{
37+
if (_ramTimer.Enabled) return;
38+
39+
_ramTimer.Enabled = true;
40+
OnTimedEvent(null, null);
41+
}
42+
43+
internal void Stop()
44+
{
45+
_ramTimer.Enabled = false;
46+
}
47+
48+
private async void OnTimedEvent(object source, ElapsedEventArgs e)
49+
{
50+
double test = await GetRamUsage();
51+
_dispatcher.Invoke(() =>
52+
{
53+
_gauge.Scales[0].Pointers[0].Value = test;
54+
_gauge.GaugeHeader = "RAM usage (" + test.ToString("F2") + "%)";
55+
});
56+
}
57+
58+
private async Task<double> GetRamUsage()
59+
{
60+
double val = await Task.Run(() =>
61+
{
62+
double total = Convert.ToDouble(_info.TotalPhysicalMemory);
63+
double usage = total - Convert.ToDouble(_info.AvailablePhysicalMemory);
64+
65+
double perc = usage / total * 100;
66+
67+
return perc;
68+
});
69+
return val;
70+
}
71+
}
72+
}

MemPlus/Classes/StyleManager.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Windows;
3+
using System.Windows.Media;
4+
using Syncfusion.Windows.Shared;
5+
6+
namespace MemPlus.Classes
7+
{
8+
/// <summary>
9+
/// Static class to change the style of an object
10+
/// </summary>
11+
internal static class StyleManager
12+
{
13+
/// <summary>
14+
/// Change the visual style of an object
15+
/// </summary>
16+
/// <param name="o">The object that needs to have a style overhaul</param>
17+
internal static void ChangeStyle(DependencyObject o)
18+
{
19+
try
20+
{
21+
SkinStorage.SetVisualStyle(o, Properties.Settings.Default.VisualStyle);
22+
SkinStorage.SetMetroBrush(o, new SolidColorBrush(Properties.Settings.Default.MetroColor));
23+
((ChromelessWindow)o).BorderThickness = new Thickness(Properties.Settings.Default.BorderThickness);
24+
((ChromelessWindow)o).CornerRadius = new CornerRadius(0, 0, 0, 0);
25+
}
26+
catch (Exception ex)
27+
{
28+
SkinStorage.SetVisualStyle(o, "Metro");
29+
MessageBox.Show(ex.Message, "AniView", MessageBoxButton.OK, MessageBoxImage.Error);
30+
}
31+
}
32+
}
33+
}

MemPlus/MemPlus.csproj

+18-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,19 @@
3636
<PropertyGroup>
3737
<StartupObject>MemPlus.App</StartupObject>
3838
</PropertyGroup>
39+
<PropertyGroup>
40+
<ApplicationIcon>ram.ico</ApplicationIcon>
41+
</PropertyGroup>
3942
<ItemGroup>
43+
<Reference Include="Microsoft.VisualBasic" />
44+
<Reference Include="Syncfusion.SfGauge.WPF, Version=15.4460.0.20, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
45+
<SpecificVersion>False</SpecificVersion>
46+
</Reference>
47+
<Reference Include="Syncfusion.Shared.Wpf" />
48+
<Reference Include="Syncfusion.Tools.Wpf" />
4049
<Reference Include="System" />
4150
<Reference Include="System.Core" />
51+
<Reference Include="System.Drawing" />
4252
<Reference Include="System.Xaml">
4353
<RequiredTargetFramework>4.0</RequiredTargetFramework>
4454
</Reference>
@@ -60,6 +70,8 @@
6070
<SubType>Code</SubType>
6171
</Compile>
6272
<Compile Include="Classes\MemPlus.cs" />
73+
<Compile Include="Classes\RamMonitor.cs" />
74+
<Compile Include="Classes\StyleManager.cs" />
6375
<Compile Include="Windows\MainWindow.xaml.cs">
6476
<DependentUpon>MainWindow.xaml</DependentUpon>
6577
<SubType>Code</SubType>
@@ -91,6 +103,11 @@
91103
<ItemGroup>
92104
<None Include="App.config" />
93105
</ItemGroup>
94-
<ItemGroup />
106+
<ItemGroup>
107+
<Resource Include="ram.ico" />
108+
</ItemGroup>
109+
<ItemGroup>
110+
<Resource Include="Resources\ram.png" />
111+
</ItemGroup>
95112
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
96113
</Project>

MemPlus/Properties/Resources.Designer.cs

+28-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MemPlus/Properties/Resources.resx

+12-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
4747
mimetype: application/x-microsoft.net.object.binary.base64
4848
value : The object must be serialized with
49-
: System.Serialization.Formatters.Binary.BinaryFormatter
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
5151
5252
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
6060
: and then encoded with base64 encoding.
6161
-->
6262
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6364
<xsd:element name="root" msdata:IsDataSet="true">
6465
<xsd:complexType>
6566
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
6869
<xsd:sequence>
6970
<xsd:element name="value" type="xsd:string" minOccurs="0" />
7071
</xsd:sequence>
71-
<xsd:attribute name="name" type="xsd:string" />
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
7273
<xsd:attribute name="type" type="xsd:string" />
7374
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
7476
</xsd:complexType>
7577
</xsd:element>
7678
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
8587
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
8688
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
8789
</xsd:sequence>
88-
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
8991
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
9092
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
9194
</xsd:complexType>
9295
</xsd:element>
9396
<xsd:element name="resheader">
@@ -109,9 +112,13 @@
109112
<value>2.0</value>
110113
</resheader>
111114
<resheader name="reader">
112-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113116
</resheader>
114117
<resheader name="writer">
115-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116119
</resheader>
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="ram" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\ram.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123+
</data>
117124
</root>

MemPlus/Properties/Settings.Designer.cs

+45-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)