From 7b2a58003fad3a3409d2a57c4bb4bf9744cf23e3 Mon Sep 17 00:00:00 2001 From: paulober <44974737+paulober@users.noreply.github.com> Date: Mon, 29 Jan 2024 02:06:41 +0100 Subject: [PATCH] Added GPU Selection Signed-off-by: paulober <44974737+paulober@users.noreply.github.com> --- .../Contracts/Services/ISampleDataService.cs | 11 - ArcticControl.Core/Models/SampleCompany.cs | 60 -- ArcticControl.Core/Models/SampleOrder.cs | 81 --- .../Models/SampleOrderDetail.cs | 52 -- .../Services/SampleDataService.cs | 521 ------------------ .../ArcticControl.GPUInterop.h | 6 +- ArcticControl/App.xaml.cs | 3 - .../Services/IIntelGraphicsControlService.cs | 3 + .../Models/GamesSettingsParameter.cs | 4 +- .../DummyIntelGraphicsControlService.cs | 3 + .../Services/IntelGraphicsControlService.cs | 51 ++ ArcticControl/Services/PageService.cs | 1 - .../ViewModels/GamesDetailViewModel.cs | 37 -- ArcticControl/ViewModels/GamesViewModel.cs | 8 +- .../ViewModels/PerformanceViewModel.cs | 30 +- ArcticControl/Views/GamesDetailPage.xaml | 107 ---- ArcticControl/Views/GamesDetailPage.xaml.cs | 43 -- ArcticControl/Views/PerformancePage.xaml | 25 +- .../Views/PerformanceValueTemplate.xaml.cs | 19 - 19 files changed, 116 insertions(+), 949 deletions(-) delete mode 100644 ArcticControl.Core/Contracts/Services/ISampleDataService.cs delete mode 100644 ArcticControl.Core/Models/SampleCompany.cs delete mode 100644 ArcticControl.Core/Models/SampleOrder.cs delete mode 100644 ArcticControl.Core/Models/SampleOrderDetail.cs delete mode 100644 ArcticControl.Core/Services/SampleDataService.cs delete mode 100644 ArcticControl/ViewModels/GamesDetailViewModel.cs delete mode 100644 ArcticControl/Views/GamesDetailPage.xaml delete mode 100644 ArcticControl/Views/GamesDetailPage.xaml.cs diff --git a/ArcticControl.Core/Contracts/Services/ISampleDataService.cs b/ArcticControl.Core/Contracts/Services/ISampleDataService.cs deleted file mode 100644 index 94511bd..0000000 --- a/ArcticControl.Core/Contracts/Services/ISampleDataService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using ArcticControl.Core.Models; - -namespace ArcticControl.Core.Contracts.Services; - -// Remove this class once your pages/features are using your data. -public interface ISampleDataService -{ - Task> GetContentGridDataAsync(); - - Task> GetListDetailsDataAsync(); -} diff --git a/ArcticControl.Core/Models/SampleCompany.cs b/ArcticControl.Core/Models/SampleCompany.cs deleted file mode 100644 index 741d0d1..0000000 --- a/ArcticControl.Core/Models/SampleCompany.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace ArcticControl.Core.Models; - -// Model for the SampleDataService. Replace with your own model. -public class SampleCompany -{ - public string? CompanyID - { - get; set; - } - - public string? CompanyName - { - get; set; - } - - public string? ContactName - { - get; set; - } - - public string? ContactTitle - { - get; set; - } - - public string? Address - { - get; set; - } - - public string? City - { - get; set; - } - - public string? PostalCode - { - get; set; - } - - public string? Country - { - get; set; - } - - public string? Phone - { - get; set; - } - - public string? Fax - { - get; set; - } - - public ICollection? Orders - { - get; set; - } -} diff --git a/ArcticControl.Core/Models/SampleOrder.cs b/ArcticControl.Core/Models/SampleOrder.cs deleted file mode 100644 index 912b160..0000000 --- a/ArcticControl.Core/Models/SampleOrder.cs +++ /dev/null @@ -1,81 +0,0 @@ -namespace ArcticControl.Core.Models; - -// Model for the SampleDataService. Replace with your own model. -public class SampleOrder -{ - public long OrderID - { - get; set; - } - - public DateTime OrderDate - { - get; set; - } - - public DateTime RequiredDate - { - get; set; - } - - public DateTime ShippedDate - { - get; set; - } - - public string? ShipperName - { - get; set; - } - - public string? ShipperPhone - { - get; set; - } - - public double Freight - { - get; set; - } - - public string? Company - { - get; set; - } - - public string? ShipTo - { - get; set; - } - - public double OrderTotal - { - get; set; - } - - public string? Status - { - get; set; - } - - public int SymbolCode - { - get; set; - } - - public string? SymbolName - { - get; set; - } - - public char Symbol => (char)SymbolCode; - - public ICollection? Details - { - get; set; - } - - public string ShortDescription => $"Order ID: {OrderID}"; - - public override string ToString() => $"{Company} {Status}"; -} diff --git a/ArcticControl.Core/Models/SampleOrderDetail.cs b/ArcticControl.Core/Models/SampleOrderDetail.cs deleted file mode 100644 index bd08b3e..0000000 --- a/ArcticControl.Core/Models/SampleOrderDetail.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace ArcticControl.Core.Models; - -// Model for the SampleDataService. Replace with your own model. -public class SampleOrderDetail -{ - public long ProductID - { - get; set; - } - - public string? ProductName - { - get; set; - } - - public int Quantity - { - get; set; - } - - public double Discount - { - get; set; - } - - public string? QuantityPerUnit - { - get; set; - } - - public double UnitPrice - { - get; set; - } - - public string? CategoryName - { - get; set; - } - - public string? CategoryDescription - { - get; set; - } - - public double Total - { - get; set; - } - - public string ShortDescription => $"Product ID: {ProductID} - {ProductName}"; -} diff --git a/ArcticControl.Core/Services/SampleDataService.cs b/ArcticControl.Core/Services/SampleDataService.cs deleted file mode 100644 index 49d9649..0000000 --- a/ArcticControl.Core/Services/SampleDataService.cs +++ /dev/null @@ -1,521 +0,0 @@ -using ArcticControl.Core.Contracts.Services; -using ArcticControl.Core.Models; - -namespace ArcticControl.Core.Services; - -// This class holds sample data used by some generated pages to show how they can be used. -// TODO: The following classes have been created to display sample data. Delete these files once your app is using real data. -// 1. Contracts/Services/ISampleDataService.cs -// 2. Services/SampleDataService.cs -// 3. Models/SampleCompany.cs -// 4. Models/SampleOrder.cs -// 5. Models/SampleOrderDetail.cs -public class SampleDataService : ISampleDataService -{ - private List _allOrders; - - public SampleDataService() - { - _allOrders = new List(); - } - - private static IEnumerable AllOrders() - { - // The following is order summary data - var companies = AllCompanies(); - return companies.SelectMany(c => c.Orders); - } - - private static IEnumerable AllCompanies() - { - return new List() - { - new SampleCompany() - { - CompanyID = "ALFKI", - CompanyName = "Company A", - ContactName = "Maria Anders", - ContactTitle = "Sales Representative", - Address = "Obere Str. 57", - City = "Berlin", - PostalCode = "12209", - Country = "Germany", - Phone = "030-0074321", - Fax = "030-0076545", - Orders = new List() - { - new SampleOrder() - { - OrderID = 10643, // Symbol Globe - OrderDate = new DateTime(1997, 8, 25), - RequiredDate = new DateTime(1997, 9, 22), - ShippedDate = new DateTime(1997, 9, 22), - ShipperName = "Speedy Express", - ShipperPhone = "(503) 555-9831", - Freight = 29.46, - Company = "Company A", - ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", - OrderTotal = 814.50, - Status = "Shipped", - SymbolCode = 57643, - SymbolName = "Globe", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 28, - ProductName = "Rössle Sauerkraut", - Quantity = 15, - Discount = 0.25, - QuantityPerUnit = "25 - 825 g cans", - UnitPrice = 45.60, - CategoryName = "Produce", - CategoryDescription = "Dried fruit and bean curd", - Total = 513.00 - }, - new SampleOrderDetail() - { - ProductID = 39, - ProductName = "Chartreuse verte", - Quantity = 21, - Discount = 0.25, - QuantityPerUnit = "750 cc per bottle", - UnitPrice = 18.0, - CategoryName = "Beverages", - CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", - Total = 283.50 - }, - new SampleOrderDetail() - { - ProductID = 46, - ProductName = "Spegesild", - Quantity = 2, - Discount = 0.25, - QuantityPerUnit = "4 - 450 g glasses", - UnitPrice = 12.0, - CategoryName = "Seafood", - CategoryDescription = "Seaweed and fish", - Total = 18.00 - } - } - }, - new SampleOrder() - { - OrderID = 10835, // Symbol Music - OrderDate = new DateTime(1998, 1, 15), - RequiredDate = new DateTime(1998, 2, 12), - ShippedDate = new DateTime(1998, 1, 21), - ShipperName = "Federal Shipping", - ShipperPhone = "(503) 555-9931", - Freight = 69.53, - Company = "Company A", - ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", - OrderTotal = 845.80, - Status = "Closed", - SymbolCode = 57737, - SymbolName = "Audio", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 59, - ProductName = "Raclette Courdavault", - Quantity = 15, - Discount = 0, - QuantityPerUnit = "5 kg pkg.", - UnitPrice = 55.00, - CategoryName = "Dairy Products", - CategoryDescription = "Cheeses", - Total = 825.00 - }, - new SampleOrderDetail() - { - ProductID = 77, - ProductName = "Original Frankfurter grüne Soße", - Quantity = 2, - Discount = 0.2, - QuantityPerUnit = "12 boxes", - UnitPrice = 13.0, - CategoryName = "Condiments", - CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", - Total = 20.80 - } - } - }, - new SampleOrder() - { - OrderID = 10952, // Symbol Calendar - OrderDate = new DateTime(1998, 3, 16), - RequiredDate = new DateTime(1998, 4, 27), - ShippedDate = new DateTime(1998, 3, 24), - ShipperName = "Speedy Express", - ShipperPhone = "(503) 555-9831", - Freight = 40.42, - Company = "Company A", - ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", - OrderTotal = 471.20, - Status = "Closed", - SymbolCode = 57699, - SymbolName = "Calendar", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 6, - ProductName = "Grandma's Boysenberry Spread", - Quantity = 16, - Discount = 0.05, - QuantityPerUnit = "12 - 8 oz jars", - UnitPrice = 25.0, - CategoryName = "Condiments", - CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", - Total = 380.00 - }, - new SampleOrderDetail() - { - ProductID = 28, - ProductName = "Rössle Sauerkraut", - Quantity = 2, - Discount = 0, - QuantityPerUnit = "25 - 825 g cans", - UnitPrice = 45.60, - CategoryName = "Produce", - CategoryDescription = "Dried fruit and bean curd", - Total = 91.20 - } - } - } - } - }, - new SampleCompany() - { - CompanyID = "ANATR", - CompanyName = "Company F", - ContactName = "Ana Trujillo", - ContactTitle = "Owner", - Address = "Avda. de la Constitución 2222", - City = "México D.F.", - PostalCode = "05021", - Country = "Mexico", - Phone = "(5) 555-4729", - Fax = "(5) 555-3745", - Orders = new List() - { - new SampleOrder() - { - OrderID = 10625, // Symbol Camera - OrderDate = new DateTime(1997, 8, 8), - RequiredDate = new DateTime(1997, 9, 5), - ShippedDate = new DateTime(1997, 8, 14), - ShipperName = "Speedy Express", - ShipperPhone = "(503) 555-9831", - Freight = 43.90, - Company = "Company F", - ShipTo = "Company F, Avda. de la Constitución 2222, 05021, México D.F., Mexico", - OrderTotal = 469.75, - Status = "Shipped", - SymbolCode = 57620, - SymbolName = "Camera", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 14, - ProductName = "Tofu", - Quantity = 3, - Discount = 0, - QuantityPerUnit = "40 - 100 g pkgs.", - UnitPrice = 23.25, - CategoryName = "Produce", - CategoryDescription = "Dried fruit and bean curd", - Total = 69.75 - }, - new SampleOrderDetail() - { - ProductID = 42, - ProductName = "Singaporean Hokkien Fried Mee", - Quantity = 5, - Discount = 0, - QuantityPerUnit = "32 - 1 kg pkgs.", - UnitPrice = 14.0, - CategoryName = "Grains/Cereals", - CategoryDescription = "Breads, crackers, pasta, and cereal", - Total = 70.00 - }, - new SampleOrderDetail() - { - ProductID = 60, - ProductName = "Camembert Pierrot", - Quantity = 10, - Discount = 0, - QuantityPerUnit = "15 - 300 g rounds", - UnitPrice = 34.00, - CategoryName = "Dairy Products", - CategoryDescription = "Cheeses", - Total = 340.00 - } - } - }, - new SampleOrder() - { - OrderID = 10926, // Symbol Clock - OrderDate = new DateTime(1998, 3, 4), - RequiredDate = new DateTime(1998, 4, 1), - ShippedDate = new DateTime(1998, 3, 11), - ShipperName = "Federal Shipping", - ShipperPhone = "(503) 555-9931", - Freight = 39.92, - Company = "Company F", - ShipTo = "Company F, Avda. de la Constitución 2222, 05021, México D.F., Mexico", - OrderTotal = 507.20, - Status = "Shipped", - SymbolCode = 57633, - SymbolName = "Clock", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 11, - ProductName = "Queso Cabrales", - Quantity = 2, - Discount = 0, - QuantityPerUnit = "1 kg pkg.", - UnitPrice = 21.0, - CategoryName = "Dairy Products", - CategoryDescription = "Cheeses", - Total = 42.00 - }, - new SampleOrderDetail() - { - ProductID = 13, - ProductName = "Konbu", - Quantity = 10, - Discount = 0, - QuantityPerUnit = "2 kg box", - UnitPrice = 6.0, - CategoryName = "Seafood", - CategoryDescription = "Seaweed and fish", - Total = 60.00 - }, - new SampleOrderDetail() - { - ProductID = 19, - ProductName = "Teatime Chocolate Biscuits", - Quantity = 7, - Discount = 0, - QuantityPerUnit = "10 boxes x 12 pieces", - UnitPrice = 9.20, - CategoryName = "Confections", - CategoryDescription = "Desserts, candies, and sweet breads", - Total = 64.40 - }, - new SampleOrderDetail() - { - ProductID = 72, - ProductName = "Mozzarella di Giovanni", - Quantity = 10, - Discount = 0, - QuantityPerUnit = "24 - 200 g pkgs.", - UnitPrice = 34.80, - CategoryName = "Dairy Products", - CategoryDescription = "Cheeses", - Total = 340.80 - } - } - } - } - }, - new SampleCompany() - { - CompanyID = "ANTON", - CompanyName = "Company Z", - ContactName = "Antonio Moreno", - ContactTitle = "Owner", - Address = "Mataderos 2312", - City = "México D.F.", - PostalCode = "05023", - Country = "Mexico", - Phone = "(5) 555-3932", - Fax = string.Empty, - Orders = new List() - { - new SampleOrder() - { - OrderID = 10507, // Symbol Contact - OrderDate = new DateTime(1997, 4, 15), - RequiredDate = new DateTime(1997, 5, 13), - ShippedDate = new DateTime(1997, 4, 22), - ShipperName = "Speedy Express", - ShipperPhone = "(503) 555-9831", - Freight = 47.45, - Company = "Company Z", - ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", - OrderTotal = 978.50, - Status = "Closed", - SymbolCode = 57661, - SymbolName = "Contact", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 43, - ProductName = "Ipoh Coffee", - Quantity = 15, - Discount = 0.15, - QuantityPerUnit = "16 - 500 g tins", - UnitPrice = 46.0, - CategoryName = "Beverages", - CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", - Total = 816.00 - }, - new SampleOrderDetail() - { - ProductID = 48, - ProductName = "Chocolade", - Quantity = 15, - Discount = 0.15, - QuantityPerUnit = "10 pkgs.", - UnitPrice = 12.75, - CategoryName = "Confections", - CategoryDescription = "Desserts, candies, and sweet breads", - Total = 162.50 - } - } - }, - new SampleOrder() - { - OrderID = 10573, // Symbol Star - OrderDate = new DateTime(1997, 6, 19), - RequiredDate = new DateTime(1997, 7, 17), - ShippedDate = new DateTime(1997, 6, 20), - ShipperName = "Federal Shipping", - ShipperPhone = "(503) 555-9931", - Freight = 84.84, - Company = "Company Z", - ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", - OrderTotal = 2082.00, - Status = "Closed", - SymbolCode = 57619, - SymbolName = "Favorite", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 17, - ProductName = "Alice Mutton", - Quantity = 18, - Discount = 0, - QuantityPerUnit = "20 - 1 kg tins", - UnitPrice = 39.00, - CategoryName = "Meat/Poultry", - CategoryDescription = "Prepared meats", - Total = 702.00 - }, - new SampleOrderDetail() - { - ProductID = 34, - ProductName = "Sasquatch Ale", - Quantity = 40, - Discount = 0, - QuantityPerUnit = "24 - 12 oz bottles", - UnitPrice = 14.0, - CategoryName = "Beverages", - CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", - Total = 560.00 - }, - new SampleOrderDetail() - { - ProductID = 53, - ProductName = "Perth Pasties", - Quantity = 25, - Discount = 0, - QuantityPerUnit = "48 pieces", - UnitPrice = 32.80, - CategoryName = "Meat/Poultry", - CategoryDescription = "Prepared meats", - Total = 820.00 - } - } - }, - new SampleOrder() - { - OrderID = 10682, // Symbol Home - OrderDate = new DateTime(1997, 9, 25), - RequiredDate = new DateTime(1997, 10, 23), - ShippedDate = new DateTime(1997, 10, 1), - ShipperName = "United Package", - ShipperPhone = "(503) 555-3199", - Freight = 36.13, - Company = "Company Z", - ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", - OrderTotal = 375.50, - Status = "Closed", - SymbolCode = 57615, - SymbolName = "Home", - Details = new List() - { - new SampleOrderDetail() - { - ProductID = 33, - ProductName = "Geitost", - Quantity = 30, - Discount = 0, - QuantityPerUnit = "500 g", - UnitPrice = 2.50, - CategoryName = "Dairy Products", - CategoryDescription = "Cheeses", - Total = 75.00 - }, - new SampleOrderDetail() - { - ProductID = 66, - ProductName = "Louisiana Hot Spiced Okra", - Quantity = 4, - Discount = 0, - QuantityPerUnit = "24 - 8 oz jars", - UnitPrice = 17.00, - CategoryName = "Condiments", - CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", - Total = 68.00 - }, - new SampleOrderDetail() - { - ProductID = 75, - ProductName = "Rhönbräu Klosterbier", - Quantity = 30, - Discount = 0, - QuantityPerUnit = "24 - 0.5 l bottles", - UnitPrice = 7.75, - CategoryName = "Beverages", - CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", - Total = 232.50 - } - } - } - } - } - }; - } - - public async Task> GetContentGridDataAsync() - { - if (_allOrders == null) - { - _allOrders = new List(AllOrders()); - } - - await Task.CompletedTask; - return _allOrders; - } - - public async Task> GetListDetailsDataAsync() - { - if (_allOrders == null) - { - _allOrders?.AddRange(AllOrders()); - } - - await Task.CompletedTask; - return _allOrders; - } -} diff --git a/ArcticControl.GPUInterop/ArcticControl.GPUInterop.h b/ArcticControl.GPUInterop/ArcticControl.GPUInterop.h index 58fe439..513087e 100644 --- a/ArcticControl.GPUInterop/ArcticControl.GPUInterop.h +++ b/ArcticControl.GPUInterop/ArcticControl.GPUInterop.h @@ -617,8 +617,6 @@ namespace ArcticControlGPUInterop { 0x5693, // <-- Arc A370M 0x5694, // <-- Arc A350M 0x56A6, // <-- Arc A310 - 0x56C1, // <-- Data Center GPU Flex 140 - 0x56C0 // <-- Data Center GPU Flex 170 }; device_names_ = gcnew List; @@ -634,6 +632,10 @@ namespace ArcticControlGPUInterop { { return device_names_; } + void ChangeSelectedDevice(int idx) + { + selected_device_ = idx; + } array^ GetTemperatures(); /// /// Very dangerous!! - Read description diff --git a/ArcticControl/App.xaml.cs b/ArcticControl/App.xaml.cs index 066708d..6f96241 100644 --- a/ArcticControl/App.xaml.cs +++ b/ArcticControl/App.xaml.cs @@ -119,7 +119,6 @@ public App() services.AddSingleton(); // Core Services - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); @@ -143,11 +142,9 @@ public App() services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/ArcticControl/Contracts/Services/IIntelGraphicsControlService.cs b/ArcticControl/Contracts/Services/IIntelGraphicsControlService.cs index bed7081..2fcd14f 100644 --- a/ArcticControl/Contracts/Services/IIntelGraphicsControlService.cs +++ b/ArcticControl/Contracts/Services/IIntelGraphicsControlService.cs @@ -5,6 +5,9 @@ public interface IIntelGraphicsControlService : IDisposable { public bool IsDummy(); public bool IsInitialized(); + + public List GetDevices(); + public bool ChangeSelectedDevice(int idx); public bool SetOverclockWaiver(); public double GetOverclockPowerLimit(); public double GetOverclockTemperatureLimit(); diff --git a/ArcticControl/Models/GamesSettingsParameter.cs b/ArcticControl/Models/GamesSettingsParameter.cs index b40d268..60c42a7 100644 --- a/ArcticControl/Models/GamesSettingsParameter.cs +++ b/ArcticControl/Models/GamesSettingsParameter.cs @@ -1,6 +1,4 @@ -using ArcticControl.Core.Models; - -namespace ArcticControl.Models; +namespace ArcticControl.Models; public struct GamesSettingsParameter { diff --git a/ArcticControl/Services/DummyIntelGraphicsControlService.cs b/ArcticControl/Services/DummyIntelGraphicsControlService.cs index c57a918..89b2bbe 100644 --- a/ArcticControl/Services/DummyIntelGraphicsControlService.cs +++ b/ArcticControl/Services/DummyIntelGraphicsControlService.cs @@ -42,4 +42,7 @@ public class DummyIntelGraphicsControlService : IIntelGraphicsControlService public bool SetOverclockTemperatureLimit(double newGpuTemperatureLimit) { return false; } public bool SetOverclockWaiver() { return false; } public bool SetSharpeningFilter(bool on, string? app = null) { return false; } + + public List GetDevices() => []; + public bool ChangeSelectedDevice(int idx) => false; } diff --git a/ArcticControl/Services/IntelGraphicsControlService.cs b/ArcticControl/Services/IntelGraphicsControlService.cs index e9837e8..1c76e07 100644 --- a/ArcticControl/Services/IntelGraphicsControlService.cs +++ b/ArcticControl/Services/IntelGraphicsControlService.cs @@ -15,6 +15,7 @@ using ManagedPeakPowerLimit = ArcticControl.Models.PeakPowerLimit; using ManagedPowerLimitsCombination = ArcticControl.Models.PowerLimitsCombination; using ManagedPowerProperties = ArcticControl.Models.PowerProperties; +using Windows.ApplicationModel.Activation; namespace ArcticControl.Services; public class IntelGraphicsControlService: IIntelGraphicsControlService @@ -31,6 +32,14 @@ public IntelGraphicsControlService() _gpuInterop = new GPUInterop(); _initialized = _gpuInterop.InitCtlApi(); + + if (_initialized) + { + // print devices + var adapterNames = _gpuInterop.GetDeviceAdapterNames(); + Debug.WriteLine("Adapters"); + Debug.WriteLine(string.Join("; ", adapterNames)); + } } catch (Exception) { @@ -43,6 +52,48 @@ public IntelGraphicsControlService() public bool IsInitialized() => _initialized; + public List GetDevices() + { + if (!_initialized || _gpuInterop == null) + { + return []; + } + + try + { + var devices = _gpuInterop.GetDeviceAdapterNames(); + return devices; + } + catch (Exception ex) + { + Debug.WriteLine("[IntelGraphicsControlService]: Error - GetDevices"); + Crashes.TrackError(ex); + } + + return []; + } + + public bool ChangeSelectedDevice(int idx) + { + if (!_initialized || _gpuInterop == null) + { + return false; + } + + try + { + _gpuInterop.ChangeSelectedDevice(idx); + return true; + } + catch (Exception ex) + { + Debug.WriteLine("[IntelGraphicsControlService]: Error - ChangeSelectedDevice"); + Crashes.TrackError(ex); + } + + return false; + } + public bool SetOverclockWaiver() { if (!_initialized || _gpuInterop == null) diff --git a/ArcticControl/Services/PageService.cs b/ArcticControl/Services/PageService.cs index 5680830..71d2e73 100644 --- a/ArcticControl/Services/PageService.cs +++ b/ArcticControl/Services/PageService.cs @@ -17,7 +17,6 @@ public PageService() Configure(); Configure(); Configure(); - Configure(); Configure(); Configure(); Configure(); diff --git a/ArcticControl/ViewModels/GamesDetailViewModel.cs b/ArcticControl/ViewModels/GamesDetailViewModel.cs deleted file mode 100644 index 55760d1..0000000 --- a/ArcticControl/ViewModels/GamesDetailViewModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using ArcticControl.Contracts.ViewModels; -using ArcticControl.Core.Contracts.Services; -using ArcticControl.Core.Models; - -using CommunityToolkit.Mvvm.ComponentModel; - -namespace ArcticControl.ViewModels; - -public class GamesDetailViewModel : ObservableRecipient, INavigationAware -{ - private readonly ISampleDataService _sampleDataService; - private SampleOrder? _item; - - public SampleOrder? Item - { - get => _item; - set => SetProperty(ref _item, value); - } - - public GamesDetailViewModel(ISampleDataService sampleDataService) - { - _sampleDataService = sampleDataService; - } - - public async void OnNavigatedTo(object parameter) - { - if (parameter is long orderID) - { - var data = await _sampleDataService.GetContentGridDataAsync(); - Item = data.First(i => i.OrderID == orderID); - } - } - - public void OnNavigatedFrom() - { - } -} diff --git a/ArcticControl/ViewModels/GamesViewModel.cs b/ArcticControl/ViewModels/GamesViewModel.cs index a3b373a..bb04808 100644 --- a/ArcticControl/ViewModels/GamesViewModel.cs +++ b/ArcticControl/ViewModels/GamesViewModel.cs @@ -3,7 +3,6 @@ using ArcticControl.Contracts.Services; using ArcticControl.Contracts.ViewModels; -using ArcticControl.Core.Contracts.Services; using ArcticControl.Helpers; using ArcticControl.Models; using CommunityToolkit.Mvvm.ComponentModel; @@ -17,7 +16,6 @@ namespace ArcticControl.ViewModels; public class GamesViewModel : ObservableRecipient, INavigationAware { private readonly INavigationService _navigationService; - private readonly ISampleDataService _sampleDataService; private readonly IGamesScannerService _gamesScannerService; public ICommand ItemClickCommand @@ -25,7 +23,7 @@ public ICommand ItemClickCommand get; } - public ObservableCollection Source { get; } = new ObservableCollection(); + public ObservableCollection Source { get; } = []; private bool _arcDriverInstalled = false; public bool ArcDriverInstalled @@ -35,12 +33,10 @@ public bool ArcDriverInstalled } public GamesViewModel( - INavigationService navigationService, - ISampleDataService sampleDataService, + INavigationService navigationService, IGamesScannerService gamesScannerService) { _navigationService = navigationService; - _sampleDataService = sampleDataService; _gamesScannerService = gamesScannerService; ItemClickCommand = new RelayCommand(OnItemClick); diff --git a/ArcticControl/ViewModels/PerformanceViewModel.cs b/ArcticControl/ViewModels/PerformanceViewModel.cs index 4b7f080..72e7d18 100644 --- a/ArcticControl/ViewModels/PerformanceViewModel.cs +++ b/ArcticControl/ViewModels/PerformanceViewModel.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System.Collections.ObjectModel; +using System.Diagnostics; using System.Globalization; using System.Management; using ArcticControl.Contracts.Services; @@ -9,6 +10,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; namespace ArcticControl.ViewModels; @@ -47,7 +49,7 @@ public class PerformanceViewModel : ObservableRecipient, INavigationAware public AdvancedObservableCollection PerformanceValues { get; init; - } = new(); + } = []; /// /// does not actually contain only slider values @@ -174,6 +176,23 @@ public bool IsTelemetryOverlayToggleBtnChecked set => SetProperty(ref _isTelemetryOverlayToggleBtnChecked, value); } + private ObservableCollection _availableGPUs; + + public ObservableCollection AvailableGPUs + { + get => _availableGPUs; + set => SetProperty(ref _availableGPUs, value); + } + + private int _selectedGPU = 0; + + public int SelectedGPU + { + get => _selectedGPU; + set => SetProperty(ref _selectedGPU, value); + } + + #region ValueDataObject properties to be able to update the values private PerformanceValueDataObject _cpuUtilizationObj = new() { Title = "CPU Utilization", Value = "0.0", Unit = "%" }; @@ -208,6 +227,7 @@ public PerformanceViewModel( _localSettingsService = localSettingsService; // _gpuInterop = new GPUInterop(); _igcs = intelGraphicsControlService; + _availableGPUs = new ObservableCollection(_igcs.GetDevices()); } public bool IsNoArcDriverInstalled() => _igcs.IsDummy(); @@ -570,6 +590,12 @@ public void SetOverclockWaiver() _igcs.SetOverclockWaiver(); } + public void AvailableGPUs_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var result = _igcs.ChangeSelectedDevice(SelectedGPU); + Debug.WriteLine("[PreformanceViewModel] ChangeSelectedDevice result: " + result.ToString()); + } + public Task TelemetryOverlayEnabledChanged() { // do telemetry overlay stuff here diff --git a/ArcticControl/Views/GamesDetailPage.xaml b/ArcticControl/Views/GamesDetailPage.xaml deleted file mode 100644 index d00b55a..0000000 --- a/ArcticControl/Views/GamesDetailPage.xaml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ArcticControl/Views/GamesDetailPage.xaml.cs b/ArcticControl/Views/GamesDetailPage.xaml.cs deleted file mode 100644 index 44fc2d6..0000000 --- a/ArcticControl/Views/GamesDetailPage.xaml.cs +++ /dev/null @@ -1,43 +0,0 @@ -using ArcticControl.Contracts.Services; -using ArcticControl.ViewModels; - -using CommunityToolkit.WinUI.UI.Animations; - -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Navigation; - -namespace ArcticControl.Views; - -public sealed partial class GamesDetailPage : Page -{ - public GamesDetailViewModel ViewModel - { - get; - } - - public GamesDetailPage() - { - ViewModel = App.GetService(); - InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - this.RegisterElementForConnectedAnimation("animationKeyContentGrid", itemHero); - } - - protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) - { - base.OnNavigatingFrom(e); - if (e.NavigationMode == NavigationMode.Back) - { - var navigationService = App.GetService(); - - if (ViewModel.Item != null) - { - navigationService.SetListDataItemForNextConnectedAnimation(ViewModel.Item); - } - } - } -} diff --git a/ArcticControl/Views/PerformancePage.xaml b/ArcticControl/Views/PerformancePage.xaml index ec54cb2..75b8c1b 100644 --- a/ArcticControl/Views/PerformancePage.xaml +++ b/ArcticControl/Views/PerformancePage.xaml @@ -157,7 +157,8 @@ BorderBrush="SlateGray" BorderThickness="0,1,0,0" Padding="0,25,0,25" - HorizontalAlignment="Stretch"> + HorizontalAlignment="Stretch" + RowSpacing="30"> @@ -166,6 +167,7 @@ + + + + + + + + + + diff --git a/ArcticControl/Views/PerformanceValueTemplate.xaml.cs b/ArcticControl/Views/PerformanceValueTemplate.xaml.cs index 76cda2d..93a32c2 100644 --- a/ArcticControl/Views/PerformanceValueTemplate.xaml.cs +++ b/ArcticControl/Views/PerformanceValueTemplate.xaml.cs @@ -1,26 +1,7 @@ -// Copyright (c) Microsoft Corporation and Contributors. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Navigation; -using ArcticControl.Core.Models; using ArcticControl.Models; -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - namespace ArcticControl.Views; public sealed partial class PerformanceValueTemplate : UserControl