mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added OSD notifications
This commit is contained in:
16
Fans.Designer.cs
generated
16
Fans.Designer.cs
generated
@@ -29,11 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
chartCPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||
buttonApply = new Button();
|
||||
buttonReset = new Button();
|
||||
@@ -46,14 +42,8 @@
|
||||
//
|
||||
chartArea1.Name = "ChartArea1";
|
||||
chartCPU.ChartAreas.Add(chartArea1);
|
||||
legend1.Name = "Legend1";
|
||||
chartCPU.Legends.Add(legend1);
|
||||
chartCPU.Location = new Point(16, 13);
|
||||
chartCPU.Name = "chartCPU";
|
||||
series1.ChartArea = "ChartArea1";
|
||||
series1.Legend = "Legend1";
|
||||
series1.Name = "Series1";
|
||||
chartCPU.Series.Add(series1);
|
||||
chartCPU.Size = new Size(900, 446);
|
||||
chartCPU.TabIndex = 0;
|
||||
chartCPU.Text = "chartCPU";
|
||||
@@ -80,14 +70,8 @@
|
||||
//
|
||||
chartArea2.Name = "ChartArea1";
|
||||
chartGPU.ChartAreas.Add(chartArea2);
|
||||
legend2.Name = "Legend1";
|
||||
chartGPU.Legends.Add(legend2);
|
||||
chartGPU.Location = new Point(16, 477);
|
||||
chartGPU.Name = "chartGPU";
|
||||
series2.ChartArea = "ChartArea1";
|
||||
series2.Legend = "Legend1";
|
||||
series2.Name = "Series1";
|
||||
chartGPU.Series.Add(series2);
|
||||
chartGPU.Size = new Size(900, 448);
|
||||
chartGPU.TabIndex = 3;
|
||||
chartGPU.Text = "chart1";
|
||||
|
||||
8
Fans.cs
8
Fans.cs
@@ -18,7 +18,7 @@ namespace GHelper
|
||||
|
||||
if (device == 1)
|
||||
title = "GPU Fan Profile";
|
||||
else
|
||||
else
|
||||
title = "CPU Fan Profile";
|
||||
|
||||
if (Program.settingsForm.perfName.Length > 0)
|
||||
@@ -34,7 +34,9 @@ namespace GHelper
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
chart.ChartAreas[0].AxisY.Minimum = 0;
|
||||
chart.ChartAreas[0].AxisY.Maximum = 100;
|
||||
chart.Legends[0].Enabled = false;
|
||||
|
||||
if (chart.Legends.Count > 0)
|
||||
chart.Legends[0].Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ namespace GHelper
|
||||
{
|
||||
|
||||
SetChart(chartCPU, 0);
|
||||
SetChart(chartGPU, 0);
|
||||
SetChart(chartGPU, 1);
|
||||
|
||||
LoadProfile(seriesCPU, 0);
|
||||
LoadProfile(seriesGPU, 1);
|
||||
|
||||
483
OSDBase.cs
Normal file
483
OSDBase.cs
Normal file
@@ -0,0 +1,483 @@
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OSD
|
||||
{
|
||||
|
||||
class OSDNativeForm : NativeWindow, IDisposable
|
||||
{
|
||||
|
||||
private bool _disposed = false;
|
||||
private byte _alpha = 250;
|
||||
private Size _size = new Size(350, 50);
|
||||
private Point _location = new Point(50, 50);
|
||||
|
||||
|
||||
protected virtual void PerformPaint(PaintEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal void Invalidate()
|
||||
{
|
||||
this.UpdateLayeredWindow();
|
||||
}
|
||||
private void UpdateLayeredWindow()
|
||||
{
|
||||
Bitmap bitmap1 = new Bitmap(this.Size.Width, this.Size.Height, PixelFormat.Format32bppArgb);
|
||||
using (Graphics graphics1 = Graphics.FromImage(bitmap1))
|
||||
{
|
||||
Rectangle rectangle1;
|
||||
SIZE size1;
|
||||
POINT point1;
|
||||
POINT point2;
|
||||
BLENDFUNCTION blendfunction1;
|
||||
rectangle1 = new Rectangle(0, 0, this.Size.Width, this.Size.Height);
|
||||
PerformPaint(new PaintEventArgs(graphics1, rectangle1));
|
||||
IntPtr ptr1 = User32.GetDC(IntPtr.Zero);
|
||||
IntPtr ptr2 = Gdi32.CreateCompatibleDC(ptr1);
|
||||
IntPtr ptr3 = bitmap1.GetHbitmap(Color.FromArgb(0));
|
||||
IntPtr ptr4 = Gdi32.SelectObject(ptr2, ptr3);
|
||||
size1.cx = this.Size.Width;
|
||||
size1.cy = this.Size.Height;
|
||||
point1.x = this.Location.X;
|
||||
point1.x = this.Location.X;
|
||||
point1.y = this.Location.Y;
|
||||
point2.x = 0;
|
||||
point2.y = 0;
|
||||
blendfunction1 = new BLENDFUNCTION();
|
||||
blendfunction1.BlendOp = 0;
|
||||
blendfunction1.BlendFlags = 0;
|
||||
blendfunction1.SourceConstantAlpha = this._alpha;
|
||||
blendfunction1.AlphaFormat = 1;
|
||||
User32.UpdateLayeredWindow(base.Handle, ptr1, ref point1, ref size1, ptr2, ref point2, 0, ref blendfunction1, 2); //2=ULW_ALPHA
|
||||
Gdi32.SelectObject(ptr2, ptr4);
|
||||
User32.ReleaseDC(IntPtr.Zero, ptr1);
|
||||
Gdi32.DeleteObject(ptr3);
|
||||
Gdi32.DeleteDC(ptr2);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Show()
|
||||
{
|
||||
if (base.Handle == IntPtr.Zero) //if handle don't equal to zero - window was created and just hided
|
||||
this.CreateWindowOnly();
|
||||
User32.ShowWindow(base.Handle, User32.SW_SHOWNOACTIVATE);
|
||||
}
|
||||
|
||||
|
||||
public virtual void Hide()
|
||||
{
|
||||
if (base.Handle == IntPtr.Zero)
|
||||
return;
|
||||
User32.ShowWindow(base.Handle, User32.SW_HIDE);
|
||||
this.DestroyHandle();
|
||||
}
|
||||
|
||||
|
||||
public virtual void Close()
|
||||
{
|
||||
this.Hide();
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void CreateWindowOnly()
|
||||
{
|
||||
|
||||
CreateParams params1 = new CreateParams();
|
||||
params1.Caption = "FloatingNativeWindow";
|
||||
int nX = this._location.X;
|
||||
int nY = this._location.Y;
|
||||
Screen screen1 = Screen.FromHandle(base.Handle);
|
||||
if ((nX + this._size.Width) > screen1.Bounds.Width)
|
||||
{
|
||||
nX = screen1.Bounds.Width - this._size.Width;
|
||||
}
|
||||
if ((nY + this._size.Height) > screen1.Bounds.Height)
|
||||
{
|
||||
nY = screen1.Bounds.Height - this._size.Height;
|
||||
}
|
||||
this._location = new Point(nX, nY);
|
||||
Size size1 = this._size;
|
||||
Point point1 = this._location;
|
||||
params1.X = nX;
|
||||
params1.Y = nY;
|
||||
params1.Height = size1.Height;
|
||||
params1.Width = size1.Width;
|
||||
params1.Parent = IntPtr.Zero;
|
||||
uint ui = User32.WS_POPUP;
|
||||
params1.Style = (int)ui;
|
||||
params1.ExStyle = User32.WS_EX_TOPMOST | User32.WS_EX_TOOLWINDOW | User32.WS_EX_LAYERED | User32.WS_EX_NOACTIVATE | User32.WS_EX_TRANSPARENT;
|
||||
this.CreateHandle(params1);
|
||||
this.UpdateLayeredWindow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual void SetBoundsCore(int x, int y, int width, int height)
|
||||
{
|
||||
if (((this.X != x) || (this.Y != y)) || ((this.Width != width) || (this.Height != height)))
|
||||
{
|
||||
if (base.Handle != IntPtr.Zero)
|
||||
{
|
||||
int num1 = 20;
|
||||
if ((this.X == x) && (this.Y == y))
|
||||
{
|
||||
num1 |= 2;
|
||||
}
|
||||
if ((this.Width == width) && (this.Height == height))
|
||||
{
|
||||
num1 |= 1;
|
||||
}
|
||||
User32.SetWindowPos(base.Handle, IntPtr.Zero, x, y, width, height, (uint)num1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Location = new Point(x, y);
|
||||
this.Size = new Size(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region # Properties #
|
||||
/// <summary>
|
||||
/// Get or set position of top-left corner of floating native window in screen coordinates
|
||||
/// </summary>
|
||||
public virtual Point Location
|
||||
{
|
||||
get { return this._location; }
|
||||
set
|
||||
{
|
||||
if (base.Handle != IntPtr.Zero)
|
||||
{
|
||||
this.SetBoundsCore(value.X, value.Y, this._size.Width, this._size.Height);
|
||||
RECT rect = new RECT();
|
||||
User32.GetWindowRect(base.Handle, ref rect);
|
||||
this._location = new Point(rect.left, rect.top);
|
||||
this.UpdateLayeredWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._location = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get or set size of client area of floating native window
|
||||
/// </summary>
|
||||
public virtual Size Size
|
||||
{
|
||||
get { return this._size; }
|
||||
set
|
||||
{
|
||||
if (base.Handle != IntPtr.Zero)
|
||||
{
|
||||
this.SetBoundsCore(this._location.X, this._location.Y, value.Width, value.Height);
|
||||
RECT rect = new RECT();
|
||||
User32.GetWindowRect(base.Handle, ref rect);
|
||||
this._size = new Size(rect.right - rect.left, rect.bottom - rect.top);
|
||||
this.UpdateLayeredWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._size = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the floating native window
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get { return this._size.Height; }
|
||||
set
|
||||
{
|
||||
this._size = new Size(this._size.Width, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the floating native window
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get { return this._size.Width; }
|
||||
set
|
||||
{
|
||||
this._size = new Size(value, this._size.Height);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get or set x-coordinate of top-left corner of floating native window in screen coordinates
|
||||
/// </summary>
|
||||
public int X
|
||||
{
|
||||
get { return this._location.X; }
|
||||
set
|
||||
{
|
||||
this.Location = new Point(value, this.Location.Y);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get or set y-coordinate of top-left corner of floating native window in screen coordinates
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return this._location.Y; }
|
||||
set
|
||||
{
|
||||
this.Location = new Point(this.Location.X, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get rectangle represented client area of floating native window in client coordinates(top-left corner always has coord. 0,0)
|
||||
/// </summary>
|
||||
public Rectangle Bound
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Rectangle(new Point(0, 0), this._size);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get or set full opacity(255) or full transparency(0) or any intermediate state for floating native window transparency
|
||||
/// </summary>
|
||||
public byte Alpha
|
||||
{
|
||||
get { return this._alpha; }
|
||||
set
|
||||
{
|
||||
if (this._alpha == value) return;
|
||||
this._alpha = value;
|
||||
this.UpdateLayeredWindow();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!this._disposed)
|
||||
{
|
||||
this.DestroyHandle();
|
||||
this._disposed = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region # Win32 #
|
||||
internal struct PAINTSTRUCT
|
||||
{
|
||||
public IntPtr hdc;
|
||||
public int fErase;
|
||||
public Rectangle rcPaint;
|
||||
public int fRestore;
|
||||
public int fIncUpdate;
|
||||
public int Reserved1;
|
||||
public int Reserved2;
|
||||
public int Reserved3;
|
||||
public int Reserved4;
|
||||
public int Reserved5;
|
||||
public int Reserved6;
|
||||
public int Reserved7;
|
||||
public int Reserved8;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct POINT
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SIZE
|
||||
{
|
||||
public int cx;
|
||||
public int cy;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct TRACKMOUSEEVENTS
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint dwFlags;
|
||||
public IntPtr hWnd;
|
||||
public uint dwHoverTime;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MSG
|
||||
{
|
||||
public IntPtr hwnd;
|
||||
public int message;
|
||||
public IntPtr wParam;
|
||||
public IntPtr lParam;
|
||||
public int time;
|
||||
public int pt_x;
|
||||
public int pt_y;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
internal struct BLENDFUNCTION
|
||||
{
|
||||
public byte BlendOp;
|
||||
public byte BlendFlags;
|
||||
public byte SourceConstantAlpha;
|
||||
public byte AlphaFormat;
|
||||
}
|
||||
internal class User32
|
||||
{
|
||||
public const uint WS_POPUP = 0x80000000;
|
||||
public const int WS_EX_TOPMOST = 0x8;
|
||||
public const int WS_EX_TOOLWINDOW = 0x80;
|
||||
public const int WS_EX_LAYERED = 0x80000;
|
||||
public const int WS_EX_TRANSPARENT = 0x20;
|
||||
public const int WS_EX_NOACTIVATE = 0x08000000;
|
||||
public const int SW_SHOWNOACTIVATE = 4;
|
||||
public const int SW_HIDE = 0;
|
||||
public const uint AW_HOR_POSITIVE = 0x1;
|
||||
public const uint AW_HOR_NEGATIVE = 0x2;
|
||||
public const uint AW_VER_POSITIVE = 0x4;
|
||||
public const uint AW_VER_NEGATIVE = 0x8;
|
||||
public const uint AW_CENTER = 0x10;
|
||||
public const uint AW_HIDE = 0x10000;
|
||||
public const uint AW_ACTIVATE = 0x20000;
|
||||
public const uint AW_SLIDE = 0x40000;
|
||||
public const uint AW_BLEND = 0x80000;
|
||||
// Methods
|
||||
private User32()
|
||||
{
|
||||
}
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool ClientToScreen(IntPtr hWnd, ref POINT pt);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DispatchMessage(ref MSG msg);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DrawFocusRect(IntPtr hWnd, ref RECT rect);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetDC(IntPtr hWnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetFocus();
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern ushort GetKeyState(int virtKey);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetParent(IntPtr hWnd);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern bool GetClientRect(IntPtr hWnd, [In, Out] ref RECT rect);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetWindow(IntPtr hWnd, int cmd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool HideCaret(IntPtr hWnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool InvalidateRect(IntPtr hWnd, ref RECT rect, bool erase);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr LoadCursor(IntPtr hInstance, uint cursor);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref RECT rect, int cPoints);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool ReleaseCapture();
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool ScreenToClient(IntPtr hWnd, ref POINT pt);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern uint SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr SetCursor(IntPtr hCursor);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr SetFocus(IntPtr hWnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int newLong);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int X, int Y, int Width, int Height, uint flags);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool ShowCaret(IntPtr hWnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool SetCapture(IntPtr hWnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int ShowWindow(IntPtr hWnd, short cmdShow);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int bRetValue, uint fWinINI);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool TrackMouseEvent(ref TRACKMOUSEEVENTS tme);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool TranslateMessage(ref MSG msg);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool UpdateWindow(IntPtr hwnd);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool WaitMessage();
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern bool AdjustWindowRectEx(ref RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
|
||||
}
|
||||
|
||||
internal class Gdi32
|
||||
{
|
||||
// Methods
|
||||
private Gdi32()
|
||||
{
|
||||
}
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int CombineRgn(IntPtr dest, IntPtr src1, IntPtr src2, int flags);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr CreateCompatibleDC(IntPtr hDC);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr CreateRectRgnIndirect(ref RECT rect);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool DeleteDC(IntPtr hDC);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr DeleteObject(IntPtr hObject);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int GetClipBox(IntPtr hDC, ref RECT rectBox);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool PatBlt(IntPtr hDC, int x, int y, int width, int height, uint flags);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int SelectClipRgn(IntPtr hDC, IntPtr hRgn);
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LOGBRUSH
|
||||
{
|
||||
public uint lbStyle;
|
||||
public uint lbColor;
|
||||
public uint lbHatch;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
72
Program.cs
72
Program.cs
@@ -1,8 +1,8 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
|
||||
@@ -84,81 +84,49 @@ public class AppConfig
|
||||
public class HardwareMonitor
|
||||
{
|
||||
|
||||
public static float? cpuTemp = -1;
|
||||
public static float? batteryDischarge = -1;
|
||||
|
||||
public float? cpuTemp = -1;
|
||||
public float? gpuTemp = -1;
|
||||
public float? batteryDischarge = -1;
|
||||
public float? batteryCharge = -1;
|
||||
|
||||
public static bool IsAdministrator()
|
||||
public static void ReadSensors()
|
||||
{
|
||||
return (new WindowsPrincipal(WindowsIdentity.GetCurrent()))
|
||||
.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
public HardwareMonitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ReadSensors()
|
||||
{
|
||||
|
||||
cpuTemp = -1;
|
||||
gpuTemp = -1;
|
||||
batteryDischarge = -1;
|
||||
|
||||
try
|
||||
{
|
||||
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
ct.Dispose();
|
||||
|
||||
if (cpuTemp < 0)
|
||||
{
|
||||
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
ct.Dispose();
|
||||
}
|
||||
|
||||
if (batteryDischarge < 0)
|
||||
{
|
||||
var ct = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true);
|
||||
batteryDischarge = ct.NextValue() / 1000;
|
||||
ct.Dispose();
|
||||
}
|
||||
|
||||
|
||||
} catch
|
||||
var cb = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true);
|
||||
batteryDischarge = ct.NextValue() / 1000;
|
||||
cb.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed reading sensors");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void StopReading()
|
||||
{
|
||||
//computer.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static NotifyIcon trayIcon = new NotifyIcon
|
||||
{
|
||||
Text = "G-Helper",
|
||||
Icon = Properties.Resources.standard,
|
||||
Visible = true
|
||||
};
|
||||
{
|
||||
Text = "G-Helper",
|
||||
Icon = Properties.Resources.standard,
|
||||
Visible = true
|
||||
};
|
||||
|
||||
public static ASUSWmi wmi = new ASUSWmi();
|
||||
public static AppConfig config = new AppConfig();
|
||||
|
||||
|
||||
public static SettingsForm settingsForm = new SettingsForm();
|
||||
public static HardwareMonitor hwmonitor = new HardwareMonitor();
|
||||
public static ToastForm toast = new ToastForm();
|
||||
|
||||
// The main entry point for the application
|
||||
public static void Main()
|
||||
@@ -186,7 +154,7 @@ namespace GHelper
|
||||
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
|
||||
IntPtr dummy = settingsForm.Handle;
|
||||
IntPtr ds = settingsForm.Handle;
|
||||
|
||||
Application.Run();
|
||||
|
||||
|
||||
10
Properties/Resources.Designer.cs
generated
10
Properties/Resources.Designer.cs
generated
@@ -80,6 +80,16 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_fan_head_96 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-fan-head-96", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
||||
@@ -133,6 +133,9 @@
|
||||
<data name="icons8-speed-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-speed-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-video-card-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@@ -142,7 +145,7 @@
|
||||
<data name="icons8-laptop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-speed-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icons8-fan-head-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-fan-head-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
BIN
Resources/icons8-fan-head-96.png
Normal file
BIN
Resources/icons8-fan-head-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
211
Settings.Designer.cs
generated
211
Settings.Designer.cs
generated
@@ -76,10 +76,10 @@
|
||||
// checkStartup
|
||||
//
|
||||
checkStartup.AutoSize = true;
|
||||
checkStartup.Location = new Point(20, 508);
|
||||
checkStartup.Margin = new Padding(2, 1, 2, 1);
|
||||
checkStartup.Location = new Point(40, 1016);
|
||||
checkStartup.Margin = new Padding(4, 2, 4, 2);
|
||||
checkStartup.Name = "checkStartup";
|
||||
checkStartup.Size = new Size(105, 19);
|
||||
checkStartup.Size = new Size(206, 36);
|
||||
checkStartup.TabIndex = 2;
|
||||
checkStartup.Text = "Run on Startup";
|
||||
checkStartup.UseVisualStyleBackColor = true;
|
||||
@@ -89,12 +89,12 @@
|
||||
//
|
||||
trackBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
trackBattery.LargeChange = 20;
|
||||
trackBattery.Location = new Point(10, 454);
|
||||
trackBattery.Margin = new Padding(2, 1, 2, 1);
|
||||
trackBattery.Location = new Point(20, 908);
|
||||
trackBattery.Margin = new Padding(4, 2, 4, 2);
|
||||
trackBattery.Maximum = 100;
|
||||
trackBattery.Minimum = 50;
|
||||
trackBattery.Name = "trackBattery";
|
||||
trackBattery.Size = new Size(338, 45);
|
||||
trackBattery.Size = new Size(676, 90);
|
||||
trackBattery.SmallChange = 10;
|
||||
trackBattery.TabIndex = 3;
|
||||
trackBattery.TickFrequency = 10;
|
||||
@@ -105,10 +105,10 @@
|
||||
//
|
||||
labelBatteryTitle.AutoSize = true;
|
||||
labelBatteryTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelBatteryTitle.Location = new Point(38, 435);
|
||||
labelBatteryTitle.Margin = new Padding(2, 0, 2, 0);
|
||||
labelBatteryTitle.Location = new Point(76, 870);
|
||||
labelBatteryTitle.Margin = new Padding(4, 0, 4, 0);
|
||||
labelBatteryTitle.Name = "labelBatteryTitle";
|
||||
labelBatteryTitle.Size = new Size(122, 15);
|
||||
labelBatteryTitle.Size = new Size(248, 32);
|
||||
labelBatteryTitle.TabIndex = 4;
|
||||
labelBatteryTitle.Text = "Battery Charge Limit";
|
||||
//
|
||||
@@ -116,20 +116,20 @@
|
||||
//
|
||||
pictureBattery.BackgroundImage = (Image)resources.GetObject("pictureBattery.BackgroundImage");
|
||||
pictureBattery.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureBattery.Location = new Point(16, 434);
|
||||
pictureBattery.Margin = new Padding(2, 1, 2, 1);
|
||||
pictureBattery.Location = new Point(32, 868);
|
||||
pictureBattery.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureBattery.Name = "pictureBattery";
|
||||
pictureBattery.Size = new Size(18, 19);
|
||||
pictureBattery.Size = new Size(36, 38);
|
||||
pictureBattery.TabIndex = 6;
|
||||
pictureBattery.TabStop = false;
|
||||
//
|
||||
// labelGPUFan
|
||||
//
|
||||
labelGPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelGPUFan.Location = new Point(205, 131);
|
||||
labelGPUFan.Margin = new Padding(2, 0, 2, 0);
|
||||
labelGPUFan.Location = new Point(410, 262);
|
||||
labelGPUFan.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGPUFan.Name = "labelGPUFan";
|
||||
labelGPUFan.Size = new Size(138, 16);
|
||||
labelGPUFan.Size = new Size(276, 32);
|
||||
labelGPUFan.TabIndex = 8;
|
||||
labelGPUFan.Text = "GPU Fan : 0%";
|
||||
labelGPUFan.TextAlign = ContentAlignment.TopRight;
|
||||
@@ -144,12 +144,12 @@
|
||||
tableGPU.Controls.Add(buttonUltimate, 2, 0);
|
||||
tableGPU.Controls.Add(buttonStandard, 1, 0);
|
||||
tableGPU.Controls.Add(buttonEco, 0, 0);
|
||||
tableGPU.Location = new Point(11, 152);
|
||||
tableGPU.Margin = new Padding(2, 1, 2, 1);
|
||||
tableGPU.Location = new Point(22, 304);
|
||||
tableGPU.Margin = new Padding(4, 2, 4, 2);
|
||||
tableGPU.Name = "tableGPU";
|
||||
tableGPU.RowCount = 1;
|
||||
tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tableGPU.Size = new Size(338, 54);
|
||||
tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tableGPU.Size = new Size(676, 108);
|
||||
tableGPU.TabIndex = 7;
|
||||
//
|
||||
// buttonUltimate
|
||||
@@ -158,10 +158,10 @@
|
||||
buttonUltimate.Dock = DockStyle.Fill;
|
||||
buttonUltimate.FlatAppearance.BorderSize = 0;
|
||||
buttonUltimate.FlatStyle = FlatStyle.Flat;
|
||||
buttonUltimate.Location = new Point(228, 6);
|
||||
buttonUltimate.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonUltimate.Location = new Point(458, 12);
|
||||
buttonUltimate.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonUltimate.Name = "buttonUltimate";
|
||||
buttonUltimate.Size = new Size(106, 42);
|
||||
buttonUltimate.Size = new Size(210, 84);
|
||||
buttonUltimate.TabIndex = 2;
|
||||
buttonUltimate.Text = "Ultimate";
|
||||
buttonUltimate.UseVisualStyleBackColor = false;
|
||||
@@ -172,10 +172,10 @@
|
||||
buttonStandard.Dock = DockStyle.Fill;
|
||||
buttonStandard.FlatAppearance.BorderSize = 0;
|
||||
buttonStandard.FlatStyle = FlatStyle.Flat;
|
||||
buttonStandard.Location = new Point(116, 6);
|
||||
buttonStandard.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonStandard.Location = new Point(233, 12);
|
||||
buttonStandard.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonStandard.Name = "buttonStandard";
|
||||
buttonStandard.Size = new Size(104, 42);
|
||||
buttonStandard.Size = new Size(209, 84);
|
||||
buttonStandard.TabIndex = 1;
|
||||
buttonStandard.Text = "Standard";
|
||||
buttonStandard.UseVisualStyleBackColor = false;
|
||||
@@ -187,10 +187,10 @@
|
||||
buttonEco.Dock = DockStyle.Fill;
|
||||
buttonEco.FlatAppearance.BorderSize = 0;
|
||||
buttonEco.FlatStyle = FlatStyle.Flat;
|
||||
buttonEco.Location = new Point(4, 6);
|
||||
buttonEco.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonEco.Location = new Point(8, 12);
|
||||
buttonEco.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonEco.Name = "buttonEco";
|
||||
buttonEco.Size = new Size(104, 42);
|
||||
buttonEco.Size = new Size(209, 84);
|
||||
buttonEco.TabIndex = 0;
|
||||
buttonEco.Text = "Eco";
|
||||
buttonEco.UseVisualStyleBackColor = false;
|
||||
@@ -199,10 +199,10 @@
|
||||
//
|
||||
labelGPU.AutoSize = true;
|
||||
labelGPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelGPU.Location = new Point(38, 132);
|
||||
labelGPU.Margin = new Padding(2, 0, 2, 0);
|
||||
labelGPU.Location = new Point(76, 264);
|
||||
labelGPU.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGPU.Name = "labelGPU";
|
||||
labelGPU.Size = new Size(67, 15);
|
||||
labelGPU.Size = new Size(136, 32);
|
||||
labelGPU.TabIndex = 9;
|
||||
labelGPU.Text = "GPU Mode";
|
||||
//
|
||||
@@ -210,20 +210,20 @@
|
||||
//
|
||||
pictureGPU.BackgroundImage = (Image)resources.GetObject("pictureGPU.BackgroundImage");
|
||||
pictureGPU.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureGPU.Location = new Point(16, 131);
|
||||
pictureGPU.Margin = new Padding(2, 1, 2, 1);
|
||||
pictureGPU.Location = new Point(32, 262);
|
||||
pictureGPU.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureGPU.Name = "pictureGPU";
|
||||
pictureGPU.Size = new Size(18, 19);
|
||||
pictureGPU.Size = new Size(36, 38);
|
||||
pictureGPU.TabIndex = 10;
|
||||
pictureGPU.TabStop = false;
|
||||
//
|
||||
// labelCPUFan
|
||||
//
|
||||
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelCPUFan.Location = new Point(205, 19);
|
||||
labelCPUFan.Margin = new Padding(2, 0, 2, 0);
|
||||
labelCPUFan.Location = new Point(410, 38);
|
||||
labelCPUFan.Margin = new Padding(4, 0, 4, 0);
|
||||
labelCPUFan.Name = "labelCPUFan";
|
||||
labelCPUFan.Size = new Size(138, 16);
|
||||
labelCPUFan.Size = new Size(276, 32);
|
||||
labelCPUFan.TabIndex = 12;
|
||||
labelCPUFan.Text = "CPU Fan : 0%";
|
||||
labelCPUFan.TextAlign = ContentAlignment.TopRight;
|
||||
@@ -238,12 +238,12 @@
|
||||
tablePerf.Controls.Add(buttonTurbo, 2, 0);
|
||||
tablePerf.Controls.Add(buttonBalanced, 1, 0);
|
||||
tablePerf.Controls.Add(buttonSilent, 0, 0);
|
||||
tablePerf.Location = new Point(11, 38);
|
||||
tablePerf.Margin = new Padding(2, 1, 2, 1);
|
||||
tablePerf.Location = new Point(22, 76);
|
||||
tablePerf.Margin = new Padding(4, 2, 4, 2);
|
||||
tablePerf.Name = "tablePerf";
|
||||
tablePerf.RowCount = 1;
|
||||
tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tablePerf.Size = new Size(338, 54);
|
||||
tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tablePerf.Size = new Size(676, 108);
|
||||
tablePerf.TabIndex = 11;
|
||||
//
|
||||
// buttonTurbo
|
||||
@@ -253,10 +253,10 @@
|
||||
buttonTurbo.FlatAppearance.BorderColor = Color.FromArgb(192, 0, 0);
|
||||
buttonTurbo.FlatAppearance.BorderSize = 0;
|
||||
buttonTurbo.FlatStyle = FlatStyle.Flat;
|
||||
buttonTurbo.Location = new Point(228, 6);
|
||||
buttonTurbo.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonTurbo.Location = new Point(458, 12);
|
||||
buttonTurbo.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonTurbo.Name = "buttonTurbo";
|
||||
buttonTurbo.Size = new Size(106, 42);
|
||||
buttonTurbo.Size = new Size(210, 84);
|
||||
buttonTurbo.TabIndex = 2;
|
||||
buttonTurbo.Text = "Turbo";
|
||||
buttonTurbo.UseVisualStyleBackColor = false;
|
||||
@@ -268,10 +268,10 @@
|
||||
buttonBalanced.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 192);
|
||||
buttonBalanced.FlatAppearance.BorderSize = 0;
|
||||
buttonBalanced.FlatStyle = FlatStyle.Flat;
|
||||
buttonBalanced.Location = new Point(116, 6);
|
||||
buttonBalanced.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonBalanced.Location = new Point(233, 12);
|
||||
buttonBalanced.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonBalanced.Name = "buttonBalanced";
|
||||
buttonBalanced.Size = new Size(104, 42);
|
||||
buttonBalanced.Size = new Size(209, 84);
|
||||
buttonBalanced.TabIndex = 1;
|
||||
buttonBalanced.Text = "Balanced";
|
||||
buttonBalanced.UseVisualStyleBackColor = false;
|
||||
@@ -284,10 +284,10 @@
|
||||
buttonSilent.FlatAppearance.BorderColor = Color.FromArgb(0, 192, 192);
|
||||
buttonSilent.FlatAppearance.BorderSize = 0;
|
||||
buttonSilent.FlatStyle = FlatStyle.Flat;
|
||||
buttonSilent.Location = new Point(4, 6);
|
||||
buttonSilent.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonSilent.Location = new Point(8, 12);
|
||||
buttonSilent.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonSilent.Name = "buttonSilent";
|
||||
buttonSilent.Size = new Size(104, 42);
|
||||
buttonSilent.Size = new Size(209, 84);
|
||||
buttonSilent.TabIndex = 0;
|
||||
buttonSilent.Text = "Silent";
|
||||
buttonSilent.UseVisualStyleBackColor = false;
|
||||
@@ -297,10 +297,10 @@
|
||||
picturePerf.BackgroundImage = (Image)resources.GetObject("picturePerf.BackgroundImage");
|
||||
picturePerf.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
picturePerf.InitialImage = null;
|
||||
picturePerf.Location = new Point(16, 18);
|
||||
picturePerf.Margin = new Padding(2, 1, 2, 1);
|
||||
picturePerf.Location = new Point(32, 36);
|
||||
picturePerf.Margin = new Padding(4, 2, 4, 2);
|
||||
picturePerf.Name = "picturePerf";
|
||||
picturePerf.Size = new Size(18, 19);
|
||||
picturePerf.Size = new Size(36, 38);
|
||||
picturePerf.TabIndex = 14;
|
||||
picturePerf.TabStop = false;
|
||||
//
|
||||
@@ -308,10 +308,10 @@
|
||||
//
|
||||
labelPerf.AutoSize = true;
|
||||
labelPerf.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelPerf.Location = new Point(38, 19);
|
||||
labelPerf.Margin = new Padding(2, 0, 2, 0);
|
||||
labelPerf.Location = new Point(76, 38);
|
||||
labelPerf.Margin = new Padding(4, 0, 4, 0);
|
||||
labelPerf.Name = "labelPerf";
|
||||
labelPerf.Size = new Size(115, 15);
|
||||
labelPerf.Size = new Size(234, 32);
|
||||
labelPerf.TabIndex = 13;
|
||||
labelPerf.Text = "Performance Mode";
|
||||
//
|
||||
@@ -319,10 +319,10 @@
|
||||
//
|
||||
checkGPU.AutoSize = true;
|
||||
checkGPU.ForeColor = SystemColors.GrayText;
|
||||
checkGPU.Location = new Point(16, 206);
|
||||
checkGPU.Margin = new Padding(2, 1, 2, 1);
|
||||
checkGPU.Location = new Point(32, 412);
|
||||
checkGPU.Margin = new Padding(4, 2, 4, 2);
|
||||
checkGPU.Name = "checkGPU";
|
||||
checkGPU.Size = new Size(273, 19);
|
||||
checkGPU.Size = new Size(550, 36);
|
||||
checkGPU.TabIndex = 15;
|
||||
checkGPU.Text = "Set Eco on battery and Standard when plugged";
|
||||
checkGPU.UseVisualStyleBackColor = true;
|
||||
@@ -332,10 +332,10 @@
|
||||
//
|
||||
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonQuit.BackColor = SystemColors.ButtonFace;
|
||||
buttonQuit.Location = new Point(288, 504);
|
||||
buttonQuit.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonQuit.Location = new Point(576, 1008);
|
||||
buttonQuit.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonQuit.Name = "buttonQuit";
|
||||
buttonQuit.Size = new Size(60, 24);
|
||||
buttonQuit.Size = new Size(120, 48);
|
||||
buttonQuit.TabIndex = 16;
|
||||
buttonQuit.Text = "Quit";
|
||||
buttonQuit.UseVisualStyleBackColor = false;
|
||||
@@ -344,10 +344,10 @@
|
||||
//
|
||||
pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage");
|
||||
pictureScreen.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureScreen.Location = new Point(16, 248);
|
||||
pictureScreen.Margin = new Padding(2, 1, 2, 1);
|
||||
pictureScreen.Location = new Point(32, 496);
|
||||
pictureScreen.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureScreen.Name = "pictureScreen";
|
||||
pictureScreen.Size = new Size(18, 19);
|
||||
pictureScreen.Size = new Size(36, 38);
|
||||
pictureScreen.TabIndex = 18;
|
||||
pictureScreen.TabStop = false;
|
||||
//
|
||||
@@ -355,10 +355,10 @@
|
||||
//
|
||||
labelSreen.AutoSize = true;
|
||||
labelSreen.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelSreen.Location = new Point(38, 248);
|
||||
labelSreen.Margin = new Padding(2, 0, 2, 0);
|
||||
labelSreen.Location = new Point(76, 496);
|
||||
labelSreen.Margin = new Padding(4, 0, 4, 0);
|
||||
labelSreen.Name = "labelSreen";
|
||||
labelSreen.Size = new Size(87, 15);
|
||||
labelSreen.Size = new Size(176, 32);
|
||||
labelSreen.TabIndex = 17;
|
||||
labelSreen.Text = "Laptop Screen";
|
||||
//
|
||||
@@ -371,12 +371,12 @@
|
||||
tableScreen.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.33333F));
|
||||
tableScreen.Controls.Add(button120Hz, 1, 0);
|
||||
tableScreen.Controls.Add(button60Hz, 0, 0);
|
||||
tableScreen.Location = new Point(11, 268);
|
||||
tableScreen.Margin = new Padding(2, 1, 2, 1);
|
||||
tableScreen.Location = new Point(22, 536);
|
||||
tableScreen.Margin = new Padding(4, 2, 4, 2);
|
||||
tableScreen.Name = "tableScreen";
|
||||
tableScreen.RowCount = 1;
|
||||
tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tableScreen.Size = new Size(338, 54);
|
||||
tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tableScreen.Size = new Size(676, 108);
|
||||
tableScreen.TabIndex = 19;
|
||||
//
|
||||
// button120Hz
|
||||
@@ -386,10 +386,10 @@
|
||||
button120Hz.FlatAppearance.BorderColor = SystemColors.ActiveBorder;
|
||||
button120Hz.FlatAppearance.BorderSize = 0;
|
||||
button120Hz.FlatStyle = FlatStyle.Flat;
|
||||
button120Hz.Location = new Point(116, 6);
|
||||
button120Hz.Margin = new Padding(4, 6, 4, 6);
|
||||
button120Hz.Location = new Point(233, 12);
|
||||
button120Hz.Margin = new Padding(8, 12, 8, 12);
|
||||
button120Hz.Name = "button120Hz";
|
||||
button120Hz.Size = new Size(104, 42);
|
||||
button120Hz.Size = new Size(209, 84);
|
||||
button120Hz.TabIndex = 1;
|
||||
button120Hz.Text = "120Hz + OD";
|
||||
button120Hz.UseVisualStyleBackColor = false;
|
||||
@@ -403,10 +403,10 @@
|
||||
button60Hz.FlatAppearance.BorderSize = 0;
|
||||
button60Hz.FlatStyle = FlatStyle.Flat;
|
||||
button60Hz.ForeColor = SystemColors.ControlText;
|
||||
button60Hz.Location = new Point(4, 6);
|
||||
button60Hz.Margin = new Padding(4, 6, 4, 6);
|
||||
button60Hz.Location = new Point(8, 12);
|
||||
button60Hz.Margin = new Padding(8, 12, 8, 12);
|
||||
button60Hz.Name = "button60Hz";
|
||||
button60Hz.Size = new Size(104, 42);
|
||||
button60Hz.Size = new Size(209, 84);
|
||||
button60Hz.TabIndex = 0;
|
||||
button60Hz.Text = "60Hz";
|
||||
button60Hz.UseVisualStyleBackColor = false;
|
||||
@@ -415,10 +415,10 @@
|
||||
//
|
||||
checkScreen.AutoSize = true;
|
||||
checkScreen.ForeColor = SystemColors.GrayText;
|
||||
checkScreen.Location = new Point(16, 322);
|
||||
checkScreen.Margin = new Padding(2, 1, 2, 1);
|
||||
checkScreen.Location = new Point(32, 644);
|
||||
checkScreen.Margin = new Padding(4, 2, 4, 2);
|
||||
checkScreen.Name = "checkScreen";
|
||||
checkScreen.Size = new Size(261, 19);
|
||||
checkScreen.Size = new Size(527, 36);
|
||||
checkScreen.TabIndex = 20;
|
||||
checkScreen.Text = "Set 60Hz on battery, and back when plugged";
|
||||
checkScreen.UseVisualStyleBackColor = true;
|
||||
@@ -427,10 +427,10 @@
|
||||
//
|
||||
checkBoost.AutoSize = true;
|
||||
checkBoost.ForeColor = SystemColors.GrayText;
|
||||
checkBoost.Location = new Point(16, 92);
|
||||
checkBoost.Margin = new Padding(2, 1, 2, 1);
|
||||
checkBoost.Location = new Point(32, 184);
|
||||
checkBoost.Margin = new Padding(4, 2, 4, 2);
|
||||
checkBoost.Name = "checkBoost";
|
||||
checkBoost.Size = new Size(161, 19);
|
||||
checkBoost.Size = new Size(320, 36);
|
||||
checkBoost.TabIndex = 21;
|
||||
checkBoost.Text = "CPU Turbo Boost enabled";
|
||||
checkBoost.UseVisualStyleBackColor = true;
|
||||
@@ -439,10 +439,10 @@
|
||||
//
|
||||
pictureBox1.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
||||
pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureBox1.Location = new Point(16, 362);
|
||||
pictureBox1.Margin = new Padding(2, 1, 2, 1);
|
||||
pictureBox1.Location = new Point(32, 724);
|
||||
pictureBox1.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(18, 18);
|
||||
pictureBox1.Size = new Size(36, 36);
|
||||
pictureBox1.TabIndex = 23;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
@@ -450,10 +450,10 @@
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
label1.Location = new Point(38, 362);
|
||||
label1.Margin = new Padding(2, 0, 2, 0);
|
||||
label1.Location = new Point(76, 724);
|
||||
label1.Margin = new Padding(4, 0, 4, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(101, 15);
|
||||
label1.Size = new Size(210, 32);
|
||||
label1.TabIndex = 22;
|
||||
label1.Text = "Laptop Keyboard";
|
||||
//
|
||||
@@ -462,12 +462,12 @@
|
||||
comboKeyboard.FlatStyle = FlatStyle.Flat;
|
||||
comboKeyboard.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboKeyboard.FormattingEnabled = true;
|
||||
comboKeyboard.ItemHeight = 17;
|
||||
comboKeyboard.ItemHeight = 37;
|
||||
comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Strobe", "Rainbow" });
|
||||
comboKeyboard.Location = new Point(18, 388);
|
||||
comboKeyboard.Location = new Point(36, 777);
|
||||
comboKeyboard.Margin = new Padding(0);
|
||||
comboKeyboard.Name = "comboKeyboard";
|
||||
comboKeyboard.Size = new Size(102, 25);
|
||||
comboKeyboard.Size = new Size(200, 45);
|
||||
comboKeyboard.TabIndex = 24;
|
||||
comboKeyboard.TabStop = false;
|
||||
//
|
||||
@@ -479,10 +479,10 @@
|
||||
buttonKeyboardColor.FlatAppearance.BorderSize = 2;
|
||||
buttonKeyboardColor.FlatStyle = FlatStyle.Flat;
|
||||
buttonKeyboardColor.ForeColor = SystemColors.ControlText;
|
||||
buttonKeyboardColor.Location = new Point(128, 388);
|
||||
buttonKeyboardColor.Location = new Point(256, 775);
|
||||
buttonKeyboardColor.Margin = new Padding(0);
|
||||
buttonKeyboardColor.Name = "buttonKeyboardColor";
|
||||
buttonKeyboardColor.Size = new Size(106, 29);
|
||||
buttonKeyboardColor.Size = new Size(212, 50);
|
||||
buttonKeyboardColor.TabIndex = 25;
|
||||
buttonKeyboardColor.Text = "Color";
|
||||
buttonKeyboardColor.UseVisualStyleBackColor = false;
|
||||
@@ -490,10 +490,10 @@
|
||||
// labelBattery
|
||||
//
|
||||
labelBattery.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelBattery.Location = new Point(205, 434);
|
||||
labelBattery.Margin = new Padding(2, 0, 2, 0);
|
||||
labelBattery.Location = new Point(410, 868);
|
||||
labelBattery.Margin = new Padding(4, 0, 4, 0);
|
||||
labelBattery.Name = "labelBattery";
|
||||
labelBattery.Size = new Size(138, 16);
|
||||
labelBattery.Size = new Size(276, 32);
|
||||
labelBattery.TabIndex = 27;
|
||||
labelBattery.Text = " ";
|
||||
labelBattery.TextAlign = ContentAlignment.TopRight;
|
||||
@@ -502,19 +502,20 @@
|
||||
//
|
||||
buttonFans.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonFans.BackColor = SystemColors.ButtonFace;
|
||||
buttonFans.Location = new Point(263, 93);
|
||||
buttonFans.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonFans.FlatAppearance.BorderSize = 0;
|
||||
buttonFans.Location = new Point(480, 186);
|
||||
buttonFans.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonFans.Name = "buttonFans";
|
||||
buttonFans.Size = new Size(82, 24);
|
||||
buttonFans.Size = new Size(210, 48);
|
||||
buttonFans.TabIndex = 28;
|
||||
buttonFans.Text = "Fan Profile";
|
||||
buttonFans.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(96F, 96F);
|
||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
ClientSize = new Size(365, 543);
|
||||
ClientSize = new Size(730, 1086);
|
||||
Controls.Add(buttonFans);
|
||||
Controls.Add(labelBattery);
|
||||
Controls.Add(buttonKeyboardColor);
|
||||
@@ -541,12 +542,12 @@
|
||||
Controls.Add(trackBattery);
|
||||
Controls.Add(checkStartup);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Margin = new Padding(2, 1, 2, 1);
|
||||
Margin = new Padding(4, 2, 4, 2);
|
||||
MaximizeBox = false;
|
||||
MdiChildrenMinimizedAnchorBottom = false;
|
||||
MinimizeBox = false;
|
||||
Name = "SettingsForm";
|
||||
Padding = new Padding(4, 6, 4, 6);
|
||||
Padding = new Padding(8, 12, 8, 12);
|
||||
ShowIcon = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "G-Helper";
|
||||
|
||||
34
Settings.cs
34
Settings.cs
@@ -338,34 +338,19 @@ namespace GHelper
|
||||
string gpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6) + "%";
|
||||
|
||||
string cpuTemp = "";
|
||||
string gpuTemp = "";
|
||||
string battery = "";
|
||||
|
||||
try
|
||||
{
|
||||
Program.hwmonitor.ReadSensors();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed reading sensors");
|
||||
}
|
||||
HardwareMonitor.ReadSensors();
|
||||
|
||||
if (Program.hwmonitor.cpuTemp > 0)
|
||||
cpuTemp = ": " + Math.Round((decimal)Program.hwmonitor.cpuTemp).ToString() + "°C - ";
|
||||
if (HardwareMonitor.cpuTemp > 0)
|
||||
cpuTemp = ": " + Math.Round((decimal)HardwareMonitor.cpuTemp).ToString() + "°C - ";
|
||||
|
||||
if (Program.hwmonitor.gpuTemp > 0)
|
||||
gpuTemp = ": " + Math.Round((decimal)Program.hwmonitor.gpuTemp).ToString() + "°C - ";
|
||||
|
||||
if (Program.hwmonitor.batteryDischarge > 0)
|
||||
battery = "Discharging: " + Math.Round((decimal)Program.hwmonitor.batteryDischarge, 1).ToString() + "W";
|
||||
|
||||
if (Program.hwmonitor.batteryCharge > 0)
|
||||
battery = "Charging: " + Math.Round((decimal)Program.hwmonitor.batteryCharge, 1).ToString() + "W";
|
||||
if (HardwareMonitor.batteryDischarge > 0)
|
||||
battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W";
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan;
|
||||
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
|
||||
Program.settingsForm.labelBattery.Text = battery;
|
||||
});
|
||||
}
|
||||
@@ -382,7 +367,7 @@ namespace GHelper
|
||||
{
|
||||
InitScreen();
|
||||
|
||||
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
|
||||
this.Left = Screen.FromControl(this).WorkingArea.Width - 10 - this.Width;
|
||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||
this.Activate();
|
||||
|
||||
@@ -393,7 +378,6 @@ namespace GHelper
|
||||
else
|
||||
{
|
||||
aTimer.Enabled = false;
|
||||
Program.hwmonitor.StopReading();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +419,11 @@ namespace GHelper
|
||||
if (fans != null && fans.Text != "")
|
||||
fans.LoadFans();
|
||||
|
||||
}
|
||||
if (notify) {
|
||||
Program.toast.RunToast(perfName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void CyclePerformanceMode()
|
||||
|
||||
85
ToastForm.Designer.cs
generated
85
ToastForm.Designer.cs
generated
@@ -1,85 +0,0 @@
|
||||
namespace GHelper
|
||||
{
|
||||
partial class ToastForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureIcon = new System.Windows.Forms.PictureBox();
|
||||
this.labelMode = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureIcon
|
||||
//
|
||||
this.pictureIcon.BackgroundImage = global::GHelper.Properties.Resources.icons8_speed_96;
|
||||
this.pictureIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.pictureIcon.Location = new System.Drawing.Point(21, 21);
|
||||
this.pictureIcon.Name = "pictureIcon";
|
||||
this.pictureIcon.Size = new System.Drawing.Size(82, 80);
|
||||
this.pictureIcon.TabIndex = 0;
|
||||
this.pictureIcon.TabStop = false;
|
||||
//
|
||||
// labelMode
|
||||
//
|
||||
this.labelMode.AutoSize = true;
|
||||
this.labelMode.Font = new System.Drawing.Font("Segoe UI", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelMode.Location = new System.Drawing.Point(127, 32);
|
||||
this.labelMode.Name = "labelMode";
|
||||
this.labelMode.Size = new System.Drawing.Size(195, 59);
|
||||
this.labelMode.TabIndex = 1;
|
||||
this.labelMode.Text = "Balanced";
|
||||
this.labelMode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// ToastForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.ClientSize = new System.Drawing.Size(356, 122);
|
||||
this.Controls.Add(this.labelMode);
|
||||
this.Controls.Add(this.pictureIcon);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MdiChildrenMinimizedAnchorBottom = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ToastForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "ToastForm";
|
||||
this.TopMost = true;
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureIcon;
|
||||
private Label labelMode;
|
||||
}
|
||||
}
|
||||
108
ToastForm.cs
108
ToastForm.cs
@@ -1,68 +1,94 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing.Drawing2D;
|
||||
using OSD;
|
||||
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
public partial class ToastForm : Form
|
||||
|
||||
static class Drawing
|
||||
{
|
||||
|
||||
private System.Windows.Forms.Timer timer = default!;
|
||||
|
||||
private const int SW_SHOWNOACTIVATE = 4;
|
||||
private const int HWND_TOPMOST = -1;
|
||||
private const uint SWP_NOACTIVATE = 0x0010;
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
||||
static extern bool SetWindowPos(
|
||||
int hWnd, // Window handle
|
||||
int hWndInsertAfter, // Placement-order handle
|
||||
int X, // Horizontal position
|
||||
int Y, // Vertical position
|
||||
int cx, // Width
|
||||
int cy, // Height
|
||||
uint uFlags); // Window positioning flags
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
|
||||
static void ShowInactiveTopmost(Form frm)
|
||||
public static GraphicsPath RoundedRect(Rectangle bounds, int radius)
|
||||
{
|
||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||
SWP_NOACTIVATE);
|
||||
int diameter = radius * 2;
|
||||
Size size = new Size(diameter, diameter);
|
||||
Rectangle arc = new Rectangle(bounds.Location, size);
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
if (radius == 0)
|
||||
{
|
||||
path.AddRectangle(bounds);
|
||||
return path;
|
||||
}
|
||||
|
||||
path.AddArc(arc, 180, 90);
|
||||
arc.X = bounds.Right - diameter;
|
||||
path.AddArc(arc, 270, 90);
|
||||
arc.Y = bounds.Bottom - diameter;
|
||||
path.AddArc(arc, 0, 90);
|
||||
arc.X = bounds.Left;
|
||||
path.AddArc(arc, 90, 90);
|
||||
path.CloseFigure();
|
||||
return path;
|
||||
}
|
||||
|
||||
public ToastForm()
|
||||
public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
InitializeComponent();
|
||||
using (GraphicsPath path = RoundedRect(bounds, cornerRadius))
|
||||
{
|
||||
graphics.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ToastForm : OSDNativeForm
|
||||
{
|
||||
|
||||
protected static string toastText = "Balanced";
|
||||
protected static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
|
||||
|
||||
protected override void PerformPaint(PaintEventArgs e)
|
||||
{
|
||||
Brush brush = new SolidBrush(Color.FromArgb(150,Color.Black));
|
||||
Drawing.FillRoundedRectangle(e.Graphics, brush, this.Bound, 10);
|
||||
|
||||
StringFormat format = new StringFormat();
|
||||
format.LineAlignment = StringAlignment.Center;
|
||||
format.Alignment = StringAlignment.Center;
|
||||
|
||||
e.Graphics.DrawString(toastText,
|
||||
new Font("Segoe UI", 16f, FontStyle.Bold),
|
||||
new SolidBrush(Color.White),
|
||||
new PointF(this.Bound.Width/2, this.Bound.Height / 2),
|
||||
format);
|
||||
}
|
||||
|
||||
public void RunToast(string text)
|
||||
{
|
||||
|
||||
Top = Screen.FromControl(this).WorkingArea.Height - this.Height - 100;
|
||||
Left = (Screen.FromControl(this).Bounds.Width - this.Width) / 2;
|
||||
toastText = text;
|
||||
Screen screen1 = Screen.FromHandle(base.Handle);
|
||||
|
||||
ShowInactiveTopmost(this);
|
||||
Width = 300;
|
||||
Height = 100;
|
||||
X = (screen1.Bounds.Width - this.Width)/2;
|
||||
Y = screen1.Bounds.Height - 300 - this.Height;
|
||||
|
||||
labelMode.Text = text;
|
||||
Show();
|
||||
|
||||
timer = new System.Windows.Forms.Timer();
|
||||
timer.Tick += new EventHandler(timer_Tick);
|
||||
timer.Stop();
|
||||
timer.Tick -= timer_Tick;
|
||||
|
||||
timer.Tick += timer_Tick;
|
||||
timer.Enabled = true;
|
||||
timer.Interval = 1000;
|
||||
timer.Interval = 2000;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void ToastForm_Show(object? sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void timer_Tick(object sender, EventArgs e)
|
||||
private void timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.Stop();
|
||||
Close();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user