-
Notifications
You must be signed in to change notification settings - Fork 39
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
Showing
9 changed files
with
6,646 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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management; | ||
using System.Runtime.ExceptionServices; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace FanCtrl | ||
{ | ||
class OSDController | ||
{ | ||
[DllImport("OSD.dll", CallingConvention = CallingConvention.Cdecl)] | ||
public static extern bool updateOSD(string osdString); | ||
|
||
[DllImport("OSD.dll", CallingConvention = CallingConvention.Cdecl)] | ||
public static extern void releaseOSD(); | ||
} | ||
} |
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,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FanCtrl | ||
{ | ||
public class OSDGroup | ||
{ | ||
public string Name { get; set; } | ||
|
||
public bool IsColor { get; set; } = false; | ||
|
||
public Color Color { get; set; } = Color.White; | ||
|
||
private List<OSDItem> mItemList = new List<OSDItem>(); | ||
public List<OSDItem> ItemList | ||
{ | ||
get { return mItemList; } | ||
} | ||
|
||
public OSDGroup() | ||
{ | ||
|
||
} | ||
|
||
public string getOSDString(int maxNameLength) | ||
{ | ||
var osdString = new StringBuilder(); | ||
|
||
// Color prefix | ||
if (IsColor == true) | ||
{ | ||
osdString.Append("<C="); | ||
|
||
var color = new byte[3]; | ||
color[0] = Color.R; | ||
color[1] = Color.G; | ||
color[2] = Color.B; | ||
osdString.Append(Util.getHexString(color)); | ||
|
||
osdString.Append(">"); | ||
} | ||
|
||
// Name | ||
string name = Name; | ||
for (int i = name.Length; i < maxNameLength; i++) | ||
{ | ||
name += " "; | ||
} | ||
|
||
osdString.Append(name); | ||
|
||
// Color postfix | ||
if (IsColor == true) | ||
{ | ||
osdString.Append("<C>"); | ||
} | ||
|
||
// item list | ||
for (int i = 0; i < mItemList.Count; i++) | ||
{ | ||
var item = mItemList[i]; | ||
osdString.Append(item.getOSDString()); | ||
} | ||
|
||
osdString.Append("\n"); | ||
return osdString.ToString(); | ||
} | ||
|
||
public OSDGroup clone() | ||
{ | ||
var group = new OSDGroup(); | ||
group.Name = this.Name; | ||
group.IsColor = this.IsColor; | ||
group.Color = Color.FromArgb(this.Color.R, this.Color.G, this.Color.B); | ||
|
||
for (int i = 0; i < mItemList.Count; i++) | ||
group.ItemList.Add(mItemList[i].clone()); | ||
|
||
return group; | ||
} | ||
} | ||
} |
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,164 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FanCtrl | ||
{ | ||
public enum OSDItemType : int | ||
{ | ||
Sensor = 0, | ||
Fan = 1, | ||
Control = 2, | ||
Predefined = 3, | ||
} | ||
|
||
public enum OSDUnitType : int | ||
{ | ||
Temperature = 0, | ||
RPM = 1, | ||
Percent = 2, | ||
//MHz = 3, | ||
//MB = 4, | ||
//FPS = 5, | ||
} | ||
|
||
public class OSDItem | ||
{ | ||
public OSDItemType ItemType { get; set; } | ||
|
||
public OSDUnitType UnitType { get; set; } | ||
|
||
public int Index { get; set; } = 0; | ||
|
||
public bool IsColor { get; set; } = false; | ||
|
||
public Color Color { get; set; } = Color.White; | ||
|
||
public string getOSDString() | ||
{ | ||
try | ||
{ | ||
var osdString = new StringBuilder(); | ||
|
||
// Color prefix | ||
if (IsColor == true) | ||
{ | ||
osdString.Append("<C="); | ||
|
||
var color = new byte[3]; | ||
color[0] = Color.R; | ||
color[1] = Color.G; | ||
color[2] = Color.B; | ||
osdString.Append(Util.getHexString(color)); | ||
|
||
osdString.Append(">"); | ||
} | ||
|
||
// Value prefix | ||
osdString.Append("<A0>"); | ||
|
||
// Value | ||
var hardwareManager = HardwareManager.getInstance(); | ||
if (ItemType == OSDItemType.Sensor) | ||
{ | ||
var sensor = hardwareManager.getSensor(Index); | ||
if (sensor == null) | ||
return ""; | ||
int value = sensor.Value; | ||
value = (OptionManager.getInstance().IsFahrenheit == true) ? Util.getFahrenheit(value) : value; | ||
osdString.Append(value.ToString()); | ||
} | ||
else if (ItemType == OSDItemType.Fan) | ||
{ | ||
var fan = hardwareManager.getFan(Index); | ||
if (fan == null) | ||
return ""; | ||
int value = fan.Value; | ||
osdString.Append(value.ToString()); | ||
} | ||
else if (ItemType == OSDItemType.Control) | ||
{ | ||
var control = hardwareManager.getControl(Index); | ||
if (control == null) | ||
return ""; | ||
int value = control.Value; | ||
osdString.Append(value.ToString()); | ||
} | ||
/* | ||
else if (ItemType == OSDItemType.Predefined) | ||
{ | ||
} | ||
*/ | ||
else | ||
{ | ||
return ""; | ||
} | ||
|
||
// Value postfix | ||
osdString.Append("<A>"); | ||
|
||
// Unit prefix | ||
osdString.Append("<A1><S0>"); | ||
|
||
// Unit | ||
osdString.Append(this.getUnitString()); | ||
|
||
// Unit postfix | ||
osdString.Append("<S><A>"); | ||
|
||
// Color postfix | ||
if (IsColor == true) | ||
{ | ||
osdString.Append("<C>"); | ||
} | ||
|
||
return osdString.ToString(); | ||
} | ||
catch { } | ||
return ""; | ||
} | ||
|
||
public OSDItem clone() | ||
{ | ||
var item = new OSDItem(); | ||
item.ItemType = this.ItemType; | ||
item.UnitType = this.UnitType; | ||
item.Index = this.Index; | ||
item.IsColor = this.IsColor; | ||
item.Color = Color.FromArgb(this.Color.R, this.Color.G, this.Color.B); | ||
return item; | ||
} | ||
|
||
public string getUnitString() | ||
{ | ||
switch (UnitType) | ||
{ | ||
case OSDUnitType.Temperature: | ||
return (OptionManager.getInstance().IsFahrenheit == false) ? " *C" : " *F"; | ||
|
||
case OSDUnitType.RPM: | ||
return " RPM"; | ||
|
||
case OSDUnitType.Percent: | ||
return " %"; | ||
|
||
/* | ||
case OSDUnitType.MHz: | ||
return " MHz"; | ||
case OSDUnitType.MB: | ||
return " MB"; | ||
case OSDUnitType.FPS: | ||
return " FPS"; | ||
*/ | ||
default: | ||
return " "; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.