- Client Configuration on XML File

- Refactoring Projects in the solution
This commit is contained in:
CMS3762\carminatini
2017-12-05 14:26:27 +01:00
parent e63dc12dff
commit 1e56f6e6d3
46 changed files with 587 additions and 276 deletions
+71
View File
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Client.Config</RootNamespace>
<AssemblyName>Client.Config</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigController.cs" />
<Compile Include="Config.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SubModels\Client.cs" />
<Compile Include="SubModels\Connection.cs" />
<Compile Include="SubModels\VendorHmi.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Client.Utils\Client.Utils.csproj">
<Project>{34434b22-d546-4a5c-b575-49720c77643a}</Project>
<Name>Client.Utils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="ClientValidator.xsd">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Config">
<xs:complexType>
<xs:all>
<xs:element name="Client">
<xs:complexType>
<xs:all>
<xs:element name="TranspColor" minOccurs='1' maxOccurs='1'/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="Connection">
<xs:complexType>
<xs:all>
<xs:element name="Id" minOccurs='1' maxOccurs='1'/>
<xs:element name="Url" minOccurs='1' maxOccurs='1'/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="VendorHmi">
<xs:complexType>
<xs:all>
<xs:element name="Enabled" minOccurs='1' maxOccurs='1'/>
<xs:element name="Type" minOccurs='1' maxOccurs='1'/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Config
{
public static class Config
{
public static SubModels.Client ClientConfig;
public static SubModels.Connection ConnectionConfig;
public static SubModels.VendorHmi VendorHmiConfig;
}
}
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Config>
<Client>
<TranspColor>#00FF00</TranspColor>
</Client>
<Connection>
<Url>http://localhost:9000/index.html</Url>
<Id>1</Id>
</Connection>
<VendorHmi>
<Enabled>true</Enabled>
<Type>1</Type>
</VendorHmi>
</Config>
+148
View File
@@ -0,0 +1,148 @@
using Client.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Xml.Schema;
namespace Client.Config
{
public class ConfigController
{
public static void ReadStartupConfig()
{
//Read Exe Folder
String XmlConfigPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
// Read validation file
XmlSchemaSet readerSettings = new XmlSchemaSet();
// Add Schema
readerSettings.Add(null, XmlConfigPath + "\\" + Constants.STARTUP_CONFIG_SCHEMA_PATH);
// Open file reader
XDocument xmlConfigFile = XDocument.Load(XmlConfigPath + "\\" + Constants.STARTUP_CONFIG_PATH);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
// Read XML Config
Config.ClientConfig = xmlConfigFile
.Descendants(Constants.CLIENT_CONFIG_KEY)
.Select(x => new SubModels.Client()
{
TranspColor = ValidateTranspColor(x.Element("TranspColor").Value)
}).FirstOrDefault();
Config.ConnectionConfig = xmlConfigFile
.Descendants(Constants.CONNECTION_CONFIG_KEY)
.Select(x => new SubModels.Connection()
{
Url = ValidateUrl(x.Element("Url").Value),
Id = ValidateClientID(x.Element("Id").Value)
}).FirstOrDefault();
Config.VendorHmiConfig = xmlConfigFile
.Descendants(Constants.VENDORHMI_CONFIG_KEY)
.Select(x => new SubModels.VendorHmi()
{
Enabled = ValidateOpenHmi(x.Element("Enabled").Value),
Type = ValidateNcType(x.Element("Type").Value)
}).FirstOrDefault();
// Read ARGS Config
if (!String.IsNullOrWhiteSpace(Arguments.Url))
Config.ConnectionConfig.Url = ValidateArgumentUrl(Arguments.Url);
}
private static void ValidationHandler(object sender, ValidationEventArgs e)
{
throw new Exception(@"Configuration Error: " + e.Message);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region PROPERTIES_VALIDATOR
private static String ValidateUrl(String value)
{
Uri NewUrl;
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile))
return value;
else
throw new Exception(@"Configuration Error: ""Connection - Url"" is not a valid URL");
}
private static String ValidateArgumentUrl(String value)
{
Uri NewUrl;
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile))
return value;
else
throw new Exception(@"Argument Url Error: is not a valid URL");
}
private static Color ValidateTranspColor(String value)
{
Color color;
try
{
color = ColorTranslator.FromHtml(value);
return color;
}
catch (Exception)
{
throw new Exception(@"Configuration Error: ""Client - TranspColor"" is not a valid Hex Color");
}
}
private static Boolean ValidateOpenHmi(String value)
{
Boolean OpenHmi;
if (Boolean.TryParse(value, out OpenHmi))
return OpenHmi;
else
throw new Exception(@"Configuration Error: ""VendorHmi - Enabled"" is not a valid Boolean Type");
}
private static ushort ValidateNcType(String value)
{
ushort Nc;
if (ushort.TryParse(value, out Nc) && Nc <= 3)
return Nc;
else
throw new Exception(@"Configuration Error: ""VendorHmi - Type"" is not a valid NC Type");
}
private static ushort ValidateClientID(String value)
{
ushort Client;
if (ushort.TryParse(value, out Client))
return Client;
else
throw new Exception(@"Configuration Error: ""Connection - Id"" is not a valid Id of CMS-Client");
}
#endregion
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("Client.Config")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Client.Config")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("205a6ade-fb5a-45cb-9c51-9817e7bb8939")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Config.SubModels
{
public class Client
{
public Color TranspColor { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Config.SubModels
{
public class Connection
{
public string Url { get; set; }
public ushort Id { get; set; }
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Config.SubModels
{
public class VendorHmi
{
public Boolean Enabled { get; set; }
public ushort Type { get; set; } /* 0: Demo - 1: Fanuc - 2: Siemens - 3: Osai */
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Utils
{
public static class Arguments
{
public static String Url { get; set; }
}
}
+49
View File
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{34434B22-D546-4A5C-B575-49720C77643A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Client.Utils</RootNamespace>
<AssemblyName>Client.Utils</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Arguments.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Utils
{
public static class Constants
{
public const string CONFIG_KEY = "Config";
public const string CLIENT_CONFIG_KEY = "Client";
public const string CONNECTION_CONFIG_KEY = "Connection";
public const string VENDORHMI_CONFIG_KEY = "VendorHmi";
// Filenames
public const string STARTUP_CONFIG_SCHEMA_PATH = "ClientValidator.xsd";
public const string STARTUP_CONFIG_PATH = "Config.xml";
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("Client.Utils")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Client.Utils")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("34434b22-d546-4a5c-b575-49720c77643a")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
@@ -1,5 +1,5 @@
using CefSharp;
using CMS_Client.Config;
using Client.Config;
using CMS_Client.View;
using System;
using System.Collections.Generic;
@@ -92,7 +92,7 @@ namespace CMS_Client.Browser_Tools
//Move NC Window
public void moveNcWindow(int X,int Y)
{
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
NcWindow.MoveNcWindow(X, Y);
}
@@ -115,7 +115,7 @@ namespace CMS_Client.Browser_Tools
//Get the ID of STEP Client
public ushort getClientID()
{
return CMSConfiguration.IDClient;
return Config.ConnectionConfig.Id;
}
public void forceStepFocus()
@@ -98,6 +98,9 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
@@ -126,7 +129,6 @@
<ItemGroup>
<Compile Include="Browser_Tools\BrowserJSObject.cs" />
<Compile Include="Browser_Tools\CefBrowserKeyHandler.cs" />
<Compile Include="Config\CMSConfiguration.cs" />
<Compile Include="Browser_Tools\CefBrowserMenuHandler.cs" />
<Compile Include="View\LoadingForm.cs">
<SubType>Form</SubType>
@@ -208,6 +210,16 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Client.Config\Client.Config.csproj">
<Project>{205a6ade-fb5a-45cb-9c51-9817e7bb8939}</Project>
<Name>Client.Config</Name>
</ProjectReference>
<ProjectReference Include="..\Client.Utils\Client.Utils.csproj">
<Project>{34434B22-D546-4A5C-B575-49720C77643A}</Project>
<Name>Client.Utils</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -224,4 +236,8 @@
<Import Project="..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets')" />
<Import Project="..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets')" />
<Import Project="..\packages\CefSharp.WinForms.57.0.0\build\CefSharp.WinForms.targets" Condition="Exists('..\packages\CefSharp.WinForms.57.0.0\build\CefSharp.WinForms.targets')" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
+2 -4
View File
@@ -1,5 +1,5 @@
using CefSharp;
using CMS_Client.Config;
using Client.Utils;
using CMS_Client.View;
using System;
using System.Collections.Generic;
@@ -25,9 +25,7 @@ namespace CMS_Client
//Check the first argument -> Url
if (args.Count() > 0)
{
Uri UrlResArg;
if(Uri.TryCreate(args[0], UriKind.Absolute, out UrlResArg) && (UrlResArg.Scheme == Uri.UriSchemeHttp || UrlResArg.Scheme == Uri.UriSchemeHttps))
CMSConfiguration.CustomUrl = args[0];
Arguments.Url = args[0];
}
//Check if is already running an instance of this application

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -45,7 +45,7 @@
this.StatusLBL.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.StatusLBL.ForeColor = System.Drawing.Color.White;
this.StatusLBL.HideSelection = false;
this.StatusLBL.Location = new System.Drawing.Point(12, 135);
this.StatusLBL.Location = new System.Drawing.Point(12, 133);
this.StatusLBL.Name = "StatusLBL";
this.StatusLBL.ReadOnly = true;
this.StatusLBL.ShortcutsEnabled = false;
@@ -63,11 +63,12 @@
this.ErrorLBL.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ErrorLBL.ForeColor = System.Drawing.Color.Maroon;
this.ErrorLBL.HideSelection = false;
this.ErrorLBL.Location = new System.Drawing.Point(12, 154);
this.ErrorLBL.Location = new System.Drawing.Point(12, 152);
this.ErrorLBL.Multiline = true;
this.ErrorLBL.Name = "ErrorLBL";
this.ErrorLBL.ReadOnly = true;
this.ErrorLBL.ShortcutsEnabled = false;
this.ErrorLBL.Size = new System.Drawing.Size(309, 13);
this.ErrorLBL.Size = new System.Drawing.Size(309, 37);
this.ErrorLBL.TabIndex = 4;
this.ErrorLBL.TabStop = false;
this.ErrorLBL.UseWaitCursor = true;
@@ -99,7 +100,7 @@
this.pictureBox1.InitialImage = global::CMS_Client.Properties.Resources.CMS_LOGO;
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(309, 98);
this.pictureBox1.Size = new System.Drawing.Size(309, 96);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 3;
this.pictureBox1.TabStop = false;
@@ -114,7 +115,7 @@
this.VersionLBL.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.VersionLBL.ForeColor = System.Drawing.Color.Navy;
this.VersionLBL.HideSelection = false;
this.VersionLBL.Location = new System.Drawing.Point(12, 116);
this.VersionLBL.Location = new System.Drawing.Point(12, 114);
this.VersionLBL.Name = "VersionLBL";
this.VersionLBL.ReadOnly = true;
this.VersionLBL.ShortcutsEnabled = false;
@@ -128,7 +129,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(101)))), ((int)(((byte)(113)))), ((int)(((byte)(120)))));
this.ClientSize = new System.Drawing.Size(333, 179);
this.ClientSize = new System.Drawing.Size(333, 201);
this.Controls.Add(this.VersionLBL);
this.Controls.Add(this.CloseLabel);
this.Controls.Add(this.ErrorLBL);
@@ -1,5 +1,5 @@
using CMS_Client.Config;
using Microsoft.WindowsAPICodePack.Taskbar;
using Microsoft.WindowsAPICodePack.Taskbar;
using Client.Config;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -111,13 +111,13 @@ namespace CMS_Client.View
return;
//try to Request
setStatus("Connecting to " + CMSConfiguration.FirstUrl + "...", "");
do { } while (!testConnection(new Uri(CMSConfiguration.FirstUrl))) ;
setStatus("Connecting to " + Config.ConnectionConfig.Url + "...", "");
do { } while (!testConnection(new Uri(Config.ConnectionConfig.Url))) ;
//Open Nc Window
setStatus("Opening the NC Window... ", "");
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
if (!OpenNcWindow())
return;
@@ -134,18 +134,17 @@ namespace CMS_Client.View
setStatus("Reading Configuration...", "");
//Read the Config
String Message = CMSConfiguration.InitializeSettings();
//Check the readed Config
if (String.IsNullOrEmpty(Message))
try
{
ConfigController.ReadStartupConfig();
setStatus("Configuration ok!", "");
return true;
}
else
catch (Exception E)
{
setStatus("Close the application!", Message);
setStatus("Close the application!", E.Message);
return false;
}
}
@@ -179,7 +178,7 @@ namespace CMS_Client.View
}
else
{
setStatus("Retry connection to: " + CMSConfiguration.FirstUrl, "Server not found (Error:" + ConnTestError + ")");
setStatus("Retry connection to: " + Config.ConnectionConfig.Url, "Server not found (Error:" + ConnTestError + ")");
return false;
}
}
@@ -1,7 +1,7 @@
using CefSharp;
using CefSharp.WinForms;
using Client.Config;
using CMS_Client.Browser_Tools;
using CMS_Client.Config;
using Microsoft.WindowsAPICodePack.Taskbar;
using System;
using System.Collections.Generic;
@@ -65,14 +65,14 @@ namespace CMS_Client.View
//Initialize the Nc-Form
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
InitializeNcForm();
//Setup Wait Cursor
Cursor.Current = Cursors.WaitCursor;
//Load the page
CefBrowser.Load(CMSConfiguration.FirstUrl);
CefBrowser.Load(Config.ConnectionConfig.Url);
}
@@ -89,7 +89,7 @@ namespace CMS_Client.View
//On Resize Form
private void MainForm_Resize(object sender, EventArgs e)
{
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
{
if (this.WindowState == FormWindowState.Minimized)
{
@@ -127,7 +127,7 @@ namespace CMS_Client.View
}
//Close the NC HMI && Stop Following Nc
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
{
NcWindow.ShowTaskBar();
NcWindow.StopNcFollowing();
@@ -145,7 +145,7 @@ namespace CMS_Client.View
private void InitializeClientSettings()
{
//Set the Transparency Key
TransparencyKey = CMSConfiguration.TransparencyKey;
TransparencyKey = Config.ClientConfig.TranspColor;
}
@@ -247,7 +247,7 @@ namespace CMS_Client.View
ShowWindow();
//Start following NC Window
if (CMSConfiguration.HMINcPresent)
if (Config.VendorHmiConfig.Enabled)
NcWindow.StartNcFollowing(MainHandle, NcHandle, NcFrm.Width, NcFrm.Height);
//If is an Error Show the Error page
@@ -1,4 +1,4 @@
using CMS_Client.Config;
using Client.Config;
using CMS_Client.Properties;
using System;
using System.Collections.Generic;
@@ -508,7 +508,7 @@ namespace CMS_Client.View
private static void SetupNcProcess()
{
IsNcSiemens = false;
switch (CMSConfiguration.NCType)
switch (Config.VendorHmiConfig.Type)
{
// 0: Demo
case 0:
-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<appSettings>
<!-- CMS Configuration -->
<add key="Url" value="http://localhost:9000/index.html" />
<add key="TranspColor" value="#00ff00" />
<add key="OpenNcHMI" value="false" /><!-- True|False: Open Nc HMI -->
<add key="NCType" value="0" /><!-- 0: Demo - 1: Fanuc - 2: Siemens - 3: Osai -->
<add key="IDClient" value="1" /><!-- 1.. N Client Identification -->
<!-- ... -->
</appSettings>
</configuration>
-216
View File
@@ -1,216 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_Client.Config
{
public static class CMSConfiguration
{
public static String CustomUrl = "";
public static String FirstUrl = "http://google.it";
public static ushort NCType = 0; /* 0: Demo - 1: Fanuc - 2: Siemens - 3: Osai */
public static ushort IDClient = 0; /* 0: Demo - 1: Fanuc - 2: Siemens - 3: Osai */
public static Color TransparencyKey = Color.Fuchsia;
public static bool HMINcPresent = false;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Read All setup Variables
public static String InitializeSettings()
{
//Setup the first URL
if (String.IsNullOrEmpty(CustomUrl))
{
if (!readFirstUrl(out FirstUrl))
return @"Configuration Error: ""Url"" is not a valid URL";
}
else
FirstUrl = CustomUrl;
//Setup NC Type
if (!readNcPresent(out HMINcPresent))
return @"Configuration Error: ""OpenNcHMI"" is not a valid Boolean Type";
//Setup NC Type
if (!readNCType(out NCType))
return @"Configuration Error: ""NCType"" is not a valid NC Type";
//Setup ID Client
if (!readIdClient(out IDClient))
return @"Configuration Error: ""IDClient"" is not a valid Id of CMS-Client";
//Setup the Transparency Key
if (!readTransparencyKey(out TransparencyKey))
return @"Configuration Error: ""TranspColor"" is not a valid Hex Color";
return "";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region SINGLE_PROPERTY_READS
//Setup the first URL
public static bool readFirstUrl(out String Url)
{
Url = "http://localhost:8080";
//Read the Key
String UrlNew = ConfigurationManager.AppSettings["Url"];
//Check if it's NULL
if (String.IsNullOrWhiteSpace(UrlNew))
return false;
//Check if it a valid URL
try
{
new Uri(UrlNew);
}
catch (Exception)
{
return false;
}
//Returns
Url = UrlNew;
return true;
}
//Setup the Transparency Key
public static bool readTransparencyKey(out Color color)
{
//Default Value
color = Color.Fuchsia;
//Read the Key
String TranspKey = ConfigurationManager.AppSettings["TranspColor"];
//Check if it's NULL
if (String.IsNullOrWhiteSpace(TranspKey))
return false;
//Check if it a valid Color
try
{
color = ColorTranslator.FromHtml(TranspKey);
}
catch (Exception)
{
return false;
}
//Returns
return true;
}
//Setup the Transparency Key
public static bool readNCType(out ushort Type)
{
//Default Value
Type = 0;
//Read the Key
String Stype = ConfigurationManager.AppSettings["NCType"];
//Check if it's NULL
if (String.IsNullOrWhiteSpace(Stype))
return false;
//Check if it a valid NC
try
{
Type = ushort.Parse(Stype);
//Check if it is not valid
if(Type > 3)
return false;
}
catch (Exception)
{
return false;
}
//Returns
return true;
}
//Setup the Transparency Key
public static bool readIdClient(out ushort IdClient)
{
//Default Value
IdClient = 1;
//Read the Key
String Sid = ConfigurationManager.AppSettings["IDClient"];
//Check if it's NULL
if (String.IsNullOrWhiteSpace(Sid))
return false;
//Check if it a valid NC
try
{
IdClient = ushort.Parse(Sid);
//Check if it is not valid
if (IdClient == 0)
return false;
}
catch (Exception)
{
return false;
}
//Returns
return true;
}
//Setup the Transparency Key
public static bool readNcPresent(out bool NcHmiPresent)
{
//Default Value
NcHmiPresent = false;
//Read the Key
String Sid = ConfigurationManager.AppSettings["OpenNcHMI"];
//Check if it's NULL
if (String.IsNullOrWhiteSpace(Sid))
return false;
//Check if it a valid NC
try
{
NcHmiPresent = Boolean.Parse(Sid);
}
catch (Exception)
{
return false;
}
//Returns
return true;
}
#endregion
}
}
+2 -2
View File
@@ -21,9 +21,9 @@ namespace Step.Config
try
{
// Add Schema
readerSettings.Add(null, STARTUP_CONFIG_SCHEMA_PATH);
readerSettings.Add(null, Environment.CurrentDirectory + "\\" + STARTUP_CONFIG_SCHEMA_PATH);
// Open file reader
XDocument xmlConfigFile = XDocument.Load(STARTUP_CONFIG_PATH);
XDocument xmlConfigFile = XDocument.Load(Environment.CurrentDirectory + "\\" + STARTUP_CONFIG_PATH);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
+2 -2
View File
@@ -46,10 +46,10 @@
<Compile Include="StartupConfigController.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="startupValidator.xsd">
<Content Include="startupValidator.xsd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</EmbeddedResource>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Step.Model\Step.Model.csproj">
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Step.UI
public ServerControlWindow()
{
InitializeComponent();
HomePageUI = "http://localhost:" + serverConfig.ServerPort.ToString() + "index.html";
HomePageUI = "http://localhost:" + ServerConfig.ServerPort.ToString() + "/index.html";
}
private static ServerControlWindow ctrlwindow = null;
+45 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step", "Step\Step.csproj", "{AFED34E1-77DB-4D81-830A-A8D0A190573D}"
ProjectSection(ProjectDependencies) = postProject
@@ -20,10 +20,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Database", "Step.Datab
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Config", "Step.Config\Step.Config.csproj", "{3F5C2483-FC87-43EF-92A8-66FF7D0E440F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Client", "Step.Client\Step.Client.csproj", "{66FA29DB-925A-402B-A4C7-D3D780FB1BC3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{66FA29DB-925A-402B-A4C7-D3D780FB1BC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step.Utils", "Step.Utils\Step.Utils.csproj", "{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Client", "CMS.Client", "{2F873243-A483-40B6-A0F7-65FC3541A269}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMS.Step", "CMS.Step", "{0769EE3C-4259-4C72-97B4-0CCAEBFA7724}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Config", "Client.Config\Client.Config.csproj", "{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Utils", "Client.Utils\Client.Utils.csproj", "{34434B22-D546-4A5C-B575-49720C77643A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -118,10 +126,45 @@ Global
{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x64.Build.0 = Release|Any CPU
{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.ActiveCfg = Release|Any CPU
{CBEB631B-ABFA-4042-9779-C0060B0DFEFE}.Release|x86.Build.0 = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|Any CPU.Build.0 = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.ActiveCfg = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x64.Build.0 = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.ActiveCfg = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Debug|x86.Build.0 = Debug|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.ActiveCfg = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|Any CPU.Build.0 = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.ActiveCfg = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x64.Build.0 = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.ActiveCfg = Release|Any CPU
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939}.Release|x86.Build.0 = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.ActiveCfg = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|x64.Build.0 = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.ActiveCfg = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Debug|x86.Build.0 = Debug|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|Any CPU.Build.0 = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.ActiveCfg = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|x64.Build.0 = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.ActiveCfg = Release|Any CPU
{34434B22-D546-4A5C-B575-49720C77643A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AFED34E1-77DB-4D81-830A-A8D0A190573D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{631375DD-06D3-49BB-8130-D9DDB34C429D} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{20FC0937-E7CA-4693-95F9-7A948EFD173B} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{357D5EE1-FFC8-489B-9232-22CF474D9A6F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{3F5C2483-FC87-43EF-92A8-66FF7D0E440F} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{66FA29DB-925A-402B-A4C7-D3D780FB1BC3} = {2F873243-A483-40B6-A0F7-65FC3541A269}
{CBEB631B-ABFA-4042-9779-C0060B0DFEFE} = {0769EE3C-4259-4C72-97B4-0CCAEBFA7724}
{205A6ADE-FB5A-45CB-9C51-9817E7BB8939} = {2F873243-A483-40B6-A0F7-65FC3541A269}
{34434B22-D546-4A5C-B575-49720C77643A} = {2F873243-A483-40B6-A0F7-65FC3541A269}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {51D459FB-B45B-4A47-984E-46C35F933A82}
EndGlobalSection