Fix Graphic selection on Windows10
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<ProjectGuid>{66FA29DB-925A-402B-A4C7-D3D780FB1BC3}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>CMS_Client</RootNamespace>
|
||||
<AssemblyName>CMS-Active Client</AssemblyName>
|
||||
<AssemblyName>CMS_Client</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
@@ -78,7 +78,7 @@
|
||||
<OutputPath>..\Step\bin\Client\x64\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
@@ -137,6 +137,7 @@
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
|
||||
+41
-2
@@ -5,12 +5,14 @@ using Chromium.WebBrowser.Event;
|
||||
using Client.Config;
|
||||
using Client.Utils;
|
||||
using CMS_Client.View;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -32,6 +34,9 @@ namespace CMS_Client
|
||||
{
|
||||
//Crate General Exception Handler
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(GeneralExMethod);
|
||||
|
||||
//Crate General Exception Handler
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(GeneralExMethod);
|
||||
|
||||
//Read App Configuration
|
||||
readConfiguration();
|
||||
@@ -58,7 +63,10 @@ namespace CMS_Client
|
||||
ShowAlarmAndClose("Only one istance of " + Application.ProductName + " can be executed!");
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
//Check Graphic Card in Energy Saving mode
|
||||
checkGraphicCard();
|
||||
|
||||
//Run the Loading Form
|
||||
Application.Run(new OpeningForm());
|
||||
@@ -89,7 +97,37 @@ namespace CMS_Client
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static private void checkGraphicCard()
|
||||
{
|
||||
|
||||
ManagementObjectSearcher VideoCardsQuery = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_VideoController");
|
||||
ManagementObjectCollection VideoCards = VideoCardsQuery.Get();
|
||||
//Check if i have more Cards
|
||||
if (VideoCards.Count > 1)
|
||||
{
|
||||
//Prepare List of Cards
|
||||
String Cardlist = "";
|
||||
foreach (ManagementObject card in VideoCards){
|
||||
Cardlist = Cardlist + " - " + card["Name"] + "\n";
|
||||
}
|
||||
|
||||
//If is Win 10 check the Registry Key
|
||||
if (Environment.OSVersion.Version.Major == 10)
|
||||
{
|
||||
string keyName = @"HKEY_CURRENT_USER\Software\Microsoft\DirectX\UserGpuPreferences";
|
||||
string valueName = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
Object value = Registry.GetValue(keyName, valueName, null);
|
||||
if (value == null || !value.Equals("GpuPreference=1;"))
|
||||
{
|
||||
//code if key Not Exist add it and restart
|
||||
Registry.SetValue(keyName, valueName, "GpuPreference=1;");
|
||||
MessageBox.Show("CMS Active has foundthis Graphic Cards:\n\n" + Cardlist +"\nThe graphic configuration has been setted. Press Ok to restart the Application",Application.ProductName);
|
||||
Application.Restart();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -203,5 +241,6 @@ namespace CMS_Client
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace CMS_Client.View
|
||||
//Instance Method
|
||||
public MainForm()
|
||||
{
|
||||
|
||||
LdFrm = new LoadingForm();
|
||||
LdFrm.Owner = this;
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -101,7 +101,7 @@
|
||||
this.CloseLabel.Margin = new System.Windows.Forms.Padding(3, 0, 2, 0);
|
||||
this.CloseLabel.Name = "CloseLabel";
|
||||
this.CloseLabel.Padding = new System.Windows.Forms.Padding(0, 0, 5, 0);
|
||||
this.CloseLabel.Size = new System.Drawing.Size(47, 57);
|
||||
this.CloseLabel.Size = new System.Drawing.Size(47, 31);
|
||||
this.CloseLabel.TabIndex = 3;
|
||||
this.CloseLabel.Text = "X";
|
||||
this.CloseLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MetroModernUI" version="1.4.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.2" targetFramework="net462" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MetroModernUI" version="1.4.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.2" targetFramework="net462" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
|
||||
</packages>
|
||||
@@ -221,8 +221,8 @@ namespace Step.Model
|
||||
}
|
||||
|
||||
// File paths
|
||||
public const string CLIENT_EXE_NAME = @"CMS-Active Client.exe";
|
||||
public const string CLIENT_EXE_NAME_NOEXT = @"CMS-Active Client";
|
||||
public const string CLIENT_EXE_NAME = @"CMS_Client.exe";
|
||||
public const string CLIENT_EXE_NAME_NOEXT = @"CMS_Client";
|
||||
public const string MAINTENANCE_ATTACHMENT_PATH = @"C:\CMS\STEP\attachment\maintenance\";
|
||||
|
||||
public const string ALARM_ATTACHMENT_PATH = @"C:\CMS\STEP\attachment\alarm\";
|
||||
|
||||
Reference in New Issue
Block a user