Compare commits
No commits in common. "main" and "1.0.0" have entirely different histories.
@ -19,15 +19,15 @@ function Replace-Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Update SoraV2BatteryHelperSetup.vdproj
|
# Update SoraV2BatteryHelperSetup.vdproj
|
||||||
$vdprojFile = "SoraV2Utils_Setup\SoraV2Utils_Setup.vdproj"
|
$vdprojFile = "SoraV2BatteryHelperSetup\SoraV2BatteryHelperSetup.vdproj"
|
||||||
$vdprojPattern = '(\s*)"ProductVersion" = "8:\d+\.\d+\.\d+"'
|
$vdprojPattern = '(\s*)"ProductVersion" = "8:\d+\.\d+\.\d+"'
|
||||||
$vdprojReplacement = '$1"ProductVersion" = "8:' + $version + '"'
|
$vdprojReplacement = '$1"ProductVersion" = "8:' + $version + '"'
|
||||||
Replace-Version -filePath $vdprojFile -regexPattern $vdprojPattern -replacement $vdprojReplacement
|
Replace-Version -filePath $vdprojFile -regexPattern $vdprojPattern -replacement $vdprojReplacement
|
||||||
|
|
||||||
# Update AssemblyInfo.cs files
|
# Update AssemblyInfo.cs files
|
||||||
$assemblyFiles = @(
|
$assemblyFiles = @(
|
||||||
"SoraV2Utils_Service\Properties\AssemblyInfo.cs",
|
"SoraV2BatteryHelperSvc\Properties\AssemblyInfo.cs",
|
||||||
"SoraV2Utils_Agent\Properties\AssemblyInfo.cs"
|
"SoraV2BatteryHelperNotification\Properties\AssemblyInfo.cs"
|
||||||
)
|
)
|
||||||
|
|
||||||
$assemblyVersionPattern = '(\s*)\[assembly: AssemblyVersion\("(\d+\.\d+\.\d+\.\d+)"\)\]'
|
$assemblyVersionPattern = '(\s*)\[assembly: AssemblyVersion\("(\d+\.\d+\.\d+\.\d+)"\)\]'
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing.Text;
|
|
||||||
|
|
||||||
namespace SoraV2Utils_Agent
|
|
||||||
{
|
|
||||||
internal class DynamicIcon
|
|
||||||
{
|
|
||||||
public static Icon CreateIcon(string text, Color textColor, Font font)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(text) || text.Length > 3)
|
|
||||||
throw new ArgumentException("Text must be between 1 and 3 characters long.", nameof(text));
|
|
||||||
|
|
||||||
// Create a 32x32 transparent bitmap
|
|
||||||
using (Bitmap bitmap = new Bitmap(32, 32))
|
|
||||||
{
|
|
||||||
using (Graphics g = Graphics.FromImage(bitmap))
|
|
||||||
{
|
|
||||||
// Set up transparency
|
|
||||||
g.Clear(Color.Transparent);
|
|
||||||
|
|
||||||
// Enable anti-aliasing for smoother text
|
|
||||||
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
|
||||||
|
|
||||||
// Determine the largest font size that will fit within 32x32
|
|
||||||
float maxFontSize = 48; // Start with a large font size
|
|
||||||
SizeF textSize;
|
|
||||||
Font adjustedFont;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
maxFontSize--;
|
|
||||||
adjustedFont = new Font(font.FontFamily, maxFontSize, font.Style);
|
|
||||||
textSize = g.MeasureString(text, adjustedFont);
|
|
||||||
}
|
|
||||||
while ((textSize.Width > 42 || textSize.Height > 42) && maxFontSize > 1);
|
|
||||||
|
|
||||||
if (textSize.Width > 42 || textSize.Height > 42)
|
|
||||||
{
|
|
||||||
// Reduce back if the scaled size exceeds 32x32
|
|
||||||
maxFontSize /= 1.25f;
|
|
||||||
adjustedFont = new Font(font.FontFamily, maxFontSize, font.Style);
|
|
||||||
textSize = g.MeasureString(text, adjustedFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the position to center the text
|
|
||||||
float x = (32 - textSize.Width) / 2;
|
|
||||||
float y = (32 - textSize.Height) / 2;
|
|
||||||
|
|
||||||
// Draw the text
|
|
||||||
using (SolidBrush textBrush = new SolidBrush(textColor))
|
|
||||||
{
|
|
||||||
g.DrawString(text, adjustedFont, textBrush, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and return the icon
|
|
||||||
return Icon.FromHandle(bitmap.GetHicon());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,8 +19,6 @@ namespace SoraV2Utils_Agent
|
|||||||
server.RegisterService<IToastNotification>(new NotificationSender());
|
server.RegisterService<IToastNotification>(new NotificationSender());
|
||||||
server.Start();
|
server.Start();
|
||||||
|
|
||||||
UpdateCheck.CheckUpdate(); //Check for Updates based on Git Releases
|
|
||||||
|
|
||||||
var serviceMonitor = new ServiceMonitor("SoraV2Utils_Service");
|
var serviceMonitor = new ServiceMonitor("SoraV2Utils_Service");
|
||||||
serviceMonitor.ServiceStopped += (sender, e) =>
|
serviceMonitor.ServiceStopped += (sender, e) =>
|
||||||
{
|
{
|
||||||
@ -28,7 +26,7 @@ namespace SoraV2Utils_Agent
|
|||||||
System.Environment.Exit(1);
|
System.Environment.Exit(1);
|
||||||
};;
|
};;
|
||||||
|
|
||||||
var trayicon = new TrayIconForm();
|
var trayicon = new TrayIcon();
|
||||||
trayicon.Display();
|
trayicon.Display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,20 +75,13 @@ namespace SoraV2Utils_Agent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Exit()
|
public void Exit()
|
||||||
{
|
|
||||||
// Stop the Service
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var client = new Client("SoraV2UtilsDeviceData");
|
var client = new Client("SoraV2UtilsDeviceData");
|
||||||
var service = client.GetServiceProxy<IMouseData>();
|
var service = client.GetServiceProxy<IMouseData>();
|
||||||
service.Exit();
|
service.Exit();
|
||||||
}
|
|
||||||
catch (TimeoutException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exit the application
|
// Exit the application gracefully
|
||||||
System.Environment.Exit(1);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,6 @@
|
|||||||
<Reference Include="Windows.UI" />
|
<Reference Include="Windows.UI" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DynamicIcon.cs" />
|
|
||||||
<Compile Include="NotificationInstaller.cs">
|
<Compile Include="NotificationInstaller.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -86,8 +85,7 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ServiceMonitor.cs" />
|
<Compile Include="ServiceMonitor.cs" />
|
||||||
<Compile Include="TrayIconForm.cs" />
|
<Compile Include="TrayIcon.cs" />
|
||||||
<Compile Include="UpdateCheck.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
@ -96,9 +94,6 @@
|
|||||||
<PackageReference Include="EasyPipes">
|
<PackageReference Include="EasyPipes">
|
||||||
<Version>1.3.0</Version>
|
<Version>1.3.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Newtonsoft.Json">
|
|
||||||
<Version>13.0.3</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
|
||||||
|
@ -9,15 +9,15 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace SoraV2Utils_Agent
|
namespace SoraV2Utils_Agent
|
||||||
{
|
{
|
||||||
public class TrayIconForm
|
public class TrayIcon
|
||||||
{
|
{
|
||||||
public TrayIconForm()
|
public TrayIcon()
|
||||||
{
|
{
|
||||||
// Create a NotifyIcon instance
|
// Create a NotifyIcon instance
|
||||||
using (NotifyIcon trayIcon = new NotifyIcon())
|
using (NotifyIcon trayIcon = new NotifyIcon())
|
||||||
{
|
{
|
||||||
// Set up the tray icon properties
|
// Set up the tray icon properties
|
||||||
trayIcon.Icon = new Icon(DynamicIcon.CreateIcon("##",Color.Red, SystemFonts.IconTitleFont), 40, 40); // Choose your own icon
|
trayIcon.Icon = new Icon(SystemIcons.WinLogo, 40, 40); // Choose your own icon
|
||||||
trayIcon.Visible = true;
|
trayIcon.Visible = true;
|
||||||
|
|
||||||
// Create a context menu
|
// Create a context menu
|
||||||
@ -29,8 +29,9 @@ namespace SoraV2Utils_Agent
|
|||||||
batteryLevelItem.Enabled = false;
|
batteryLevelItem.Enabled = false;
|
||||||
batteryRuntimeItem.Enabled = false;
|
batteryRuntimeItem.Enabled = false;
|
||||||
|
|
||||||
|
|
||||||
|
// Add an exit menu item
|
||||||
contextMenu.MenuItems.Add("Exit", (sender, e) => ServiceIPC.Instance.Exit());
|
contextMenu.MenuItems.Add("Exit", (sender, e) => ServiceIPC.Instance.Exit());
|
||||||
contextMenu.MenuItems.Add("Check for Update ", (sender, e) => UpdateCheck.CheckUpdate());
|
|
||||||
|
|
||||||
contextMenu.MenuItems.Add(batteryLevelItem);
|
contextMenu.MenuItems.Add(batteryLevelItem);
|
||||||
contextMenu.MenuItems.Add(batteryRuntimeItem);
|
contextMenu.MenuItems.Add(batteryRuntimeItem);
|
||||||
@ -53,8 +54,6 @@ namespace SoraV2Utils_Agent
|
|||||||
// Update the context menu items
|
// Update the context menu items
|
||||||
batteryLevelItem.Text = batteryLevelText;
|
batteryLevelItem.Text = batteryLevelText;
|
||||||
batteryRuntimeItem.Text = $"Battery Runtime: {batteryRuntimeText}";
|
batteryRuntimeItem.Text = $"Battery Runtime: {batteryRuntimeText}";
|
||||||
batteryRuntimeItem.Text = $"Battery Runtime: {batteryRuntimeText}";
|
|
||||||
trayIcon.Icon = new Icon(DynamicIcon.CreateIcon(ServiceIPC.DeviceStatus.Battery.ToString(), Color.White, new Font("Arial",32)), 32, 32);
|
|
||||||
|
|
||||||
// Update every second
|
// Update every second
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
@ -1,62 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace SoraV2Utils_Agent
|
|
||||||
{
|
|
||||||
public class UpdateCheck
|
|
||||||
{
|
|
||||||
private static string GetLatestReleaseTag()
|
|
||||||
{
|
|
||||||
using (var client = new HttpClient())
|
|
||||||
{
|
|
||||||
var url = $"https://git.jan.sx/api/v1/repos/krjan02/SoraV2Utils/releases/latest";
|
|
||||||
var response = client.GetStringAsync(url).Result;
|
|
||||||
var json = JObject.Parse(response);
|
|
||||||
return json["tag_name"].ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetCurrentVersion()
|
|
||||||
{
|
|
||||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
|
||||||
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
|
|
||||||
return fvi.FileVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsVersionLower(string currentVersion, string releaseVersion)
|
|
||||||
{
|
|
||||||
Version current = Version.Parse(currentVersion);
|
|
||||||
Version release = Version.Parse(releaseVersion);
|
|
||||||
|
|
||||||
return current.CompareTo(release) < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CheckUpdate()
|
|
||||||
{
|
|
||||||
var CurrentVersion = GetCurrentVersion();
|
|
||||||
var LatestVersion = GetLatestReleaseTag();
|
|
||||||
|
|
||||||
if (IsVersionLower(CurrentVersion, LatestVersion))
|
|
||||||
{
|
|
||||||
DialogResult dialogResult = MessageBox.Show("" +
|
|
||||||
String.Format("Version {0} is available. You are running {1}" +
|
|
||||||
"\nDo you want to Update now?", LatestVersion, CurrentVersion),
|
|
||||||
"SoraV2 Utils Updater", MessageBoxButtons.YesNo);
|
|
||||||
if (dialogResult == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
System.Diagnostics.Process.Start("https://git.jan.sx/krjan02/SoraV2Utils/releases/latest");
|
|
||||||
ServiceIPC.Instance.Exit(); //Stop the Service and the Agent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -87,7 +87,7 @@ namespace SoraV2Utils_Service
|
|||||||
|
|
||||||
_data["SoraV2Utils"].AddKey("criticalThreshold", "10");
|
_data["SoraV2Utils"].AddKey("criticalThreshold", "10");
|
||||||
_data["SoraV2Utils"].GetKeyData("criticalThreshold").Comments.Add("Threshold for second (critial) warning");
|
_data["SoraV2Utils"].GetKeyData("criticalThreshold").Comments.Add("Threshold for second (critial) warning");
|
||||||
this.parser.WriteFile(AppDomain.CurrentDomain.BaseDirectory + "\\SoraV2Utils.ini", _data);
|
this.parser.WriteFile("SoraV2Utils.ini", _data);
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,11 @@ namespace SoraV2Tools
|
|||||||
{
|
{
|
||||||
private const ushort VID = 0x1915;
|
private const ushort VID = 0x1915;
|
||||||
private const ushort PID_WIRELESS = 0xAE1C;
|
private const ushort PID_WIRELESS = 0xAE1C;
|
||||||
private const ushort PID_WIRED = 0xAE12;
|
private const ushort PID_WIRED = 0xAE11;
|
||||||
|
|
||||||
public static List<HidDevice> GetDevice()
|
public static List<HidDevice> GetDevice()
|
||||||
{
|
{
|
||||||
List<HidDevice> devices = HidDevices.Enumerate(VID, PID_WIRELESS)
|
var devices = HidDevices.Enumerate(VID, PID_WIRELESS).ToList();
|
||||||
.Concat(HidDevices.Enumerate(VID, PID_WIRED))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
@ -74,12 +72,8 @@ namespace SoraV2Tools
|
|||||||
byte fullCharge = responseData[11];
|
byte fullCharge = responseData[11];
|
||||||
byte online = responseData[12];
|
byte online = responseData[12];
|
||||||
|
|
||||||
if ((device.Attributes.ProductId == PID_WIRELESS && online == 1) ||
|
|
||||||
(device.Attributes.ProductId == PID_WIRED && charging == 1))
|
|
||||||
{
|
|
||||||
return new DeviceStatus(battery, charging, fullCharge, online);
|
return new DeviceStatus(battery, charging, fullCharge, online);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new DeviceStatus();
|
return new DeviceStatus();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user