This repository has been archived by the owner on Jul 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hyrules
authored and
Hyrules
committed
Jun 27, 2016
1 parent
612cea2
commit b37fe6f
Showing
399 changed files
with
38,416 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CpuTempMon", "CpuTempMon\CpuTempMon.csproj", "{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Management; | ||
using OpenHardwareMonitor; | ||
using OpenHardwareMonitor.Hardware; | ||
using OpenHardwareMonitor.Collections; | ||
using System.Windows.Threading; | ||
using System.ComponentModel; | ||
|
||
namespace CpuTempMon | ||
{ | ||
public class CpuTemp | ||
{ | ||
|
||
|
||
public float? temperature | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public string pollSensorName; | ||
|
||
public List<ISensor> cpuSensors | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
private DispatcherTimer timer; | ||
private Computer comp; | ||
private BackgroundWorker bgwOpen; | ||
private bool _notWorking = false; | ||
public bool Working | ||
{ | ||
get{ return _notWorking;} | ||
private set{ _notWorking = value;} | ||
} | ||
|
||
public CpuTemp(int pollingInterval) | ||
{ | ||
|
||
comp = new Computer(); | ||
timer = new DispatcherTimer(); | ||
timer.Tick += timer_Tick; | ||
timer.Interval = new TimeSpan(0, 0, pollingInterval); | ||
comp.CPUEnabled = true; | ||
|
||
bgwOpen = new BackgroundWorker(); | ||
bgwOpen.DoWork += bgwOpen_DoWork; | ||
try | ||
{ | ||
comp.Open(); | ||
UpdateSensors(); | ||
comp.Close(); | ||
Working = true; | ||
} | ||
catch (Exception) | ||
{ | ||
Working = false; | ||
} | ||
|
||
pollSensorName = "CPU Package"; | ||
} | ||
|
||
void bgwOpen_DoWork(object sender, DoWorkEventArgs e) | ||
{ | ||
try | ||
{ | ||
comp.Open(); | ||
timer.Start(); | ||
Working = true; | ||
} | ||
catch(Exception) | ||
{ | ||
Working = false; | ||
} | ||
|
||
|
||
} | ||
|
||
public void Start() | ||
{ | ||
if (!timer.IsEnabled && Working) | ||
{ | ||
bgwOpen.RunWorkerAsync(); | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
if (timer.IsEnabled && Working) | ||
{ | ||
timer.Stop(); | ||
comp.Close(); | ||
} | ||
} | ||
|
||
void timer_Tick(object sender, EventArgs e) | ||
{ | ||
UpdateSensors(); | ||
int cpuPackage = cpuSensors.FindIndex(sensor => sensor.Name == pollSensorName); | ||
if (cpuPackage == -1) | ||
cpuPackage = 0; | ||
|
||
temperature = cpuSensors[cpuPackage].Value; | ||
OnTempUpdated?.Invoke(this, new CpuTempEventArgs() { currentTemp= temperature}); | ||
} | ||
|
||
public event CpuTempEvent OnTempUpdated; | ||
public delegate void CpuTempEvent(object sender, CpuTempEventArgs e); | ||
public event CpuSensorEvent OnSensorUpdated; | ||
public delegate void CpuSensorEvent(object sender, EventArgs e); | ||
|
||
private void UpdateSensors() | ||
{ | ||
foreach (IHardware hardware in comp.Hardware) | ||
{ | ||
if (hardware.HardwareType != HardwareType.CPU) continue; | ||
|
||
hardware.Update(); | ||
|
||
cpuSensors = hardware.Sensors.ToList<ISensor>(); | ||
cpuSensors.RemoveAll(sens => sens.SensorType != SensorType.Temperature); | ||
} | ||
OnSensorUpdated?.Invoke(this, new EventArgs()); | ||
} | ||
} | ||
|
||
public class CpuTempEventArgs : EventArgs | ||
{ | ||
public float? currentTemp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{C7CA3BB7-F708-4E24-B667-B05B6BC8EE5E}</ProjectGuid> | ||
<OutputType>library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CpuTempMon</RootNamespace> | ||
<AssemblyName>CpuTempMon</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<WarningLevel>4</WarningLevel> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\WinHue3\bin\Debug\plugins\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<RegisterForComInterop>false</RegisterForComInterop> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="OpenHardwareMonitorLib"> | ||
<HintPath>..\..\packages\OpenHardwareMonitor\OpenHardwareMonitorLib.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.Composition" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Xaml"> | ||
<RequiredTargetFramework>4.0</RequiredTargetFramework> | ||
</Reference> | ||
<Reference Include="WindowsBase" /> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="Xceed.Wpf.Toolkit, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="CpuTemp.cs" /> | ||
<Compile Include="CpuTempMonitor.cs" /> | ||
<Compile Include="ReverseBoolConverter.cs" /> | ||
<Compile Include="SettingsForm.xaml.cs"> | ||
<DependentUpon>SettingsForm.xaml</DependentUpon> | ||
</Compile> | ||
<Page Include="SettingsForm.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs"> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<AppDesigner Include="Properties\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\HueLib_base\HueLibBase.csproj"> | ||
<Project>{88e71b52-56b4-49cd-965c-e44c3ed5d275}</Project> | ||
<Name>HueLibBase</Name> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\IWinHuePlugin\IWinHuePlugin\WinHuePluginModule.csproj"> | ||
<Project>{fe2bea8f-0b23-4b6b-96cf-df29ae67d31f}</Project> | ||
<Name>WinHuePluginModule</Name> | ||
<EmbedInteropTypes>True</EmbedInteropTypes> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Resources\cputemp.png" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.