From 39dca2c10340c59f50b0af221414451e8fecebb9 Mon Sep 17 00:00:00 2001 From: Martin Regen Date: Wed, 20 Nov 2019 16:05:24 +0100 Subject: [PATCH] Complex Types client library (#849) Adds a complex type system client library extension for custom enumerations and structure types based on a server dictionary or DataTypeDefinition using emitted classes at runtime. - Custom types are added to the session factory, not to the global factory. Types are loaded when the session connects by adding ` var complexTypeSystem = new ComplexTypeSystem(session); await complexTypeSystem.Load(); ` - Custom type properties can be accessed with an accessor [propertyname] or [index]. Direct access through the properties is possible, but some cases do not update the optional or union flags correctly. - Support includes V1.03 dictionaries and V1.04 DataTypeDefinitions (--> known issues). - NetCoreComplexClient can be used for quick testing servers. It prints out all custom types with content and subscribes to all. Also includes sample how to write back complex type variables and how to output JSON. - The UA Sample Client and the Quickstart Data Type client can be used for testing with UI. Many issues were adressed to be able to read and write complex types, however some support is limited, e.g. only editing simple fields is currently working (help wanted). - Caveat: The complex type libaries for .Net Core must be built for .netcoreapp, so it needs a seperate nuget package for the complex type client extension. - Support for a factory type builder class to allow to plugin other type builder methods (e.g. Codedom etc...) - Added JSON test case and include the complex types client in the testing shell script, so the complex types lib is tested on mac/linux too. - Few fixes in the JSON encoder. Finding enough servers with custom types is an issue, so if you find servers with unsupported custom types please provide feedback. Known limitations: - Only V1.03 OPC binary dictionaries are supported (no XML Schema dictionaries). - V1.03 dictionary structure definitions are only supported if they can be mapped to a V1.04 DataTypeDefinition. Nested types and cross dictionary refs should work. - OptionSet is only partially implemented. Only shows the byte arrays, not the flags. - Opaque Types in dictionaries are ignored. --- .travis.yml | 2 + .../ComplexTypeSystem.cs | 807 ++++++++ .../DataTypeDefinitionExtension.cs | 295 +++ .../IComplexTypeFactory.cs | 123 ++ .../IComplexTypeProperties.cs | 139 ++ .../Opc.Ua.Client.ComplexTypes.csproj | 30 + .../TypeBuilder/AssemblyModule.cs} | 84 +- .../TypeBuilder/AttributeExtensions.cs | 236 +++ .../TypeBuilder/ComplexTypeBuilder.cs | 228 +++ .../TypeBuilder/ComplexTypeFactory.cs} | 66 +- .../TypeBuilder/ComplexTypeFieldBuilder.cs | 131 ++ .../Types/BaseComplexType.cs | 936 ++++++++++ .../Types/OptionalFieldsComplexType.cs | 317 ++++ .../Types/StructureDefinitionAttribute.cs} | 68 +- .../Types/StructureFieldAttribute.cs} | 69 +- .../Types/StructureTypeAttribute.cs | 48 + .../Types/UnionComplexType.cs | 329 ++++ .../SDK/Opc.Ua.Client/Session.cs | 28 +- .../Client.Net4/UA Sample Client.csproj | 4 + .../ClientControls.Net4/ClientUtils.cs | 108 +- .../Common (OLD)/BaseListCtrl.Designer.cs | 95 - .../Common (OLD)/BaseListCtrl.cs | 866 --------- .../Common (OLD)/BaseListCtrl.resx | 120 -- .../Common (OLD)/BaseTreeCtrl.Designer.cs | 93 - .../Common (OLD)/BaseTreeCtrl.cs | 456 ----- .../Common (OLD)/BaseTreeCtrl.resx | 120 -- .../Common (OLD)/ClipboardHack.cs | 155 -- .../ComplexValueEditDlg.Designer.cs | 148 -- .../Common (OLD)/ComplexValueEditDlg.cs | 105 -- .../Common (OLD)/ComplexValueEditDlg.resx | 120 -- .../Common (OLD)/DataListCtrl.Designer.cs | 144 -- .../Common (OLD)/DataListCtrl.cs | 1519 --------------- .../Common (OLD)/DataListCtrl.resx | 123 -- .../DateTimeValueEditDlg.Designer.cs | 148 -- .../Common (OLD)/DateTimeValueEditDlg.resx | 120 -- .../Common (OLD)/ExceptionDlg.Designer.cs | 131 -- .../Common (OLD)/ExceptionDlg.cs | 135 -- .../Common (OLD)/ExceptionDlg.resx | 120 -- .../Common (OLD)/GuiUtils.Designer.cs | 116 -- .../Common (OLD)/GuiUtils.cs | 998 ---------- .../Common (OLD)/GuiUtils.resx | 539 ------ .../Common (OLD)/NodeIdCtrl.Designer.cs | 106 -- .../Common (OLD)/NodeIdCtrl.cs | 206 -- .../Common (OLD)/NodeIdCtrl.resx | 120 -- .../NodeIdValueEditDlg.Designer.cs | 148 -- .../Common (OLD)/NodeIdValueEditDlg.cs | 98 - .../Common (OLD)/NodeIdValueEditDlg.resx | 120 -- .../NumericValueEditDlg.Designer.cs | 149 -- .../Common (OLD)/NumericValueEditDlg.cs | 163 -- .../Common (OLD)/NumericValueEditDlg.resx | 120 -- .../ReferenceTypeCtrl.Designer.cs | 93 - .../Common (OLD)/ReferenceTypeCtrl.cs | 273 --- .../Common (OLD)/ReferenceTypeCtrl.resx | 120 -- .../StringValueEditDlg.Designer.cs | 150 -- .../Common (OLD)/StringValueEditDlg.resx | 120 -- .../Common/Client/ConnectServerCtrl.cs | 4 + .../Common (OLD)/DataListCtrl.cs | 52 +- .../Configuration/Common (OLD)/GuiUtils.cs | 2 +- .../Common (OLD)/ReferenceTypeCtrl.cs | 4 +- .../Common (OLD)/SimpleValueEditDlg.cs | 2 +- .../UA Client Controls.csproj | 4 + .../Controls.Net4/Common/ArgumentListCtrl.cs | 2 +- .../Controls.Net4/Common/AttributeListCtrl.cs | 2 +- .../Common/DataListCtrl.Designer.cs | 141 -- .../Controls.Net4/Common/DataListCtrl.cs | 1659 ----------------- .../Controls.Net4/Common/DataListCtrl.resx | 123 -- .../Samples/Controls.Net4/Common/GuiUtils2.cs | 215 --- .../Controls.Net4/Common/GuiUtils2.resx | 301 --- .../Common/NodeIdValueEditDlg.Designer.cs | 147 -- .../Common/NodeIdValueEditDlg.resx | 120 -- .../Common/ReferenceTypeCtrl.Designer.cs | 93 - .../Controls.Net4/Common/ReferenceTypeCtrl.cs | 270 --- .../Common/ReferenceTypeCtrl.resx | 120 -- .../Common/SimpleValueEditDlg.Designer.cs | 162 -- .../Common/SimpleValueEditDlg.cs | 141 -- .../Common/SimpleValueEditDlg.resx | 120 -- .../Controls.Net4/Sessions/BrowseListCtrl.cs | 2 +- .../Sessions/BrowseOptionsDlg.Designer.cs | 4 +- .../Controls.Net4/Sessions/BrowseTreeCtrl.cs | 4 +- .../Controls.Net4/Sessions/SessionOpenDlg.cs | 4 + .../Subscriptions/HistoryReadDlg.Designer.cs | 4 +- .../MonitoredItemDlg.Designer.cs | 4 +- .../Subscriptions/ReadDlg.Designer.cs | 4 +- .../Subscriptions/WriteDlg.Designer.cs | 4 +- .../Subscriptions/WriteValueListCtrl.cs | 2 +- .../Controls.Net4/UA Sample Controls.csproj | 54 +- .../NetCoreComplexClient.csproj | 54 + .../Opc.Ua.ComplexClient.Config.xml | 99 + .../Samples/NetCoreComplexClient/Program.cs | 613 ++++++ .../NetCoreConsoleClient.csproj | 28 +- .../Workshop/Aggregation/UA Aggregation.sln | 9 + .../DataTypes/Client/DataTypes Client.csproj | 4 + .../Workshop/DataTypes/Client/MainForm.cs | 7 + .../Workshop/DataTypes/Client/MainForm.resx | 10 +- .../Workshop/Reference/UA Reference.sln | 6 + .../Configuration/ApplicationConfiguration.cs | 8 +- .../Types/BuiltIn/ExtensionObject.cs | 168 +- .../Opc.Ua.Core/Types/Encoders/JsonEncoder.cs | 12 +- .../Types/Schemas/StandardTypes.bsd | 2 +- Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs | 23 +- UA Core Library.sln | 6 + UA Global Discovery Server.sln | 6 + UA Quickstart Applications.sln | 7 + UA-NetStandard.sln | 30 + appveyor.yml | 2 +- .../Opc.Ua.Client.ComplexTypes.Symbols.nuspec | 30 + nuget/Opc.Ua.Client.ComplexTypes.nuspec | 28 + nuget/Opc.Ua.Symbols.nuspec | 2 +- nuget/Opc.Ua.nuspec | 2 +- testclientserver.sh | 14 +- 110 files changed, 4955 insertions(+), 12390 deletions(-) create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/DataTypeDefinitionExtension.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeFactory.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeProperties.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Opc.Ua.Client.ComplexTypes.csproj rename SampleApplications/{Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.cs => SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AssemblyModule.cs} (56%) create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeBuilder.cs rename SampleApplications/{Samples/Controls.Net4/Common/GuiUtils2.Designer.cs => SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFactory.cs} (56%) create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFieldBuilder.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs rename SampleApplications/{Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.cs => SDK/Opc.Ua.Client.ComplexTypes/Types/StructureDefinitionAttribute.cs} (60%) rename SampleApplications/{Samples/Controls.Net4/Common/NodeIdValueEditDlg.cs => SDK/Opc.Ua.Client.ComplexTypes/Types/StructureFieldAttribute.cs} (50%) create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureTypeAttribute.cs create mode 100644 SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ClipboardHack.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.resx delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.resx delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.resx delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.resx delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.resx delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.Designer.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.resx delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.Designer.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.cs delete mode 100644 SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.resx create mode 100644 SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj create mode 100644 SampleApplications/Samples/NetCoreComplexClient/Opc.Ua.ComplexClient.Config.xml create mode 100644 SampleApplications/Samples/NetCoreComplexClient/Program.cs create mode 100644 nuget/Opc.Ua.Client.ComplexTypes.Symbols.nuspec create mode 100644 nuget/Opc.Ua.Client.ComplexTypes.nuspec diff --git a/.travis.yml b/.travis.yml index 1a0c6bf010..7cdd0b16a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,10 @@ script: - dotnet build -c Debug /p:NoHttps=true SampleApplications/Samples/NetCoreConsoleServer/NetCoreConsoleServer.csproj - dotnet build -c Release /p:NoHttps=true SampleApplications/Samples/NetCoreConsoleServer/NetCoreConsoleServer.csproj - dotnet build -c Debug SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj + - dotnet build -c Debug SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj - dotnet build -c Debug SampleApplications/Samples/NetCoreConsoleServer/NetCoreConsoleServer.csproj - dotnet build -c Release SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj + - dotnet build -c Release SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj - dotnet build -c Release SampleApplications/Samples/NetCoreConsoleServer/NetCoreConsoleServer.csproj - dotnet build -c Debug SampleApplications/Workshop/Aggregation/ConsoleAggregationServer - dotnet build -c Release SampleApplications/Workshop/Aggregation/ConsoleAggregationServer diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs new file mode 100644 index 0000000000..557bc5bbb3 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs @@ -0,0 +1,807 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using static Opc.Ua.Utils; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Manages the custom types of a server for a client session. + /// Loads the custom types into the type factory + /// of a client session, to allow for decoding and encoding + /// of custom enumeration types and structured types. + /// + /// + /// Support for V1.03 dictionaries and all V1.04 data type definitions + /// with the following known restrictions: + /// - Support only for V1.03 structured types which can be mapped to the V1.04 + /// structured type definition. Unsupported V1.03 types are ignored. + /// - V1.04 OptionSet does not create the enumeration flags. + /// + public class ComplexTypeSystem + { + #region Constructors + /// + /// Initializes the type system with a session to load the custom types. + /// + public ComplexTypeSystem(Session session) + { + Initialize(session, new ComplexTypeBuilderFactory()); + } + + /// + /// Initializes the type system with a session to load the custom types + /// and a customized type builder factory + /// + public ComplexTypeSystem( + Session session, + IComplexTypeFactory complexTypeBuilderFactory) + { + Initialize(session, complexTypeBuilderFactory); + } + + private void Initialize( + Session session, + IComplexTypeFactory complexTypeBuilderFactory) + { + m_session = session; + m_complexTypeBuilderFactory = complexTypeBuilderFactory; + } + #endregion + + #region Public Members + /// + /// Load a single custom type with subtypes. + /// + public Task LoadType(NodeId nodeId, bool subTypes) + { + // FUTURE: Implement loader for a single type. Currently loading all types. + return Load(); + } + + /// + /// Load all custom types of a namespace. + /// + public Task LoadTypeDictionary(string nameSpace) + { + // FUTURE: Implement loader for all custom types of a namespace. Currently loading all types. + return Load(); + } + + /// + /// Load all custom types from a server into the session system type factory. + /// + /// + /// The loader follows the following strategy: + /// - Load all DataType nodes of the Enumeration subtypes. + /// - Load all DataType nodes of the Structure subtypes. + /// - Create all enumerated custom types using the DataTypeDefinion attribute, if available. + /// - Create all remaining enumerated custom types using the EnumValues or EnumStrings property, if available. + /// - Create all structured types using the DataTypeDefinion attribute, if available. + /// if there are type definitions remaining + /// - Load the binary schema dictionaries with type definitions. + /// - Create all enumerated custom types using the dictionaries. + /// - Convert all structured types in the dictionaries to the DataTypeDefinion attribute, if possible. + /// - Create all structured types from the dictionaries using the DataTypeDefinion attribute.. + /// + public async Task Load() + { + try + { + // load server types + var serverEnumTypes = LoadDataTypes(DataTypeIds.Enumeration); + var serverStructTypes = LoadDataTypes(DataTypeIds.Structure, true); + LoadBaseDataTypes(serverEnumTypes, serverStructTypes); + await LoadDictionaryDataTypes(serverEnumTypes, serverStructTypes); + return true; + } + catch (ServiceResultException sre) + { + Utils.Trace(sre, $"Failed to load the custom type dictionary."); + return false; + } + } + + /// + /// Get the types defined in this type system. + /// + public Type[] GetDefinedTypes() + { + return m_complexTypeBuilderFactory.GetTypes(); + } + #endregion + + #region Private Members + /// + /// Load all custom types from dictionaries into the sessions system type factory. + /// + private async Task LoadDictionaryDataTypes( + IList serverEnumTypes, + IList serverStructTypes + ) + { + // build a type dictionary with all new types + var allTypes = new List(); + allTypes.AddRange(serverEnumTypes); + allTypes.AddRange(serverStructTypes); + + // strip known types from the work list + serverEnumTypes = RemoveKnownTypes(serverEnumTypes); + + // load the binary schema dictionaries from the server + var typeSystem = await m_session.LoadDataTypeSystem(); + + // TODO: sort dictionaries with import dependencies to the end of the list + + // create custom types for all dictionaries + foreach (var dictionaryId in typeSystem) + { + try + { + var dictionary = dictionaryId.Value; + var targetNamespace = dictionary.TypeDictionary.TargetNamespace; + var structureList = new List(); + var enumList = new List(); + + // split into enumeration and structure types and sort + // types with dependencies to the end of the list. + SplitAndSortDictionary(dictionary, structureList, enumList); + + // create assembly for all types in the same module + var complexTypeBuilder = m_complexTypeBuilderFactory.Create( + targetNamespace, + m_session.NamespaceUris.GetIndex(targetNamespace), + dictionary.Name); + + // Add all unknown enumeration types + AddEnumTypes(complexTypeBuilder, enumList, serverEnumTypes); + + int lastStructureCount = 0; + while (structureList.Count > 0 && + structureList.Count != lastStructureCount) + { + lastStructureCount = structureList.Count; + var retryStructureList = new List(); + // build structured types + foreach (var item in structureList) + { + var structuredObject = item as Opc.Ua.Schema.Binary.StructuredType; + if (structuredObject != null) + { + var nodeId = dictionary.DataTypes.Where(d => d.Value.DisplayName == item.Name).FirstOrDefault().Value; + + // find the data type node and the binary encoding id + ExpandedNodeId typeId; + ExpandedNodeId binaryEncodingId; + DataTypeNode dataTypeNode; + bool newTypeDescription = BrowseTypeIdsForDictionaryComponent( + ExpandedNodeId.ToNodeId(nodeId.NodeId, m_session.NamespaceUris), + out typeId, + out binaryEncodingId, + out dataTypeNode); + + if (!newTypeDescription) + { + Utils.Trace(TraceMasks.Error, $"Skip the type definition of {item.Name} because the data type node was not found."); + continue; + } + + if (GetSystemType(typeId) != null) + { + Utils.Trace(TraceMasks.Information, $"Skip the type definition of {item.Name} because the type already exists."); + continue; + } + + // Use DataTypeDefinition attribute, if available (>=V1.04) + StructureDefinition structureDefinition = dataTypeNode.DataTypeDefinition?.Body as StructureDefinition; + if (structureDefinition == null) + { + try + { + // convert the binary schema description to a StructureDefinition + structureDefinition = structuredObject.ToStructureDefinition( + binaryEncodingId, + allTypes, + m_session.NamespaceUris); + } + catch (ServiceResultException sre) + { + Utils.Trace(sre, $"Skip the type definition of {item.Name}."); + continue; + } + } + + Type complexType = null; + if (structureDefinition != null) + { + // build the actual structured type in an assembly + complexType = AddStructuredType( + complexTypeBuilder, + structureDefinition, + dataTypeNode.BrowseName.Name, + typeId, + binaryEncodingId); + + // Add new type to factory + if (complexType != null) + { + AddEncodeableType(binaryEncodingId, complexType); + AddEncodeableType(typeId, complexType); + } + } + + if (complexType == null) + { + retryStructureList.Add(item); + Utils.Trace(TraceMasks.Error, $"Skipped the type definition of {item.Name}. Retry in next round."); + } + } + } + structureList = retryStructureList; + } + } + catch (ServiceResultException sre) + { + Utils.Trace(sre, + $"Unexpected error processing {dictionaryId.Value.Name}."); + } + } + } + + /// + /// Load all custom types with DataTypeDefinition into the type factory. + /// + private void LoadBaseDataTypes( + IList serverEnumTypes, + IList serverStructTypes + ) + { + // strip known types + serverEnumTypes = RemoveKnownTypes(serverEnumTypes); + serverStructTypes = RemoveKnownTypes(serverStructTypes); + + // add new enum Types for all namespaces + var enumTypesToDoList = new List(); + int namespaceCount = m_session.NamespaceUris.Count; + + // create enumeration types for all namespaces + for (uint i = 0; i < namespaceCount; i++) + { + IComplexTypeBuilder complexTypeBuilder = null; + var enumTypes = serverEnumTypes.Where(node => node.NodeId.NamespaceIndex == i).ToList(); + if (enumTypes.Count != 0) + { + if (complexTypeBuilder == null) + { + string targetNamespace = m_session.NamespaceUris.GetString(i); + complexTypeBuilder = m_complexTypeBuilderFactory.Create( + targetNamespace, + (int)i); + } + foreach (var enumType in enumTypes) + { + var newType = AddEnumType(complexTypeBuilder, enumType as DataTypeNode); + if (newType != null) + { + // match namespace and add to type factory + AddEncodeableType(enumType.NodeId, newType); + } + else + { + enumTypesToDoList.Add(enumType); + } + } + } + } + + bool retryAddStructType; + var structTypesToDoList = new List(); + var structTypesWorkList = serverStructTypes; + + // create structured types for all namespaces + do + { + retryAddStructType = false; + for (uint i = 0; i < namespaceCount; i++) + { + IComplexTypeBuilder complexTypeBuilder = null; + var structTypes = structTypesWorkList.Where(node => node.NodeId.NamespaceIndex == i).ToList(); + if (structTypes.Count != 0) + { + if (complexTypeBuilder == null) + { + string targetNamespace = m_session.NamespaceUris.GetString(i); + complexTypeBuilder = m_complexTypeBuilderFactory.Create( + targetNamespace, + (int)i); + } + foreach (INode structType in structTypes) + { + Type newType = null; + var dataTypeNode = structType as DataTypeNode; + var structureDefinition = dataTypeNode.DataTypeDefinition?.Body as StructureDefinition; + if (structureDefinition != null) + { + try + { + newType = AddStructuredType( + complexTypeBuilder, + structureDefinition, + dataTypeNode.BrowseName.Name, + structType.NodeId, + structureDefinition.DefaultEncodingId + ); + } + catch + { + // creating the new type failed, likely a missing dependency, retry later + retryAddStructType = true; + } + if (newType != null) + { + // match namespace and add new type to type factory + AddEncodeableType(structureDefinition.DefaultEncodingId, newType); + AddEncodeableType(structType.NodeId, newType); + } + } + if (newType == null) + { + structTypesToDoList.Add(structType); + } + } + } + } + // due to type dependencies, retry missing types until there is no more progress + if (retryAddStructType && + structTypesWorkList.Count != structTypesToDoList.Count) + { + structTypesWorkList = structTypesToDoList; + structTypesToDoList = new List(); + } + } while (retryAddStructType); + } + + + /// + /// Helper to ensure the expanded nodeId contains a valid namespaceUri. + /// + /// The expanded nodeId. + /// The session namespace table. + /// The normalized expanded nodeId. + private ExpandedNodeId NormalizeExpandedNodeId(ExpandedNodeId expandedNodeId) + { + var nodeId = ExpandedNodeId.ToNodeId(expandedNodeId, m_session.NamespaceUris); + return NodeId.ToExpandedNodeId(nodeId, m_session.NamespaceUris); + } + + /// + /// Browse for the type and encoding id for a dictionary component. + /// + /// + /// To find the typeId and encodingId for a dictionary type definition: + /// i) inverse browse the description to get the encodingid + /// ii) from the description inverse browse for encoding + /// to get the subtype typeid + /// iii) load the DataType node + /// + /// + /// + /// + /// + private bool BrowseTypeIdsForDictionaryComponent( + NodeId nodeId, + out ExpandedNodeId typeId, + out ExpandedNodeId encodingId, + out DataTypeNode dataTypeNode) + { + typeId = ExpandedNodeId.Null; + encodingId = ExpandedNodeId.Null; + dataTypeNode = null; + + var references = m_session.NodeCache.FindReferences( + nodeId, + ReferenceTypeIds.HasDescription, + true, + false + ); + + if (references.Count == 1) + { + encodingId = references.First().NodeId; + references = m_session.NodeCache.FindReferences( + encodingId, + ReferenceTypeIds.HasEncoding, + true, + false + ); + encodingId = NormalizeExpandedNodeId(encodingId); + + if (references.Count == 1) + { + typeId = references.First().NodeId; + dataTypeNode = m_session.NodeCache.Find(typeId) as DataTypeNode; + typeId = NormalizeExpandedNodeId(typeId); + return true; + } + } + return false; + } + + /// + /// Browse for the property. + /// + /// + /// Browse for property (type description) of an enum datatype. + /// + /// + /// + private INode BrowseForSingleProperty( + ExpandedNodeId nodeId) + { + var references = m_session.NodeCache.FindReferences( + nodeId, + ReferenceTypeIds.HasProperty, + false, + false + ); + return references.FirstOrDefault(); + } + + /// + /// Load all subTypes and optionally nested subtypes of a type definition. + /// Filter for all subtypes or only subtypesoutside the default namespace. + /// + private IList LoadDataTypes(ExpandedNodeId dataType, bool nestedSubTypes = false, bool filterUATypes = true) + { + var result = new List(); + var nodesToBrowse = new ExpandedNodeIdCollection(); + nodesToBrowse.Add(dataType); + + while (nodesToBrowse.Count > 0) + { + var nextNodesToBrowse = new ExpandedNodeIdCollection(); + foreach (var node in nodesToBrowse) + { + var response = m_session.NodeCache.FindReferences( + node, + ReferenceTypeIds.HasSubtype, + false, + false); + + if (nestedSubTypes) + { + nextNodesToBrowse.AddRange(response.Select(r => r.NodeId).ToList()); + } + if (filterUATypes) + { + // filter out default namespace + result.AddRange(response.Where(rd => rd.NodeId.NamespaceIndex != 0)); + } + else + { + result.AddRange(response); + } + } + nodesToBrowse = nextNodesToBrowse; + } + + return result; + } + + /// + /// Remove all known types in the type factory from a list of DataType nodes. + /// + private IList RemoveKnownTypes(IList nodeList) + { + return nodeList.Where( + node => GetSystemType(node.NodeId) == null).ToList(); + } + + /// + /// Get the factory system type for an expanded node id. + /// + private Type GetSystemType(ExpandedNodeId nodeId) + { + if (!nodeId.IsAbsolute) + { + nodeId = NormalizeExpandedNodeId(nodeId); + } + return m_session.Factory.GetSystemType(nodeId); + } + + /// + /// Add an enum type defined in a binary schema dictionary. + /// + private void AddEnumTypes( + IComplexTypeBuilder complexTypeBuilder, + IList enumList, + IList enumerationTypes + ) + { + foreach (var item in enumList) + { + Type newType = null; + DataTypeNode enumType = enumerationTypes.Where(node => + node.BrowseName.Name == item.Name && + (node.NodeId.NamespaceIndex == complexTypeBuilder.TargetNamespaceIndex || + complexTypeBuilder.TargetNamespaceIndex == -1)).FirstOrDefault() + as DataTypeNode; + if (enumType != null) + { + // try dictionary enum definition + var enumeratedObject = item as Schema.Binary.EnumeratedType; + if (enumeratedObject != null) + { + // 1. use Dictionary entry + newType = complexTypeBuilder.AddEnumType(enumeratedObject); + } + if (newType == null) + { + var dataType = m_session.NodeCache.Find(enumType.NodeId) as DataTypeNode; + if (dataType != null) + { + if (dataType.DataTypeDefinition != null) + { + // 2. use DataTypeDefinition + newType = complexTypeBuilder.AddEnumType(enumType.BrowseName.Name, dataType.DataTypeDefinition); + } + else + { + // browse for EnumFields or EnumStrings property + var property = BrowseForSingleProperty(enumType.NodeId); + var enumArray = m_session.ReadValue( + ExpandedNodeId.ToNodeId(property.NodeId, m_session.NamespaceUris)); + if (enumArray.Value is ExtensionObject[]) + { + // 3. use EnumValues + newType = complexTypeBuilder.AddEnumType(enumType.BrowseName.Name, (ExtensionObject[])enumArray.Value); + } + else if (enumArray.Value is LocalizedText[]) + { + // 4. use EnumStrings + newType = complexTypeBuilder.AddEnumType(enumType.BrowseName.Name, (LocalizedText[])enumArray.Value); + } + } + } + } + if (newType != null) + { + // match namespace and add to type factory + AddEncodeableType(enumType.NodeId, newType); + } + } + } + } + + /// + /// Helper to add new type with absolute ExpandedNodeId. + /// + private void AddEncodeableType(ExpandedNodeId nodeId, Type type) + { + var internalNodeId = NormalizeExpandedNodeId(nodeId); + Utils.TraceDebug($"Adding Type {type.FullName} as: {internalNodeId.ToString()}"); + m_session.Factory.AddEncodeableType(internalNodeId, type); + } + + /// + /// Add an enum type defined in a DataType node. + /// + private Type AddEnumType( + IComplexTypeBuilder complexTypeBuilder, + DataTypeNode enumTypeNode + ) + { + Type newType = null; + if (enumTypeNode != null) + { + string name = enumTypeNode.BrowseName.Name; + if (enumTypeNode.DataTypeDefinition != null) + { + // 1. use DataTypeDefinition + newType = complexTypeBuilder.AddEnumType(name, enumTypeNode.DataTypeDefinition); + } + else + { + // browse for EnumFields or EnumStrings property + var property = BrowseForSingleProperty(enumTypeNode.NodeId); + var enumArray = m_session.ReadValue( + ExpandedNodeId.ToNodeId(property.NodeId, + m_session.NamespaceUris)); + if (enumArray.Value is ExtensionObject[]) + { + // 2. use EnumValues + newType = complexTypeBuilder.AddEnumType(name, (ExtensionObject[])enumArray.Value); + } + else if (enumArray.Value is LocalizedText[]) + { + // 3. use EnumStrings + newType = complexTypeBuilder.AddEnumType(name, (LocalizedText[])enumArray.Value); + } + } + } + return newType; + } + + /// + /// Add structured type to assembly with StructureDefinition. + /// + private Type AddStructuredType( + IComplexTypeBuilder complexTypeBuilder, + StructureDefinition structureDefinition, + string typeName, + ExpandedNodeId complexTypeId, + ExpandedNodeId binaryEncodingId, + ExpandedNodeId xmlEncodingId = null + ) + { + // check all types + var typeList = new List(); + foreach (StructureField field in structureDefinition.Fields) + { + var newType = GetFieldType(field); + if (newType == null) + { + // missing that type + return null; + } + typeList.Add(newType); + } + + var fieldBuilder = complexTypeBuilder.AddStructuredType( + typeName, + structureDefinition + ); + + fieldBuilder.AddTypeIdAttribute(complexTypeId, binaryEncodingId, xmlEncodingId); + + int order = 1; + var typeListEnumerator = typeList.GetEnumerator(); + foreach (StructureField field in structureDefinition.Fields) + { + typeListEnumerator.MoveNext(); + fieldBuilder.AddField(field, typeListEnumerator.Current, order); + order += 1; + } + + return fieldBuilder.CreateType(); + } + + /// + /// Determine the type of a field in a StructureField definition. + /// + private Type GetFieldType(StructureField field) + { + Type fieldType = null; + Type collectionType = null; + if (field.DataType.NamespaceIndex == 0) + { + fieldType = Opc.Ua.TypeInfo.GetSystemType(field.DataType, m_session.Factory); + if (field.ValueRank >= 0) + { + if (fieldType == typeof(Byte[])) + { + collectionType = typeof(ByteStringCollection); + } + else if (fieldType == typeof(Single)) + { + collectionType = typeof(FloatCollection); + } + else + { + var assemblyQualifiedName = typeof(StatusCode).Assembly; + String collectionClassName = "Opc.Ua." + fieldType.Name + "Collection, " + assemblyQualifiedName; + collectionType = Type.GetType(collectionClassName); + } + } + } + else + { + fieldType = GetSystemType(field.DataType); + if (fieldType == null) + { + return null; + } + if (field.ValueRank >= 0) + { + String collectionClassName = (fieldType.Namespace != null) ? fieldType.Namespace + "." : ""; + collectionClassName += fieldType.Name + "Collection, " + fieldType.Assembly; + collectionType = Type.GetType(collectionClassName); + } + } + + if (field.ValueRank >= 0) + { + if (collectionType != null) + { + fieldType = collectionType; + } + else + { + fieldType = fieldType.MakeArrayType(); + } + } + + return fieldType; + } + + /// + /// Split the dictionary types into a list of structures and enumerations. + /// Sort the structures by dependencies, with structures with dependent + /// types at the end of the list, so they can be added to the factory in order. + /// + private void SplitAndSortDictionary( + DataDictionary dictionary, + List structureList, + List enumList + ) + { + foreach (var item in dictionary.TypeDictionary.Items) + { + var structuredObject = item as Opc.Ua.Schema.Binary.StructuredType; + if (structuredObject != null) + { + var dependentFields = structuredObject.Field.Where(f => f.TypeName.Namespace == dictionary.TypeDictionary.TargetNamespace); + if (dependentFields.Count() == 0) + { + structureList.Insert(0, structuredObject); + } + else + { + structureList.Add(structuredObject); + } + } + else if (item is Opc.Ua.Schema.Binary.EnumeratedType) + { + enumList.Add(item); + } + else if (item is Opc.Ua.Schema.Binary.OpaqueType) + { + // TODO + } + else + { + throw new ServiceResultException(StatusCodes.BadUnexpectedError, $"Unexpected Type in binary schema: {item.GetType().Name}."); + } + } + } + #endregion + + #region Private Fields + Session m_session; + IComplexTypeFactory m_complexTypeBuilderFactory; + const string m_opcComplexTypesPrefix = "Opc.Ua.ComplexTypes."; + #endregion + } + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/DataTypeDefinitionExtension.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/DataTypeDefinitionExtension.cs new file mode 100644 index 0000000000..59079dbaf5 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/DataTypeDefinitionExtension.cs @@ -0,0 +1,295 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Extensions to convert binary schema type definitions to DataTypeDefinitions. + /// + public static class DataTypeDefinitionExtension + { + #region Public Extensions + /// + /// Convert a binary schema type definition to a + /// StructureDefinition. + /// + /// + /// Support for: + /// - Structures, structures with optional fields and unions. + /// - Nested types and typed arrays with length field. + /// The converter has the following known restrictions: + /// - Support only for V1.03 structured types which can be mapped to the V1.04 + /// structured type definition. + /// The following dictionary tags cause bail out for a structure: + /// - use of a terminator of length in bytes + /// - an array length field is not a direct predecessor of the array + /// - The switch value of a union is not the first field. + /// - The selector bits of optional fields are not stored in a 32 bit variable + /// and do not add up to 32 bits. + /// + public static StructureDefinition ToStructureDefinition( + this Schema.Binary.StructuredType structuredType, + ExpandedNodeId defaultEncodingId, + IList typeDictionary, + NamespaceTable namespaceTable) + { + var structureDefinition = new StructureDefinition() + { + BaseDataType = null, + DefaultEncodingId = ExpandedNodeId.ToNodeId(defaultEncodingId, namespaceTable), + Fields = new StructureFieldCollection(), + StructureType = StructureType.Structure + }; + + bool isSupportedType = true; + bool hasBitField = false; + bool isUnionType = false; + + foreach (var field in structuredType.Field) + { + // check for yet unsupported properties + if (field.IsLengthInBytes || + field.Terminator != null) + { + isSupportedType = false; + } + + if (field.SwitchValue != 0) + { + isUnionType = true; + } + + if (field.TypeName.Namespace == Namespaces.OpcBinarySchema || + field.TypeName.Namespace == Namespaces.OpcUa) + { + if (field.TypeName.Name == "Bit") + { + hasBitField = true; + continue; + } + } + if (field.Length != 0) + { + isSupportedType = false; + } + } + + // test forbidden combinations + if (!isSupportedType) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "The structure definition uses a Terminator or LengthInBytes, which are not supported."); + } + + if (isUnionType && hasBitField) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "The structure definition combines a Union and a bit filed, both of which are not supported in a single structure."); + } + + if (isUnionType) + { + structureDefinition.StructureType = StructureType.Union; + } + + if (hasBitField) + { + structureDefinition.StructureType = StructureType.StructureWithOptionalFields; + } + + byte switchFieldBitPosition = 0; + Int32 dataTypeFieldPosition = 0; + var switchFieldBits = new Dictionary(); + // convert fields + foreach (var field in structuredType.Field) + { + // consume optional bits + if (field.TypeName.IsXmlBitType()) + { + var count = structureDefinition.Fields.Count; + if (count == 0 && + switchFieldBitPosition < 32) + { + structureDefinition.StructureType = StructureType.StructureWithOptionalFields; + byte fieldLength = (byte)((field.Length == 0) ? 1u : field.Length); + switchFieldBits[field.Name] = switchFieldBitPosition; + switchFieldBitPosition += fieldLength; + } + else + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "Options for bit selectors must be 32 bit in size, use the Int32 datatype and must be the first element in the structure."); + } + continue; + } + + if (switchFieldBitPosition != 0 && + switchFieldBitPosition != 32) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "Bitwise option selectors must have 32 bits."); + } + + var dataTypeField = new StructureField() + { + Name = field.Name, + Description = null, + DataType = field.TypeName.ToNodeId(typeDictionary, namespaceTable), + IsOptional = false, + MaxStringLength = 0, + ArrayDimensions = null, + ValueRank = -1 + }; + + if (field.LengthField != null) + { + // handle array length + var lastField = structureDefinition.Fields.Last(); + if (lastField.Name != field.LengthField) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "The length field must precede the type field of an array."); + } + lastField.Name = field.Name; + lastField.DataType = field.TypeName.ToNodeId(typeDictionary, namespaceTable); + lastField.ValueRank = 1; + } + else + { + if (isUnionType) + { + // ignore the switchfield + if (field.SwitchField == null) + { + if (structureDefinition.Fields.Count != 0) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "The switch field of a union must be the first field in the complex type."); + } + continue; + } + if (structureDefinition.Fields.Count != dataTypeFieldPosition) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + "The count of the switch field of the union member is not matching the field position."); + } + dataTypeFieldPosition++; + } + else + { + if (field.SwitchField != null) + { + dataTypeField.IsOptional = true; + byte value; + if (!switchFieldBits.TryGetValue(field.SwitchField, out value)) + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + $"The switch field for {field.SwitchField} does not exist."); + } + } + } + structureDefinition.Fields.Add(dataTypeField); + } + } + + return structureDefinition; + } + + /// + /// Test for special Bit type used in the binary schema structure definition. + /// + private static bool IsXmlBitType(this XmlQualifiedName typeName) + { + if (typeName.Namespace == Namespaces.OpcBinarySchema || + typeName.Namespace == Namespaces.OpcUa) + { + if (typeName.Name == "Bit") + { + return true; + } + } + return false; + } + + /// + /// Look up the node id for a qualified name of a type + /// in a binary schema type definition. + /// + private static NodeId ToNodeId( + this XmlQualifiedName typeName, + IList typeCollection, + NamespaceTable namespaceTable) + { + if (typeName.Namespace == Namespaces.OpcBinarySchema || + typeName.Namespace == Namespaces.OpcUa) + { + switch (typeName.Name) + { + case "CharArray": return DataTypeIds.String; + case "Variant": return DataTypeIds.BaseDataType; + case "ExtensionObject": return DataTypeIds.Structure; + } + var internalField = typeof(DataTypeIds).GetField(typeName.Name); + if (internalField == null) + { + throw new ServiceResultException(StatusCodes.BadDataTypeIdUnknown, + $"The type {typeName.Name} was not found in the internal type factory."); + } + return (NodeId)internalField.GetValue(typeName.Name); + } + else + { + var referenceId = typeCollection.Where(t => + t.DisplayName == typeName.Name && + t.NodeId.NamespaceUri == typeName.Namespace).FirstOrDefault(); + if (referenceId == null) + { + // TODO: servers may have multiple dictionaries with different + // target namespace but types are stored for all in the same namespace. + // Find a way to find the right namespace here + referenceId = typeCollection.Where(t => + t.DisplayName == typeName.Name).FirstOrDefault(); + if (referenceId == null) + { + throw new ServiceResultException(StatusCodes.BadDataTypeIdUnknown, + $"The type {typeName.Name} in namespace {typeName.Namespace} was not found."); + } + } + return ExpandedNodeId.ToNodeId(referenceId.NodeId, namespaceTable); + } + } + #endregion + } +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeFactory.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeFactory.cs new file mode 100644 index 0000000000..d4a8598c38 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeFactory.cs @@ -0,0 +1,123 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Factory class for the complex type builder. + /// + public abstract class IComplexTypeFactory + { + /// + /// Create a new type builder instance for this factory. + /// + public abstract IComplexTypeBuilder Create( + string targetNamespace, + int targetNamespaceIndex, + string moduleName = null); + + /// + /// Types defined in the factory. + /// + public abstract Type[] GetTypes(); + } + + /// + /// Interface to dynamically build custom + /// enum types and structured types. + /// + public interface IComplexTypeBuilder + { + /// + /// Target namespace information. + /// + string TargetNamespace { get; } + int TargetNamespaceIndex { get; } + + /// + /// Create an enum type from a binary schema definition. + /// Available before OPC UA V1.04. + /// + Type AddEnumType(Schema.Binary.EnumeratedType enumeratedType); + + /// + /// Create an enum type from an EnumDefinition in an ExtensionObject. + /// Available since OPC UA V1.04 in the DataTypeDefinition attribute. + /// + Type AddEnumType(string typeName, ExtensionObject typeDefinition); + + /// + /// Create an enum type from an EnumValue property of a DataType node. + /// Available before OPC UA V1.04. + /// + Type AddEnumType(string typeName, ExtensionObject[] enumDefinition); + + /// + /// Create an enum type from the EnumString array of a DataType node. + /// Available before OPC UA V1.04. + /// + Type AddEnumType(string typeName, LocalizedText[] enumDefinition); + + /// + /// Create a complex type from a StructureDefinition. + /// Available since OPC UA V1.04 in the DataTypeDefinition attribute. + /// + IComplexTypeFieldBuilder AddStructuredType( + string name, + StructureDefinition structureDefinition); + } + + /// + /// Interface to build property fields. + /// + public interface IComplexTypeFieldBuilder + { + /// + /// Build the StructureTypeId attribute for a complex type. + /// + void AddTypeIdAttribute( + ExpandedNodeId complexTypeId, + ExpandedNodeId binaryEncodingId, + ExpandedNodeId xmlEncodingId + ); + + /// + /// Create a property field of a class with get and set. + /// + void AddField(StructureField field, Type fieldType, int order); + + /// + /// Finish the type creation and returns the new type. + /// + Type CreateType(); + } +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeProperties.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeProperties.cs new file mode 100644 index 0000000000..7fa83ac8af --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/IComplexTypeProperties.cs @@ -0,0 +1,139 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.Serialization; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Attribute for a complex type property. + /// + public class ComplexTypePropertyAttribute + { + public readonly PropertyInfo PropertyInfo; + public readonly StructureFieldAttribute FieldAttribute; + public readonly DataMemberAttribute DataAttribute; + + public ComplexTypePropertyAttribute( + PropertyInfo propertyInfo, + StructureFieldAttribute fieldAttribute, + DataMemberAttribute dataAttribute + ) + { + PropertyInfo = propertyInfo; + FieldAttribute = fieldAttribute; + DataAttribute = dataAttribute; + } + + /// + /// PropertyInfo + /// + public string Name => PropertyInfo.Name; + + /// + /// Get the value of a property. + /// + public object GetValue(object o) + { + return PropertyInfo.GetValue(o); + } + + /// + /// Set the value of a property. + /// + public void SetValue(object o, object v) + { + PropertyInfo.SetValue(o, v); + } + + /// + /// Type of property. + /// + public Type PropertyType => PropertyInfo.PropertyType; + + /// + /// StructureFieldAttribute + /// + public bool IsOptional => FieldAttribute.IsOptional; + public int ValueRank => FieldAttribute.ValueRank; + + /// + /// DataMemberAttribute + /// + public int Order => DataAttribute.Order; + + /// + /// Optional field mask of the property. + /// + public UInt32 OptionalFieldMask; + } + + /// + /// Interface to access properties of a complex type. + /// + public interface IComplexTypeProperties + { + /// + /// Get count of properties. + /// + int GetPropertyCount(); + + /// + /// Get ordered list of property names. + /// + IList GetPropertyNames(); + + /// + /// Get ordered list of property types. + /// + IList GetPropertyTypes(); + + /// + /// Access property values by index. + /// + object this[int index] { get; set; } + + /// + /// Access property values by name. + /// + object this[string name] { get; set; } + + /// + /// Ordered enumerator for properties. + /// + IEnumerable GetPropertyEnumerator(); + + } + + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Opc.Ua.Client.ComplexTypes.csproj b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Opc.Ua.Client.ComplexTypes.csproj new file mode 100644 index 0000000000..25a9e84bb9 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Opc.Ua.Client.ComplexTypes.csproj @@ -0,0 +1,30 @@ + + + + net46;netcoreapp2.0 + Opc.Ua.Client.ComplexTypes + 7 + Opc.Ua.Client.ComplexTypes + OPC UA Complex Types Client Class Library + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AssemblyModule.cs similarity index 56% rename from SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.cs rename to SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AssemblyModule.cs index 494721c2ba..8a78449a16 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.cs +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AssemblyModule.cs @@ -27,70 +27,54 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -namespace Opc.Ua.Client.Controls +using System; +using System.Reflection; +using System.Reflection.Emit; + +namespace Opc.Ua.Client.ComplexTypes { /// - /// A dialog to edit a date/time value + /// Use a single assembly and module builder instance to build the type system. /// - public partial class DateTimeValueEditDlg : Form + public class AssemblyModule { #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes the object with default values. /// - public DateTimeValueEditDlg() + public AssemblyModule(string assemblyName = null) { - InitializeComponent(); + m_assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly( + new AssemblyName(assemblyName ?? Guid.NewGuid().ToString()), + AssemblyBuilderAccess.Run); + m_moduleBuilder = m_assemblyBuilder.DefineDynamicModule(m_opcTypesModuleName); } #endregion - - #region Public Interface + + #region Public Members /// - /// Displays the dialog. + /// Get the module builder instance. /// - public bool ShowDialog(ref DateTime value) + public ModuleBuilder GetModuleBuilder() { - if (value < ValueCTRL.MinDate) - { - ValueCTRL.Value = ValueCTRL.MinDate; - } - else if (value > ValueCTRL.MaxDate) - { - ValueCTRL.Value = ValueCTRL.MaxDate; - } - else - { - ValueCTRL.Value = value; - } - - if (ShowDialog() != DialogResult.OK) - { - return false; - } - - value = ValueCTRL.Value; - - if (value == ValueCTRL.MinDate) - { - value = DateTime.MinValue; - } - - if (value == ValueCTRL.MaxDate) - { - value = DateTime.MaxValue; - } - - return true; + return m_moduleBuilder; } + + /// + /// Get the types defined in this assembly. + /// + public Type[] GetTypes() + { + return m_assemblyBuilder.GetTypes(); + } + #endregion + + #region Private Fields + AssemblyBuilder m_assemblyBuilder; + ModuleBuilder m_moduleBuilder; + private const string m_opcTypesModuleName = "Opc.Ua.ComplexTypes.Module"; #endregion } -} + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs new file mode 100644 index 0000000000..97ffce4771 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs @@ -0,0 +1,236 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.Serialization; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Extensions to build attributes for the complex type builder. + /// + public static class AttributeExtensions + { + #region Extensions + /// + /// Get the return type of an item in a collection. + /// + public static Type GetItemType(this Type collectionType) + { + return collectionType.GetMethod("get_Item").ReturnType; + } + + /// + /// Build the DataContract attribute for a complex type. + /// + public static void DataContractAttribute(this TypeBuilder builder, string Namespace) + { + var attribute = DataContractAttributeBuilder(Namespace); + builder.SetCustomAttribute(attribute); + } + + /// + /// Build the DataContract attribute for an enumeration type. + /// + public static void DataContractAttribute(this EnumBuilder builder, string Namespace) + { + var attribute = DataContractAttributeBuilder(Namespace); + builder.SetCustomAttribute(attribute); + } + + /// + /// Build the DataMember attribute for a complex type. + /// + public static void DataMemberAttribute(this PropertyBuilder typeBuilder, string name, bool isRequired, int order) + { + var attribute = DataMemberAttributeBuilder(name, isRequired, order); + typeBuilder.SetCustomAttribute(attribute); + } + + /// + /// Build the StructureDefiniton attribute for a complex type. + /// + public static void StructureDefinitonAttribute( + this TypeBuilder typeBuilder, + StructureDefinition structureDefinition) + { + var attributeType = typeof(StructureDefinitionAttribute); + var baseDataType = StructureDefinitionAttribute.FromBaseType(structureDefinition.BaseDataType); + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("DefaultEncodingId"), + attributeType.GetProperty("BaseDataType"), + attributeType.GetProperty("StructureType") + }, + new object[] // values to assign + { + structureDefinition.DefaultEncodingId.ToString(), + baseDataType, + structureDefinition.StructureType + }); + typeBuilder.SetCustomAttribute(builder); + } + + /// + /// Build the StructureTypeId attribute for a complex type. + /// + public static void StructureTypeIdAttribute( + this TypeBuilder typeBuilder, + ExpandedNodeId complexTypeId, + ExpandedNodeId binaryEncodingId, + ExpandedNodeId xmlEncodingId + ) + { + var attributeType = typeof(StructureTypeIdAttribute); + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("ComplexTypeId"), + attributeType.GetProperty("BinaryEncodingId"), + attributeType.GetProperty("XmlEncodingId") + }, + new object[] // values to assign + { + complexTypeId?.ToString(), + binaryEncodingId?.ToString(), + xmlEncodingId?.ToString() + }); + typeBuilder.SetCustomAttribute(builder); + } + + /// + /// Build the StructureField attribute for a complex type. + /// + public static void StructureFieldAttribute( + this PropertyBuilder typeBuilder, + StructureField structureField) + { + var attributeType = typeof(StructureFieldAttribute); + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("ValueRank"), + attributeType.GetProperty("MaxStringLength"), + attributeType.GetProperty("IsOptional") + }, + new object[] // values to assign + { + structureField.ValueRank, + structureField.MaxStringLength, + structureField.IsOptional + }); + typeBuilder.SetCustomAttribute(builder); + } + + /// + /// Build the EnumMember attribute for an enumeration type. + /// + public static void EnumMemberAttribute(this FieldBuilder typeBuilder, string Name, int Value) + { + var attributeType = typeof(EnumMemberAttribute); + Type[] ctorParams = new Type[] { typeof(string) }; + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("Value") + }, + new object[] // values to assign + { + Name+"_"+Value.ToString() + }); + typeBuilder.SetCustomAttribute(builder); + } + #endregion + + #region Private Static Members + /// + /// Build the DataMember attribute. + /// + private static CustomAttributeBuilder DataMemberAttributeBuilder(string name, bool isRequired, int order) + { + var attributeType = typeof(DataMemberAttribute); + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("Name"), + attributeType.GetProperty("IsRequired"), + attributeType.GetProperty("Order") + }, + new object[] // values to assign + { + name, + isRequired, + order + }); + return builder; + } + + /// + /// Build the DataContract attribute. + /// + private static CustomAttributeBuilder DataContractAttributeBuilder(string Namespace) + { + var attributeType = typeof(DataContractAttribute); + ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); + CustomAttributeBuilder builder = new CustomAttributeBuilder( + ctorInfo, + new object[0], // constructor arguments + new[] // properties to assign + { + attributeType.GetProperty("Namespace") + }, + new object[] // values to assign + { + Namespace + }); + return builder; + } + #endregion + + } +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeBuilder.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeBuilder.cs new file mode 100644 index 0000000000..88096da780 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeBuilder.cs @@ -0,0 +1,228 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Build an assembly with custom enum types and + /// complex types based on the BaseComplexType class + /// using System.Reflection.Emit. + /// + public class ComplexTypeBuilder : IComplexTypeBuilder + { + #region Constructors + /// + /// Initializes the object with default values. + /// + public ComplexTypeBuilder( + AssemblyModule moduleFactory, + string targetNamespace, + int targetNamespaceIndex, + string moduleName = null) + { + m_targetNamespace = targetNamespace; + m_targetNamespaceIndex = targetNamespaceIndex; + m_moduleName = FindModuleName(moduleName, targetNamespace, targetNamespaceIndex); + m_moduleBuilder = moduleFactory.GetModuleBuilder(); + } + #endregion + + #region Public Members + public string TargetNamespace => m_targetNamespace; + public int TargetNamespaceIndex => m_targetNamespaceIndex; + + /// + /// Create an enum type from a binary schema definition. + /// Available before OPC UA V1.04. + /// + public Type AddEnumType(Schema.Binary.EnumeratedType enumeratedType) + { + if (enumeratedType == null) + { + throw new ArgumentNullException(nameof(enumeratedType)); + } + var enumBuilder = m_moduleBuilder.DefineEnum( + GetFullQualifiedTypeName(enumeratedType.Name), + TypeAttributes.Public, + typeof(int)); + enumBuilder.DataContractAttribute(m_targetNamespace); + foreach (var enumValue in enumeratedType.EnumeratedValue) + { + var newEnum = enumBuilder.DefineLiteral(enumValue.Name, enumValue.Value); + newEnum.EnumMemberAttribute(enumValue.Name, enumValue.Value); + } + return enumBuilder.CreateTypeInfo(); + } + + /// + /// Create an enum type from an EnumDefinition in an ExtensionObject. + /// Available since OPC UA V1.04 in the DataTypeDefinition attribute. + /// + public Type AddEnumType(string typeName, ExtensionObject typeDefinition) + { + var enumDefinition = typeDefinition.Body as EnumDefinition; + if (enumDefinition == null) + { + throw new ArgumentNullException(nameof(typeDefinition)); + } + + var enumBuilder = m_moduleBuilder.DefineEnum( + GetFullQualifiedTypeName(typeName), + TypeAttributes.Public, + typeof(int)); + enumBuilder.DataContractAttribute(m_targetNamespace); + foreach (var enumValue in enumDefinition.Fields) + { + var newEnum = enumBuilder.DefineLiteral(enumValue.Name, (int)enumValue.Value); + newEnum.EnumMemberAttribute(enumValue.Name, (int)enumValue.Value); + } + return enumBuilder.CreateTypeInfo(); + } + + /// + /// Create an enum type from an EnumValue property of a DataType node. + /// Available before OPC UA V1.04. + /// + public Type AddEnumType(string typeName, ExtensionObject[] enumDefinition) + { + if (enumDefinition == null) + { + throw new ArgumentNullException(nameof(enumDefinition)); + } + + var enumBuilder = m_moduleBuilder.DefineEnum( + GetFullQualifiedTypeName(typeName), + TypeAttributes.Public, + typeof(int)); + enumBuilder.DataContractAttribute(m_targetNamespace); + foreach (var extensionObject in enumDefinition) + { + var enumValue = extensionObject.Body as EnumValueType; + var name = enumValue.DisplayName.Text; + var newEnum = enumBuilder.DefineLiteral(name, (int)enumValue.Value); + newEnum.EnumMemberAttribute(name, (int)enumValue.Value); + } + return enumBuilder.CreateTypeInfo(); + } + + /// + /// Create an enum type from the EnumString array of a DataType node. + /// Available before OPC UA V1.04. + /// + public Type AddEnumType(string typeName, LocalizedText[] enumDefinition) + { + if (enumDefinition == null) + { + throw new ArgumentNullException(nameof(enumDefinition)); + } + + var enumBuilder = m_moduleBuilder.DefineEnum( + GetFullQualifiedTypeName(typeName), + TypeAttributes.Public, + typeof(int)); + enumBuilder.DataContractAttribute(m_targetNamespace); + int value = 0; + foreach (var enumValue in enumDefinition) + { + var name = enumValue.Text; + var newEnum = enumBuilder.DefineLiteral(name, value); + newEnum.EnumMemberAttribute(name, value); + value++; + } + return enumBuilder.CreateTypeInfo(); + } + + /// + /// Create a complex type from a StructureDefinition. + /// Available since OPC UA V1.04 in the DataTypeDefinition attribute. + /// + public IComplexTypeFieldBuilder AddStructuredType( + string name, + StructureDefinition structureDefinition) + { + if (structureDefinition == null) + { + throw new ArgumentNullException(nameof(structureDefinition)); + } + Type baseType; + switch (structureDefinition.StructureType) + { + case StructureType.StructureWithOptionalFields: baseType = typeof(OptionalFieldsComplexType); break; + case StructureType.Union: baseType = typeof(UnionComplexType); break; + case StructureType.Structure: + default: baseType = typeof(BaseComplexType); break; + } + var structureBuilder = m_moduleBuilder.DefineType( + GetFullQualifiedTypeName(name), + TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Serializable, + baseType); + structureBuilder.DataContractAttribute(m_targetNamespace); + structureBuilder.StructureDefinitonAttribute(structureDefinition); + return new ComplexTypeFieldBuilder(structureBuilder, structureDefinition.StructureType); + } + #endregion + + #region Private Members + /// + /// Create a unique namespace module name for the type. + /// + private string FindModuleName(string moduleName, string targetNamespace, int targetNamespaceIndex) + { + if (String.IsNullOrWhiteSpace(moduleName)) + { + Uri uri = new Uri(targetNamespace); + string tempName = uri.AbsolutePath; + tempName = tempName.Replace("/", ""); + var splitName = tempName.Split(':'); + moduleName = splitName.Last(); + } + return moduleName; + } + + private string GetFullQualifiedTypeName(string name) + { + return "Opc.Ua.ComplexTypes." + m_moduleName + "." + name; + } + #endregion + + #region Private Fields + private ModuleBuilder m_moduleBuilder; + private string m_targetNamespace; + private string m_moduleName; + private int m_targetNamespaceIndex; + #endregion + } + +}//namespace diff --git a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.Designer.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFactory.cs similarity index 56% rename from SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.Designer.cs rename to SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFactory.cs index 73e539a269..8dc21c5dee 100644 --- a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.Designer.cs +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFactory.cs @@ -27,46 +27,48 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ -namespace Opc.Ua.Sample.Controls + +using System; + +namespace Opc.Ua.Client.ComplexTypes { - partial class GuiUtils2 + /// + /// Factory function for the default complex type builder + /// using classes created with Reflection.Emit. + /// + public class ComplexTypeBuilderFactory : + IComplexTypeFactory { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + AssemblyModule m_moduleFactory; - /// - /// Clean up any resources being used. + /// + /// Factory creates types in the assembly module. /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) + public ComplexTypeBuilderFactory(string assemblyName = null) { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); + m_moduleFactory = new AssemblyModule(assemblyName); } - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// + /// Create a new type builder which uses Reflection.Emit. /// - private void InitializeComponent() + public override IComplexTypeBuilder Create( + string targetNamespace, + int targetNamespaceIndex, + string moduleName = null) { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GuiUtils2)); - this.SuspendLayout(); - // - // GuiUtils - // - this.Name = "GuiUtils"; - this.ResumeLayout(false); - + return new ComplexTypeBuilder( + m_moduleFactory, targetNamespace, + targetNamespaceIndex, moduleName); + } + + /// + /// Return array of all types created in this factory. + /// + public override Type[] GetTypes() + { + return m_moduleFactory.GetTypes(); } - #endregion } -} + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFieldBuilder.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFieldBuilder.cs new file mode 100644 index 0000000000..4efd55deb0 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeFieldBuilder.cs @@ -0,0 +1,131 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Reflection; +using System.Reflection.Emit; + +namespace Opc.Ua.Client.ComplexTypes +{ + /// + /// Builder for property fields. + /// + public class ComplexTypeFieldBuilder : IComplexTypeFieldBuilder + { + #region Constructors + public ComplexTypeFieldBuilder( + TypeBuilder structureBuilder, + StructureType structureType) + { + m_structureBuilder = structureBuilder; + m_structureType = structureType; + } + #endregion + + #region Public Properties + /// + /// Build the StructureTypeId attribute for a complex type. + /// + public void AddTypeIdAttribute( + ExpandedNodeId complexTypeId, + ExpandedNodeId binaryEncodingId, + ExpandedNodeId xmlEncodingId + ) + { + m_structureBuilder.StructureTypeIdAttribute( + complexTypeId, + binaryEncodingId, + xmlEncodingId + ); + } + + /// + /// Create a property field of a class with get and set. + /// + public void AddField(StructureField field, Type fieldType, int order) + { + var fieldBuilder = m_structureBuilder.DefineField("_" + field.Name, fieldType, FieldAttributes.Private); + var propertyBuilder = m_structureBuilder.DefineProperty( + field.Name, + PropertyAttributes.None, + fieldType, + null); + var methodAttributes = + System.Reflection.MethodAttributes.Public | + System.Reflection.MethodAttributes.HideBySig | + System.Reflection.MethodAttributes.Virtual; + + var setBuilder = m_structureBuilder.DefineMethod("set_" + field.Name, methodAttributes, null, new[] { fieldType }); + var setIl = setBuilder.GetILGenerator(); + setIl.Emit(OpCodes.Ldarg_0); + setIl.Emit(OpCodes.Ldarg_1); + setIl.Emit(OpCodes.Stfld, fieldBuilder); + if (m_structureType == StructureType.Union) + { + // set the union selector to the new field index + FieldInfo unionField = typeof(UnionComplexType).GetField( + "m_switchField", + BindingFlags.NonPublic | + BindingFlags.Instance); + setIl.Emit(OpCodes.Ldarg_0); + setIl.Emit(OpCodes.Ldc_I4, order); + setIl.Emit(OpCodes.Stfld, unionField); + } + setIl.Emit(OpCodes.Ret); + + var getBuilder = m_structureBuilder.DefineMethod("get_" + field.Name, methodAttributes, fieldType, Type.EmptyTypes); + var getIl = getBuilder.GetILGenerator(); + getIl.Emit(OpCodes.Ldarg_0); + getIl.Emit(OpCodes.Ldfld, fieldBuilder); + getIl.Emit(OpCodes.Ret); + + propertyBuilder.SetGetMethod(getBuilder); + propertyBuilder.SetSetMethod(setBuilder); + propertyBuilder.DataMemberAttribute(field.Name, false, order); + propertyBuilder.StructureFieldAttribute(field); + } + + /// + /// Finish the type creation and returns the new type. + /// + public Type CreateType() + { + var complexType = m_structureBuilder.CreateType(); + m_structureBuilder = null; + return complexType; + } + #endregion + + #region Private Member + private TypeBuilder m_structureBuilder; + private StructureType m_structureType; + #endregion + } +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs new file mode 100644 index 0000000000..92db8680f2 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs @@ -0,0 +1,936 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using System.Text; +using System.Xml; + +namespace Opc.Ua.Client.ComplexTypes +{ + + public class BaseComplexType : + IEncodeable, IFormattable, IComplexTypeInstance, IComplexTypeProperties + { + #region Constructors + /// + /// Initializes the object with default values. + /// + public BaseComplexType() + { + TypeId = ExpandedNodeId.Null; + BinaryEncodingId = ExpandedNodeId.Null; + XmlEncodingId = ExpandedNodeId.Null; + m_context = MessageContextExtension.CurrentContext; + InitializePropertyAttributes(); + } + + /// + /// Initializes the object with a . + /// + /// The type to copy and create an instance from + public BaseComplexType(ExpandedNodeId typeId) + { + TypeId = typeId; + } + + [OnSerializing()] + private void UpdateContext(StreamingContext context) + { + m_context = MessageContextExtension.CurrentContext; + } + + /// + /// Initializes the object during deserialization. + /// + [OnDeserializing()] + private void Initialize(StreamingContext context) + { + TypeId = ExpandedNodeId.Null; + m_context = MessageContextExtension.CurrentContext; + } + #endregion + + #region Public Properties + /// + public ExpandedNodeId TypeId { get; set; } + + /// + public ExpandedNodeId BinaryEncodingId { get; set; } + + /// + public ExpandedNodeId XmlEncodingId { get; set; } + + /// + /// Makes a deep copy of the object. + /// + /// + /// A new object that is a copy of this instance. + /// + public new virtual object MemberwiseClone() + { + Type thisType = this.GetType(); + BaseComplexType clone = Activator.CreateInstance(thisType) as BaseComplexType; + + clone.TypeId = TypeId; + clone.BinaryEncodingId = BinaryEncodingId; + clone.XmlEncodingId = XmlEncodingId; + + // clone all properties of derived class + foreach (var property in GetPropertyEnumerator()) + { + property.SetValue(clone, Utils.Clone(property.GetValue(this))); + } + + return clone; + } + + /// + public virtual void Encode(IEncoder encoder) + { + encoder.PushNamespace(TypeId.NamespaceUri); + + foreach (var property in GetPropertyEnumerator()) + { + EncodeProperty(encoder, property.PropertyInfo, property.ValueRank); + } + + encoder.PopNamespace(); + } + + /// + public virtual void Decode(IDecoder decoder) + { + decoder.PushNamespace(TypeId.NamespaceUri); + + foreach (var property in GetPropertyEnumerator()) + { + DecodeProperty(decoder, property.PropertyInfo, property.ValueRank); + } + + decoder.PopNamespace(); + } + + /// + public virtual bool IsEqual(IEncodeable equalValue) + { + if (Object.ReferenceEquals(this, equalValue)) + { + return true; + } + + var valueBaseType = equalValue as BaseComplexType; + if (valueBaseType == null) + { + return false; + } + + var valueType = valueBaseType.GetType(); + if (this.GetType() != valueType) + { + return false; + } + + foreach (var property in GetPropertyEnumerator()) + { + if (!Utils.IsEqual(property.GetValue(this), property.GetValue(valueBaseType))) + { + return false; + } + } + + return true; + } + + /// + public override string ToString() + { + return ToString(null, null); + } + #endregion + + #region IFormattable Members + /// + /// Returns the string representation of the complex type. + /// + /// (Unused). Leave this as null + /// The provider of a mechanism for retrieving an object to control formatting. + /// + /// A containing the value of the current embeded instance in the specified format. + /// + /// Thrown if the format parameter is not null + public virtual string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + StringBuilder body = new StringBuilder(); + + foreach (var property in GetPropertyEnumerator()) + { + AppendPropertyValue(formatProvider, body, property.GetValue(this), property.ValueRank); + } + + if (body.Length > 0) + { + body.Append("}"); + return body.ToString(); + } + + if (!NodeId.IsNull(this.TypeId)) + { + return String.Format(formatProvider, "{{{0}}}", this.TypeId); + } + + return "(null)"; + } + + throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format)); + } + #endregion + + #region IComplexTypeProperties + /// + public virtual int GetPropertyCount() + { + return m_propertyList.Count; + } + + /// + public virtual IList GetPropertyNames() + { + return m_propertyList.Select(p => p.Name).ToList(); + } + + /// + public virtual IList GetPropertyTypes() + { + return m_propertyList.Select(p => p.PropertyType).ToList(); + } + + /// + /// Access property values by index. + /// + public virtual object this[int index] + { + get => m_propertyList.ElementAt(index).GetValue(this); + set => m_propertyList.ElementAt(index).SetValue(this, value); + } + + /// + /// Access property values by name. + /// + public virtual object this[string name] + { + get => m_propertyDict[name].GetValue(this); + set => m_propertyDict[name].SetValue(this, value); + } + + /// + /// Ordered enumerator for properties. + /// + public virtual IEnumerable GetPropertyEnumerator() + { + return m_propertyList; + } + #endregion + + #region Private Members + /// + /// Formatting helper. + /// + private void AddSeparator(StringBuilder body) + { + if (body.Length == 0) + { + body.Append("{"); + } + else + { + body.Append(" | "); + } + } + + /// + /// Append a property to the value string. + /// Handle arrays and enumerations. + /// + protected void AppendPropertyValue( + IFormatProvider formatProvider, + StringBuilder body, + object value, + int valueRank) + { + AddSeparator(body); + if (valueRank >= 0 && + value is IEnumerable) + { + bool first = true; + var enumerable = value as IEnumerable; + body.Append("["); + foreach (var item in enumerable) + { + if (!first) + { + body.Append(","); + } + AppendPropertyValue(formatProvider, body, item); + first = false; + } + body.Append("]"); + } + else + { + AppendPropertyValue(formatProvider, body, value); + } + } + + /// + /// Append a property to the value string. + /// + private void AppendPropertyValue( + IFormatProvider formatProvider, + StringBuilder body, + object value) + { + if (value is byte[]) + { + body.AppendFormat(formatProvider, "Byte[{0}]", ((byte[])value).Length); + return; + } + + if (value is XmlElement) + { + body.AppendFormat(formatProvider, "<{0}>", ((XmlElement)value).Name); + return; + } + + body.AppendFormat("{0}", value); + } + + /// + /// Encode a property based on the property type and value rank. + /// + protected void EncodeProperty(IEncoder encoder, PropertyInfo property, int valueRank) + { + if (valueRank < 0) + { + EncodeProperty(encoder, property); + } + else + { + EncodePropertyArray(encoder, property); + } + } + + /// + /// Encode a scalar property based on the property type. + /// + private void EncodeProperty(IEncoder encoder, PropertyInfo property) + { + var propertyType = property.PropertyType; + if (propertyType == typeof(Boolean)) + { + encoder.WriteBoolean(property.Name, (Boolean)property.GetValue(this)); + } + else if (propertyType == typeof(SByte)) + { + encoder.WriteSByte(property.Name, (SByte)property.GetValue(this)); + } + else if (propertyType == typeof(Byte)) + { + encoder.WriteByte(property.Name, (Byte)property.GetValue(this)); + } + else if (propertyType == typeof(Int16)) + { + encoder.WriteInt16(property.Name, (Int16)property.GetValue(this)); + } + else if (propertyType == typeof(UInt16)) + { + encoder.WriteUInt16(property.Name, (UInt16)property.GetValue(this)); + } + else if (propertyType.IsEnum) + { + encoder.WriteEnumerated(property.Name, (Enum)property.GetValue(this)); + } + else if (propertyType == typeof(Int32)) + { + encoder.WriteInt32(property.Name, (Int32)property.GetValue(this)); + } + else if (propertyType == typeof(UInt32)) + { + encoder.WriteUInt32(property.Name, (UInt32)property.GetValue(this)); + } + else if (propertyType == typeof(Int64)) + { + encoder.WriteInt64(property.Name, (Int64)property.GetValue(this)); + } + else if (propertyType == typeof(UInt64)) + { + encoder.WriteUInt64(property.Name, (UInt64)property.GetValue(this)); + } + else if (propertyType == typeof(Single)) + { + encoder.WriteFloat(property.Name, (Single)property.GetValue(this)); + } + else if (propertyType == typeof(Double)) + { + encoder.WriteDouble(property.Name, (Double)property.GetValue(this)); + } + else if (propertyType == typeof(String)) + { + encoder.WriteString(property.Name, (String)property.GetValue(this)); + } + else if (propertyType == typeof(DateTime)) + { + encoder.WriteDateTime(property.Name, (DateTime)property.GetValue(this)); + } + else if (propertyType == typeof(Uuid)) + { + encoder.WriteGuid(property.Name, (Uuid)property.GetValue(this)); + } + else if (propertyType == typeof(Byte[])) + { + encoder.WriteByteArray(property.Name, (Byte[])property.GetValue(this)); + } + else if (propertyType == typeof(XmlElement)) + { + encoder.WriteXmlElement(property.Name, (XmlElement)property.GetValue(this)); + } + else if (propertyType == typeof(NodeId)) + { + encoder.WriteNodeId(property.Name, (NodeId)property.GetValue(this)); + } + else if (propertyType == typeof(ExpandedNodeId)) + { + encoder.WriteExpandedNodeId(property.Name, (ExpandedNodeId)property.GetValue(this)); + } + else if (propertyType == typeof(StatusCode)) + { + encoder.WriteStatusCode(property.Name, (StatusCode)property.GetValue(this)); + } + else if (propertyType == typeof(DiagnosticInfo)) + { + encoder.WriteDiagnosticInfo(property.Name, (DiagnosticInfo)property.GetValue(this)); + } + else if (propertyType == typeof(QualifiedName)) + { + encoder.WriteQualifiedName(property.Name, (QualifiedName)property.GetValue(this)); + } + else if (propertyType == typeof(LocalizedText)) + { + encoder.WriteLocalizedText(property.Name, (LocalizedText)property.GetValue(this)); + } + else if (propertyType == typeof(DataValue)) + { + encoder.WriteDataValue(property.Name, (DataValue)property.GetValue(this)); + } + else if (propertyType == typeof(Variant)) + { + encoder.WriteVariant(property.Name, (Variant)property.GetValue(this)); + } + else if (propertyType == typeof(ExtensionObject)) + { + encoder.WriteExtensionObject(property.Name, (ExtensionObject)property.GetValue(this)); + } + else if (typeof(IEncodeable).IsAssignableFrom(propertyType)) + { + encoder.WriteEncodeable(property.Name, (IEncodeable)property.GetValue(this), propertyType); + } + else + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + $"Unknown type {propertyType} to encode."); + } + } + + /// + /// Encode an array property based on the base property type. + /// + private void EncodePropertyArray(IEncoder encoder, PropertyInfo property) + { + var elementType = property.PropertyType.GetElementType(); + if (elementType == null) + { + elementType = property.PropertyType.GetItemType(); + } + if (elementType == typeof(Boolean)) + { + encoder.WriteBooleanArray(property.Name, (BooleanCollection)property.GetValue(this)); + } + else if (elementType == typeof(SByte)) + { + encoder.WriteSByteArray(property.Name, (SByteCollection)property.GetValue(this)); + } + else if (elementType == typeof(Byte)) + { + encoder.WriteByteArray(property.Name, (ByteCollection)property.GetValue(this)); + } + else if (elementType == typeof(Int16)) + { + encoder.WriteInt16Array(property.Name, (Int16Collection)property.GetValue(this)); + } + else if (elementType == typeof(UInt16)) + { + encoder.WriteUInt16Array(property.Name, (UInt16Collection)property.GetValue(this)); + } + else if (elementType == typeof(Int32)) + { + encoder.WriteInt32Array(property.Name, (Int32Collection)property.GetValue(this)); + } + else if (elementType.IsEnum) + { + encoder.WriteEnumeratedArray(property.Name, (Array)property.GetValue(this), elementType); + } + else if (elementType == typeof(UInt32)) + { + encoder.WriteUInt32Array(property.Name, (UInt32Collection)property.GetValue(this)); + } + else if (elementType == typeof(Int64)) + { + encoder.WriteInt64Array(property.Name, (Int64Collection)property.GetValue(this)); + } + else if (elementType == typeof(UInt64)) + { + encoder.WriteUInt64Array(property.Name, (UInt64Collection)property.GetValue(this)); + } + else if (elementType == typeof(Single)) + { + encoder.WriteFloatArray(property.Name, (FloatCollection)property.GetValue(this)); + } + else if (elementType == typeof(Double)) + { + encoder.WriteDoubleArray(property.Name, (DoubleCollection)property.GetValue(this)); + } + else if (elementType == typeof(String)) + { + encoder.WriteStringArray(property.Name, (StringCollection)property.GetValue(this)); + } + else if (elementType == typeof(DateTime)) + { + encoder.WriteDateTimeArray(property.Name, (DateTimeCollection)property.GetValue(this)); + } + else if (elementType == typeof(Uuid)) + { + encoder.WriteGuidArray(property.Name, (UuidCollection)property.GetValue(this)); + } + else if (elementType == typeof(Byte[])) + { + encoder.WriteByteStringArray(property.Name, (ByteStringCollection)property.GetValue(this)); + } + else if (elementType == typeof(XmlElement)) + { + encoder.WriteXmlElementArray(property.Name, (XmlElementCollection)property.GetValue(this)); + } + else if (elementType == typeof(NodeId)) + { + encoder.WriteNodeIdArray(property.Name, (NodeIdCollection)property.GetValue(this)); + } + else if (elementType == typeof(ExpandedNodeId)) + { + encoder.WriteExpandedNodeIdArray(property.Name, (ExpandedNodeIdCollection)property.GetValue(this)); + } + else if (elementType == typeof(StatusCode)) + { + encoder.WriteStatusCodeArray(property.Name, (StatusCodeCollection)property.GetValue(this)); + } + else if (elementType == typeof(DiagnosticInfo)) + { + encoder.WriteDiagnosticInfoArray(property.Name, (DiagnosticInfoCollection)property.GetValue(this)); + } + else if (elementType == typeof(QualifiedName)) + { + encoder.WriteQualifiedNameArray(property.Name, (QualifiedNameCollection)property.GetValue(this)); + } + else if (elementType == typeof(LocalizedText)) + { + encoder.WriteLocalizedTextArray(property.Name, (LocalizedTextCollection)property.GetValue(this)); + } + else if (elementType == typeof(DataValue)) + { + encoder.WriteDataValueArray(property.Name, (DataValueCollection)property.GetValue(this)); + } + else if (elementType == typeof(Variant)) + { + encoder.WriteVariantArray(property.Name, (VariantCollection)property.GetValue(this)); + } + else if (elementType == typeof(ExtensionObject)) + { + encoder.WriteExtensionObjectArray(property.Name, (ExtensionObjectCollection)property.GetValue(this)); + } + else if (typeof(IEncodeable).IsAssignableFrom(elementType)) + { + var value = property.GetValue(this); + IEncodeableCollection encodable = value as IEncodeableCollection; + if (encodable == null) + { + encodable = IEncodeableCollection.ToIEncodeableCollection(value as IEncodeable[]); + } + encoder.WriteEncodeableArray(property.Name, encodable.ToArray(), property.PropertyType); + } + else + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + $"Unknown type {elementType} to encode."); + } + } + + /// + /// Decode a property based on the property type and value rank. + /// + protected void DecodeProperty(IDecoder decoder, PropertyInfo property, int valueRank) + { + if (valueRank < 0) + { + DecodeProperty(decoder, property); + } + else + { + DecodePropertyArray(decoder, property); + } + } + + /// + /// Decode a scalar property based on the property type. + /// + private void DecodeProperty(IDecoder decoder, PropertyInfo property) + { + var propertyType = property.PropertyType; + if (propertyType == typeof(Boolean)) + { + property.SetValue(this, decoder.ReadBoolean(property.Name)); + } + else if (propertyType == typeof(SByte)) + { + property.SetValue(this, decoder.ReadSByte(property.Name)); + } + else if (propertyType == typeof(Byte)) + { + property.SetValue(this, decoder.ReadByte(property.Name)); + } + else if (propertyType == typeof(Int16)) + { + property.SetValue(this, decoder.ReadInt16(property.Name)); + } + else if (propertyType == typeof(UInt16)) + { + property.SetValue(this, decoder.ReadUInt16(property.Name)); + } + else if (propertyType.IsEnum) + { + property.SetValue(this, decoder.ReadEnumerated(property.Name, propertyType)); + } + else if (propertyType == typeof(Int32)) + { + property.SetValue(this, decoder.ReadInt32(property.Name)); + } + else if (propertyType == typeof(UInt32)) + { + property.SetValue(this, decoder.ReadUInt32(property.Name)); + } + else if (propertyType == typeof(Int64)) + { + property.SetValue(this, decoder.ReadInt64(property.Name)); + } + else if (propertyType == typeof(UInt64)) + { + property.SetValue(this, decoder.ReadUInt64(property.Name)); + } + else if (propertyType == typeof(Single)) + { + property.SetValue(this, decoder.ReadFloat(property.Name)); + } + else if (propertyType == typeof(Double)) + { + property.SetValue(this, decoder.ReadDouble(property.Name)); + } + else if (propertyType == typeof(String)) + { + property.SetValue(this, decoder.ReadString(property.Name)); + } + else if (propertyType == typeof(DateTime)) + { + property.SetValue(this, decoder.ReadDateTime(property.Name)); + } + else if (propertyType == typeof(Uuid)) + { + property.SetValue(this, decoder.ReadGuid(property.Name)); + } + else if (propertyType == typeof(Byte[])) + { + property.SetValue(this, decoder.ReadByteString(property.Name)); + } + else if (propertyType == typeof(XmlElement)) + { + property.SetValue(this, decoder.ReadXmlElement(property.Name)); + } + else if (propertyType == typeof(NodeId)) + { + property.SetValue(this, decoder.ReadNodeId(property.Name)); + } + else if (propertyType == typeof(ExpandedNodeId)) + { + property.SetValue(this, decoder.ReadExpandedNodeId(property.Name)); + } + else if (propertyType == typeof(StatusCode)) + { + property.SetValue(this, decoder.ReadStatusCode(property.Name)); + } + else if (propertyType == typeof(DiagnosticInfo)) + { + property.SetValue(this, decoder.ReadDiagnosticInfo(property.Name)); + } + else if (propertyType == typeof(QualifiedName)) + { + property.SetValue(this, decoder.ReadQualifiedName(property.Name)); + } + else if (propertyType == typeof(LocalizedText)) + { + property.SetValue(this, decoder.ReadLocalizedText(property.Name)); + } + else if (propertyType == typeof(DataValue)) + { + property.SetValue(this, decoder.ReadDataValue(property.Name)); + } + else if (propertyType == typeof(Variant)) + { + property.SetValue(this, decoder.ReadVariant(property.Name)); + } + else if (propertyType == typeof(ExtensionObject)) + { + property.SetValue(this, decoder.ReadExtensionObject(property.Name)); + } + else if (typeof(IEncodeable).IsAssignableFrom(propertyType)) + { + property.SetValue(this, decoder.ReadEncodeable(property.Name, propertyType)); + } + else + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + $"Unknown type {propertyType} to decode."); + } + } + + /// + /// Decode an array property based on the base property type. + /// + private void DecodePropertyArray(IDecoder decoder, PropertyInfo property) + { + var elementType = property.PropertyType.GetElementType(); + if (elementType == null) + { + elementType = property.PropertyType.GetItemType(); + } + if (elementType == typeof(Boolean)) + { + property.SetValue(this, decoder.ReadBooleanArray(property.Name)); + } + else if (elementType == typeof(SByte)) + { + property.SetValue(this, decoder.ReadSByteArray(property.Name)); + } + else if (elementType == typeof(Byte)) + { + property.SetValue(this, decoder.ReadByteArray(property.Name)); + } + else if (elementType == typeof(Int16)) + { + property.SetValue(this, decoder.ReadInt16Array(property.Name)); + } + else if (elementType == typeof(UInt16)) + { + property.SetValue(this, decoder.ReadUInt16Array(property.Name)); + } + else if (elementType.IsEnum) + { + property.SetValue(this, decoder.ReadEnumeratedArray(property.Name, elementType)); + } + else if (elementType == typeof(Int32)) + { + property.SetValue(this, decoder.ReadInt32Array(property.Name)); + } + else if (elementType == typeof(UInt32)) + { + property.SetValue(this, decoder.ReadUInt32Array(property.Name)); + } + else if (elementType == typeof(Int64)) + { + property.SetValue(this, decoder.ReadInt64Array(property.Name)); + } + else if (elementType == typeof(UInt64)) + { + property.SetValue(this, decoder.ReadUInt64Array(property.Name)); + } + else if (elementType == typeof(Single)) + { + property.SetValue(this, decoder.ReadFloatArray(property.Name)); + } + else if (elementType == typeof(Double)) + { + property.SetValue(this, decoder.ReadDoubleArray(property.Name)); + } + else if (elementType == typeof(String)) + { + property.SetValue(this, decoder.ReadStringArray(property.Name)); + } + else if (elementType == typeof(DateTime)) + { + property.SetValue(this, decoder.ReadDateTimeArray(property.Name)); + } + else if (elementType == typeof(Uuid)) + { + property.SetValue(this, decoder.ReadGuidArray(property.Name)); + } + else if (elementType == typeof(Byte[])) + { + property.SetValue(this, decoder.ReadByteStringArray(property.Name)); + } + else if (elementType == typeof(XmlElement)) + { + property.SetValue(this, decoder.ReadXmlElementArray(property.Name)); + } + else if (elementType == typeof(NodeId)) + { + property.SetValue(this, decoder.ReadNodeIdArray(property.Name)); + } + else if (elementType == typeof(ExpandedNodeId)) + { + property.SetValue(this, decoder.ReadExpandedNodeIdArray(property.Name)); + } + else if (elementType == typeof(StatusCode)) + { + property.SetValue(this, decoder.ReadStatusCodeArray(property.Name)); + } + else if (elementType == typeof(DiagnosticInfo)) + { + property.SetValue(this, decoder.ReadDiagnosticInfoArray(property.Name)); + } + else if (elementType == typeof(QualifiedName)) + { + property.SetValue(this, decoder.ReadQualifiedNameArray(property.Name)); + } + else if (elementType == typeof(LocalizedText)) + { + property.SetValue(this, decoder.ReadLocalizedTextArray(property.Name)); + } + else if (elementType == typeof(DataValue)) + { + property.SetValue(this, decoder.ReadDataValueArray(property.Name)); + } + else if (elementType == typeof(Variant)) + { + property.SetValue(this, decoder.ReadVariantArray(property.Name)); + } + else if (elementType == typeof(ExtensionObject)) + { + property.SetValue(this, decoder.ReadExtensionObjectArray(property.Name)); + } + else if (typeof(IEncodeable).IsAssignableFrom(elementType)) + { + property.SetValue(this, decoder.ReadEncodeableArray(property.Name, elementType)); + } + else + { + throw new ServiceResultException(StatusCodes.BadNotSupported, + $"Unknown type {elementType} to decode."); + } + } + + /// + /// Helper to determine the use of reversible encoding. + /// + protected bool GetUseReversibleEncoding(IEncoder encoder) + { + JsonEncoder jsonEncoder = encoder as JsonEncoder; + if (jsonEncoder != null) + { + return jsonEncoder.UseReversibleEncoding; + } + return true; + } + + /// + /// Initialize the helpers for property enumerator and dictionary. + /// + protected virtual void InitializePropertyAttributes() + { + var definitionAttribute = (StructureDefinitionAttribute) + GetType().GetCustomAttribute(typeof(StructureDefinitionAttribute)); + if (definitionAttribute != null) + { + m_structureBaseType = definitionAttribute.BaseDataType; + } + + var typeAttribute = (StructureTypeIdAttribute) + GetType().GetCustomAttribute(typeof(StructureTypeIdAttribute)); + if (typeAttribute != null) + { + TypeId = ExpandedNodeId.Parse(typeAttribute.ComplexTypeId); + BinaryEncodingId = ExpandedNodeId.Parse(typeAttribute.BinaryEncodingId); + XmlEncodingId = ExpandedNodeId.Parse(typeAttribute.XmlEncodingId); + } + + m_propertyList = new List(); + var properties = GetType().GetProperties(); + foreach (var property in properties) + { + StructureFieldAttribute fieldAttribute = (StructureFieldAttribute) + property.GetCustomAttribute(typeof(StructureFieldAttribute)); + + if (fieldAttribute == null) + { + continue; + } + + DataMemberAttribute dataAttribute = (DataMemberAttribute) + property.GetCustomAttribute(typeof(DataMemberAttribute)); + + var newProperty = new ComplexTypePropertyAttribute(property, fieldAttribute, dataAttribute); + + m_propertyList.Add(newProperty); + } + m_propertyList = m_propertyList.OrderBy(p => p.Order).ToList(); + m_propertyDict = m_propertyList.ToDictionary(p => p.Name, p => p); + } + #endregion + + #region Private Fields + private ServiceMessageContext m_context; + private StructureBaseDataType m_structureBaseType; + protected IList m_propertyList; + protected Dictionary m_propertyDict; + #endregion + } + + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs new file mode 100644 index 0000000000..6e63b6e196 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs @@ -0,0 +1,317 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Opc.Ua.Client.ComplexTypes +{ + public class OptionalFieldsComplexType : BaseComplexType + { + #region Constructors + /// + /// Initializes the object with default values. + /// + public OptionalFieldsComplexType() + { + m_encodingMask = 0; + } + + /// + /// Initializes the object with a . + /// + /// The type to copy and create an instance from + public OptionalFieldsComplexType(ExpandedNodeId typeId) : base(typeId) + { + m_encodingMask = 0; + } + #endregion + + #region Public Properties + + UInt32 EncodingMask => m_encodingMask; + + /// + /// Makes a deep copy of the object. + /// + /// + /// A new object that is a copy of this instance. + /// + public override object MemberwiseClone() + { + OptionalFieldsComplexType clone = (OptionalFieldsComplexType)base.MemberwiseClone(); + clone.m_encodingMask = m_encodingMask; + return clone; + } + + /// + public override void Encode(IEncoder encoder) + { + bool useReversibleEncoding = GetUseReversibleEncoding(encoder); + + encoder.PushNamespace(TypeId.NamespaceUri); + + if (useReversibleEncoding) + { + encoder.WriteUInt32("EncodingMask", m_encodingMask); + } + + foreach (var property in GetPropertyEnumerator()) + { + if (property.IsOptional) + { + if ((property.OptionalFieldMask & m_encodingMask) == 0) + { + continue; + } + } + + EncodeProperty(encoder, property.PropertyInfo, property.ValueRank); + } + encoder.PopNamespace(); + } + + /// + public override void Decode(IDecoder decoder) + { + decoder.PushNamespace(TypeId.NamespaceUri); + + m_encodingMask = decoder.ReadUInt32("EncodingMask"); + + foreach (var property in GetPropertyEnumerator()) + { + if (property.IsOptional) + { + if ((property.OptionalFieldMask & m_encodingMask) == 0) + { + continue; + } + } + + DecodeProperty(decoder, property.PropertyInfo, property.ValueRank); + } + decoder.PopNamespace(); + } + + /// + public override bool IsEqual(IEncodeable equalValue) + { + if (Object.ReferenceEquals(this, equalValue)) + { + return true; + } + + var valueBaseType = equalValue as OptionalFieldsComplexType; + if (valueBaseType == null) + { + return false; + } + + if (m_encodingMask != valueBaseType.EncodingMask) + { + return false; + } + + var valueType = valueBaseType.GetType(); + if (this.GetType() != valueType) + { + return false; + } + + foreach (var property in GetPropertyEnumerator()) + { + if (property.IsOptional) + { + if ((property.OptionalFieldMask & m_encodingMask) == 0) + { + continue; + } + } + + if (!Utils.IsEqual(property.GetValue(this), property.GetValue(valueBaseType))) + { + return false; + } + } + + return true; + } + #endregion + + #region IFormattable Members + /// + /// Returns the string representation of the complex type. + /// + /// (Unused). Leave this as null + /// The provider of a mechanism for retrieving an object to control formatting. + /// + /// A containing the value of the current embeded instance in the specified format. + /// + /// Thrown if the format parameter is not null + public override string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + StringBuilder body = new StringBuilder(); + foreach (var property in GetPropertyEnumerator()) + { + if (property.IsOptional) + { + if ((property.OptionalFieldMask & m_encodingMask) == 0) + { + continue; + } + } + + AppendPropertyValue(formatProvider, body, property.GetValue(this), property.ValueRank); + } + + if (body.Length > 0) + { + body.Append("}"); + return body.ToString(); + } + + if (!NodeId.IsNull(this.TypeId)) + { + return String.Format(formatProvider, "{{{0}}}", this.TypeId); + } + + return "(null)"; + } + + throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format)); + } + #endregion + + #region IComplexTypeProperties Members + /// + /// Access property values by index. + /// + public override object this[int index] + { + get + { + var property = m_propertyList.ElementAt(index); + if (property.IsOptional && + (property.OptionalFieldMask & m_encodingMask) == 0) + { + return null; + } + return property.GetValue(this); + } + set + { + var property = m_propertyList.ElementAt(index); + property.SetValue(this, value); + if (property.IsOptional) + { + if (value == null) + { + m_encodingMask &= ~property.OptionalFieldMask; + } + else + { + m_encodingMask |= property.OptionalFieldMask; + } + } + } + } + + /// + /// Access property values by name. + /// + public override object this[string name] + { + get + { + ComplexTypePropertyAttribute property; + if (m_propertyDict.TryGetValue(name, out property)) + { + if (property.IsOptional && + (property.OptionalFieldMask & m_encodingMask) == 0) + { + return null; + } + return property.GetValue(this); + } + throw new KeyNotFoundException(); + } + set + { + ComplexTypePropertyAttribute property; + if (m_propertyDict.TryGetValue(name, out property)) + { + property.SetValue(this, value); + if (value == null) + { + m_encodingMask &= ~property.OptionalFieldMask; + } + else + { + m_encodingMask |= property.OptionalFieldMask; + } + } + else + { + throw new KeyNotFoundException(); + } + } + } + #endregion + + #region Private Members + protected override void InitializePropertyAttributes() + { + base.InitializePropertyAttributes(); + + // build optional field mask attribute + UInt32 optionalFieldMask = 1; + foreach (var property in GetPropertyEnumerator()) + { + property.OptionalFieldMask = 0; + if (property.IsOptional) + { + property.OptionalFieldMask = optionalFieldMask; + optionalFieldMask <<= 1; + } + } + } + #endregion + + #region Private Fields + protected UInt32 m_encodingMask; + #endregion + } + + +}//namespace diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureDefinitionAttribute.cs similarity index 60% rename from SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.cs rename to SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureDefinitionAttribute.cs index cfb0fef1f9..cad5cbd515 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.cs +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureDefinitionAttribute.cs @@ -27,59 +27,49 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -namespace Opc.Ua.Client.Controls +using System; + +namespace Opc.Ua.Client.ComplexTypes { + + public enum StructureBaseDataType + { + Structure, + OptionSet, + Union + } + /// - /// A dialog to edit a string value. + /// Attribute for a base complex type structure definition. /// - public partial class StringValueEditDlg : Form + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public class StructureDefinitionAttribute : Attribute { #region Constructors - /// - /// Initializes a new instance of the class. - /// - public StringValueEditDlg() + public StructureDefinitionAttribute() { - InitializeComponent(); + StructureType = StructureType.Structure; } #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public string ShowDialog(string value) + #region Public Methods + public static StructureBaseDataType FromBaseType(NodeId baseTypeId) { - ValueTB.Text = value; - - if (value != null) + if (baseTypeId == DataTypeIds.Union) { - int length = value.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).Length; - - if (length > 20) - { - length = 20; - } - - this.Height += (length-1)*16; + return StructureBaseDataType.Union; } - - if (ShowDialog() != DialogResult.OK) + if (baseTypeId == DataTypeIds.OptionSet) { - return null; + return StructureBaseDataType.OptionSet; } - - return ValueTB.Text; + return StructureBaseDataType.Structure; } #endregion + #region Public Properties + public string DefaultEncodingId { get; set; } + public StructureBaseDataType BaseDataType { get; set; } + public StructureType StructureType { get; set; } + #endregion } -} +}//namespace diff --git a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureFieldAttribute.cs similarity index 50% rename from SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.cs rename to SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureFieldAttribute.cs index 405419caac..5d868ffb3d 100644 --- a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.cs +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureFieldAttribute.cs @@ -27,66 +27,31 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -using Opc.Ua.Client; - -namespace Opc.Ua.Sample.Controls +namespace Opc.Ua.Client.ComplexTypes { - public partial class NodeIdValueEditDlg : Form + /// + /// Attribute for a base complex type field definition. + /// + + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public class StructureFieldAttribute : Attribute { #region Constructors - public NodeIdValueEditDlg() + public StructureFieldAttribute() { - InitializeComponent(); + ValueRank = -1; + MaxStringLength = 0; + IsOptional = false; } #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public NodeId ShowDialog(Session session, NodeId value) - { - if (session == null) throw new ArgumentNullException("session"); - ValueCTRL.Browser = new Browser(session); - ValueCTRL.RootId = Objects.RootFolder; - ValueCTRL.Identifier = value; - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return ValueCTRL.Identifier; - } - - /// - /// Displays the dialog. - /// - public ExpandedNodeId ShowDialog(Session session, ExpandedNodeId value) - { - if (session == null) throw new ArgumentNullException("session"); - - ValueCTRL.Browser = new Browser(session); - ValueCTRL.RootId = Objects.RootFolder; - ValueCTRL.Identifier = ExpandedNodeId.ToNodeId(value, session.NamespaceUris); - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return ValueCTRL.Identifier; - } + #region Public Properties + public Int32 ValueRank { get; set; } + public UInt32 MaxStringLength { get; set; } + public bool IsOptional { get; set; } #endregion } -} +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureTypeAttribute.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureTypeAttribute.cs new file mode 100644 index 0000000000..ede8f9abd1 --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/StructureTypeAttribute.cs @@ -0,0 +1,48 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; + +namespace Opc.Ua.Client.ComplexTypes +{ + + /// + /// Attribute for type ids of a structure definition. + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public class StructureTypeIdAttribute : Attribute + { + #region Public Properties + public string ComplexTypeId { get; set; } + public string BinaryEncodingId { get; set; } + public string XmlEncodingId { get; set; } + #endregion + } +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs new file mode 100644 index 0000000000..67ab328e7c --- /dev/null +++ b/SampleApplications/SDK/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs @@ -0,0 +1,329 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace Opc.Ua.Client.ComplexTypes +{ + public class UnionComplexType : BaseComplexType + { + #region Constructors + /// + /// Initializes the object with default values. + /// + public UnionComplexType() : base() + { + m_switchField = 0; + } + + /// + /// Initializes the object with a . + /// + /// The type to copy and create an instance from + public UnionComplexType(ExpandedNodeId typeId) : base(typeId) + { + m_switchField = 0; + } + #endregion + + #region Public Properties + /// + /// The union selector determines which property is valid. + /// A value of 0 means all properties are invalid, x=1..n means the + /// xth property is valid. + /// + UInt32 SwitchField => m_switchField; + + /// + /// Makes a deep copy of the object. + /// + /// + /// A new object that is a copy of this instance. + /// + public override object MemberwiseClone() + { + UnionComplexType clone = (UnionComplexType)base.MemberwiseClone(); + clone.m_switchField = m_switchField; + return clone; + } + + /// + public override void Encode(IEncoder encoder) + { + bool useReversibleEncoding = GetUseReversibleEncoding(encoder); + + encoder.PushNamespace(TypeId.NamespaceUri); + + if (useReversibleEncoding) + { + encoder.WriteUInt32("SwitchField", m_switchField); + } + + if (m_switchField != 0) + { + int unionSelector = 1; + int valueRank = -1; + PropertyInfo unionProperty = null; + foreach (var property in GetPropertyEnumerator()) + { + if (unionSelector == m_switchField) + { + valueRank = property.ValueRank; + unionProperty = property.PropertyInfo; + break; + } + unionSelector++; + } + EncodeProperty(encoder, unionProperty, valueRank); + } + + encoder.PopNamespace(); + } + + /// + public override void Decode(IDecoder decoder) + { + decoder.PushNamespace(TypeId.NamespaceUri); + + m_switchField = decoder.ReadUInt32("SwitchField"); + + UInt32 unionSelector = m_switchField; + if (unionSelector > 0) + { + foreach (var property in GetPropertyEnumerator()) + { + if (--unionSelector == 0) + { + DecodeProperty(decoder, property.PropertyInfo, property.ValueRank); + break; + } + } + } + decoder.PopNamespace(); + } + + /// + public override bool IsEqual(IEncodeable equalValue) + { + if (Object.ReferenceEquals(this, equalValue)) + { + return true; + } + + var valueBaseType = equalValue as UnionComplexType; + if (valueBaseType == null) + { + return false; + } + + if (SwitchField != valueBaseType.SwitchField) + { + return false; + } + + var valueType = valueBaseType.GetType(); + if (this.GetType() != valueType) + { + return false; + } + + if (m_switchField != 0) + { + UInt32 unionSelector = m_switchField; + foreach (var property in GetPropertyEnumerator()) + { + if (--unionSelector == 0) + { + if (!Utils.IsEqual(property.GetValue(this), property.GetValue(valueBaseType))) + { + return false; + } + break; + } + } + } + return true; + } + #endregion + + #region IFormattable Members + /// + /// Returns the string representation of the complex type. + /// + /// (Unused). Leave this as null + /// The provider of a mechanism for retrieving an object to control formatting. + /// + /// A containing the value of the current embeded instance in the specified format. + /// + /// Thrown if the format parameter is not null + public override string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + StringBuilder body = new StringBuilder(); + if (m_switchField != 0) + { + UInt32 unionSelector = m_switchField; + foreach (var property in GetPropertyEnumerator()) + { + if (--unionSelector == 0) + { + object unionProperty = property.GetValue(this); + AppendPropertyValue(formatProvider, body, unionProperty, property.ValueRank); + break; + } + } + } + + if (body.Length > 0) + { + body.Append("}"); + return body.ToString(); + } + + if (!NodeId.IsNull(this.TypeId)) + { + return String.Format(formatProvider, "{{{0}}}", this.TypeId); + } + + return "(null)"; + } + + throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format)); + } + #endregion + + #region IComplexTypeProperties Members + /// + /// Access property values by index. + /// + /// + /// The value of a Union is determined by the union selector. + /// Calling get on an unselected property returns null, + /// otherwise the selected object. + /// Calling get with an invalid index (e.g.-1) returns the selected object. + /// Calling set with a valid object on a selected property sets the value and the + /// union selector. + /// Calling set with a null object or an invalid index unselects the union. + /// + public override object this[int index] + { + get + { + if (index + 1 == (int)m_switchField) + { + return m_propertyList.ElementAt(index).GetValue(this); + } + if (index < 0 && + m_switchField > 0) + { + return m_propertyList.ElementAt((int)m_switchField - 1).GetValue(this); + } + return null; + } + set + { + if (index >= 0) + { + m_propertyList.ElementAt(index).SetValue(this, value); + // note: selector is updated in SetValue by emitted code for union + // m_unionSelector = (uint)(index + 1); + if (value != null) + { + return; + } + // reset union selector if value is a null + } + m_switchField = 0; + } + } + + /// + /// Access property values by name. + /// + /// + /// The value of a Union is determined by the union selector. + /// Calling get on an unselected property returns null, + /// otherwise the selected object. + /// Calling get with an invalid name returns the selected object. + /// Calling set with a valid object on a selected property sets the value and the + /// union selector. + /// Calling set with a null object or an invalid name unselects the union. + /// + public override object this[string name] + { + get + { + if (SwitchField > 0) + { + ComplexTypePropertyAttribute property; + if (m_propertyDict.TryGetValue(name, out property)) + { + if ((int)m_switchField == property.Order) + { + return property.GetValue(this); + } + } + else + { + return m_propertyList.ElementAt((int)SwitchField - 1).GetValue(this); + } + } + return null; + } + set + { + ComplexTypePropertyAttribute property; + if (m_propertyDict.TryGetValue(name, out property)) + { + property.SetValue(this, value); + // note: selector is updated in SetValue by emitted code for union + // m_unionSelector = (uint)(property.Order); + if (value != null) + { + return; + } + // reset union selector if value is a null + } + m_switchField = 0; + } + } + #endregion + + #region Private Fields + protected UInt32 m_switchField; + #endregion + } + + +}//namespace diff --git a/SampleApplications/SDK/Opc.Ua.Client/Session.cs b/SampleApplications/SDK/Opc.Ua.Client/Session.cs index 35c032beaf..2b8bd987b9 100644 --- a/SampleApplications/SDK/Opc.Ua.Client/Session.cs +++ b/SampleApplications/SDK/Opc.Ua.Client/Session.cs @@ -225,7 +225,7 @@ namespace Opc.Ua.Client { m_namespaceUris = new NamespaceTable(); m_serverUris = new StringTable(); - m_factory = ServiceMessageContext.GlobalContext.Factory; + m_factory = new EncodeableFactory(EncodeableFactory.GlobalFactory); } // set the default preferred locales. @@ -879,7 +879,7 @@ namespace Opc.Ua.Client } // create message context. - ServiceMessageContext messageContext = configuration.CreateMessageContext(); + ServiceMessageContext messageContext = configuration.CreateMessageContext(true); // update endpoint description using the discovery endpoint. if (endpoint.UpdateBeforeConnect) @@ -961,14 +961,18 @@ namespace Opc.Ua.Client /// The new session object. public static Session Recreate(Session template) { + ServiceMessageContext messageContext = template.m_configuration.CreateMessageContext(); + messageContext.Factory = template.Factory; + // create the channel object used to connect to the server. ITransportChannel channel = SessionChannel.Create( template.m_configuration, template.m_endpoint.Description, template.m_endpoint.Configuration, template.m_instanceCertificate, - template.m_configuration.SecurityConfiguration.SendCertificateChain ? template.m_instanceCertificateChain : null, - template.m_configuration.CreateMessageContext()); + template.m_configuration.SecurityConfiguration.SendCertificateChain ? + template.m_instanceCertificateChain : null, + messageContext); // create the session object. Session session = new Session(channel, template, true); @@ -998,6 +1002,7 @@ namespace Opc.Ua.Client return session; } #endregion + #region Delegates and Events /// /// Used to handle renews of user identity tokens before reconnect. @@ -1015,6 +1020,7 @@ namespace Opc.Ua.Client private event RenewUserIdentityEventHandler m_RenewUserIdentity; #endregion + #region Public Methods /// /// Reconnects to the server after a network failure. @@ -1514,9 +1520,16 @@ namespace Opc.Ua.Client if (dictionaryId.NamespaceIndex != 0 && !m_dictionaries.TryGetValue(dictionaryId, out dictionaryToLoad)) { - dictionaryToLoad = new DataDictionary(this); - await dictionaryToLoad.Load(r); - m_dictionaries[dictionaryId] = dictionaryToLoad; + try + { + dictionaryToLoad = new DataDictionary(this); + await dictionaryToLoad.Load(r); + m_dictionaries[dictionaryId] = dictionaryToLoad; + } + catch (Exception ex) + { + Utils.Trace("Dictionary load error for Dictionary {0} : {1}", r.NodeId, ex.Message); + } } } @@ -3031,6 +3044,7 @@ namespace Opc.Ua.Client } } #endregion + #region Close Methods /// /// Disconnects from the server and frees any network resources. diff --git a/SampleApplications/Samples/Client.Net4/UA Sample Client.csproj b/SampleApplications/Samples/Client.Net4/UA Sample Client.csproj index ae25a4efa4..45abdda8cb 100644 --- a/SampleApplications/Samples/Client.Net4/UA Sample Client.csproj +++ b/SampleApplications/Samples/Client.Net4/UA Sample Client.csproj @@ -120,6 +120,10 @@ {d918c0f6-39bd-4ed0-8323-e5a2eb9a85da} Opc.Ua.Core + + {fe9eeb39-0698-4a19-b770-e66836ce0002} + Opc.Ua.Client.ComplexTypes + {15100583-bfef-431b-a1ea-1e5a843a39b1} Opc.Ua.Client diff --git a/SampleApplications/Samples/ClientControls.Net4/ClientUtils.cs b/SampleApplications/Samples/ClientControls.Net4/ClientUtils.cs index 59bdfb52e0..4d82c4b984 100644 --- a/SampleApplications/Samples/ClientControls.Net4/ClientUtils.cs +++ b/SampleApplications/Samples/ClientControls.Net4/ClientUtils.cs @@ -28,12 +28,9 @@ * ======================================================================*/ using System; -using System.Text; using System.Collections.Generic; -using Opc.Ua; -using Opc.Ua.Client; using System.Drawing; -using System.Windows.Forms; +using System.Text; namespace Opc.Ua.Client.Controls { @@ -208,69 +205,79 @@ namespace Opc.Ua.Client.Controls { case Attributes.AccessLevel: case Attributes.UserAccessLevel: - { - byte? field = value.Value as byte?; - - if (field != null) { - return GetAccessLevelDisplayText(field.Value); - } + byte? field = value.Value as byte?; - break; - } + if (field != null) + { + return GetAccessLevelDisplayText(field.Value); + } + + break; + } case Attributes.EventNotifier: - { - byte? field = value.Value as byte?; - - if (field != null) { - return GetEventNotifierDisplayText(field.Value); - } + byte? field = value.Value as byte?; - break; - } + if (field != null) + { + return GetEventNotifierDisplayText(field.Value); + } + + break; + } case Attributes.DataType: - { - return session.NodeCache.GetDisplayText(value.Value as NodeId); - } + { + return session.NodeCache.GetDisplayText(value.Value as NodeId); + } case Attributes.ValueRank: - { - int? field = value.Value as int?; - - if (field != null) { - return GetValueRankDisplayText(field.Value); - } + int? field = value.Value as int?; - break; - } + if (field != null) + { + return GetValueRankDisplayText(field.Value); + } + + break; + } case Attributes.NodeClass: - { - int? field = value.Value as int?; - - if (field != null) { - return ((NodeClass)field.Value).ToString(); - } + int? field = value.Value as int?; - break; - } + if (field != null) + { + return ((NodeClass)field.Value).ToString(); + } + + break; + } case Attributes.NodeId: - { - NodeId field = value.Value as NodeId; - - if (!NodeId.IsNull(field)) { - return field.ToString(); + NodeId field = value.Value as NodeId; + + if (!NodeId.IsNull(field)) + { + return field.ToString(); + } + + return "Null"; } - return "Null"; - } + case Attributes.DataTypeDefinition: + { + ExtensionObject field = value.Value as ExtensionObject; + if (field != null) + { + return field.ToString(); + } + break; + } } // check for byte strings. @@ -280,7 +287,7 @@ namespace Opc.Ua.Client.Controls } // use default format. - return value.ToString(); + return value.ToString(); } #endregion @@ -343,7 +350,7 @@ namespace Opc.Ua.Client.Controls continue; } - + // check if all references have been fetched. if (results[ii].References.Count == 0) { @@ -421,7 +428,7 @@ namespace Opc.Ua.Client.Controls return null; } } - + /// /// Browses the address space and returns the references found. /// @@ -790,6 +797,7 @@ namespace Opc.Ua.Client.Controls } #endregion + #region Type Model Browsing /// /// Collects the instance declarations for a type. @@ -1288,7 +1296,7 @@ namespace Opc.Ua.Client.Controls } return -1; - } + } #endregion } } diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.Designer.cs deleted file mode 100644 index a4bbe46e55..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.Designer.cs +++ /dev/null @@ -1,95 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class BaseListCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ItemsLV = new System.Windows.Forms.ListView(); - this.SuspendLayout(); - // - // ItemsLV - // - this.ItemsLV.AllowDrop = true; - this.ItemsLV.Dock = System.Windows.Forms.DockStyle.Fill; - this.ItemsLV.FullRowSelect = true; - this.ItemsLV.Location = new System.Drawing.Point(0, 0); - this.ItemsLV.Name = "ItemsLV"; - this.ItemsLV.Size = new System.Drawing.Size(541, 412); - this.ItemsLV.TabIndex = 0; - this.ItemsLV.UseCompatibleStateImageBehavior = false; - this.ItemsLV.View = System.Windows.Forms.View.Details; - this.ItemsLV.DragEnter += new System.Windows.Forms.DragEventHandler(this.ItemsLV_DragEnter); - this.ItemsLV.DragDrop += new System.Windows.Forms.DragEventHandler(this.ItemsLV_DragDrop); - this.ItemsLV.DoubleClick += new System.EventHandler(this.ItemsLV_DoubleClick); - this.ItemsLV.SelectedIndexChanged += new System.EventHandler(this.ItemsLV_SelectedIndexChanged); - this.ItemsLV.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ItemsLV_MouseUp); - this.ItemsLV.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ItemsLV_MouseMove); - this.ItemsLV.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ItemsLV_MouseDown); - // - // BaseListCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.ItemsLV); - this.Name = "BaseListCtrl"; - this.Size = new System.Drawing.Size(541, 412); - this.ResumeLayout(false); - - } - - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.cs deleted file mode 100644 index 73a83d5543..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.cs +++ /dev/null @@ -1,866 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A base class for list controls. - /// - public partial class BaseListCtrl : UserControl - { - /// - /// Initializes a new instance of the class. - /// - public BaseListCtrl() - { - InitializeComponent(); - - ItemsLV.SmallImageList = new GuiUtils().ImageList; - ItemsLV.ListViewItemSorter = new BaseListCtrlSorter(this); - } - - /// - /// The ListView contained in the control. - /// - protected System.Windows.Forms.ListView ItemsLV; - - #region Public Interface - /// - /// Whether the control should allow items to be dragged. - /// - [DefaultValue(false)] - public bool EnableDragging - { - get { return m_enableDragging; } - set { m_enableDragging = value; } - } - - /// - /// The instructions to display when no items are in the list. - /// - public string Instructions - { - get { return m_instructions; } - set { m_instructions = value; } - } - - /// - /// Whether new items should be pre-pended to the list. - /// - [DefaultValue(false)] - public bool PrependItems - { - get { return m_prependItems; } - set { m_prependItems = value; } - } - - /// - /// Raised whenever items are 'picked' in the control. - /// - public event ListItemActionEventHandler ItemsPicked - { - add { m_ItemsPicked += value; } - remove { m_ItemsPicked -= value; } - } - - /// - /// Raised whenever items are selected in the control. - /// - public event ListItemActionEventHandler ItemsSelected - { - add { m_ItemsSelected += value; } - remove { m_ItemsSelected -= value; } - } - - /// - /// Raised whenever items are added to the control. - /// - public event ListItemActionEventHandler ItemsAdded - { - add { m_ItemsAdded += value; } - remove { m_ItemsAdded -= value; } - } - - /// - /// Raised whenever items are modified in the control. - /// - public event ListItemActionEventHandler ItemsModified - { - add { m_ItemsModified += value; } - remove { m_ItemsModified -= value; } - } - - /// - /// Raised whenever items are removed from the control. - /// - public event ListItemActionEventHandler ItemsRemoved - { - add { m_ItemsRemoved += value; } - remove { m_ItemsRemoved -= value; } - } - - /// - /// Returns the number of items in the control. - /// - public int Count - { - get { return ItemsLV.Items.Count; } - } - - /// - /// Returns the objects associated with the items in the control. - /// - public Array GetItems(System.Type type) - { - ArrayList items = new ArrayList(); - - foreach (ListViewItem listItem in ItemsLV.Items) - { - items.Add(listItem.Tag); - } - - return items.ToArray(type); - } - - /// - /// Returns the objects associated with the selected items in the control. - /// - public Array GetSelectedItems(System.Type type) - { - ArrayList items = new ArrayList(); - - if (ItemsLV.View == View.Details) - { - foreach (ListViewItem listItem in ItemsLV.SelectedItems) - { - items.Add(listItem.Tag); - } - } - - return items.ToArray(type); - } - #endregion - - #region Private Members - private bool m_prependItems; - private event ListItemActionEventHandler m_ItemsPicked; - private event ListItemActionEventHandler m_ItemsSelected; - private event ListItemActionEventHandler m_ItemsAdded; - private event ListItemActionEventHandler m_ItemsModified; - private event ListItemActionEventHandler m_ItemsRemoved; - private object[][] m_columns; - private bool m_updating; - private int m_updateCount; - private string m_instructions; - private Point m_dragPosition; - private bool m_enableDragging; - #endregion - - #region Protected Methods - /// - /// Returns tag of the selected item. Null if no items or more than one item is selected. - /// - protected object SelectedTag - { - get - { - if (ItemsLV.SelectedItems.Count != 1) - { - return null; - } - - return ItemsLV.SelectedItems[0].Tag; - } - } - - /// - /// Deletes the currently selected items. - /// - protected virtual void DeleteSelection() - { - List itemsToDelete = new List(); - - foreach (ListViewItem item in ItemsLV.SelectedItems) - { - itemsToDelete.Add(item); - } - - foreach (ListViewItem item in itemsToDelete) - { - item.Remove(); - } - } - - /// - /// Compares two items in the list. - /// - protected virtual int CompareItems(object item1, object item2) - { - IComparable comparable = item1 as IComparable; - - if (comparable != null) - { - return comparable.CompareTo(item2); - } - - return 0; - } - - /// - /// Returns the data to drag. - /// - protected virtual object GetDataToDrag() - { - if (ItemsLV.SelectedItems.Count > 0) - { - ArrayList data = new ArrayList(); - - foreach (ListViewItem listItem in ItemsLV.SelectedItems) - { - data.Add(listItem.Tag); - } - - return data.ToArray(); - } - - return null; - } - - /// - /// Adds an item to the list. - /// - protected virtual ListViewItem AddItem(object item) - { - return AddItem(item, "SimpleItem", -1); - } - - /// - /// Adds an item to the list. - /// - protected virtual ListViewItem AddItem(object item, string icon, int index) - { - // switch to detail view as soon as an item is added. - if (ItemsLV.View == View.List) - { - ItemsLV.Items.Clear(); - ItemsLV.View = View.Details; - } - - ListViewItem listItem = null; - - if (m_updating) - { - if (m_updateCount < ItemsLV.Items.Count) - { - listItem = ItemsLV.Items[m_updateCount]; - } - - m_updateCount++; - } - - if (listItem == null) - { - listItem = new ListViewItem(); - } - - listItem.Text = String.Format("{0}", item); - listItem.ImageKey = icon; - listItem.Tag = item; - - // fill columns with blanks. - for (int ii = listItem.SubItems.Count; ii < ItemsLV.Columns.Count-1; ii++) - { - listItem.SubItems.Add(String.Empty); - } - - // calculate new index. - int newIndex = index; - - if (index < 0 || index > ItemsLV.Items.Count) - { - newIndex = ItemsLV.Items.Count; - } - - // update columns. - UpdateItem(listItem, item, newIndex); - - if (listItem.ListView == null) - { - // add to control. - if (index >= 0 && index <= ItemsLV.Items.Count) - { - ItemsLV.Items.Insert(index, listItem); - } - else - { - ItemsLV.Items.Add(listItem); - } - } - - // return new item. - return listItem; - } - - /// - /// Starts overwriting the contents of the control. - /// - protected void BeginUpdate() - { - m_updating = true; - m_updateCount = 0; - } - - /// - /// Finishes overwriting the contents of the control. - /// - protected void EndUpdate() - { - m_updating = false; - - while (ItemsLV.Items.Count > m_updateCount) - { - ItemsLV.Items[ItemsLV.Items.Count-1].Remove(); - } - - m_updateCount = 0; - AdjustColumns(); - } - - /// - /// Updates a list item with the current contents of an object. - /// - protected virtual void UpdateItem(ListViewItem listItem, object item) - { - listItem.Tag = item; - } - - /// - /// Updates a list item with the current contents of an object. - /// - protected virtual void UpdateItem(ListViewItem listItem, object item, int index) - { - UpdateItem(listItem, item); - } - - /// - /// Sets the columns shown in the list view. - /// - protected virtual void SetColumns(object[][] columns) - { - ItemsLV.Clear(); - - m_columns = columns; - - foreach (object[] column in columns) - { - ColumnHeader header = new ColumnHeader(); - - header.Text = column[0] as string; - header.TextAlign = (HorizontalAlignment)column[1]; - - ItemsLV.Columns.Add(header); - } - - ColumnHeader blank = new ColumnHeader(); - blank.Text = String.Empty; - ItemsLV.Columns.Add(blank); - - AdjustColumns(); - } - - /// - /// Adjusts the columns shown in the list view. - /// - protected virtual void AdjustColumns() - { - if (ItemsLV.View == View.List || ItemsLV.Items.Count == 0) - { - ItemsLV.View = View.List; - - if (ItemsLV.Items.Count == 0 && !String.IsNullOrEmpty(m_instructions)) - { - ListViewItem item = new ListViewItem(m_instructions); - - item.ImageKey = "Info"; - item.ForeColor = Color.Gray; - - ItemsLV.Items.Add(item); - } - - ItemsLV.Columns[0].Width = -2; - return; - } - - ItemsLV.View = View.Details; - - for (int ii = 0; ii < m_columns.Length && ii < ItemsLV.Columns.Count; ii++) - { - // check for fixed width columns. - if (m_columns[ii].Length >= 4 && m_columns[ii][3] != null) - { - int width = (int)m_columns[ii][3]; - - if (ItemsLV.Columns[ii].Width < width) - { - ItemsLV.Columns[ii].Width = width; - } - - continue; - } - - // check mandatory columns. - if (m_columns[ii].Length < 3 || m_columns[ii][2] == null) - { - ItemsLV.Columns[ii].Width = -2; - continue; - } - - // check if all items have the default value for the column. - bool display = false; - - foreach (ListViewItem listItem in ItemsLV.Items) - { - if (!m_columns[ii][2].Equals(listItem.SubItems[ii].Text)) - { - display = true; - break; - } - } - - // only display columns with non-default information. - if (display) - { - ItemsLV.Columns[ii].Width = -2; - } - else - { - ItemsLV.Columns[ii].Width = 0; - } - } - - if (ItemsLV.Columns.Count > 0) - { - ItemsLV.Columns[ItemsLV.Columns.Count-1].Width = 0; - } - } - - /// - /// Enables the state of menu items. - /// - protected virtual void EnableMenuItems(ListViewItem clickedItem) - { - // do nothing. - } - - /// - /// Sends notifications whenever items in the control are 'picked'. - /// - protected virtual void PickItems() - { - if (m_ItemsPicked != null) - { - ICollection data = GetDataToDrag() as ICollection; - - if (data != null) - { - m_ItemsPicked(this, new ListItemActionEventArgs(ListItemAction.Picked, data)); - } - } - } - - /// - /// Sends notifications whenever items in the control are 'selected'. - /// - protected virtual void SelectItems() - { - if (m_ItemsSelected != null) - { - object[] selectedObjects = new object[ItemsLV.SelectedItems.Count]; - - for (int ii = 0; ii < selectedObjects.Length; ii++) - { - selectedObjects[ii] = ItemsLV.SelectedItems[ii].Tag; - } - - m_ItemsSelected(this, new ListItemActionEventArgs(ListItemAction.Selected, selectedObjects)); - } - } - - /// - /// Sends notifications that an item has been added to the control. - /// - protected virtual void NotifyItemAdded(object item) - { - NotifyItemsAdded(new object[] { item }); - } - - /// - /// Sends notifications that items have been added to the control. - /// - protected virtual void NotifyItemsAdded(object[] items) - { - if (m_ItemsAdded != null && items != null && items.Length > 0) - { - m_ItemsAdded(this, new ListItemActionEventArgs(ListItemAction.Added, items)); - } - } - - /// - /// Sends notifications that an item has been modified in the control. - /// - protected virtual void NotifyItemModified(object item) - { - NotifyItemsModified(new object[] { item }); - } - - /// - /// Sends notifications that items have been modified in the control. - /// - protected virtual void NotifyItemsModified(object[] items) - { - if (m_ItemsModified != null && items != null && items.Length > 0) - { - m_ItemsModified(this, new ListItemActionEventArgs(ListItemAction.Modified, items)); - } - } - - /// - /// Sends notifications that and item has been removed from the control. - /// - protected virtual void NotifyItemRemoved(object item) - { - NotifyItemsRemoved(new object[] { item }); - } - - /// - /// Sends notifications that items have been removed from the control. - /// - protected virtual void NotifyItemsRemoved(object[] items) - { - if (m_ItemsRemoved != null && items != null && items.Length > 0) - { - m_ItemsRemoved(this, new ListItemActionEventArgs(ListItemAction.Removed, items)); - } - } - - /// - /// Finds the list item with specified tag in the control, - /// - protected ListViewItem FindItem(object tag) - { - foreach (ListViewItem listItem in ItemsLV.Items) - { - if (Object.ReferenceEquals(tag, listItem.Tag)) - { - return listItem; - } - } - - return null; - } - - /// - /// Returns the tag associated with a selected item. - /// - protected object GetSelectedTag(int index) - { - if (ItemsLV.SelectedItems.Count > index) - { - return ItemsLV.SelectedItems[index].Tag; - } - - return null; - } - #endregion - - #region BaseListCtrlSorter Class - /// - /// A class that allows the list to be sorted. - /// - private class BaseListCtrlSorter : IComparer - { - /// - /// Initializes the sorter. - /// - public BaseListCtrlSorter(BaseListCtrl control) - { - m_control = control; - } - - /// - /// Compares the two items. - /// - public int Compare(object x, object y) - { - ListViewItem itemX = x as ListViewItem; - ListViewItem itemY = y as ListViewItem; - - return m_control.CompareItems(itemX.Tag, itemY.Tag); - } - - private BaseListCtrl m_control; - } - #endregion - - #region Event Handlers - private void ItemsLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) - { - try - { - // ignore non-right clicks. - if (e.Button == MouseButtons.Left) - { - m_dragPosition = e.Location; - return; - } - - // disable everything. - if (ItemsLV.ContextMenuStrip != null) - { - foreach (ToolStripItem item in ItemsLV.ContextMenuStrip.Items) - { - ToolStripMenuItem menuItem = item as ToolStripMenuItem; - - if (menuItem == null) - { - continue; - } - - menuItem.Enabled = false; - - if (menuItem.DropDown != null) - { - foreach (ToolStripItem subItem in menuItem.DropDown.Items) - { - ToolStripMenuItem subMenuItem = subItem as ToolStripMenuItem; - - if (subMenuItem != null) - { - subMenuItem.Enabled = false; - } - } - } - } - } - - // selects the item that was right clicked on. - ListViewItem clickedItem = ItemsLV.GetItemAt(e.X, e.Y); - - // ensure clicked item is selected. - if (clickedItem != null) - { - clickedItem.Selected = true; - } - - // enable menu items according to context. - EnableMenuItems(clickedItem); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ItemsLV_MouseUp(object sender, MouseEventArgs e) - { - try - { - if (e.Button == MouseButtons.Left) - { - m_dragPosition = e.Location; - return; - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ItemsLV_DoubleClick(object sender, System.EventArgs e) - { - try - { - PickItems(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ItemsLV_SelectedIndexChanged(object sender, System.EventArgs e) - { - try - { - SelectItems(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ItemsLV_MouseMove(object sender, MouseEventArgs e) - { - if (m_enableDragging && e.Button == MouseButtons.Left && !m_dragPosition.Equals(e.Location)) - { - object data = GetDataToDrag(); - - if (data != null) - { - ItemsLV.DoDragDrop(data, DragDropEffects.Copy); - } - } - } - - /// - /// Handles the DragEnter event of the ItemsLV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void ItemsLV_DragEnter(object sender, DragEventArgs e) - { - if (m_enableDragging) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - - /// - /// Handles the DragDrop event of the ItemsLV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void ItemsLV_DragDrop(object sender, DragEventArgs e) - { - // overriden by sub-class. - } - #endregion - } - - #region ListItemAction Enumeration - /// - /// The possible actions that could affect an item. - /// - public enum ListItemAction - { - - /// - /// The item was picked (double clicked). - /// - Picked, - - /// - /// The item was selected. - /// - Selected, - - /// - /// The item was added. - /// - Added, - - /// - /// The item was modified. - /// - Modified, - - /// - /// The item was removed. - /// - Removed - } - #endregion - - #region ListItemActionEventArgs Class - /// - /// The event argurments passed when an item event occurs. - /// - public class ListItemActionEventArgs : EventArgs - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// The action. - /// The items. - public ListItemActionEventArgs(ListItemAction action, ICollection items) - { - m_items = items; - m_action = action; - } - #endregion - - #region Public Properties - /// - /// Gets the items. - /// - /// The items. - public ICollection Items - { - get { return m_items; } - } - - /// - /// Gets the action. - /// - /// The action. - public ListItemAction Action - { - get { return m_action; } - } - #endregion - - #region Private Fields - private ICollection m_items; - private ListItemAction m_action; - #endregion - } - - /// - /// The delegate used to receive item action events. - /// - public delegate void ListItemActionEventHandler(object sender, ListItemActionEventArgs e); - #endregion -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseListCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.Designer.cs deleted file mode 100644 index ef3f02ee97..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class BaseTreeCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.NodesTV = new System.Windows.Forms.TreeView(); - this.SuspendLayout(); - // - // NodesTV - // - this.NodesTV.AllowDrop = true; - this.NodesTV.Dock = System.Windows.Forms.DockStyle.Fill; - this.NodesTV.Location = new System.Drawing.Point(0, 0); - this.NodesTV.Name = "NodesTV"; - this.NodesTV.Size = new System.Drawing.Size(489, 397); - this.NodesTV.TabIndex = 1; - this.NodesTV.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.NodesTV_GiveFeedback); - this.NodesTV.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.NodesTV_BeforeExpand); - this.NodesTV.DoubleClick += new System.EventHandler(this.NodesTV_DoubleClick); - this.NodesTV.DragDrop += new System.Windows.Forms.DragEventHandler(this.NodesTV_DragDrop); - this.NodesTV.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.NodesTV_AfterSelect); - this.NodesTV.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NodesTV_MouseDown); - this.NodesTV.DragEnter += new System.Windows.Forms.DragEventHandler(this.NodesTV_DragEnter); - this.NodesTV.DragOver += new System.Windows.Forms.DragEventHandler(this.NodesTV_DragOver); - // - // BaseTreeCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.NodesTV); - this.Name = "BaseTreeCtrl"; - this.Size = new System.Drawing.Size(489, 397); - this.ResumeLayout(false); - - } - - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.cs deleted file mode 100644 index 6ca19f4a64..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.cs +++ /dev/null @@ -1,456 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A base class for tree controls. - /// - public partial class BaseTreeCtrl : UserControl - { - /// - /// Initializes a new instance of the class. - /// - public BaseTreeCtrl() - { - InitializeComponent(); - NodesTV.ImageList = new GuiUtils().ImageList; - NodesTV.ItemHeight = 18; - } - - #region Public Interface - /// - /// The TreeView contained in the Control. - /// - protected System.Windows.Forms.TreeView NodesTV; - - /// - /// Raised whenever a node is 'picked' in the control. - /// - public event TreeNodeActionEventHandler NodePicked - { - add { m_NodePicked += value; } - remove { m_NodePicked -= value; } - } - - /// - /// Raised whenever a node is selected in the control. - /// - public event TreeNodeActionEventHandler NodeSelected - { - add { m_NodeSelected += value; } - remove { m_NodeSelected -= value; } - } - - /// - /// Whether the control should allow items to be dragged. - /// - public bool EnableDragging - { - get { return m_enableDragging; } - set { m_enableDragging = value; } - } - #endregion - - #region Private Fields - private event TreeNodeActionEventHandler m_NodePicked; - private event TreeNodeActionEventHandler m_NodeSelected; - private bool m_enableDragging; - #endregion - - #region Protected Methods - /// - /// Adds an item to the tree. - /// - protected virtual TreeNode AddNode(TreeNode treeNode, object item) - { - return AddNode(treeNode, item, String.Format("{0}", item), "ClosedFolder"); - } - - /// - /// Adds an item to the tree. - /// - protected virtual TreeNode AddNode(TreeNode parent, object item, string text, string icon) - { - // create node. - TreeNode treeNode = new TreeNode(); - - // update text/icon. - UpdateNode(treeNode, item, text, icon); - - // add to control. - if (parent == null) - { - NodesTV.Nodes.Add(treeNode); - } - else - { - parent.Nodes.Add(treeNode); - } - - // return new tree node. - return treeNode; - } - - /// - /// Updates a tree node with the current contents of an object. - /// - protected virtual void UpdateNode(TreeNode treeNode, object item, string text, string icon) - { - treeNode.Text = text; - treeNode.Tag = item; - treeNode.ImageKey = icon; - treeNode.SelectedImageKey = icon; - } - - /// - /// Returns the data to drag. - /// - protected virtual object GetDataToDrag(TreeNode node) - { - return node.Tag; - } - - /// - /// Enables the state of menu items. - /// - protected virtual void EnableMenuItems(TreeNode clickedNode) - { - // do nothing. - } - - /// - /// Initializes a node before expanding it. - /// - protected virtual bool BeforeExpand(TreeNode clickedNode) - { - return false; - } - - /// - /// Sends notifications whenever a node in the control is 'picked'. - /// - protected virtual void PickNode() - { - if (m_NodePicked != null) - { - if (NodesTV.SelectedNode != null) - { - object parent = null; - - if (NodesTV.SelectedNode.Parent != null) - { - parent = NodesTV.SelectedNode.Tag; - } - - m_NodePicked(this, new TreeNodeActionEventArgs(TreeNodeAction.Picked, NodesTV.SelectedNode.Tag, parent)); - } - } - } - - /// - /// Sends notifications whenever a node in the control is 'selected'. - /// - protected virtual void SelectNode() - { - if (m_NodeSelected != null) - { - if (NodesTV.SelectedNode != null) - { - object parent = null; - - if (NodesTV.SelectedNode.Parent != null) - { - parent = NodesTV.SelectedNode.Tag; - } - - m_NodeSelected(this, new TreeNodeActionEventArgs(TreeNodeAction.Selected, NodesTV.SelectedNode.Tag, parent)); - } - } - } - - /// - /// Returns the Tag for the current selection. - /// - protected object SelectedTag - { - get - { - if (NodesTV.SelectedNode != null) - { - return NodesTV.SelectedNode.Tag; - } - - return null; - } - } - #endregion - - #region Event Handlers - private void NodesTV_AfterSelect(object sender, TreeViewEventArgs e) - { - try - { - SelectNode(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void NodesTV_BeforeExpand(object sender, TreeViewCancelEventArgs e) - { - try - { - Cursor = Cursors.WaitCursor; - e.Cancel = BeforeExpand(e.Node); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - finally - { - Cursor = Cursors.Default; - } - } - - private void NodesTV_DoubleClick(object sender, EventArgs e) - { - try - { - PickNode(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void NodesTV_MouseDown(object sender, MouseEventArgs e) - { - try - { - // selects the item that was right clicked on. - TreeNode clickedNode = NodesTV.SelectedNode = NodesTV.GetNodeAt(e.X, e.Y); - - // no item clicked on - do nothing. - if (clickedNode == null) return; - - // start drag operation. - if (e.Button == MouseButtons.Left) - { - if (m_enableDragging) - { - object data = GetDataToDrag(clickedNode); - - if (data != null) - { - NodesTV.DoDragDrop(data, DragDropEffects.Copy); - } - } - - return; - } - - // disable everything. - if (NodesTV.ContextMenuStrip != null) - { - foreach (ToolStripItem item in NodesTV.ContextMenuStrip.Items) - { - ToolStripMenuItem menuItem = item as ToolStripMenuItem; - - if (menuItem == null) - { - continue; - } - - menuItem.Enabled = false; - - if (menuItem.DropDown != null) - { - foreach (ToolStripItem subItem in menuItem.DropDown.Items) - { - ToolStripMenuItem subMenuItem = subItem as ToolStripMenuItem; - - if (subMenuItem != null) - { - subMenuItem.Enabled = false; - } - } - } - } - } - - // enable menu items according to context. - if (e.Button == MouseButtons.Right) - { - EnableMenuItems(clickedNode); - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - /// - /// Handles the DragEnter event of the NodesTV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void NodesTV_DragEnter(object sender, DragEventArgs e) - { - if (m_enableDragging) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - - /// - /// Handles the DragDrop event of the NodesTV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void NodesTV_DragDrop(object sender, DragEventArgs e) - { - // overridden by sub-class. - } - - /// - /// Handles the GiveFeedback event of the NodesTV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void NodesTV_GiveFeedback(object sender, GiveFeedbackEventArgs e) - { - // overridden by sub-class. - } - - /// - /// Handles the DragOver event of the NodesTV control. - /// - /// The source of the event. - /// The instance containing the event data. - protected virtual void NodesTV_DragOver(object sender, DragEventArgs e) - { - // overridden by sub-class. - } - #endregion - } - - #region TreeNodeAction Eumeration - /// - /// The possible actions that could affect a node. - /// - public enum TreeNodeAction - { - /// - /// A node was picked in the tree. - /// - Picked, - - /// - /// A node was selected in the tree. - /// - Selected - } - #endregion - - #region TreeNodeActionEventArgs class - /// - /// The event argurments passed when an node event occurs. - /// - public class TreeNodeActionEventArgs : EventArgs - { - #region Constructor - /// - /// Initializes the object. - /// - public TreeNodeActionEventArgs(TreeNodeAction action, object node, object parent) - { - m_node = node; - m_parent = parent; - m_action = action; - } - #endregion - - #region Private Fields - /// - /// The tag associated with the node that was acted on. - /// - public object Node - { - get { return m_node; } - } - - /// - /// The tag associated with the parent of the node that was acted on. - /// - public object Parent - { - get { return m_parent; } - } - - /// - /// The action in question. - /// - public TreeNodeAction Action - { - get { return m_action; } - } - #endregion - - #region Private Fields - private object m_node; - private object m_parent; - private TreeNodeAction m_action; - #endregion - } - - /// - /// The delegate used to receive node action events. - /// - public delegate void TreeNodeActionEventHandler(object sender, TreeNodeActionEventArgs e); - #endregion -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/BaseTreeCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ClipboardHack.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ClipboardHack.cs deleted file mode 100644 index 27959440ee..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ClipboardHack.cs +++ /dev/null @@ -1,155 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Threading; - -namespace Opc.Ua.Client.Controls -{ - /// - /// This class is used to work around a bug in the MS VPC implementation. - /// - /// - /// Clipborad operations will fail if this class is not used on VPCs with the - /// virtual machine additions installed. - /// - public static class ClipboardHack - { - #region Public Methods - /// - /// Retrieves the data from the clipboard. - /// - public static object GetData(string format) - { - lock (m_lock) - { - m_format = format; - m_data = null; - m_error = null; - - Thread thread = new Thread(new ThreadStart(GetClipboardPrivate)); - thread.IsBackground = true; - - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - thread.Join(); - - if (m_error != null) - { - throw new ServiceResultException(m_error, StatusCodes.BadUnexpectedError); - } - - return m_data; - } - } - - /// - /// Saves the data in the clipboard. - /// - public static void SetData(string format, object data) - { - lock (m_lock) - { - m_format = format; - m_data = data; - m_error = null; - - Thread thread = new Thread(new ThreadStart(SetClipboardPrivate)); - thread.IsBackground = true; - - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - thread.Join(); - - if (m_error != null) - { - throw new ServiceResultException(m_error, StatusCodes.BadUnexpectedError); - } - } - } - #endregion - - #region Private Methods - /// - /// Gets the data in the clipboard if it is the correct format. - /// - private static void GetClipboardPrivate() - { - try - { - m_error = null; - - if (String.IsNullOrEmpty(m_format) || !Clipboard.ContainsData(m_format)) - { - m_data = null; - return; - } - - m_data = Clipboard.GetData(m_format); - } - catch (Exception e) - { - m_error = e; - } - } - - /// - /// Saves the data in the clipboard if it is the correct format. - /// - private static void SetClipboardPrivate() - { - try - { - m_error = null; - - if (String.IsNullOrEmpty(m_format) || m_data == null) - { - return; - } - - Clipboard.SetData(m_format, m_data); - } - catch (Exception e) - { - m_error = e; - } - } - #endregion - - #region Private Fields - private static object m_lock = new object(); - private static string m_format = null; - private static object m_data = null; - private static Exception m_error = null; - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.Designer.cs deleted file mode 100644 index 03d9335f7a..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.Designer.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class ComplexValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.panel1 = new System.Windows.Forms.Panel(); - this.ValueCTRL = new Opc.Ua.Client.Controls.DataListCtrl(); - this.ButtonsPN.SuspendLayout(); - this.panel1.SuspendLayout(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 317); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(707, 28); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.Location = new System.Drawing.Point(4, 1); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - this.OkBTN.Click += new System.EventHandler(this.OkBTN_Click); - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(628, 1); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // panel1 - // - this.panel1.Controls.Add(this.ValueCTRL); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(707, 317); - this.panel1.TabIndex = 1; - // - // ValueCTRL - // - this.ValueCTRL.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueCTRL.AutoUpdate = true; - this.ValueCTRL.Instructions = null; - this.ValueCTRL.LatestValue = true; - this.ValueCTRL.Location = new System.Drawing.Point(4, 3); - this.ValueCTRL.Name = "ValueCTRL"; - this.ValueCTRL.Size = new System.Drawing.Size(699, 311); - this.ValueCTRL.TabIndex = 0; - // - // ComplexValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(707, 345); - this.Controls.Add(this.panel1); - this.Controls.Add(this.ButtonsPN); - this.MinimumSize = new System.Drawing.Size(287, 98); - this.Name = "ComplexValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Value"; - this.ButtonsPN.ResumeLayout(false); - this.panel1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel panel1; - private DataListCtrl ValueCTRL; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.cs deleted file mode 100644 index 31e23f2d44..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A dialog to edit a complex value. - /// - public partial class ComplexValueEditDlg : Form - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - public ComplexValueEditDlg() - { - InitializeComponent(); - } - #endregion - - #region Private Fields - private object m_value; - #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public object ShowDialog(object value) - { - return ShowDialog(value, null); - } - - /// - /// Displays the dialog. - /// - public object ShowDialog(object value, MonitoredItem monitoredItem) - { - m_value = Utils.Clone(value); - - ValueCTRL.MonitoredItem = monitoredItem; - ValueCTRL.ShowValue(m_value); - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return m_value; - } - #endregion - - #region Event Handlers - private void OkBTN_Click(object sender, EventArgs e) - { - try - { - DialogResult = DialogResult.OK; - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ComplexValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.Designer.cs deleted file mode 100644 index ea80ffc745..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.Designer.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - /// - /// - /// - partial class DataListCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.PopupMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.UpdatesMI = new System.Windows.Forms.ToolStripMenuItem(); - this.RefreshMI = new System.Windows.Forms.ToolStripMenuItem(); - this.ClearMI = new System.Windows.Forms.ToolStripMenuItem(); - this.Separator01 = new System.Windows.Forms.ToolStripSeparator(); - this.EditMI = new System.Windows.Forms.ToolStripMenuItem(); - this.PopupMenu.SuspendLayout(); - this.SuspendLayout(); - // - // ItemsLV - // - this.ItemsLV.ContextMenuStrip = this.PopupMenu; - this.ItemsLV.MultiSelect = false; - this.ItemsLV.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ItemsLV_MouseClick); - // - // PopupMenu - // - this.PopupMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.UpdatesMI, - this.RefreshMI, - this.ClearMI, - this.Separator01, - this.EditMI}); - this.PopupMenu.Name = "PopupMenu"; - this.PopupMenu.Size = new System.Drawing.Size(136, 98); - // - // UpdatesMI - // - this.UpdatesMI.Checked = true; - this.UpdatesMI.CheckState = System.Windows.Forms.CheckState.Checked; - this.UpdatesMI.Name = "UpdatesMI"; - this.UpdatesMI.Size = new System.Drawing.Size(135, 22); - this.UpdatesMI.Text = "Auto Update"; - this.UpdatesMI.CheckedChanged += new System.EventHandler(this.UpdatesMI_CheckedChanged); - // - // RefreshMI - // - this.RefreshMI.Name = "RefreshMI"; - this.RefreshMI.Size = new System.Drawing.Size(135, 22); - this.RefreshMI.Text = "Refresh"; - this.RefreshMI.Click += new System.EventHandler(this.RefreshMI_Click); - // - // ClearMI - // - this.ClearMI.Name = "ClearMI"; - this.ClearMI.Size = new System.Drawing.Size(135, 22); - this.ClearMI.Text = "Clear"; - this.ClearMI.Click += new System.EventHandler(this.ClearMI_Click); - // - // Separator01 - // - this.Separator01.Name = "Separator01"; - this.Separator01.Size = new System.Drawing.Size(132, 6); - // - // EditMI - // - this.EditMI.Name = "EditMI"; - this.EditMI.Size = new System.Drawing.Size(135, 22); - this.EditMI.Text = "Edit Value..."; - this.EditMI.Click += new System.EventHandler(this.EditMI_Click); - // - // DataListCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.Name = "DataListCtrl"; - this.Controls.SetChildIndex(this.ItemsLV, 0); - this.PopupMenu.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ContextMenuStrip PopupMenu; - private System.Windows.Forms.ToolStripMenuItem UpdatesMI; - private System.Windows.Forms.ToolStripMenuItem RefreshMI; - private System.Windows.Forms.ToolStripMenuItem ClearMI; - private System.Windows.Forms.ToolStripSeparator Separator01; - private System.Windows.Forms.ToolStripMenuItem EditMI; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.cs deleted file mode 100644 index 9a6ba0410c..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.cs +++ /dev/null @@ -1,1519 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -using System.Runtime.Serialization; -using System.Xml; -using System.Xml.Serialization; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Client.Controls -{ - /// - /// Displays a hierarchical view of a complex value. - /// - public partial class DataListCtrl : Opc.Ua.Client.Controls.BaseListCtrl - { - /// - /// Initializes a new instance of the class. - /// - public DataListCtrl() - { - InitializeComponent(); - SetColumns(m_ColumnNames); - } - - #region Private Fields - /// - /// The columns to display in the control. - /// - private readonly object[][] m_ColumnNames = new object[][] - { - new object[] { "Name", HorizontalAlignment.Left, null }, - new object[] { "Value", HorizontalAlignment.Left, null, 250 }, - new object[] { "Type", HorizontalAlignment.Left, null } - }; - - private bool m_latestValue = true; - private bool m_expanding; - private int m_depth; - private Font m_defaultFont; - private MonitoredItem m_monitoredItem; - - private const string UnknownType = "(unknown)"; - private const string NullValue = "(null)"; - private const string ExpandIcon = "ExpandPlus"; - private const string CollapseIcon = "ExpandMinus"; - #endregion - - #region Public Interface - /// - /// Whether to update the control when the value changes. - /// - public bool AutoUpdate - { - get { return UpdatesMI.Checked; } - set { UpdatesMI.Checked = value; } - } - - /// - /// Whether to only display the latest value for a monitored item. - /// - public bool LatestValue - { - get { return m_latestValue; } - set { m_latestValue = value; } - } - - /// - /// The monitored item associated with the value. - /// - public MonitoredItem MonitoredItem - { - get { return m_monitoredItem; } - set { m_monitoredItem = value; } - } - - /// - /// Clears the contents of the control, - /// - public void Clear() - { - ItemsLV.Items.Clear(); - AdjustColumns(); - } - - /// - /// Displays a value in the control. - /// - public void ShowValue(object value) - { - ShowValue(value, false); - } - - /// - /// Displays a value in the control. - /// - public void ShowValue(object value, bool overwrite) - { - if (!overwrite) - { - Clear(); - } - - if (value is byte[]) - { - m_defaultFont = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); - } - else - { - m_defaultFont = ItemsLV.Font; - } - - m_expanding = false; - m_depth = 0; - - // show the value. - int index = 0; - ShowValue(ref index, ref overwrite, value); - - // adjust columns. - AdjustColumns(); - } - #endregion - - #region Overridden Methods - /// - /// Enables the menu items. - /// - protected override void EnableMenuItems(ListViewItem clickedItem) - { - RefreshMI.Enabled = true; - ClearMI.Enabled = true; - - if (ItemsLV.SelectedItems.Count == 1) - { - ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState; - EditMI.Enabled = IsEditableType(state.Component); - } - } - #endregion - - #region ValueState Class - /// - /// Stores the state associated with an item. - /// - private class ValueState - { - public bool Expanded = false; - public bool Expandable = false; - public object Value = null; - public object Component = null; - public object ComponentId = null; - } - #endregion - - #region Private Members - /// - /// Returns true is the value is an editable type. - /// - private bool IsEditableType(object value) - { - if (value is bool) return true; - if (value is sbyte) return true; - if (value is byte) return true; - if (value is short) return true; - if (value is ushort) return true; - if (value is int) return true; - if (value is uint) return true; - if (value is long) return true; - if (value is ulong) return true; - if (value is float) return true; - if (value is double) return true; - if (value is string) return true; - if (value is DateTime) return true; - if (value is Guid) return true; - - return false; - } - - /// - /// Shows the components of a value in the control. - /// - private void ShowChildren(ListViewItem listItem) - { - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable || state.Expanded) - { - return; - } - - m_expanding = true; - m_depth = listItem.IndentCount+1; - - state.Expanded = true; - listItem.ImageKey = CollapseIcon; - - int index = listItem.Index+1; - bool overwrite = false; - - ShowValue(ref index, ref overwrite, state.Component); - - AdjustColumns(); - } - - /// - /// Hides the components of a value in the control. - /// - private void HideChildren(ListViewItem listItem) - { - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable || !state.Expanded) - { - return; - } - - for (int ii = listItem.Index+1; ii < ItemsLV.Items.Count;) - { - ListViewItem childItem = ItemsLV.Items[ii]; - - if (childItem.IndentCount <= listItem.IndentCount) - { - break; - } - - childItem.Remove(); - } - - state.Expanded = false; - listItem.ImageKey = ExpandIcon; - } - - /// - /// Returns the list item at the specified index. - /// - private ListViewItem GetListItem(int index, ref bool overwrite, string name, string type) - { - ListViewItem listitem = null; - - // switch to detail view as soon as an item is added. - if (ItemsLV.View == View.List) - { - ItemsLV.Items.Clear(); - ItemsLV.View = View.Details; - } - - // check if there is an item that could be re-used. - if (!m_expanding && index < ItemsLV.Items.Count) - { - listitem = ItemsLV.Items[index]; - - // check if still possible to overwrite values. - if (overwrite) - { - if (listitem.SubItems[0].Text != name || listitem.SubItems[2].Text != type) - { - overwrite = false; - } - } - - listitem.SubItems[0].Text = name; - listitem.SubItems[2].Text = type; - - return listitem; - } - - overwrite = false; - - listitem = new ListViewItem(name); - - listitem.SubItems.Add(String.Empty); - listitem.SubItems.Add(type); - - listitem.Font = m_defaultFont; - listitem.ImageKey = ExpandIcon; - listitem.IndentCount = m_depth; - listitem.Tag = new ValueState(); - - if (!m_expanding) - { - ItemsLV.Items.Add(listitem); - } - else - { - ItemsLV.Items.Insert(index, listitem); - } - - return listitem; - } - - /// - /// Returns true if the type can be expanded. - /// - private bool IsExpandableType(object value) - { - // check for null. - if (value == null) - { - return false; - } - - // check for Variant. - if (value is Variant) - { - return IsExpandableType(((Variant)value).Value); - } - - // check for bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - return false; - } - - // check for xml element. - XmlElement xml = value as XmlElement; - - if (xml != null) - { - if (xml.ChildNodes.Count == 1 && xml.ChildNodes[0] is XmlText) - { - return false; - } - - return xml.HasChildNodes; - } - - // check for array. - Array array = value as Array; - - if (array != null) - { - return array.Length > 0; - } - - // check for list. - IList list = value as IList; - - if (list != null) - { - return list.Count > 0; - } - - // check for encodeable object. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - return true; - } - - // check for extension object. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - return IsExpandableType(extension.Body); - } - - // check for data value. - DataValue datavalue = value as DataValue; - - if (datavalue != null) - { - return true; - } - - // check for event value. - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - return true; - } - - // must be a simple value. - return false; - } - - /// - /// Formats a value for display in the control. - /// - private string GetValueText(object value) - { - // check for null. - if (value == null) - { - return "(null)"; - } - - // format bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - StringBuilder buffer = new StringBuilder(); - - for (int ii = 0; ii < bytes.Length; ii++) - { - if (ii != 0 && ii%16 == 0) - { - buffer.Append(" "); - } - - buffer.AppendFormat("{0:X2} ", bytes[ii]); - } - - return buffer.ToString(); - } - - // format xml element. - XmlElement xml = value as XmlElement; - - if (xml != null) - { - // return the entire element if not expandable. - if (!IsExpandableType(xml)) - { - return xml.OuterXml; - } - - // show only the start tag. - string text = xml.OuterXml; - - int index = text.IndexOf('>'); - - if (index != -1) - { - text = text.Substring(0, index); - } - - return text; - } - - // format array. - Array array = value as Array; - - if (array != null) - { - return Utils.Format("{1}[{0}]", array.Length, value.GetType().GetElementType().Name); - } - - // format list. - IList list = value as IList; - - if (list != null) - { - string type = value.GetType().Name; - - if (type.EndsWith("Collection")) - { - type = type.Substring(0, type.Length - "Collection".Length); - } - else - { - type = "Object"; - } - - return Utils.Format("{1}[{0}]", list.Count, type); - } - - // format encodeable object. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - return encodeable.GetType().Name; - } - - // format extension object. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - return GetValueText(extension.Body); - } - - // check for event value. - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - if (m_monitoredItem != null) - { - return String.Format("{0}", m_monitoredItem.GetEventType(eventFields)); - } - - return eventFields.GetType().Name; - } - - // check for data value. - DataValue dataValue = value as DataValue; - - if (dataValue != null) - { - if (StatusCode.IsBad(dataValue.StatusCode)) - { - return String.Format("{0}", dataValue.StatusCode); - } - - return String.Format("{0}", dataValue.Value); - } - - // use default formatting. - return Utils.Format("{0}", value); - } - - /// - /// Updates the list with the specified value. - /// - private void UpdateList( - ref int index, - ref bool overwrite, - object value, - object componentValue, - object componentId, - string name, - string type) - { - // get the list item to update. - ListViewItem listitem = GetListItem(index, ref overwrite, name, type); - - // update list item. - listitem.SubItems[1].Text = GetValueText(componentValue); - - // move to next item. - index++; - - ValueState state = listitem.Tag as ValueState; - - // recursively update sub-values if item is expanded. - if (overwrite) - { - if (state.Expanded && state.Expandable) - { - m_depth++; - ShowValue(ref index, ref overwrite, componentValue); - m_depth--; - } - } - - // update state. - state.Expandable = IsExpandableType(componentValue); - state.Value = value; - state.Component = componentValue; - state.ComponentId = componentId; - - if (!state.Expandable) - { - listitem.ImageKey = CollapseIcon; - } - } - - /// - /// Shows property of an encodeable object in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, IEncodeable value, PropertyInfo property) - { - // get the name of the property. - string name = Utils.GetDataMemberName(property); - - if (name == null) - { - return; - } - - // get the property value. - object propertyValue = null; - - MethodInfo[] accessors = property.GetAccessors(); - - for (int ii = 0; ii < accessors.Length; ii++) - { - if (accessors[ii].ReturnType == property.PropertyType) - { - propertyValue = accessors[ii].Invoke(value, null); - break; - } - } - - if (propertyValue is Variant) - { - propertyValue = ((Variant)propertyValue).Value; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - propertyValue, - property, - name, - property.PropertyType.Name); - } - - /// - /// Shows the element of an array in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, Array value, int element) - { - // get the name of the element. - string name = Utils.Format("[{0}]", element); - - // get the element value. - object elementValue = value.GetValue(element); - - // get the type name. - string type = null; - - if (elementValue != null) - { - type = elementValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - elementValue, - element, - name, - type); - } - - /// - /// Asks for confirmation before expanding a long list. - /// - private bool PromptOnLongList(int length) - { - if (length < 256) - { - return true; - } - - DialogResult result = MessageBox.Show("It may take a long time to display the list are you sure you want to continue?", "Warning", MessageBoxButtons.YesNo); - - if (result == DialogResult.Yes) - { - return true; - } - - return false; - } - - /// - /// Shows the element of a list in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, IList value, int element) - { - // get the name of the element. - string name = Utils.Format("[{0}]", element); - - // get the element value. - object elementValue = value[element]; - - // get the type name. - string type = null; - - if (elementValue != null) - { - type = elementValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - elementValue, - element, - name, - type); - } - - /// - /// Shows an XML element in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, XmlElement value, int childIndex) - { - // ignore children that are not elements. - XmlElement child = value.ChildNodes[childIndex] as XmlElement; - - if (child == null) - { - return; - } - - // get the name of the element. - string name = Utils.Format("{0}", child.Name); - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - child, - childIndex, - name, - type); - } - - /// - /// Shows an event in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, EventFieldList value, int fieldIndex) - { - // ignore children that are not elements. - object field = value.EventFields[fieldIndex].Value; - - if (field == null) - { - return; - } - - // get the name of the element. - string name = null; - - if (m_monitoredItem != null) - { - name = m_monitoredItem.GetFieldName(fieldIndex); - } - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - field, - fieldIndex, - name, - type); - } - - /// - /// Shows a byte array in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, byte[] value, int blockStart) - { - // get the name of the element. - string name = Utils.Format("[{0:X4}]", blockStart); - - int bytesLeft = value.Length - blockStart; - - if (bytesLeft > 16) - { - bytesLeft = 16; - } - - // get the element value. - byte[] blockValue = new byte[bytesLeft]; - Array.Copy(value, blockStart, blockValue, 0, bytesLeft); - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - blockValue, - blockStart, - name, - type); - } - - /// - /// Shows a data value in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, DataValue value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Value"; - componentValue = value.Value; - - ExtensionObject extension = componentValue as ExtensionObject; - - if (extension != null) - { - componentValue = extension.Body; - } - - break; - } - - case 1: - { - name = "StatusCode"; - componentValue = value.StatusCode; - break; - } - - case 2: - { - if (value.SourceTimestamp != DateTime.MinValue) - { - name = "SourceTimestamp"; - componentValue = value.SourceTimestamp; - } - - break; - } - - case 3: - { - if (value.ServerTimestamp != DateTime.MinValue) - { - name = "ServerTimestamp"; - componentValue = value.ServerTimestamp; - } - - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows a node id in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, NodeId value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "IdType"; - componentValue = value.IdType; - break; - } - - case 1: - { - name = "Identifier"; - componentValue = value.Identifier; - break; - } - - case 2: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows am expanded node id in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, ExpandedNodeId value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "IdType"; - componentValue = value.IdType; - break; - } - - case 1: - { - name = "Identifier"; - componentValue = value.Identifier; - break; - } - - case 2: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - - case 3: - { - name = "NamespaceUri"; - componentValue = value.NamespaceUri; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows qualified name in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, QualifiedName value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Name"; - componentValue = value.Name; - break; - } - - case 1: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows localized text in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, LocalizedText value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Text"; - componentValue = value.Text; - break; - } - - case 1: - { - name = "Locale"; - componentValue = value.Locale; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows a string in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, string value) - { - string name = "Value"; - object componentValue = value; - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - 0, - name, - type); - } - - /// - /// Shows a value in control. - /// - private void ShowValue(ref int index, ref bool overwrite, object value) - { - if (value == null) - { - return; - } - - // show monitored items. - MonitoredItem monitoredItem = value as MonitoredItem; - - if (monitoredItem != null) - { - m_monitoredItem = monitoredItem; - ShowValue(ref index, ref overwrite, monitoredItem.LastValue); - return; - } - - // show data changes - MonitoredItemNotification datachange = value as MonitoredItemNotification; - - if (datachange != null) - { - ShowValue(ref index, ref overwrite, datachange.Value); - return; - } - - // show events - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - for (int ii = 0; ii < eventFields.EventFields.Count; ii++) - { - ShowValue(ref index, ref overwrite, eventFields, ii); - } - - return; - } - - // show extension bodies. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - ShowValue(ref index, ref overwrite, extension.Body); - return; - } - - // show encodeables. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - PropertyInfo[] properties = encodeable.GetType().GetProperties(); - - foreach (PropertyInfo property in properties) - { - ShowValue(ref index, ref overwrite, encodeable, property); - } - - return; - } - - // show bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - if (!PromptOnLongList(bytes.Length/16)) - { - return; - } - - for (int ii = 0; ii < bytes.Length; ii+=16) - { - ShowValue(ref index, ref overwrite, bytes, ii); - } - - return; - } - - // show arrays - Array array = value as Array; - - if (array != null) - { - if (!PromptOnLongList(array.Length)) - { - return; - } - - for (int ii = 0; ii < array.Length; ii++) - { - ShowValue(ref index, ref overwrite, array, ii); - } - - return; - } - - // show lists - IList list = value as IList; - - if (list != null) - { - if (!PromptOnLongList(list.Count)) - { - return; - } - - for (int ii = 0; ii < list.Count; ii++) - { - ShowValue(ref index, ref overwrite, list, ii); - } - - return; - } - - // show xml elements - XmlElement xml = value as XmlElement; - - if (xml != null) - { - if (!PromptOnLongList(xml.ChildNodes.Count)) - { - return; - } - - for (int ii = 0; ii < xml.ChildNodes.Count; ii++) - { - ShowValue(ref index, ref overwrite, xml, ii); - } - - return; - } - - // show data value. - DataValue datavalue = value as DataValue; - - if (datavalue != null) - { - ShowValue(ref index, ref overwrite, datavalue, 0); - ShowValue(ref index, ref overwrite, datavalue, 1); - ShowValue(ref index, ref overwrite, datavalue, 2); - ShowValue(ref index, ref overwrite, datavalue, 3); - return; - } - - // show node id value. - NodeId nodeId = value as NodeId; - - if (nodeId != null) - { - ShowValue(ref index, ref overwrite, nodeId, 0); - ShowValue(ref index, ref overwrite, nodeId, 1); - ShowValue(ref index, ref overwrite, nodeId, 2); - return; - } - - // show expanded node id value. - ExpandedNodeId expandedNodeId = value as ExpandedNodeId; - - if (expandedNodeId != null) - { - ShowValue(ref index, ref overwrite, expandedNodeId, 0); - ShowValue(ref index, ref overwrite, expandedNodeId, 1); - ShowValue(ref index, ref overwrite, expandedNodeId, 2); - ShowValue(ref index, ref overwrite, expandedNodeId, 3); - return; - } - - // show qualified name value. - QualifiedName qualifiedName = value as QualifiedName; - - if (qualifiedName != null) - { - ShowValue(ref index, ref overwrite, qualifiedName, 0); - ShowValue(ref index, ref overwrite, qualifiedName, 1); - return; - } - - // show qualified name value. - LocalizedText localizedText = value as LocalizedText; - - if (localizedText != null) - { - ShowValue(ref index, ref overwrite, localizedText, 0); - ShowValue(ref index, ref overwrite, localizedText, 1); - return; - } - - // show variant. - Variant? variant = value as Variant?; - - if (variant != null) - { - ShowValue(ref index, ref overwrite, variant.Value.Value); - return; - } - - // show unknown types as strings. - ShowValue(ref index, ref overwrite, String.Format("{0}", value)); - } - - private void ItemsLV_MouseClick(object sender, MouseEventArgs e) - { - try - { - if (e.Button != MouseButtons.Left) - { - return; - } - - ListViewItem listItem = ItemsLV.GetItemAt(e.X, e.Y); - - if (listItem == null) - { - return; - } - - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable) - { - return; - } - - if (state.Expanded) - { - HideChildren(listItem); - } - else - { - ShowChildren(listItem); - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - - #region Event Handlers - private void UpdatesMI_CheckedChanged(object sender, EventArgs e) - { - try - { - /* - if (m_monitoredItem != null) - { - if (UpdatesMI.Checked) - { - m_monitoredItem.Notification += m_MonitoredItemNotification; - } - else - { - m_monitoredItem.Notification -= m_MonitoredItemNotification; - } - } - */ - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void RefreshMI_Click(object sender, EventArgs e) - { - try - { - /* - Clear(); - ShowValue(m_monitoredItem); - */ - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ClearMI_Click(object sender, EventArgs e) - { - try - { - Clear(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void EditMI_Click(object sender, EventArgs e) - { - try - { - if (ItemsLV.SelectedItems.Count != 1) - { - return; - } - - ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState; - - if (!IsEditableType(state.Component)) - { - return; - } - - object value = null; - - /* - object value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType()); - - if (value == null) - { - return; - } - * */ - - if (state.Value is IEncodeable) - { - PropertyInfo property = (PropertyInfo)state.ComponentId; - - MethodInfo[] accessors = property.GetAccessors(); - - for (int ii = 0; ii < accessors.Length; ii++) - { - if (accessors[ii].ReturnType == typeof(void)) - { - accessors[ii].Invoke(state.Value, new object[] { value }); - state.Component = value; - break; - } - } - } - - DataValue datavalue = state.Value as DataValue; - - if (datavalue != null) - { - int component = (int)state.ComponentId; - - switch (component) - { - case 0: { datavalue.Value = value; break; } - } - } - - if (state.Value is IList) - { - int ii = (int)state.ComponentId; - ((IList)state.Value)[ii] = value; - state.Component = value; - } - - m_expanding = false; - int index = 0; - bool overwrite = true; - ShowValue(ref index, ref overwrite, state.Value); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.resx deleted file mode 100644 index edd3be8a4d..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DataListCtrl.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.Designer.cs deleted file mode 100644 index 2f09a26a32..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.Designer.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class DateTimeValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ValueCTRL = new System.Windows.Forms.DateTimePicker(); - this.ButtonsPN.SuspendLayout(); - this.MainPN.SuspendLayout(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 28); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(215, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(136, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // MainPN - // - this.MainPN.Controls.Add(this.ValueCTRL); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Size = new System.Drawing.Size(215, 28); - this.MainPN.TabIndex = 1; - // - // ValueCTRL - // - this.ValueCTRL.CustomFormat = "yyyy-MM-dd HH:mm:ss"; - this.ValueCTRL.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.ValueCTRL.Location = new System.Drawing.Point(4, 5); - this.ValueCTRL.MaxDate = new System.DateTime(2100, 12, 21, 0, 0, 0, 0); - this.ValueCTRL.MinDate = new System.DateTime(1900, 1, 1, 0, 0, 0, 0); - this.ValueCTRL.Name = "ValueCTRL"; - this.ValueCTRL.Size = new System.Drawing.Size(207, 20); - this.ValueCTRL.TabIndex = 0; - // - // DateTimeValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(215, 59); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.ButtonsPN); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(221, 91); - this.Name = "DateTimeValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit DateTime Value"; - this.ButtonsPN.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel MainPN; - private System.Windows.Forms.DateTimePicker ValueCTRL; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/DateTimeValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.Designer.cs deleted file mode 100644 index 7627d6db3d..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.Designer.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class ExceptionDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.BottomPanel = new System.Windows.Forms.Panel(); - this.OkButton = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ExceptionBrowser = new System.Windows.Forms.WebBrowser(); - this.BottomPanel.SuspendLayout(); - this.MainPN.SuspendLayout(); - this.SuspendLayout(); - // - // BottomPanel - // - this.BottomPanel.Controls.Add(this.OkButton); - this.BottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom; - this.BottomPanel.Location = new System.Drawing.Point(0, 433); - this.BottomPanel.Name = "BottomPanel"; - this.BottomPanel.Size = new System.Drawing.Size(770, 37); - this.BottomPanel.TabIndex = 0; - // - // OkButton - // - this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); - this.OkButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.OkButton.Location = new System.Drawing.Point(348, 8); - this.OkButton.Name = "OkButton"; - this.OkButton.Size = new System.Drawing.Size(75, 23); - this.OkButton.TabIndex = 0; - this.OkButton.Text = "OK"; - this.OkButton.UseVisualStyleBackColor = true; - this.OkButton.Click += new System.EventHandler(this.OkButton_Click); - // - // MainPN - // - this.MainPN.Controls.Add(this.ExceptionBrowser); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Padding = new System.Windows.Forms.Padding(3); - this.MainPN.Size = new System.Drawing.Size(770, 433); - this.MainPN.TabIndex = 1; - // - // ExceptionBrowser - // - this.ExceptionBrowser.Dock = System.Windows.Forms.DockStyle.Fill; - this.ExceptionBrowser.Location = new System.Drawing.Point(3, 3); - this.ExceptionBrowser.MinimumSize = new System.Drawing.Size(20, 20); - this.ExceptionBrowser.Name = "ExceptionBrowser"; - this.ExceptionBrowser.Size = new System.Drawing.Size(764, 427); - this.ExceptionBrowser.TabIndex = 0; - // - // ExceptionDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(770, 470); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.BottomPanel); - this.Name = "ExceptionDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Exception"; - this.BottomPanel.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel BottomPanel; - private System.Windows.Forms.Button OkButton; - private System.Windows.Forms.Panel MainPN; - private System.Windows.Forms.WebBrowser ExceptionBrowser; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.cs deleted file mode 100644 index e2d48d479f..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.cs +++ /dev/null @@ -1,135 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A dialog that displays an exception trace in an HTML page. - /// - public partial class ExceptionDlg : Form - { - /// - /// Initializes a new instance of the class. - /// - public ExceptionDlg() - { - InitializeComponent(); - } - - /// - /// Replaces all special characters in the message. - /// - private string ReplaceSpecialCharacters(string message) - { - message = message.Replace("&", "&"); - message = message.Replace("<", "<"); - message = message.Replace(">", ">"); - message = message.Replace("\"", """); - message = message.Replace("'", "'"); - message = message.Replace("\r\n", "
"); - - return message; - } - - /// - /// Display the exception in the dialog. - /// - public void ShowDialog(string caption, Exception e) - { - Text = caption; - - StringBuilder buffer = new StringBuilder(); - - buffer.Append(""); - - while (e != null) - { - string message = e.Message; - - ServiceResultException exception = e as ServiceResultException; - - if (exception != null) - { - message = exception.ToLongString(); - } - - message = ReplaceSpecialCharacters(message); - - if (exception != null) - { - buffer.Append("

"); - buffer.Append(""); - buffer.Append(message); - buffer.Append(""); - buffer.Append("

"); - } - else - { - buffer.Append(""); - buffer.Append(message); - buffer.Append("
"); - } - - message = e.StackTrace; - - if (!String.IsNullOrEmpty(message)) - { - message = ReplaceSpecialCharacters(message); - - buffer.Append("

"); - buffer.Append(""); - buffer.Append(message); - buffer.Append(""); - buffer.Append("

"); - } - - e = e.InnerException; - } - - buffer.Append(""); - - ExceptionBrowser.DocumentText = buffer.ToString(); - - ShowDialog(); - } - - private void OkButton_Click(object sender, EventArgs e) - { - Close(); - } - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ExceptionDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.Designer.cs deleted file mode 100644 index 7d88864373..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.Designer.cs +++ /dev/null @@ -1,116 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class GuiUtils - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GuiUtils)); - this.ImageList = new System.Windows.Forms.ImageList(this.components); - this.SuspendLayout(); - // - // ImageList - // - this.ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ImageList.ImageStream"))); - this.ImageList.TransparentColor = System.Drawing.Color.Transparent; - this.ImageList.Images.SetKeyName(0, "SimpleItem"); - this.ImageList.Images.SetKeyName(1, "Object"); - this.ImageList.Images.SetKeyName(2, "FolderOld"); - this.ImageList.Images.SetKeyName(3, "Area"); - this.ImageList.Images.SetKeyName(4, "Variable"); - this.ImageList.Images.SetKeyName(5, "Property"); - this.ImageList.Images.SetKeyName(6, "Method"); - this.ImageList.Images.SetKeyName(7, "ReferenceType"); - this.ImageList.Images.SetKeyName(8, "DataType"); - this.ImageList.Images.SetKeyName(9, "View"); - this.ImageList.Images.SetKeyName(10, "ExpandPlus"); - this.ImageList.Images.SetKeyName(11, "ExpandMinus"); - this.ImageList.Images.SetKeyName(12, "VariableType"); - this.ImageList.Images.SetKeyName(13, "ObjectType"); - this.ImageList.Images.SetKeyName(14, "Info"); - this.ImageList.Images.SetKeyName(15, "Server"); - this.ImageList.Images.SetKeyName(16, "ServerStopped"); - this.ImageList.Images.SetKeyName(17, "Computer"); - this.ImageList.Images.SetKeyName(18, "Network"); - this.ImageList.Images.SetKeyName(19, "Folder"); - this.ImageList.Images.SetKeyName(20, "SelectedFolder"); - this.ImageList.Images.SetKeyName(21, "Process"); - this.ImageList.Images.SetKeyName(22, "Certificate"); - this.ImageList.Images.SetKeyName(23, "CertificateStore"); - this.ImageList.Images.SetKeyName(24, "Users"); - this.ImageList.Images.SetKeyName(25, "Service"); - this.ImageList.Images.SetKeyName(26, "InvalidCertificate"); - this.ImageList.Images.SetKeyName(27, "Drive"); - this.ImageList.Images.SetKeyName(28, "ServiceGroup"); - this.ImageList.Images.SetKeyName(29, "Desktop"); - this.ImageList.Images.SetKeyName(30, "SingleUser"); - this.ImageList.Images.SetKeyName(31, "UserGroup"); - this.ImageList.Images.SetKeyName(32, "RedCross"); - this.ImageList.Images.SetKeyName(33, "GreenCheck"); - this.ImageList.Images.SetKeyName(34, "UsersRedCross"); - // - // GuiUtils - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Name = "GuiUtils"; - this.ResumeLayout(false); - - } - - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.cs deleted file mode 100644 index 52e9f7c578..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.cs +++ /dev/null @@ -1,998 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; -using Opc.Ua.Configuration; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A class that provide various common utility functions and shared resources. - /// - public partial class GuiUtils : UserControl - { - /// - /// Initializes a new instance of the class. - /// - public GuiUtils() - { - InitializeComponent(); - } - - /// - /// The list of icon images. - /// - public System.Windows.Forms.ImageList ImageList; - - /// - /// Displays the details of an exception. - /// - public static void HandleException(string caption, MethodBase method, Exception e) - { - if (String.IsNullOrEmpty(caption)) - { - caption = method.Name; - } - - new ExceptionDlg().ShowDialog(caption, e); - } - - /// - /// Defines names for the available 16x16 icons. - /// - public static class Icons - { - /// - /// An attribute - /// - public const string Attribute = "SimpleItem"; - - /// - /// A property - /// - public const string Property = "Property"; - - /// - /// A variable - /// - public const string Variable = "Variable"; - - /// - /// An object - /// - public const string Object = "Object"; - - /// - /// A method - /// - public const string Method = "Method"; - - /// - /// A single computer. - /// - public const string Computer = "Computer"; - - /// - /// A computer network. - /// - public const string Network = "Network"; - - /// - /// A folder. - /// - public const string Folder = "Folder"; - - /// - /// A selected folder. - /// - public const string SelectedFolder = "SelectedFolder"; - - /// - /// A process or application. - /// - public const string Process = "Process"; - - /// - /// A certificate - /// - public const string Certificate = "Certificate"; - - /// - /// An invalid certificate - /// - public const string InvalidCertificate = "InvalidCertificate"; - - /// - /// A certificate store - /// - public const string CertificateStore = "CertificateStore"; - - /// - /// A group of users. - /// - public const string Users = "Users"; - - /// - /// A service. - /// - public const string Service = "Service"; - - /// - /// A logical drive. - /// - public const string Drive = "Drive"; - - /// - /// The computer desktop. - /// - public const string Desktop = "Desktop"; - - /// - /// A single user. - /// - public const string SingleUser = "SingleUser"; - - /// - /// A group of services. - /// - public const string ServiceGroup = "ServiceGroup"; - - /// - /// A group of users. - /// - public const string UserGroup = "UserGroup"; - - /// - /// A green check - /// - public const string GreenCheck = "GreenCheck"; - - /// - /// A red cross - /// - public const string RedCross = "RedCross"; - - /// - /// A users icon with a red cross through it. - /// - public const string UsersRedCross = "UsersRedCross"; - } - - /// - /// Uses the command line to override the UA TCP implementation specified in the configuration. - /// - /// The configuration instance that stores the configurable information for a UA application. - /// - public static void OverrideUaTcpImplementation(ApplicationConfiguration configuration) - { - // check if UA TCP configuration included. - TransportConfiguration transport = null; - - for (int ii = 0; ii < configuration.TransportConfigurations.Count; ii++) - { - if (configuration.TransportConfigurations[ii].UriScheme == Utils.UriSchemeOpcTcp) - { - transport = configuration.TransportConfigurations[ii]; - break; - } - } - - // check if UA TCP implementation explicitly specified. - if (transport != null) - { - string[] args = Environment.GetCommandLineArgs(); - - if (args != null && args.Length > 1) - { - if (String.Compare(args[1], "-uaTcpAnsiC", StringComparison.InvariantCultureIgnoreCase) == 0) - { - transport.TypeName = Utils.UaTcpBindingNativeStack; - } - else if (String.Compare(args[1], "-uaTcpDotNet", StringComparison.InvariantCultureIgnoreCase) == 0) - { - transport.TypeName = Utils.UaTcpBindingDefault; - } - } - } - } - - /// - /// Displays the UA-TCP configuration in the form. - /// - /// The form to display the UA-TCP configuration. - /// The configuration instance that stores the configurable information for a UA application. - public static void DisplayUaTcpImplementation(Form form, ApplicationConfiguration configuration) - { - // check if UA TCP configuration included. - TransportConfiguration transport = null; - - for (int ii = 0; ii < configuration.TransportConfigurations.Count; ii++) - { - if (configuration.TransportConfigurations[ii].UriScheme == Utils.UriSchemeOpcTcp) - { - transport = configuration.TransportConfigurations[ii]; - break; - } - } - - // check if UA TCP implementation explicitly specified. - if (transport != null) - { - string text = form.Text; - - int index = text.LastIndexOf("(UA TCP - "); - - if (index >= 0) - { - text = text.Substring(0, index); - } - - if (transport.TypeName == Utils.UaTcpBindingNativeStack) - { - form.Text = Utils.Format("{0} (UA TCP - ANSI C)", text); - } - else - { - form.Text = Utils.Format("{0} (UA TCP - C#)", text); - } - } - } - - /// - /// Handles a certificate validation error. - /// - /// The caller's text is used as the caption of the shown to provide details about the error. - /// The validator (not used). - /// The instance event arguments provided when a certificate validation error occurs. - public static void HandleCertificateValidationError(Form caller, CertificateValidator validator, CertificateValidationEventArgs e) - { - StringBuilder buffer = new StringBuilder(); - - buffer.AppendFormat("Certificate could not validated: {0}\r\n\r\n", e.Error.StatusCode); - buffer.AppendFormat("Subject: {0}\r\n", e.Certificate.Subject); - buffer.AppendFormat("Issuer: {0}\r\n", (e.Certificate.Subject == e.Certificate.Issuer)?"Self-signed":e.Certificate.Issuer); - buffer.AppendFormat("Valid From: {0}\r\n", e.Certificate.NotBefore); - buffer.AppendFormat("Valid To: {0}\r\n", e.Certificate.NotAfter); - buffer.AppendFormat("Thumbprint: {0}\r\n\r\n", e.Certificate.Thumbprint); - - buffer.AppendFormat("Accept anyways?"); - - if (MessageBox.Show(buffer.ToString(), caller.Text, MessageBoxButtons.YesNo) == DialogResult.Yes) - { - e.Accept = true; - } - } - - /// - /// Does any configuration checks before starting up. - /// - public static ApplicationConfiguration LoadConfiguration( - string configSectionName, - ApplicationType applicationType, - string defaultConfigFile, - bool interactive) - { - // get the location of the config file. - string filePath = ApplicationConfiguration.GetFilePathFromAppConfig(configSectionName); - - if (filePath == null || !System.IO.File.Exists(filePath)) - { - filePath = Utils.GetAbsoluteFilePath(defaultConfigFile, false, false, false); - } - - try - { - // load the configuration file. - ApplicationConfiguration configuration = ApplicationConfiguration.Load(new System.IO.FileInfo(filePath), applicationType, null); - - if (configuration == null) - { - return null; - } - - return configuration; - } - catch (Exception e) - { - // warn user. - if (interactive) - { - StringBuilder message = new StringBuilder(); - - message.Append("Could not load configuration file.\r\n"); - message.Append(filePath); - message.Append("\r\n"); - message.Append("\r\n"); - message.Append(e.Message); - - MessageBox.Show(message.ToString(), "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - Utils.Trace(e, "Could not load configuration file. {0}", filePath); - return null; - } - } - - /// - /// Does any configuration checks before starting up. - /// - public static ApplicationConfiguration DoStartupChecks( - string configSectionName, - ApplicationType applicationType, - string defaultConfigFile, - bool interactive) - { - // load the configuration file. - ApplicationConfiguration configuration = LoadConfiguration(configSectionName, applicationType, defaultConfigFile, interactive); - - if (configuration == null) - { - return null; - } - - // check the certificate. - X509Certificate2 certificate = CheckApplicationInstanceCertificate(configuration, 1024, interactive, true); - - if (certificate == null) - { - return null; - } - - // ensure the application uri matches the certificate. - string applicationUri = Utils.GetApplicationUriFromCertficate(certificate); - - if (applicationUri != null) - { - configuration.ApplicationUri = applicationUri; - } - - return configuration; - } - - /// - /// Configures the firewall. - /// - /// The configuration. - /// if set to true if the user should be prompted. - public static void ConfigureFirewall(ApplicationConfiguration configuration, bool interactive) - { - // check if application configuration requires it. - if (!configuration.SecurityConfiguration.ConfigureFirewall) - { - return; - } - - // ensure the firewall is configured. - if (configuration.ServerConfiguration == null && configuration.DiscoveryServerConfiguration == null) - { - return; - } - - // check if there are any ports to open. - StringCollection baseAddresses = null; - - if (configuration.ServerConfiguration != null) - { - baseAddresses = configuration.ServerConfiguration.BaseAddresses; - } - - if (configuration.DiscoveryServerConfiguration != null) - { - baseAddresses = configuration.DiscoveryServerConfiguration.BaseAddresses; - } - - if (baseAddresses == null || baseAddresses.Count == 0) - { - return; - } - - // check if firewall needs configuration. - try - { - if (!ConfigUtils.CheckFirewallAccess(Application.ExecutablePath, baseAddresses)) - { - bool configure = true; - - if (interactive) - { - string message = "The firewall has not been configured to allow external access to the server. Configure firewall?"; - - if (MessageBox.Show(message, configuration.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) - { - configure = false; - } - } - - if (configure) - { - ConfigUtils.SetFirewallAccess(configuration.ApplicationName, Application.ExecutablePath, baseAddresses); - } - } - } - catch (Exception e) - { - Utils.Trace(e, "Unexpected error while checking or changing the firewall configuration."); - } - } - - /// - /// Deletes an existing application instance certificate. - /// - /// The configuration instance that stores the configurable information for a UA application. - public static void DeleteApplicationInstanceCertificate(ApplicationConfiguration configuration) - { - // create a default certificate id none specified. - CertificateIdentifier id = configuration.SecurityConfiguration.ApplicationCertificate; - - if (id == null) - { - return; - } - - // delete private key. - X509Certificate2 certificate = id.Find(); - - // delete trusted peer certificate. - if (configuration.SecurityConfiguration != null && configuration.SecurityConfiguration.TrustedPeerCertificates != null) - { - string thumbprint = id.Thumbprint; - - if (certificate != null) - { - thumbprint = certificate.Thumbprint; - } - - if (!String.IsNullOrEmpty(thumbprint)) - { - using (ICertificateStore store = configuration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) - { - store.Delete(thumbprint); - } - } - } - - // delete private key. - if (certificate != null) - { - using (ICertificateStore store = id.OpenStore()) - { - store.Delete(certificate.Thumbprint); - } - } - } - - /// - /// Creates an application instance certificate if one does not already exist. - /// - public static X509Certificate2 CheckApplicationInstanceCertificate(ApplicationConfiguration configuration) - { - return CheckApplicationInstanceCertificate(configuration, 1024, Environment.UserInteractive, true); - } - - /// - /// Creates an application instance certificate if one does not already exist. - /// - public static X509Certificate2 CheckApplicationInstanceCertificate( - ApplicationConfiguration configuration, - ushort keySize, - bool interactive, - bool updateFile) - { - // create a default certificate id none specified. - CertificateIdentifier id = configuration.SecurityConfiguration.ApplicationCertificate; - - if (id == null) - { - id = new CertificateIdentifier(); - id.StoreType = Utils.DefaultStoreType; - id.StorePath = Utils.DefaultStorePath; - id.SubjectName = configuration.ApplicationName; - } - - bool createNewCertificate = false; - IList serverDomainNames = configuration.GetServerDomainNames(); - - // check for private key. - X509Certificate2 certificate = id.Find(true); - - if (certificate == null) - { - // check if config file has wrong thumprint. - if (!String.IsNullOrEmpty(id.SubjectName) && !String.IsNullOrEmpty(id.Thumbprint)) - { - CertificateIdentifier id2 = new CertificateIdentifier(); - id2.StoreType = id.StoreType; - id2.StorePath = id.StorePath; - id2.SubjectName = id.SubjectName; - id = id2; - - certificate = id2.Find(true); - - if (certificate != null) - { - string message = Utils.Format( - "Matching certificate with SubjectName={0} found but with a different thumbprint. Use certificate?", - id.SubjectName); - - if (interactive) - { - if (MessageBox.Show(message, configuration.ApplicationName, MessageBoxButtons.YesNo) == DialogResult.No) - { - certificate = null; - } - } - } - } - } - - // check if private key is missing. - if (certificate == null) - { - certificate = id.Find(false); - - if (certificate != null) - { - string message = Utils.Format( - "Matching certificate with SubjectName={0} found but without a private key. Create a new certificate?", - id.SubjectName); - - if (interactive) - { - if (MessageBox.Show(message, configuration.ApplicationName, MessageBoxButtons.YesNo) == DialogResult.No) - { - certificate = null; - } - } - } - } - - // check domains. - if (certificate != null) - { - IList certificateDomainNames = Utils.GetDomainsFromCertficate(certificate); - - for (int ii = 0; ii < serverDomainNames.Count; ii++) - { - if (Utils.FindStringIgnoreCase(certificateDomainNames, serverDomainNames[ii])) - { - continue; - } - - if (String.Compare(serverDomainNames[ii], "localhost", StringComparison.OrdinalIgnoreCase) == 0) - { - // check computer name. - string computerName = System.Net.Dns.GetHostName(); - - if (Utils.FindStringIgnoreCase(certificateDomainNames, computerName)) - { - continue; - } - - // check for aliases. - System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry(computerName); - - bool found = false; - - for (int jj = 0; jj < entry.Aliases.Length; jj++) - { - if (Utils.FindStringIgnoreCase(certificateDomainNames, entry.Aliases[jj])) - { - found = true; - break; - } - } - - if (found) - { - continue; - } - - // check for ip addresses. - for (int jj = 0; jj < entry.AddressList.Length; jj++) - { - if (Utils.FindStringIgnoreCase(certificateDomainNames, entry.AddressList[jj].ToString())) - { - found = true; - break; - } - } - - if (found) - { - continue; - } - } - - string message = Utils.Format( - "The server is configured to use domain '{0}' which does not appear in the certificate. Update certificate?", - serverDomainNames[ii]); - - createNewCertificate = true; - - if (interactive) - { - if (MessageBox.Show(message, configuration.ApplicationName, MessageBoxButtons.YesNo) != DialogResult.Yes) - { - createNewCertificate = false; - continue; - } - } - - Utils.Trace(message); - break; - } - - if (!createNewCertificate) - { - // check if key size matches. - if (keySize == certificate.PublicKey.Key.KeySize) - { - AddToTrustedStore(configuration, certificate); - return certificate; - } - } - } - - // prompt user. - if (interactive) - { - if (!createNewCertificate) - { - if (MessageBox.Show("Application does not have an instance certificate. Create one automatically?", configuration.ApplicationName, MessageBoxButtons.YesNo) == DialogResult.No) - { - return null; - } - } - } - - // delete existing certificate. - if (certificate != null) - { - DeleteApplicationInstanceCertificate(configuration); - } - - // add the localhost. - if (serverDomainNames.Count == 0) - { - serverDomainNames.Add(System.Net.Dns.GetHostName()); - } - - certificate = Opc.Ua.CertificateFactory.CreateCertificate( - id.StoreType, - id.StorePath, - configuration.ApplicationUri, - configuration.ApplicationName, - null, - serverDomainNames, - keySize, - 300); - - id.Certificate = certificate; - AddToTrustedStore(configuration, certificate); - - if (updateFile && !String.IsNullOrEmpty(configuration.SourceFilePath)) - { - configuration.SaveToFile(configuration.SourceFilePath); - } - - configuration.CertificateValidator.Update(configuration.SecurityConfiguration); - - return configuration.SecurityConfiguration.ApplicationCertificate.LoadPrivateKey(null); - } - - /// - /// Adds the certificate to the Trusted Certificate Store - /// - /// The application's configuration which specifies the location of the TrustedStore. - /// The certificate to register. - public static void AddToTrustedStore(ApplicationConfiguration configuration, X509Certificate2 certificate) - { - ICertificateStore store = configuration.SecurityConfiguration.TrustedPeerCertificates.OpenStore(); - - try - { - // check if it already exists. - X509Certificate2 certificate2 = store.FindByThumbprint(certificate.Thumbprint); - - if (certificate2 != null) - { - return; - } - - List subjectName = Utils.ParseDistinguishedName(certificate.Subject); - - // check for old certificate. - X509Certificate2Collection certificates = store.Enumerate(); - - for (int ii = 0; ii < certificates.Count; ii++) - { - if (Utils.CompareDistinguishedName(certificates[ii], subjectName)) - { - if (certificates[ii].Thumbprint == certificate.Thumbprint) - { - return; - } - - store.Delete(certificates[ii].Thumbprint); - break; - } - } - - // add new certificate. - X509Certificate2 publicKey = new X509Certificate2(certificate.GetRawCertData()); - store.Add(publicKey); - } - finally - { - store.Close(); - } - } - - /// - /// Returns a default value for the data type. - /// - public static object GetDefaultValue(NodeId datatypeId, int valueRank) - { - Type type = TypeInfo.GetSystemType(datatypeId, EncodeableFactory.GlobalFactory); - - if (type == null) - { - return null; - } - - if (valueRank < 0) - { - if (type == typeof(String)) - { - return System.String.Empty; - } - - if (type == typeof(byte[])) - { - return new byte[0]; - } - - if (type == typeof(NodeId)) - { - return Opc.Ua.NodeId.Null; - } - - if (type == typeof(ExpandedNodeId)) - { - return Opc.Ua.ExpandedNodeId.Null; - } - - if (type == typeof(QualifiedName)) - { - return Opc.Ua.QualifiedName.Null; - } - - if (type == typeof(LocalizedText)) - { - return Opc.Ua.LocalizedText.Null; - } - - if (type == typeof(Guid)) - { - return System.Guid.Empty; - } - - if (type == typeof(System.Xml.XmlElement)) - { - System.Xml.XmlDocument document = new System.Xml.XmlDocument(); - document.InnerXml = ""; - return document.DocumentElement; - } - - return Activator.CreateInstance(type); - } - - return Array.CreateInstance(type, new int[valueRank]); - } - - /// - /// Displays a dialog that allows a use to edit a value. - /// - public static object EditValue(Session session, object value) - { - TypeInfo typeInfo = TypeInfo.Construct(value); - - if (typeInfo != null) - { - return EditValue(session, value, (uint)typeInfo.BuiltInType, typeInfo.ValueRank); - } - - return null; - } - - /// - /// Displays a dialog that allows a use to edit a value. - /// - public static object EditValue(Session session, object value, NodeId datatypeId, int valueRank) - { - if (value == null) - { - value = GetDefaultValue(datatypeId, valueRank); - } - - if (valueRank >= 0) - { - return new ComplexValueEditDlg().ShowDialog(value); - } - - BuiltInType builtinType = TypeInfo.GetBuiltInType(datatypeId, session.TypeTree); - - switch (builtinType) - { - case BuiltInType.Boolean: - case BuiltInType.Byte: - case BuiltInType.SByte: - case BuiltInType.Int16: - case BuiltInType.UInt16: - case BuiltInType.Int32: - case BuiltInType.UInt32: - case BuiltInType.Int64: - case BuiltInType.UInt64: - case BuiltInType.Float: - case BuiltInType.Double: - case BuiltInType.Enumeration: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(builtinType, valueRank)); - } - - case BuiltInType.Number: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.Double, valueRank)); - } - - case BuiltInType.Integer: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.Int64, valueRank)); - } - - case BuiltInType.UInteger: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.UInt64, valueRank)); - } - - case BuiltInType.NodeId: - { - return new NodeIdValueEditDlg().ShowDialog(session, (NodeId)value); - } - - case BuiltInType.ExpandedNodeId: - { - return new NodeIdValueEditDlg().ShowDialog(session, (ExpandedNodeId)value); - } - - case BuiltInType.DateTime: - { - DateTime datetime = (DateTime)value; - - if (new DateTimeValueEditDlg().ShowDialog(ref datetime)) - { - return datetime; - } - - return null; - } - - case BuiltInType.QualifiedName: - { - QualifiedName qname = (QualifiedName)value; - - string name = new StringValueEditDlg().ShowDialog(qname.Name); - - if (name != null) - { - return new QualifiedName(name, qname.NamespaceIndex); - } - - return null; - } - - case BuiltInType.String: - { - return new StringValueEditDlg().ShowDialog((string)value); - } - - case BuiltInType.LocalizedText: - { - LocalizedText ltext = (LocalizedText)value; - - string text = new StringValueEditDlg().ShowDialog(ltext.Text); - - if (text != null) - { - return new LocalizedText(text, ltext.Locale); - } - - return null; - } - } - - return new ComplexValueEditDlg().ShowDialog(value); - } - - /// - /// Returns to display icon for the target of a reference. - /// - public static string GetTargetIcon(Session session, ReferenceDescription reference) - { - return GetTargetIcon(session, reference.NodeClass, reference.TypeDefinition); - } - - /// - /// Returns to display icon for the target of a reference. - /// - public static string GetTargetIcon(Session session, NodeClass nodeClass, ExpandedNodeId typeDefinitionId) - { - // make sure the type definition is in the cache. - INode typeDefinition = session.NodeCache.Find(typeDefinitionId); - - switch (nodeClass) - { - case NodeClass.Object: - { - if (session.TypeTree.IsTypeOf(typeDefinitionId, ObjectTypes.FolderType)) - { - return "Folder"; - } - - return "Object"; - } - - case NodeClass.Variable: - { - if (session.TypeTree.IsTypeOf(typeDefinitionId, VariableTypes.PropertyType)) - { - return "Property"; - } - - return "Variable"; - } - } - - return nodeClass.ToString(); - } - - #region Private Methods - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.resx deleted file mode 100644 index e1e42bcd1d..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/GuiUtils.resx +++ /dev/null @@ -1,539 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - False - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAe - XwAAAk1TRnQBSQFMAgEBIwEAASQBAAEEAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABkAMAAQEBAAEYBgABbBIAP/8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AbYB7QH4AakB7AH2AZIB4QHzAY0BoQGqAdUB3AHgHv8D+AOI - AzMD3gn/A94DMwOIA/g//wHYAe4B9gEUAaoB4QGGAeEB9AFrAdYB9AFQAcsB8QEXAZgByAHYAe4B9gn/ - Af0B7AH9Cf8B2gHeAeEBjwGkAawBjwGkAawBjwGkAawBjwGkAawBjwGkAawB1QHcAeAk/wPuA4gDMwP4 - A/8D+AMzA4gD7kX/AdgB7gH2ARQBqgHhAYUB4QH1ARcBmAHIAdgB7gH2tP8B2AHuAfYBFAGqAeEB2AHu - AfZ7/wFCAU0BPgcAAT4DAAEoAwABQAMAAZADAAEBAQABAQUAAYABBBYAA///AP8A/wD/AIUACw== - - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.Designer.cs deleted file mode 100644 index 9cad6797f0..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.Designer.cs +++ /dev/null @@ -1,106 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class NodeIdCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.NodeIdTB = new System.Windows.Forms.TextBox(); - this.BrowseBTN = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // NodeIdTB - // - this.NodeIdTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.NodeIdTB.Location = new System.Drawing.Point(0, 0); - this.NodeIdTB.Name = "NodeIdTB"; - this.NodeIdTB.Size = new System.Drawing.Size(175, 20); - this.NodeIdTB.TabIndex = 0; - this.NodeIdTB.TextChanged += new System.EventHandler(this.NodeIdTB_TextChanged); - // - // BrowseBTN - // - this.BrowseBTN.Dock = System.Windows.Forms.DockStyle.Right; - this.BrowseBTN.Location = new System.Drawing.Point(176, 0); - this.BrowseBTN.Name = "BrowseBTN"; - this.BrowseBTN.Size = new System.Drawing.Size(24, 20); - this.BrowseBTN.TabIndex = 5; - this.BrowseBTN.Text = "..."; - this.BrowseBTN.UseVisualStyleBackColor = true; - this.BrowseBTN.Click += new System.EventHandler(this.BrowseBTN_Click); - // - // NodeIdCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.BrowseBTN); - this.Controls.Add(this.NodeIdTB); - this.MaximumSize = new System.Drawing.Size(4096, 20); - this.MinimumSize = new System.Drawing.Size(100, 20); - this.Name = "NodeIdCtrl"; - this.Size = new System.Drawing.Size(200, 20); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox NodeIdTB; - private System.Windows.Forms.Button BrowseBTN; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.cs deleted file mode 100644 index 9d03afdc78..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.cs +++ /dev/null @@ -1,206 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A list of node ids. - /// - public partial class NodeIdCtrl : UserControl - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - public NodeIdCtrl() - { - InitializeComponent(); - - m_rootId = Objects.RootFolder; - BrowseBTN.Enabled = false; - } - #endregion - - #region Event Handlers - private Browser m_browser; - private NodeId m_rootId; - private ReferenceDescription m_reference; - private event EventHandler m_IdentifierChanged; - #endregion - - #region Public Interface - /// - /// Raised if the node id is changed. - /// - public event EventHandler IdentifierChanged - { - add { m_IdentifierChanged += value; } - remove { m_IdentifierChanged -= value; } - } - - /// - /// The browser to used browse for a node id. - /// - [DefaultValue(null)] - public Browser Browser - { - get - { - return m_browser; - } - - set - { - m_browser = value; - BrowseBTN.Enabled = m_browser != null; - } - } - - /// - /// The root node id to display when browsing. - /// - [DefaultValue(null)] - public NodeId RootId - { - get - { - return m_rootId; - } - - set - { - m_rootId = value; - - if (NodeId.IsNull(m_rootId)) - { - m_rootId = Objects.RootFolder; - } - } - } - - /// - /// Returns true if the control is empty. - /// - [DefaultValue(false)] - public bool IsEmpty - { - get - { - return String.IsNullOrEmpty(NodeIdTB.Text); - } - } - - /// - /// The node identifier specified in the control. - /// - [DefaultValue(null)] - public NodeId Identifier - { - get - { - return NodeId.Parse(NodeIdTB.Text); - } - - set - { - NodeIdTB.Text = Utils.Format("{0}", value); - } - } - - /// - /// The reference seleected if the browse feature was used. - /// - [DefaultValue(null)] - public ReferenceDescription Reference - { - get - { - return m_reference; - } - - set - { - m_reference = value; - - if (m_reference != null) - { - NodeIdTB.Text = Utils.Format("{0}", m_reference.NodeId); - } - } - } - #endregion - - #region Event Handlers - private void BrowseBTN_Click(object sender, EventArgs e) - { - try - { - /* - ReferenceDescription reference = new SelectNodeDlg().ShowDialog(m_browser, RootId); - - if (reference != null) - { - NodeIdTB.Text = Utils.Format("{0}", reference.NodeId); - m_reference = reference; - - if (m_IdentifierChanged != null) - { - m_IdentifierChanged(this, null); - } - } - * */ - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void NodeIdTB_TextChanged(object sender, EventArgs e) - { - if (m_IdentifierChanged != null) - { - m_IdentifierChanged(this, null); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.Designer.cs deleted file mode 100644 index 57c9ff7ca2..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.Designer.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class NodeIdValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ValueCTRL = new Opc.Ua.Client.Controls.NodeIdCtrl(); - this.ButtonsPN.SuspendLayout(); - this.MainPN.SuspendLayout(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 28); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(297, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(218, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // MainPN - // - this.MainPN.Controls.Add(this.ValueCTRL); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Size = new System.Drawing.Size(297, 28); - this.MainPN.TabIndex = 1; - // - // ValueCTRL - // - this.ValueCTRL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueCTRL.Location = new System.Drawing.Point(4, 4); - this.ValueCTRL.MaximumSize = new System.Drawing.Size(4096, 20); - this.ValueCTRL.MinimumSize = new System.Drawing.Size(100, 20); - this.ValueCTRL.Name = "ValueCTRL"; - this.ValueCTRL.Size = new System.Drawing.Size(289, 20); - this.ValueCTRL.TabIndex = 2; - // - // NumericValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(297, 59); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.ButtonsPN); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(221, 91); - this.Name = "NumericValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit NodeId"; - this.ButtonsPN.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel MainPN; - private Opc.Ua.Client.Controls.NodeIdCtrl ValueCTRL; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.cs deleted file mode 100644 index c09b73bcc8..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.cs +++ /dev/null @@ -1,98 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A dialog used to edit a NodeId. - /// - public partial class NodeIdValueEditDlg : Form - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - public NodeIdValueEditDlg() - { - InitializeComponent(); - } - #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public NodeId ShowDialog(Session session, NodeId value) - { - if (session == null) throw new ArgumentNullException("session"); - - ValueCTRL.Browser = new Browser(session); - ValueCTRL.RootId = Objects.RootFolder; - ValueCTRL.Identifier = value; - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return ValueCTRL.Identifier; - } - - /// - /// Displays the dialog. - /// - public ExpandedNodeId ShowDialog(Session session, ExpandedNodeId value) - { - if (session == null) throw new ArgumentNullException("session"); - - ValueCTRL.Browser = new Browser(session); - ValueCTRL.RootId = Objects.RootFolder; - ValueCTRL.Identifier = ExpandedNodeId.ToNodeId(value, session.NamespaceUris); - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return ValueCTRL.Identifier; - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NodeIdValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.Designer.cs deleted file mode 100644 index 47e4df17c2..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.Designer.cs +++ /dev/null @@ -1,149 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class NumericValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ValueCTRL = new System.Windows.Forms.NumericUpDown(); - this.ButtonsPN.SuspendLayout(); - this.MainPN.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.ValueCTRL)).BeginInit(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 28); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(215, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(136, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // MainPN - // - this.MainPN.Controls.Add(this.ValueCTRL); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Size = new System.Drawing.Size(215, 28); - this.MainPN.TabIndex = 1; - // - // ValueCTRL - // - this.ValueCTRL.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueCTRL.Location = new System.Drawing.Point(4, 5); - this.ValueCTRL.Name = "ValueCTRL"; - this.ValueCTRL.Size = new System.Drawing.Size(207, 20); - this.ValueCTRL.TabIndex = 0; - // - // NumericValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(215, 59); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.ButtonsPN); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(221, 91); - this.Name = "NumericValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Numeric Value"; - this.ButtonsPN.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.ValueCTRL)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel MainPN; - private System.Windows.Forms.NumericUpDown ValueCTRL; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.cs deleted file mode 100644 index 8b9b55fbd5..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.cs +++ /dev/null @@ -1,163 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -namespace Opc.Ua.Client.Controls -{ - /// - /// A dialog to edit a numeric value. - /// - public partial class NumericValueEditDlg : Form - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - public NumericValueEditDlg() - { - InitializeComponent(); - } - #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public object ShowDialog(object value, Type type) - { - if (type == null && value != null) - { - type = value.GetType(); - } - - if (type == typeof(Variant)) - { - type = typeof(double); - } - - SetLimits(type); - - ValueCTRL.Value = Convert.ToDecimal(value); - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return Convert.ChangeType(ValueCTRL.Value, type); - } - #endregion - - #region Private Methods - /// - /// Sets the limits according to the data type. - /// - private void SetLimits(Type type) - { - if (type == typeof(sbyte)) - { - ValueCTRL.Minimum = SByte.MinValue; - ValueCTRL.Maximum = SByte.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(byte)) - { - ValueCTRL.Minimum = Byte.MinValue; - ValueCTRL.Maximum = Byte.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(short)) - { - ValueCTRL.Minimum = Int16.MinValue; - ValueCTRL.Maximum = Int16.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(ushort)) - { - ValueCTRL.Minimum = UInt16.MinValue; - ValueCTRL.Maximum = UInt16.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(int)) - { - ValueCTRL.Minimum = Int32.MinValue; - ValueCTRL.Maximum = Int32.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(uint)) - { - ValueCTRL.Minimum = UInt32.MinValue; - ValueCTRL.Maximum = UInt32.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(long)) - { - ValueCTRL.Minimum = Int64.MinValue; - ValueCTRL.Maximum = Int64.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(ulong)) - { - ValueCTRL.Minimum = UInt64.MinValue; - ValueCTRL.Maximum = UInt64.MaxValue; - ValueCTRL.DecimalPlaces = 0; - } - - if (type == typeof(float)) - { - ValueCTRL.Minimum = Decimal.MinValue; - ValueCTRL.Maximum = Decimal.MaxValue; - ValueCTRL.DecimalPlaces = 6; - } - - if (type == typeof(double)) - { - ValueCTRL.Minimum = Decimal.MinValue; - ValueCTRL.Maximum = Decimal.MaxValue; - ValueCTRL.DecimalPlaces = 15; - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/NumericValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.Designer.cs deleted file mode 100644 index fe7c6d5544..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class ReferenceTypeCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ReferenceTypesCB = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // ReferenceTypesCB - // - this.ReferenceTypesCB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ReferenceTypesCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ReferenceTypesCB.FormattingEnabled = true; - this.ReferenceTypesCB.Location = new System.Drawing.Point(0, 0); - this.ReferenceTypesCB.Name = "ReferenceTypesCB"; - this.ReferenceTypesCB.Size = new System.Drawing.Size(200, 21); - this.ReferenceTypesCB.TabIndex = 0; - this.ReferenceTypesCB.SelectedIndexChanged += new System.EventHandler(this.ReferenceTypesCB_SelectedIndexChanged); - // - // ReferenceTypeCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.ReferenceTypesCB); - this.MaximumSize = new System.Drawing.Size(4096, 21); - this.MinimumSize = new System.Drawing.Size(200, 21); - this.Name = "ReferenceTypeCtrl"; - this.Size = new System.Drawing.Size(200, 21); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ComboBox ReferenceTypesCB; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.cs deleted file mode 100644 index dce9122b47..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.cs +++ /dev/null @@ -1,273 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -namespace Opc.Ua.Client.Controls -{ - /// - /// Displays a drop down list of reference types. - /// - public partial class ReferenceTypeCtrl : UserControl - { - #region Constructors - /// - /// Initializes a new instance of the class. - /// - public ReferenceTypeCtrl() - { - InitializeComponent(); - m_baseTypeId = ReferenceTypes.References; - } - #endregion - - #region Private Fields - private Session m_session; - private NodeId m_baseTypeId; - private event EventHandler m_referenceSelectionChanged; - #endregion - - #region Public Interface - /// - /// Initializes the control with references starting with the specified based type. - /// - public void Initialize(Session session, NodeId baseTypeId) - { - m_session = session; - m_baseTypeId = baseTypeId; - - if (NodeId.IsNull(m_baseTypeId)) - { - m_baseTypeId = ReferenceTypes.References; - } - - ReferenceTypesCB.Items.Clear(); - - // recurcively fetch the reference types from the server. - if (m_session != null) - { - AddReferenceTypes(m_baseTypeId, null); - } - } - - /// - /// The currently seleected reference type id. - /// - public NodeId SelectedTypeId - { - get - { - ReferenceTypeChoice choice = ReferenceTypesCB.SelectedItem as ReferenceTypeChoice; - - if (choice == null) - { - return null; - } - - return choice.ReferenceType.NodeId; - } - - set - { - for (int ii = 0; ii < ReferenceTypesCB.Items.Count; ii++) - { - ReferenceTypeChoice choice = ReferenceTypesCB.Items[ii] as ReferenceTypeChoice; - - if (choice != null && choice.ReferenceType.NodeId == value) - { - ReferenceTypesCB.SelectedIndex = ii; - return; - } - } - - if (ReferenceTypesCB.Items.Count > 0) - { - ReferenceTypesCB.SelectedIndex = 0; - } - } - } - - /// - /// Raised when the selected reference is changed. - /// - public event EventHandler ReferenceSelectionChanged - { - add { m_referenceSelectionChanged += value; } - remove { m_referenceSelectionChanged -= value; } - } - - #region ReferenceSelectedEventArgs Class - /// - /// Specifies the nodes that where selected in the control. - /// - public class ReferenceSelectedEventArgs : EventArgs - { - /// - /// Constructs a new object. - /// - public ReferenceSelectedEventArgs(NodeId selectedTypeId) - { - m_referenceTypeId = selectedTypeId; - } - - /// - /// The reference type that was selected. - /// - public NodeId ReferenceTypeId - { - get { return m_referenceTypeId; } - } - - private NodeId m_referenceTypeId; - } - #endregion - #endregion - - #region ReferenceTypeChoice Class - /// - /// A reference type that may be used as a browse filter. - /// - private class ReferenceTypeChoice - { - /// - /// The text to display in the control. - /// - public override string ToString() - { - if (ReferenceType == null) - { - return ""; - } - - StringBuilder text = new StringBuilder(); - - GetPrefix(text); - - if (text.Length > 0) - { - text.Append("> "); - } - - if (ReferenceType != null) - { - text.Append(ReferenceType.ToString()); - } - - return text.ToString(); - } - - /// - /// Adds a prefix for subtypes. - /// - private void GetPrefix(StringBuilder prefix) - { - if (SuperType != null) - { - SuperType.GetPrefix(prefix); - prefix.Append("--"); - } - } - - public ReferenceTypeNode ReferenceType; - public ReferenceTypeChoice SuperType; - } - #endregion - - #region Private Methods - /// - /// Adds the reference types to drop down box. - /// - private void AddReferenceTypes(ExpandedNodeId referenceTypeId, ReferenceTypeChoice supertype) - { - if (referenceTypeId == null) throw new ApplicationException("referenceTypeId"); - - try - { - // find reference. - ReferenceTypeNode node = m_session.NodeCache.Find(referenceTypeId) as ReferenceTypeNode; - - if (node == null) - { - return; - } - - // add reference to combobox. - ReferenceTypeChoice choice = new ReferenceTypeChoice(); - - choice.ReferenceType = node; - choice.SuperType = supertype; - - ReferenceTypesCB.Items.Add(choice); - - // recursively add subtypes. - IList subtypes = m_session.NodeCache.FindReferences(node.NodeId, ReferenceTypeIds.HasSubtype, false, true); - - foreach (INode subtype in subtypes) - { - AddReferenceTypes(subtype.NodeId, choice); - } - } - catch (Exception e) - { - Utils.Trace(e, "Ignoring unknown reference type."); - return; - } - } - #endregion - - #region Event Handlers - private void ReferenceTypesCB_SelectedIndexChanged(object sender, EventArgs e) - { - try - { - if (m_referenceSelectionChanged != null) - { - NodeId referenceTypeId = SelectedTypeId; - - if (referenceTypeId != null) - { - m_referenceSelectionChanged(this, new ReferenceSelectedEventArgs(referenceTypeId)); - } - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/ReferenceTypeCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.Designer.cs b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.Designer.cs deleted file mode 100644 index 54348ad8a1..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.Designer.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Client.Controls -{ - partial class StringValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ValueTB = new System.Windows.Forms.TextBox(); - this.ButtonsPN.SuspendLayout(); - this.MainPN.SuspendLayout(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 24); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(252, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(173, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // MainPN - // - this.MainPN.Controls.Add(this.ValueTB); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Padding = new System.Windows.Forms.Padding(3); - this.MainPN.Size = new System.Drawing.Size(252, 24); - this.MainPN.TabIndex = 1; - // - // ValueTB - // - this.ValueTB.Dock = System.Windows.Forms.DockStyle.Fill; - this.ValueTB.Location = new System.Drawing.Point(3, 3); - this.ValueTB.MinimumSize = new System.Drawing.Size(4, 20); - this.ValueTB.Multiline = true; - this.ValueTB.Name = "ValueTB"; - this.ValueTB.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.ValueTB.Size = new System.Drawing.Size(246, 20); - this.ValueTB.TabIndex = 0; - this.ValueTB.Text = "Default"; - // - // StringValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(252, 55); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.ButtonsPN); - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(221, 89); - this.Name = "StringValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit String Value"; - this.ButtonsPN.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - this.MainPN.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel MainPN; - private System.Windows.Forms.TextBox ValueTB; - } -} diff --git a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.resx b/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/ClientControls.Net4/Common (OLD)/StringValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/ClientControls.Net4/Common/Client/ConnectServerCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Common/Client/ConnectServerCtrl.cs index f8d6838d25..669daf5345 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Common/Client/ConnectServerCtrl.cs +++ b/SampleApplications/Samples/ClientControls.Net4/Common/Client/ConnectServerCtrl.cs @@ -33,6 +33,7 @@ using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using System.Threading.Tasks; +using Opc.Ua.Client.ComplexTypes; namespace Opc.Ua.Client.Controls { @@ -307,6 +308,9 @@ namespace Opc.Ua.Client.Controls // raise an event. DoConnectComplete(null); + var typeSystemLoader = new ComplexTypeSystem(m_session); + await typeSystemLoader.Load(); + // return the new session. return m_session; } diff --git a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/DataListCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/DataListCtrl.cs index 4026c68f4f..92e9b1931d 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/DataListCtrl.cs +++ b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/DataListCtrl.cs @@ -557,12 +557,38 @@ namespace Opc.Ua.Client.Controls if (dataValue != null) { - if (StatusCode.IsBad(dataValue.StatusCode)) + StringBuilder formattedValue = new StringBuilder(); + + if (!StatusCode.IsGood(dataValue.StatusCode)) { - return String.Format("{0}", dataValue.StatusCode); + formattedValue.Append("["); + formattedValue.AppendFormat("Q:{0}", dataValue.StatusCode); } - return String.Format("{0}", dataValue.Value); + DateTime now = DateTime.UtcNow; + + if ((dataValue != null) && + ((dataValue.ServerTimestamp > now) || (dataValue.SourceTimestamp > now))) + { + if (formattedValue.ToString().Length > 0) + { + formattedValue.Append(", "); + } + else + { + formattedValue.Append("["); + } + + formattedValue.Append("T:future"); + } + + if (formattedValue.ToString().Length > 0) + { + formattedValue.Append("] "); + } + + formattedValue.AppendFormat("{0}", dataValue.Value); + return formattedValue.ToString(); } // use default formatting. @@ -583,10 +609,16 @@ namespace Opc.Ua.Client.Controls { // get the list item to update. ListViewItem listitem = GetListItem(index, ref overwrite, name, type); - - // update list item. - listitem.SubItems[1].Text = GetValueText(componentValue); - + if (componentValue is StatusCode) + { + listitem.SubItems[1].Text = componentValue.ToString(); + } + else + { + // update list item. + listitem.SubItems[1].Text = GetValueText(componentValue); + } + // move to next item. index++; @@ -1700,12 +1732,12 @@ namespace Opc.Ua.Client.Controls ((IList)state.Value)[ii] = value; state.Component = value; } - + m_expanding = false; - int index = (int)state.ComponentIndex; + int index = (int)state.ComponentIndex - 1; int indentCount = ItemsLV.Items[index].IndentCount; - while (ItemsLV.Items[index - 1].IndentCount == indentCount) + while (index > 0 && ItemsLV.Items[index - 1].IndentCount == indentCount) { --index; } diff --git a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/GuiUtils.cs b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/GuiUtils.cs index e222458214..baa69d3028 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/GuiUtils.cs +++ b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/GuiUtils.cs @@ -452,7 +452,7 @@ namespace Opc.Ua.Client.Controls if (text != null) { - return new LocalizedText(text, ltext.Locale); + return new LocalizedText(ltext.Locale, text); } return null; diff --git a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/ReferenceTypeCtrl.cs b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/ReferenceTypeCtrl.cs index dce9122b47..83cb9c6d26 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/ReferenceTypeCtrl.cs +++ b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/ReferenceTypeCtrl.cs @@ -50,7 +50,7 @@ namespace Opc.Ua.Client.Controls public ReferenceTypeCtrl() { InitializeComponent(); - m_baseTypeId = ReferenceTypes.References; + m_baseTypeId = Opc.Ua.ReferenceTypeIds.References; } #endregion @@ -71,7 +71,7 @@ namespace Opc.Ua.Client.Controls if (NodeId.IsNull(m_baseTypeId)) { - m_baseTypeId = ReferenceTypes.References; + m_baseTypeId = ReferenceTypeIds.References; } ReferenceTypesCB.Items.Clear(); diff --git a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/SimpleValueEditDlg.cs b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/SimpleValueEditDlg.cs index 45ee0a43d9..6a3e9debed 100644 --- a/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/SimpleValueEditDlg.cs +++ b/SampleApplications/Samples/ClientControls.Net4/Configuration/Common (OLD)/SimpleValueEditDlg.cs @@ -122,7 +122,7 @@ namespace Opc.Ua.Client.Controls if (m_type == typeof(float)) return Convert.ToSingle(text); if (m_type == typeof(double)) return Convert.ToDouble(text); if (m_type == typeof(string)) return text; - if (m_type == typeof(DateTime)) return DateTime.Parse(text); + if (m_type == typeof(DateTime)) return DateTime.ParseExact(text, "yyyy-MM-dd HH:mm:ss.fff", null); if (m_type == typeof(Guid)) return new Guid(text); if (m_type == typeof(QualifiedName)) return new QualifiedName(text); if (m_type == typeof(LocalizedText)) return new LocalizedText(text); diff --git a/SampleApplications/Samples/ClientControls.Net4/UA Client Controls.csproj b/SampleApplications/Samples/ClientControls.Net4/UA Client Controls.csproj index afda1bcce2..929f3ebb00 100644 --- a/SampleApplications/Samples/ClientControls.Net4/UA Client Controls.csproj +++ b/SampleApplications/Samples/ClientControls.Net4/UA Client Controls.csproj @@ -1019,6 +1019,10 @@ {d918c0f6-39bd-4ed0-8323-e5a2eb9a85da} Opc.Ua.Core + + {fe9eeb39-0698-4a19-b770-e66836ce0002} + Opc.Ua.Client.ComplexTypes + {15100583-bfef-431b-a1ea-1e5a843a39b1} Opc.Ua.Client diff --git a/SampleApplications/Samples/Controls.Net4/Common/ArgumentListCtrl.cs b/SampleApplications/Samples/Controls.Net4/Common/ArgumentListCtrl.cs index 3fb03ca59a..b084f25a09 100644 --- a/SampleApplications/Samples/Controls.Net4/Common/ArgumentListCtrl.cs +++ b/SampleApplications/Samples/Controls.Net4/Common/ArgumentListCtrl.cs @@ -258,7 +258,7 @@ namespace Opc.Ua.Sample.Controls return; } - object value = GuiUtils2.EditValue(m_session, arguments[0].Value, arguments[0].DataType, arguments[0].ValueRank); + object value = GuiUtils.EditValue(m_session, arguments[0].Value, arguments[0].DataType, arguments[0].ValueRank); if (value != null) { diff --git a/SampleApplications/Samples/Controls.Net4/Common/AttributeListCtrl.cs b/SampleApplications/Samples/Controls.Net4/Common/AttributeListCtrl.cs index 13b22d1fc7..b2cc39400a 100644 --- a/SampleApplications/Samples/Controls.Net4/Common/AttributeListCtrl.cs +++ b/SampleApplications/Samples/Controls.Net4/Common/AttributeListCtrl.cs @@ -562,7 +562,7 @@ namespace Opc.Ua.Sample.Controls if (items != null && items.Length == 1) { - object value = GuiUtils2.EditValue(m_session, items[0].Value); + object value = GuiUtils.EditValue(m_session, items[0].Value); if (!m_readOnly) { diff --git a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.Designer.cs b/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.Designer.cs deleted file mode 100644 index aca40ac9d6..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.Designer.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Sample.Controls -{ - partial class DataListCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.PopupMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.UpdatesMI = new System.Windows.Forms.ToolStripMenuItem(); - this.RefreshMI = new System.Windows.Forms.ToolStripMenuItem(); - this.ClearMI = new System.Windows.Forms.ToolStripMenuItem(); - this.Separator01 = new System.Windows.Forms.ToolStripSeparator(); - this.EditMI = new System.Windows.Forms.ToolStripMenuItem(); - this.PopupMenu.SuspendLayout(); - this.SuspendLayout(); - // - // ItemsLV - // - this.ItemsLV.ContextMenuStrip = this.PopupMenu; - this.ItemsLV.MultiSelect = false; - this.ItemsLV.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ItemsLV_MouseClick); - // - // PopupMenu - // - this.PopupMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.UpdatesMI, - this.RefreshMI, - this.ClearMI, - this.Separator01, - this.EditMI}); - this.PopupMenu.Name = "PopupMenu"; - this.PopupMenu.Size = new System.Drawing.Size(136, 98); - // - // UpdatesMI - // - this.UpdatesMI.Checked = true; - this.UpdatesMI.CheckState = System.Windows.Forms.CheckState.Checked; - this.UpdatesMI.Name = "UpdatesMI"; - this.UpdatesMI.Size = new System.Drawing.Size(135, 22); - this.UpdatesMI.Text = "Auto Update"; - this.UpdatesMI.CheckedChanged += new System.EventHandler(this.UpdatesMI_CheckedChanged); - // - // RefreshMI - // - this.RefreshMI.Name = "RefreshMI"; - this.RefreshMI.Size = new System.Drawing.Size(135, 22); - this.RefreshMI.Text = "Refresh"; - this.RefreshMI.Click += new System.EventHandler(this.RefreshMI_Click); - // - // ClearMI - // - this.ClearMI.Name = "ClearMI"; - this.ClearMI.Size = new System.Drawing.Size(135, 22); - this.ClearMI.Text = "Clear"; - this.ClearMI.Click += new System.EventHandler(this.ClearMI_Click); - // - // Separator01 - // - this.Separator01.Name = "Separator01"; - this.Separator01.Size = new System.Drawing.Size(132, 6); - // - // EditMI - // - this.EditMI.Name = "EditMI"; - this.EditMI.Size = new System.Drawing.Size(135, 22); - this.EditMI.Text = "Edit Value..."; - this.EditMI.Click += new System.EventHandler(this.EditMI_Click); - // - // DataListCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.Name = "DataListCtrl"; - this.Controls.SetChildIndex(this.ItemsLV, 0); - this.PopupMenu.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ContextMenuStrip PopupMenu; - private System.Windows.Forms.ToolStripMenuItem UpdatesMI; - private System.Windows.Forms.ToolStripMenuItem RefreshMI; - private System.Windows.Forms.ToolStripMenuItem ClearMI; - private System.Windows.Forms.ToolStripSeparator Separator01; - private System.Windows.Forms.ToolStripMenuItem EditMI; - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.cs b/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.cs deleted file mode 100644 index be48dc160d..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.cs +++ /dev/null @@ -1,1659 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -using System.ServiceModel; -using System.Runtime.Serialization; -using System.Xml; -using System.Xml.Serialization; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Sample.Controls -{ - public partial class DataListCtrl : Opc.Ua.Client.Controls.BaseListCtrl - { - public DataListCtrl() - { - InitializeComponent(); - SetColumns(m_ColumnNames); - } - - #region Private Fields - /// - /// The columns to display in the control. - /// - private readonly object[][] m_ColumnNames = new object[][] - { - new object[] { "Name", HorizontalAlignment.Left, null }, - new object[] { "Value", HorizontalAlignment.Left, null, 250 }, - new object[] { "Type", HorizontalAlignment.Left, null } - }; - - private bool m_latestValue = true; - private bool m_expanding; - private int m_depth; - private Font m_defaultFont; - private MonitoredItem m_monitoredItem; - - private const string UnknownType = "(unknown)"; - private const string NullValue = "(null)"; - private const string ExpandIcon = "ExpandPlus"; - private const string CollapseIcon = "ExpandMinus"; - #endregion - - #region Public Interface - /// - /// Whether to update the control when the value changes. - /// - public bool AutoUpdate - { - get { return UpdatesMI.Checked; } - set { UpdatesMI.Checked = value; } - } - - /// - /// Whether to only display the latest value for a monitored item. - /// - public bool LatestValue - { - get { return m_latestValue; } - set { m_latestValue = value; } - } - - /// - /// The monitored item associated with the value. - /// - public MonitoredItem MonitoredItem - { - get { return m_monitoredItem; } - set { m_monitoredItem = value; } - } - - /// - /// Clears the contents of the control, - /// - public void Clear() - { - ItemsLV.Items.Clear(); - AdjustColumns(); - } - - /// - /// Displays a value in the control. - /// - public void ShowValue(object value) - { - ShowValue(value, false); - } - - /// - /// Displays a value in the control. - /// - public void ShowValue(object value, bool overwrite) - { - if (!overwrite) - { - Clear(); - } - - if (value is byte[]) - { - m_defaultFont = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); - } - else - { - m_defaultFont = ItemsLV.Font; - } - - m_expanding = false; - m_depth = 0; - - // show the value. - int index = 0; - ShowValue(ref index, ref overwrite, value); - - // adjust columns. - AdjustColumns(); - } - #endregion - - #region Overridden Methods - /// - /// Enables the menu items. - /// - protected override void EnableMenuItems(ListViewItem clickedItem) - { - RefreshMI.Enabled = true; - ClearMI.Enabled = true; - - if (ItemsLV.SelectedItems.Count == 1) - { - ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState; - EditMI.Enabled = IsEditableType(state.Component); - } - } - #endregion - - #region ValueState Class - /// - /// Stores the state associated with an item. - /// - private class ValueState - { - public bool Expanded = false; - public bool Expandable = false; - public object Value = null; - public object Component = null; - public object ComponentId = null; - } - #endregion - - #region Private Members - /// - /// Returns true is the value is an editable type. - /// - private bool IsEditableType(object value) - { - if (value is bool) return true; - if (value is sbyte) return true; - if (value is byte) return true; - if (value is short) return true; - if (value is ushort) return true; - if (value is int) return true; - if (value is uint) return true; - if (value is long) return true; - if (value is ulong) return true; - if (value is float) return true; - if (value is double) return true; - if (value is string) return true; - if (value is DateTime) return true; - if (value is Guid) return true; - - return false; - } - - /// - /// Shows the components of a value in the control. - /// - private void ShowChildren(ListViewItem listItem) - { - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable || state.Expanded) - { - return; - } - - m_expanding = true; - m_depth = listItem.IndentCount+1; - - state.Expanded = true; - listItem.ImageKey = CollapseIcon; - - int index = listItem.Index+1; - bool overwrite = false; - - ShowValue(ref index, ref overwrite, state.Component); - - AdjustColumns(); - } - - /// - /// Hides the components of a value in the control. - /// - private void HideChildren(ListViewItem listItem) - { - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable || !state.Expanded) - { - return; - } - - for (int ii = listItem.Index+1; ii < ItemsLV.Items.Count;) - { - ListViewItem childItem = ItemsLV.Items[ii]; - - if (childItem.IndentCount <= listItem.IndentCount) - { - break; - } - - childItem.Remove(); - } - - state.Expanded = false; - listItem.ImageKey = ExpandIcon; - } - - /// - /// Returns the list item at the specified index. - /// - private ListViewItem GetListItem(int index, ref bool overwrite, string name, string type) - { - ListViewItem listitem = null; - - // switch to detail view as soon as an item is added. - if (ItemsLV.View == View.List) - { - ItemsLV.Items.Clear(); - ItemsLV.View = View.Details; - } - - // check if there is an item that could be re-used. - if (!m_expanding && index < ItemsLV.Items.Count) - { - listitem = ItemsLV.Items[index]; - - // check if still possible to overwrite values. - if (overwrite) - { - if (listitem.SubItems[0].Text != name || listitem.SubItems[2].Text != type) - { - overwrite = false; - } - } - - listitem.SubItems[0].Text = name; - listitem.SubItems[2].Text = type; - - return listitem; - } - - overwrite = false; - - listitem = new ListViewItem(name); - - listitem.SubItems.Add(String.Empty); - listitem.SubItems.Add(type); - - listitem.Font = m_defaultFont; - listitem.ImageKey = ExpandIcon; - listitem.IndentCount = m_depth; - listitem.Tag = new ValueState(); - - if (!m_expanding) - { - ItemsLV.Items.Add(listitem); - } - else - { - ItemsLV.Items.Insert(index, listitem); - } - - return listitem; - } - - /// - /// Returns true if the type can be expanded. - /// - private bool IsExpandableType(object value) - { - // check for null. - if (value == null) - { - return false; - } - - // check for Variant. - if (value is Variant) - { - return IsExpandableType(((Variant)value).Value); - } - - // check for bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - return false; - } - - // check for xml element. - XmlElement xml = value as XmlElement; - - if (xml != null) - { - if (xml.ChildNodes.Count == 1 && xml.ChildNodes[0] is XmlText) - { - return false; - } - - return xml.HasChildNodes; - } - - // check for array. - Array array = value as Array; - - if (array == null) - { - Matrix matrix = value as Matrix; - - if (matrix != null) - { - array = matrix.ToArray(); - } - } - - if (array != null) - { - return array.Length > 0; - } - - // check for list. - IList list = value as IList; - - if (list != null) - { - return list.Count > 0; - } - - // check for encodeable object. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - return true; - } - - // check for extension object. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - return IsExpandableType(extension.Body); - } - - // check for data value. - DataValue datavalue = value as DataValue; - - if (datavalue != null) - { - return true; - } - - // check for event value. - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - return true; - } - - // must be a simple value. - return false; - } - - /// - /// Formats a value for display in the control. - /// - private string GetValueText(object value) - { - // check for null. - if (value == null) - { - return "(null)"; - } - - // format bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - StringBuilder buffer = new StringBuilder(); - - for (int ii = 0; ii < bytes.Length; ii++) - { - if (ii != 0 && ii%16 == 0) - { - buffer.Append(" "); - } - - buffer.AppendFormat("{0:X2} ", bytes[ii]); - } - - return buffer.ToString(); - } - - // format xml element. - XmlElement xml = value as XmlElement; - - if (xml != null) - { - // return the entire element if not expandable. - if (!IsExpandableType(xml)) - { - return xml.OuterXml; - } - - // show only the start tag. - string text = xml.OuterXml; - - int index = text.IndexOf('>'); - - if (index != -1) - { - text = text.Substring(0, index); - } - - return text; - } - - // format array. - Array array = value as Array; - - if (array != null) - { - if (array.Rank > 1) - { - int[] lenghts = new int[array.Rank]; - - for (int i = 0; i < array.Rank; ++i) - { - lenghts[i] = array.GetLength(i); - } - - return Utils.Format("{1}[{0}]", string.Join(",", lenghts), value.GetType().GetElementType().Name); - } - else - { - return Utils.Format("{1}[{0}]", array.Length, value.GetType().GetElementType().Name); - } - } - - // format list. - IList list = value as IList; - - if (list != null) - { - string type = value.GetType().Name; - - if (type.EndsWith("Collection")) - { - type = type.Substring(0, type.Length - "Collection".Length); - } - else - { - type = "Object"; - } - - return Utils.Format("{1}[{0}]", list.Count, type); - } - - // format encodeable object. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - return encodeable.GetType().Name; - } - - // format extension object. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - return GetValueText(extension.Body); - } - - // check for event value. - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - if (m_monitoredItem != null) - { - return String.Format("{0}", m_monitoredItem.GetEventType(eventFields)); - } - - return eventFields.GetType().Name; - } - - // check for data value. - DataValue dataValue = value as DataValue; - - if (dataValue != null) - { - StringBuilder formattedValue = new StringBuilder(); - - if (!StatusCode.IsGood(dataValue.StatusCode)) - { - formattedValue.Append("["); - formattedValue.AppendFormat("Q:{0}", dataValue.StatusCode); - } - - DateTime now = DateTime.UtcNow; - - if ((dataValue != null) && - ((dataValue.ServerTimestamp > now) || (dataValue.SourceTimestamp > now))) - { - if (formattedValue.ToString().Length > 0) - { - formattedValue.Append(", "); - } - else - { - formattedValue.Append("["); - } - - formattedValue.Append("T:future"); - } - - if (formattedValue.ToString().Length > 0) - { - formattedValue.Append("] "); - } - - formattedValue.AppendFormat("{0}", dataValue.Value); - return formattedValue.ToString(); - } - - // use default formatting. - return Utils.Format("{0}", value); - } - - /// - /// Updates the list with the specified value. - /// - private void UpdateList( - ref int index, - ref bool overwrite, - object value, - object componentValue, - object componentId, - string name, - string type) - { - // get the list item to update. - ListViewItem listitem = GetListItem(index, ref overwrite, name, type); - - if (componentValue is StatusCode) - { - listitem.SubItems[1].Text = componentValue.ToString(); - } - else - { - // update list item. - listitem.SubItems[1].Text = GetValueText(componentValue); - } - - // move to next item. - index++; - - ValueState state = listitem.Tag as ValueState; - - // recursively update sub-values if item is expanded. - if (overwrite) - { - if (state.Expanded && state.Expandable) - { - m_depth++; - ShowValue(ref index, ref overwrite, componentValue); - m_depth--; - } - } - - // update state. - state.Expandable = IsExpandableType(componentValue); - state.Value = value; - state.Component = componentValue; - state.ComponentId = componentId; - - if (!state.Expandable) - { - listitem.ImageKey = CollapseIcon; - } - } - - /// - /// Shows property of an encodeable object in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, IEncodeable value, PropertyInfo property) - { - // get the name of the property. - string name = Utils.GetDataMemberName(property); - - if (name == null) - { - return; - } - - // get the property value. - object propertyValue = null; - - MethodInfo[] accessors = property.GetAccessors(); - - for (int ii = 0; ii < accessors.Length; ii++) - { - if (accessors[ii].ReturnType == property.PropertyType) - { - propertyValue = accessors[ii].Invoke(value, null); - break; - } - } - - if (propertyValue is Variant) - { - propertyValue = ((Variant)propertyValue).Value; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - propertyValue, - property, - name, - property.PropertyType.Name); - } - - /// - /// Shows the element of an array in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, Array value, int element) - { - // get the name of the element. - string name = Utils.Format("[{0}]", element); - - object elementValue = null; - - if (value.Rank > 1) - { - int[] smallArrayDimmensions = new int[value.Rank - 1]; - int length = 1; - - for (int i = 0; i < value.Rank - 1; ++i) - { - smallArrayDimmensions[i] = value.GetLength(i + 1); - length *= smallArrayDimmensions[i]; - } - - Array flatArray = Utils.FlattenArray(value); - Array flatSmallArray = Array.CreateInstance(value.GetType().GetElementType(), length); - Array.Copy(flatArray, element * value.GetLength(1), flatSmallArray, 0, length); - Array smallArray = Array.CreateInstance(value.GetType().GetElementType(), smallArrayDimmensions); - int[] indexes = new int[smallArrayDimmensions.Length]; - - for (int ii = 0; ii < flatSmallArray.Length; ii++) - { - smallArray.SetValue(flatSmallArray.GetValue(ii), indexes); - - for (int jj = indexes.Length-1; jj >= 0; jj--) - { - indexes[jj]++; - - if (indexes[jj] < smallArrayDimmensions[jj]) - { - break; - } - - indexes[jj] = 0; - } - } - - elementValue = smallArray; - } - else - { - elementValue = value.GetValue(element); - } - - // get the type name. - string type = null; - - if (elementValue != null) - { - type = elementValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - elementValue, - element, - name, - type); - } - - /// - /// Asks for confirmation before expanding a long list. - /// - private bool PromptOnLongList(int length) - { - if (length < 256) - { - return true; - } - - DialogResult result = MessageBox.Show("It may take a long time to display the list are you sure you want to continue?", "Warning", MessageBoxButtons.YesNo); - - if (result == DialogResult.Yes) - { - return true; - } - - return false; - } - - /// - /// Shows the element of a list in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, IList value, int element) - { - // get the name of the element. - string name = Utils.Format("[{0}]", element); - - // get the element value. - object elementValue = value[element]; - - // get the type name. - string type = null; - - if (elementValue != null) - { - type = elementValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - elementValue, - element, - name, - type); - } - - /// - /// Shows an XML element in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, XmlElement value, int childIndex) - { - // ignore children that are not elements. - XmlElement child = value.ChildNodes[childIndex] as XmlElement; - - if (child == null) - { - return; - } - - // get the name of the element. - string name = Utils.Format("{0}", child.Name); - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - child, - childIndex, - name, - type); - } - - /// - /// Shows an event in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, EventFieldList value, int fieldIndex) - { - // ignore children that are not elements. - object field = value.EventFields[fieldIndex].Value; - - if (field == null) - { - return; - } - - // get the name of the element. - string name = null; - - if (m_monitoredItem != null) - { - name = m_monitoredItem.GetFieldName(fieldIndex); - } - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - field, - fieldIndex, - name, - type); - } - - /// - /// Shows a byte array in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, byte[] value, int blockStart) - { - // get the name of the element. - string name = Utils.Format("[{0:X4}]", blockStart); - - int bytesLeft = value.Length - blockStart; - - if (bytesLeft > 16) - { - bytesLeft = 16; - } - - // get the element value. - byte[] blockValue = new byte[bytesLeft]; - Array.Copy(value, blockStart, blockValue, 0, bytesLeft); - - // get the type name. - string type = value.GetType().Name; - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - blockValue, - blockStart, - name, - type); - } - - /// - /// Shows a data value in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, DataValue value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Value"; - componentValue = value.Value; - - ExtensionObject extension = componentValue as ExtensionObject; - - if (extension != null) - { - componentValue = extension.Body; - } - - break; - } - - case 1: - { - name = "StatusCode"; - componentValue = value.StatusCode; - break; - } - - case 2: - { - if (value.SourceTimestamp != DateTime.MinValue) - { - name = "SourceTimestamp"; - componentValue = value.SourceTimestamp; - } - - break; - } - - case 3: - { - if (value.ServerTimestamp != DateTime.MinValue) - { - name = "ServerTimestamp"; - componentValue = value.ServerTimestamp; - } - - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows a node id in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, NodeId value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "IdType"; - componentValue = value.IdType; - break; - } - - case 1: - { - name = "Identifier"; - componentValue = value.Identifier; - break; - } - - case 2: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows am expanded node id in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, ExpandedNodeId value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "IdType"; - componentValue = value.IdType; - break; - } - - case 1: - { - name = "Identifier"; - componentValue = value.Identifier; - break; - } - - case 2: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - - case 3: - { - name = "NamespaceUri"; - componentValue = value.NamespaceUri; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows qualified name in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, QualifiedName value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Name"; - componentValue = value.Name; - break; - } - - case 1: - { - name = "NamespaceIndex"; - componentValue = value.NamespaceIndex; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows localized text in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, LocalizedText value, int component) - { - string name = null; - object componentValue = null; - - switch (component) - { - case 0: - { - name = "Text"; - componentValue = value.Text; - break; - } - - case 1: - { - name = "Locale"; - componentValue = value.Locale; - break; - } - } - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - component, - name, - type); - } - - /// - /// Shows a string in the control. - /// - private void ShowValue(ref int index, ref bool overwrite, string value) - { - string name = "Value"; - object componentValue = value; - - // don't display empty components. - if (name == null) - { - return; - } - - // get the type name. - string type = "(unknown)"; - - if (componentValue != null) - { - type = componentValue.GetType().Name; - } - - // update the list view. - UpdateList( - ref index, - ref overwrite, - value, - componentValue, - 0, - name, - type); - } - - /// - /// Shows a value in control. - /// - private void ShowValue(ref int index, ref bool overwrite, object value) - { - if (value == null) - { - return; - } - - // show monitored items. - MonitoredItem monitoredItem = value as MonitoredItem; - - if (monitoredItem != null) - { - m_monitoredItem = monitoredItem; - ShowValue(ref index, ref overwrite, monitoredItem.LastValue); - return; - } - - // show data changes - MonitoredItemNotification datachange = value as MonitoredItemNotification; - - if (datachange != null) - { - ShowValue(ref index, ref overwrite, datachange.Value); - return; - } - - // show events - EventFieldList eventFields = value as EventFieldList; - - if (eventFields != null) - { - for (int ii = 0; ii < eventFields.EventFields.Count; ii++) - { - ShowValue(ref index, ref overwrite, eventFields, ii); - } - - return; - } - - // show extension bodies. - ExtensionObject extension = value as ExtensionObject; - - if (extension != null) - { - ShowValue(ref index, ref overwrite, extension.Body); - return; - } - - // show encodeables. - IEncodeable encodeable = value as IEncodeable; - - if (encodeable != null) - { - PropertyInfo[] properties = encodeable.GetType().GetProperties(); - - foreach (PropertyInfo property in properties) - { - ShowValue(ref index, ref overwrite, encodeable, property); - } - - return; - } - - // show bytes. - byte[] bytes = value as byte[]; - - if (bytes != null) - { - if (!PromptOnLongList(bytes.Length/16)) - { - return; - } - - for (int ii = 0; ii < bytes.Length; ii+=16) - { - ShowValue(ref index, ref overwrite, bytes, ii); - } - - return; - } - - // show arrays - Array array = value as Array; - - if (array == null) - { - Matrix matrix = value as Matrix; - - if (matrix != null) - { - array = matrix.ToArray(); - } - } - - if (array != null) - { - if (!PromptOnLongList(array.GetLength(0))) - { - return; - } - - for (int ii = 0; ii < array.GetLength(0); ii++) - { - ShowValue(ref index, ref overwrite, array, ii); - } - - return; - } - - // show lists - IList list = value as IList; - - if (list != null) - { - if (!PromptOnLongList(list.Count)) - { - return; - } - - for (int ii = 0; ii < list.Count; ii++) - { - ShowValue(ref index, ref overwrite, list, ii); - } - - return; - } - - // show xml elements - XmlElement xml = value as XmlElement; - - if (xml != null) - { - if (!PromptOnLongList(xml.ChildNodes.Count)) - { - return; - } - - for (int ii = 0; ii < xml.ChildNodes.Count; ii++) - { - ShowValue(ref index, ref overwrite, xml, ii); - } - - return; - } - - // show data value. - DataValue datavalue = value as DataValue; - - if (datavalue != null) - { - ShowValue(ref index, ref overwrite, datavalue, 0); - ShowValue(ref index, ref overwrite, datavalue, 1); - ShowValue(ref index, ref overwrite, datavalue, 2); - ShowValue(ref index, ref overwrite, datavalue, 3); - return; - } - - // show node id value. - NodeId nodeId = value as NodeId; - - if (nodeId != null) - { - ShowValue(ref index, ref overwrite, nodeId, 0); - ShowValue(ref index, ref overwrite, nodeId, 1); - ShowValue(ref index, ref overwrite, nodeId, 2); - return; - } - - // show expanded node id value. - ExpandedNodeId expandedNodeId = value as ExpandedNodeId; - - if (expandedNodeId != null) - { - ShowValue(ref index, ref overwrite, expandedNodeId, 0); - ShowValue(ref index, ref overwrite, expandedNodeId, 1); - ShowValue(ref index, ref overwrite, expandedNodeId, 2); - ShowValue(ref index, ref overwrite, expandedNodeId, 3); - return; - } - - // show qualified name value. - QualifiedName qualifiedName = value as QualifiedName; - - if (qualifiedName != null) - { - ShowValue(ref index, ref overwrite, qualifiedName, 0); - ShowValue(ref index, ref overwrite, qualifiedName, 1); - return; - } - - // show qualified name value. - LocalizedText localizedText = value as LocalizedText; - - if (localizedText != null) - { - ShowValue(ref index, ref overwrite, localizedText, 0); - ShowValue(ref index, ref overwrite, localizedText, 1); - return; - } - - // show variant. - Variant? variant = value as Variant?; - - if (variant != null) - { - ShowValue(ref index, ref overwrite, variant.Value.Value); - return; - } - - // show unknown types as strings. - ShowValue(ref index, ref overwrite, String.Format("{0}", value)); - } - - /* - private void MonitoredItem_Notification(object sender, EventArgs e) - { - if (InvokeRequired) - { - BeginInvoke(m_MonitoredItemNotification, sender, e); - return; - } - else if (!IsHandleCreated) - { - return; - } - - try - { - if (!Object.ReferenceEquals(sender, m_monitoredItem)) - { - return; - } - - MonitoredItemEventArgs args = e as MonitoredItemEventArgs; - - if (args == null) - { - return; - } - - m_expanding = false; - - int index = 0; - bool overwrite = true; - - ShowValue(ref index, ref overwrite, args.NotificationValue); - AdjustColumns(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - */ - - private void ItemsLV_MouseClick(object sender, MouseEventArgs e) - { - try - { - if (e.Button != MouseButtons.Left) - { - return; - } - - ListViewItem listItem = ItemsLV.GetItemAt(e.X, e.Y); - - if (listItem == null) - { - return; - } - - ValueState state = listItem.Tag as ValueState; - - if (state == null || !state.Expandable) - { - return; - } - - if (state.Expanded) - { - HideChildren(listItem); - } - else - { - ShowChildren(listItem); - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - - #region Event Handlers - private void UpdatesMI_CheckedChanged(object sender, EventArgs e) - { - try - { - /* - if (m_monitoredItem != null) - { - if (UpdatesMI.Checked) - { - m_monitoredItem.Notification += m_MonitoredItemNotification; - } - else - { - m_monitoredItem.Notification -= m_MonitoredItemNotification; - } - } - */ - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void RefreshMI_Click(object sender, EventArgs e) - { - try - { - /* - Clear(); - ShowValue(m_monitoredItem); - */ - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void ClearMI_Click(object sender, EventArgs e) - { - try - { - Clear(); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - - private void EditMI_Click(object sender, EventArgs e) - { - try - { - if (ItemsLV.SelectedItems.Count != 1) - { - return; - } - - ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState; - - if (!IsEditableType(state.Component)) - { - return; - } - - object value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType()); - - if (value == null) - { - return; - } - - if (state.Value is IEncodeable) - { - PropertyInfo property = (PropertyInfo)state.ComponentId; - - MethodInfo[] accessors = property.GetAccessors(); - - for (int ii = 0; ii < accessors.Length; ii++) - { - if (accessors[ii].ReturnType == typeof(void)) - { - accessors[ii].Invoke(state.Value, new object[] { value }); - state.Component = value; - break; - } - } - } - - DataValue datavalue = state.Value as DataValue; - - if (datavalue != null) - { - int component = (int)state.ComponentId; - - switch (component) - { - case 0: { datavalue.Value = value; break; } - } - } - - if (state.Value is IList) - { - int ii = (int)state.ComponentId; - ((IList)state.Value)[ii] = value; - state.Component = value; - } - - m_expanding = false; - int index = 0; - bool overwrite = true; - ShowValue(ref index, ref overwrite, state.Value); - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.resx b/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.resx deleted file mode 100644 index 664168a023..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/DataListCtrl.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.cs b/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.cs deleted file mode 100644 index 4da7e53599..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.cs +++ /dev/null @@ -1,215 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Sample.Controls -{ - /// - /// A class that provide various common utility functions and shared resources. - /// - public partial class GuiUtils2 : Form - { - /// - /// Displays a dialog that allows a use to edit a value. - /// - public static object EditValue(Session session, object value) - { - TypeInfo typeInfo = TypeInfo.Construct(value); - - if (typeInfo != null) - { - return EditValue(session, value, (uint)typeInfo.BuiltInType, typeInfo.ValueRank); - } - - return null; - } - - /// - /// Displays a dialog that allows a use to edit a value. - /// - public static object EditValue(Session session, object value, NodeId datatypeId, int valueRank) - { - if (value == null) - { - value = GuiUtils.GetDefaultValue(datatypeId, valueRank); - } - - if (valueRank >= 0) - { - return new ComplexValueEditDlg().ShowDialog(value); - } - - BuiltInType builtinType = TypeInfo.GetBuiltInType(datatypeId, session.TypeTree); - - switch (builtinType) - { - case BuiltInType.Boolean: - case BuiltInType.Byte: - case BuiltInType.SByte: - case BuiltInType.Int16: - case BuiltInType.UInt16: - case BuiltInType.Int32: - case BuiltInType.UInt32: - case BuiltInType.Int64: - case BuiltInType.UInt64: - case BuiltInType.Float: - case BuiltInType.Double: - case BuiltInType.Enumeration: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(builtinType, valueRank)); - } - - case BuiltInType.Number: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.Double, valueRank)); - } - - case BuiltInType.Integer: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.Int64, valueRank)); - } - - case BuiltInType.UInteger: - { - return new NumericValueEditDlg().ShowDialog(value, TypeInfo.GetSystemType(BuiltInType.UInt64, valueRank)); - } - - case BuiltInType.NodeId: - { - return new NodeIdValueEditDlg().ShowDialog(session, (NodeId)value); - } - - case BuiltInType.ExpandedNodeId: - { - return new NodeIdValueEditDlg().ShowDialog(session, (ExpandedNodeId)value); - } - - case BuiltInType.DateTime: - { - DateTime datetime = (DateTime)value; - - if (new DateTimeValueEditDlg().ShowDialog(ref datetime)) - { - return datetime; - } - - return null; - } - - case BuiltInType.QualifiedName: - { - QualifiedName qname = (QualifiedName)value; - - string name = new StringValueEditDlg().ShowDialog(qname.Name); - - if (name != null) - { - return new QualifiedName(name, qname.NamespaceIndex); - } - - return null; - } - - case BuiltInType.String: - { - return new StringValueEditDlg().ShowDialog((string)value); - } - - case BuiltInType.LocalizedText: - { - LocalizedText ltext = (LocalizedText)value; - - string text = new StringValueEditDlg().ShowDialog(ltext.Text); - - if (text != null) - { - return new LocalizedText(ltext.Locale, text); - } - - return null; - } - } - - return new ComplexValueEditDlg().ShowDialog(value); - } - - /// - /// Returns to display icon for the target of a reference. - /// - public static string GetTargetIcon(Session session, ReferenceDescription reference) - { - return GetTargetIcon(session, reference.NodeClass, reference.TypeDefinition); - } - - /// - /// Returns to display icon for the target of a reference. - /// - public static string GetTargetIcon(Session session, NodeClass nodeClass, ExpandedNodeId typeDefinitionId) - { - // make sure the type definition is in the cache. - INode typeDefinition = session.NodeCache.Find(typeDefinitionId); - - switch (nodeClass) - { - case NodeClass.Object: - { - if (session.TypeTree.IsTypeOf(typeDefinitionId, ObjectTypes.FolderType)) - { - return "Folder"; - } - - return "Object"; - } - - case NodeClass.Variable: - { - if (session.TypeTree.IsTypeOf(typeDefinitionId, VariableTypes.PropertyType)) - { - return "Property"; - } - - return "Variable"; - } - } - - return nodeClass.ToString(); - } - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.resx b/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.resx deleted file mode 100644 index 0915d012af..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/GuiUtils2.resx +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD0 - JwAAAk1TRnQBSQFMAgEBEQEAARMBAAEEAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABUAMAAQEBAAEYBgABPBIAMP+QAAOAJAAJ/5AAA4ASwAMAD/8DAAb/kA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wGkAawBjwGkAawB1QHcAeAk/wPuA4gDMwP4A/8D+AMzA4gD7kX/AdgB7gH2 - ARQBqgHhAYUB4QH1ARcBmAHIAdgB7gH2tP8B2AHuAfYBFAGqAeEB2AHuAfZ7/wFCAU0BPgcAAT4DAAEo - AwABQAMAAVADAAEBAQABAQUAAYABAhYAA///AP8AgwAL - - - \ No newline at end of file diff --git a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.Designer.cs deleted file mode 100644 index 4d04a441ef..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.Designer.cs +++ /dev/null @@ -1,147 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Sample.Controls -{ - partial class NodeIdValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.MainPN = new System.Windows.Forms.Panel(); - this.ValueCTRL = new Opc.Ua.Client.Controls.NodeIdCtrl(); - this.ButtonsPN.SuspendLayout(); - this.MainPN.SuspendLayout(); - this.SuspendLayout(); - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 28); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(297, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(218, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // MainPN - // - this.MainPN.Controls.Add(this.ValueCTRL); - this.MainPN.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainPN.Location = new System.Drawing.Point(0, 0); - this.MainPN.Name = "MainPN"; - this.MainPN.Size = new System.Drawing.Size(297, 28); - this.MainPN.TabIndex = 1; - // - // ValueCTRL - // - this.ValueCTRL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueCTRL.Location = new System.Drawing.Point(4, 4); - this.ValueCTRL.MaximumSize = new System.Drawing.Size(4096, 20); - this.ValueCTRL.MinimumSize = new System.Drawing.Size(100, 20); - this.ValueCTRL.Name = "ValueCTRL"; - this.ValueCTRL.Size = new System.Drawing.Size(289, 20); - this.ValueCTRL.TabIndex = 2; - // - // NodeIdValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(297, 59); - this.Controls.Add(this.MainPN); - this.Controls.Add(this.ButtonsPN); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "NodeIdValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit NodeId"; - this.ButtonsPN.ResumeLayout(false); - this.MainPN.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel MainPN; - private Opc.Ua.Client.Controls.NodeIdCtrl ValueCTRL; - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.resx b/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.resx deleted file mode 100644 index d58980a38d..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/NodeIdValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.Designer.cs b/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.Designer.cs deleted file mode 100644 index 929d256c40..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Sample.Controls -{ - partial class ReferenceTypeCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ReferenceTypesCB = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // ReferenceTypesCB - // - this.ReferenceTypesCB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ReferenceTypesCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ReferenceTypesCB.FormattingEnabled = true; - this.ReferenceTypesCB.Location = new System.Drawing.Point(0, 0); - this.ReferenceTypesCB.Name = "ReferenceTypesCB"; - this.ReferenceTypesCB.Size = new System.Drawing.Size(200, 21); - this.ReferenceTypesCB.TabIndex = 0; - this.ReferenceTypesCB.SelectedIndexChanged += new System.EventHandler(this.ReferenceTypesCB_SelectedIndexChanged); - // - // ReferenceTypeCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.ReferenceTypesCB); - this.MaximumSize = new System.Drawing.Size(4096, 21); - this.MinimumSize = new System.Drawing.Size(200, 21); - this.Name = "ReferenceTypeCtrl"; - this.Size = new System.Drawing.Size(200, 21); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ComboBox ReferenceTypesCB; - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.cs b/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.cs deleted file mode 100644 index d82aaf0a0c..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.cs +++ /dev/null @@ -1,270 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client; -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Sample.Controls -{ - public partial class ReferenceTypeCtrl : UserControl - { - #region Constructors - public ReferenceTypeCtrl() - { - InitializeComponent(); - m_baseTypeId = Opc.Ua.ReferenceTypeIds.References; - } - #endregion - - #region Private Fields - private Session m_session; - private NodeId m_baseTypeId; - private event EventHandler m_referenceSelectionChanged; - #endregion - - #region Public Interface - /// - /// Initializes the control with references starting with the specified based type. - /// - public void Initialize(Session session, NodeId baseTypeId) - { - m_session = session; - m_baseTypeId = baseTypeId; - - if (NodeId.IsNull(m_baseTypeId)) - { - m_baseTypeId = ReferenceTypeIds.References; - } - - ReferenceTypesCB.Items.Clear(); - - // recurcively fetch the reference types from the server. - if (m_session != null) - { - AddReferenceTypes(m_baseTypeId, null); - } - } - - /// - /// The currently seleected reference type id. - /// - public NodeId SelectedTypeId - { - get - { - ReferenceTypeChoice choice = ReferenceTypesCB.SelectedItem as ReferenceTypeChoice; - - if (choice == null) - { - return null; - } - - return choice.ReferenceType.NodeId; - } - - set - { - for (int ii = 0; ii < ReferenceTypesCB.Items.Count; ii++) - { - ReferenceTypeChoice choice = ReferenceTypesCB.Items[ii] as ReferenceTypeChoice; - - if (choice != null && choice.ReferenceType.NodeId == value) - { - ReferenceTypesCB.SelectedIndex = ii; - return; - } - } - - if (ReferenceTypesCB.Items.Count > 0) - { - ReferenceTypesCB.SelectedIndex = 0; - } - } - } - - /// - /// Raised when the selected reference is changed. - /// - public event EventHandler ReferenceSelectionChanged - { - add { m_referenceSelectionChanged += value; } - remove { m_referenceSelectionChanged -= value; } - } - - #region ReferenceSelectedEventArgs Class - /// - /// Specifies the nodes that where selected in the control. - /// - public class ReferenceSelectedEventArgs : EventArgs - { - /// - /// Constructs a new object. - /// - public ReferenceSelectedEventArgs(NodeId selectedTypeId) - { - m_referenceTypeId = selectedTypeId; - } - - /// - /// The reference type that was selected. - /// - public NodeId ReferenceTypeId - { - get { return m_referenceTypeId; } - } - - private NodeId m_referenceTypeId; - } - #endregion - #endregion - - #region ReferenceTypeChoice Class - /// - /// A reference type that may be used as a browse filter. - /// - private class ReferenceTypeChoice - { - /// - /// The text to display in the control. - /// - public override string ToString() - { - if (ReferenceType == null) - { - return ""; - } - - StringBuilder text = new StringBuilder(); - - GetPrefix(text); - - if (text.Length > 0) - { - text.Append("> "); - } - - if (ReferenceType != null) - { - text.Append(ReferenceType.ToString()); - } - - return text.ToString(); - } - - /// - /// Adds a prefix for subtypes. - /// - private void GetPrefix(StringBuilder prefix) - { - if (SuperType != null) - { - SuperType.GetPrefix(prefix); - prefix.Append("--"); - } - } - - public ReferenceTypeNode ReferenceType; - public ReferenceTypeChoice SuperType; - } - #endregion - - #region Private Methods - /// - /// Adds the reference types to drop down box. - /// - private void AddReferenceTypes(ExpandedNodeId referenceTypeId, ReferenceTypeChoice supertype) - { - if (referenceTypeId == null) throw new ApplicationException("referenceTypeId"); - - try - { - // find reference. - ReferenceTypeNode node = m_session.NodeCache.Find(referenceTypeId) as ReferenceTypeNode; - - if (node == null) - { - return; - } - - // add reference to combobox. - ReferenceTypeChoice choice = new ReferenceTypeChoice(); - - choice.ReferenceType = node; - choice.SuperType = supertype; - - ReferenceTypesCB.Items.Add(choice); - - // recursively add subtypes. - IList subtypes = m_session.NodeCache.FindReferences(node.NodeId, ReferenceTypeIds.HasSubtype, false, true); - - foreach (INode subtype in subtypes) - { - AddReferenceTypes(subtype.NodeId, choice); - } - } - catch (Exception e) - { - Utils.Trace(e, "Ignoring unknown reference type."); - return; - } - } - #endregion - - #region Event Handlers - private void ReferenceTypesCB_SelectedIndexChanged(object sender, EventArgs e) - { - try - { - if (m_referenceSelectionChanged != null) - { - NodeId referenceTypeId = SelectedTypeId; - - if (referenceTypeId != null) - { - m_referenceSelectionChanged(this, new ReferenceSelectedEventArgs(referenceTypeId)); - } - } - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.resx b/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.resx deleted file mode 100644 index 19dc0dd8b3..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/ReferenceTypeCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.Designer.cs deleted file mode 100644 index ab5566540c..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.Designer.cs +++ /dev/null @@ -1,162 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -namespace Opc.Ua.Sample.Controls -{ - partial class SimpleValueEditDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.ValueLB = new System.Windows.Forms.Label(); - this.ButtonsPN = new System.Windows.Forms.Panel(); - this.OkBTN = new System.Windows.Forms.Button(); - this.CancelBTN = new System.Windows.Forms.Button(); - this.panel1 = new System.Windows.Forms.Panel(); - this.ValueTB = new System.Windows.Forms.TextBox(); - this.ButtonsPN.SuspendLayout(); - this.panel1.SuspendLayout(); - this.SuspendLayout(); - // - // ValueLB - // - this.ValueLB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueLB.AutoSize = true; - this.ValueLB.Location = new System.Drawing.Point(4, 9); - this.ValueLB.Name = "ValueLB"; - this.ValueLB.Size = new System.Drawing.Size(34, 13); - this.ValueLB.TabIndex = 0; - this.ValueLB.Text = "Value"; - this.ValueLB.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // ButtonsPN - // - this.ButtonsPN.Controls.Add(this.OkBTN); - this.ButtonsPN.Controls.Add(this.CancelBTN); - this.ButtonsPN.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonsPN.Location = new System.Drawing.Point(0, 33); - this.ButtonsPN.Name = "ButtonsPN"; - this.ButtonsPN.Size = new System.Drawing.Size(311, 31); - this.ButtonsPN.TabIndex = 0; - // - // OkBTN - // - this.OkBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.OkBTN.Location = new System.Drawing.Point(4, 4); - this.OkBTN.Name = "OkBTN"; - this.OkBTN.Size = new System.Drawing.Size(75, 23); - this.OkBTN.TabIndex = 1; - this.OkBTN.Text = "OK"; - this.OkBTN.UseVisualStyleBackColor = true; - this.OkBTN.Click += new System.EventHandler(this.OkBTN_Click); - // - // CancelBTN - // - this.CancelBTN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBTN.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBTN.Location = new System.Drawing.Point(232, 4); - this.CancelBTN.Name = "CancelBTN"; - this.CancelBTN.Size = new System.Drawing.Size(75, 23); - this.CancelBTN.TabIndex = 0; - this.CancelBTN.Text = "Cancel"; - this.CancelBTN.UseVisualStyleBackColor = true; - // - // panel1 - // - this.panel1.Controls.Add(this.ValueTB); - this.panel1.Controls.Add(this.ValueLB); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(311, 33); - this.panel1.TabIndex = 1; - // - // ValueTB - // - this.ValueTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ValueTB.Location = new System.Drawing.Point(44, 7); - this.ValueTB.Name = "ValueTB"; - this.ValueTB.Size = new System.Drawing.Size(263, 20); - this.ValueTB.TabIndex = 1; - // - // SimpleValueEditDlg - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(311, 64); - this.Controls.Add(this.panel1); - this.Controls.Add(this.ButtonsPN); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "SimpleValueEditDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Value"; - this.ButtonsPN.ResumeLayout(false); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Label ValueLB; - private System.Windows.Forms.Panel ButtonsPN; - private System.Windows.Forms.Button OkBTN; - private System.Windows.Forms.Button CancelBTN; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.TextBox ValueTB; - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.cs b/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.cs deleted file mode 100644 index ae2cb0b058..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* ======================================================================== - * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. - * - * OPC Foundation MIT License 1.00 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * The complete license agreement can be found here: - * http://opcfoundation.org/License/MIT/1.00/ - * ======================================================================*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -using Opc.Ua.Client.Controls; - -namespace Opc.Ua.Sample.Controls -{ - public partial class SimpleValueEditDlg : Form - { - #region Constructors - public SimpleValueEditDlg() - { - InitializeComponent(); - this.Icon = ClientUtils.GetAppIcon(); - } - #endregion - - #region Private Fields - private object m_value; - private Type m_type; - #endregion - - #region Public Interface - /// - /// Displays the dialog. - /// - public object ShowDialog(object value, Type type) - { - if (type == null) throw new ArgumentNullException("type"); - - m_type = type; - - this.Text = Utils.Format("{0} ({1})", this.Text, type.Name); - - ValueTB.Text = Utils.Format("{0}", value); - - if (ShowDialog() != DialogResult.OK) - { - return null; - } - - return m_value; - } - - /// - /// Returns true if the dialog supports editing the type. - /// - public static bool IsSimpleType(Type type) - { - if (type == typeof(bool)) return true; - if (type == typeof(sbyte)) return true; - if (type == typeof(byte)) return true; - if (type == typeof(short)) return true; - if (type == typeof(ushort)) return true; - if (type == typeof(int)) return true; - if (type == typeof(uint)) return true; - if (type == typeof(long)) return true; - if (type == typeof(ulong)) return true; - if (type == typeof(float)) return true; - if (type == typeof(double)) return true; - if (type == typeof(string)) return true; - if (type == typeof(DateTime)) return true; - if (type == typeof(Guid)) return true; - - return false; - } - #endregion - - private object Parse(string text) - { - if (m_type == typeof(bool)) return Convert.ToBoolean(text); - if (m_type == typeof(sbyte)) return Convert.ToSByte(text); - if (m_type == typeof(byte)) return Convert.ToByte(text); - if (m_type == typeof(short)) return Convert.ToInt16(text); - if (m_type == typeof(ushort)) return Convert.ToUInt16(text); - if (m_type == typeof(int)) return Convert.ToInt32(text); - if (m_type == typeof(uint)) return Convert.ToUInt32(text); - if (m_type == typeof(long)) return Convert.ToInt64(text); - if (m_type == typeof(ulong)) return Convert.ToUInt64(text); - if (m_type == typeof(float)) return Convert.ToSingle(text); - if (m_type == typeof(double)) return Convert.ToDouble(text); - if (m_type == typeof(string)) return text; - if (m_type == typeof(DateTime)) return DateTime.ParseExact(text, "yyyy-MM-dd HH:mm:ss.fff", null); - if (m_type == typeof(Guid)) return new Guid(text); - if (m_type == typeof(QualifiedName)) return new QualifiedName(text); - if (m_type == typeof(LocalizedText)) return new LocalizedText(text); - - throw new ServiceResultException(StatusCodes.BadUnexpectedError, "Cannot convert type."); - } - - #region Event Handlers - private void OkBTN_Click(object sender, EventArgs e) - { - try - { - m_value = Parse(ValueTB.Text); - DialogResult = DialogResult.OK; - } - catch (Exception exception) - { - GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); - } - } - #endregion - } -} diff --git a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.resx b/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.resx deleted file mode 100644 index d58980a38d..0000000000 --- a/SampleApplications/Samples/Controls.Net4/Common/SimpleValueEditDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseListCtrl.cs b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseListCtrl.cs index bf922fd222..3542c778a0 100644 --- a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseListCtrl.cs +++ b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseListCtrl.cs @@ -258,7 +258,7 @@ namespace Opc.Ua.Sample.Controls } ItemData item = new ItemData(referenceType, !reference.IsForward, target, typeDefinition); - AddItem(item, GuiUtils2.GetTargetIcon(m_browser.Session, reference), -1); + AddItem(item, GuiUtils.GetTargetIcon(m_browser.Session, reference), -1); if ((target.NodeClass & (NodeClass.Variable | NodeClass.VariableType)) != 0) { diff --git a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseOptionsDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseOptionsDlg.Designer.cs index ca0bc6a134..f43a25348d 100644 --- a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseOptionsDlg.Designer.cs +++ b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseOptionsDlg.Designer.cs @@ -70,7 +70,7 @@ namespace Opc.Ua.Sample.Controls this.BrowseBTN = new System.Windows.Forms.Button(); this.ViewIdTB = new System.Windows.Forms.TextBox(); this.ViewIdLB = new System.Windows.Forms.Label(); - this.ReferenceTypeCTRL = new Opc.Ua.Sample.Controls.ReferenceTypeCtrl(); + this.ReferenceTypeCTRL = new Opc.Ua.Client.Controls.ReferenceTypeCtrl(); this.NodeClassList = new System.Windows.Forms.CheckedListBox(); this.NodeClassMaskCK = new System.Windows.Forms.CheckBox(); this.NodeClassMaskLB = new System.Windows.Forms.Label(); @@ -417,7 +417,7 @@ namespace Opc.Ua.Sample.Controls private System.Windows.Forms.CheckBox NodeClassMaskCK; private System.Windows.Forms.Label NodeClassMaskLB; private System.Windows.Forms.Label ViewIdLB; - private Opc.Ua.Sample.Controls.ReferenceTypeCtrl ReferenceTypeCTRL; + private Opc.Ua.Client.Controls.ReferenceTypeCtrl ReferenceTypeCTRL; private System.Windows.Forms.Label ViewVersionLB; private System.Windows.Forms.CheckBox ViewTimestampCK; private System.Windows.Forms.DateTimePicker ViewTimestampDP; diff --git a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseTreeCtrl.cs b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseTreeCtrl.cs index 70b51f0e0e..d3d323d4d0 100644 --- a/SampleApplications/Samples/Controls.Net4/Sessions/BrowseTreeCtrl.cs +++ b/SampleApplications/Samples/Controls.Net4/Sessions/BrowseTreeCtrl.cs @@ -206,7 +206,7 @@ namespace Opc.Ua.Sample.Controls reference.TypeDefinition = null; string text = GetTargetText(reference); - string icon = GuiUtils2.GetTargetIcon(m_browser.Session, reference); + string icon = GuiUtils.GetTargetIcon(m_browser.Session, reference); TreeNode root = AddNode(null, reference, text, icon); root.Nodes.Add(new TreeNode()); @@ -725,7 +725,7 @@ namespace Opc.Ua.Sample.Controls } string text = GetTargetText(reference); - string icon = GuiUtils2.GetTargetIcon(m_browser.Session, reference); + string icon = GuiUtils.GetTargetIcon(m_browser.Session, reference); TreeNode container = parent; diff --git a/SampleApplications/Samples/Controls.Net4/Sessions/SessionOpenDlg.cs b/SampleApplications/Samples/Controls.Net4/Sessions/SessionOpenDlg.cs index 2afc37b412..6d73780aff 100644 --- a/SampleApplications/Samples/Controls.Net4/Sessions/SessionOpenDlg.cs +++ b/SampleApplications/Samples/Controls.Net4/Sessions/SessionOpenDlg.cs @@ -28,6 +28,7 @@ * ======================================================================*/ using Opc.Ua.Client; +using Opc.Ua.Client.ComplexTypes; using Opc.Ua.Client.Controls; using System; using System.Collections.Generic; @@ -258,6 +259,9 @@ namespace Opc.Ua.Sample.Controls // open the session. session.Open(sessionName, (uint)session.SessionTimeout, identity, preferredLocales, checkDomain ?? true); + var typeSystemLoader = new ComplexTypeSystem(session); + typeSystemLoader.Load().Wait(); + OpenComplete(null); } catch (Exception exception) diff --git a/SampleApplications/Samples/Controls.Net4/Subscriptions/HistoryReadDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Subscriptions/HistoryReadDlg.Designer.cs index cc2c712b40..2cd45f95e7 100644 --- a/SampleApplications/Samples/Controls.Net4/Subscriptions/HistoryReadDlg.Designer.cs +++ b/SampleApplications/Samples/Controls.Net4/Subscriptions/HistoryReadDlg.Designer.cs @@ -27,6 +27,8 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ +using Opc.Ua.Client.Controls; + namespace Opc.Ua.Sample.Controls { partial class HistoryReadDlg @@ -65,7 +67,7 @@ namespace Opc.Ua.Sample.Controls this.SplitterPN = new System.Windows.Forms.SplitContainer(); this.HistoryReadDetailsCTRL = new Opc.Ua.Sample.HistoryReadDetails(); this.BrowseCTRL = new Opc.Ua.Sample.Controls.BrowseTreeCtrl(); - this.ReadResultsCTRL = new Opc.Ua.Sample.Controls.DataListCtrl(); + this.ReadResultsCTRL = new Opc.Ua.Client.Controls.DataListCtrl(); this.ReadValuesCTRL = new Opc.Ua.Sample.Controls.ReadValueListCtrl(); this.MainPN = new System.Windows.Forms.Panel(); this.ButtonsPN.SuspendLayout(); diff --git a/SampleApplications/Samples/Controls.Net4/Subscriptions/MonitoredItemDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Subscriptions/MonitoredItemDlg.Designer.cs index 3941ff102c..98b25fd835 100644 --- a/SampleApplications/Samples/Controls.Net4/Subscriptions/MonitoredItemDlg.Designer.cs +++ b/SampleApplications/Samples/Controls.Net4/Subscriptions/MonitoredItemDlg.Designer.cs @@ -27,6 +27,8 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ +using Opc.Ua.Client.Controls; + namespace Opc.Ua.Sample.Controls { partial class MonitoredItemDlg @@ -77,7 +79,7 @@ namespace Opc.Ua.Sample.Controls this.LastMessageIdTB = new System.Windows.Forms.ToolStripStatusLabel(); this.SplitterPN = new System.Windows.Forms.SplitContainer(); this.MonitoredItemsCTRL = new Opc.Ua.Sample.Controls.MonitoredItemStatusCtrl(); - this.LatestValueCTRL = new Opc.Ua.Sample.Controls.DataListCtrl(); + this.LatestValueCTRL = new Opc.Ua.Client.Controls.DataListCtrl(); this.DataChangesCTRL = new Opc.Ua.Sample.Controls.DataChangeNotificationListCtrl(); this.EventsCTRL = new Opc.Ua.Sample.Controls.EventNotificationListListCtrl(); this.MainPN = new System.Windows.Forms.Panel(); diff --git a/SampleApplications/Samples/Controls.Net4/Subscriptions/ReadDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Subscriptions/ReadDlg.Designer.cs index b0ed1e8996..7b3e0c2a12 100644 --- a/SampleApplications/Samples/Controls.Net4/Subscriptions/ReadDlg.Designer.cs +++ b/SampleApplications/Samples/Controls.Net4/Subscriptions/ReadDlg.Designer.cs @@ -27,6 +27,8 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ +using Opc.Ua.Client.Controls; + namespace Opc.Ua.Sample.Controls { partial class ReadDlg @@ -65,7 +67,7 @@ namespace Opc.Ua.Sample.Controls this.SplitterPN = new System.Windows.Forms.SplitContainer(); this.MainPN = new System.Windows.Forms.Panel(); this.BrowseCTRL = new Opc.Ua.Sample.Controls.BrowseTreeCtrl(); - this.ReadResultsCTRL = new Opc.Ua.Sample.Controls.DataListCtrl(); + this.ReadResultsCTRL = new Opc.Ua.Client.Controls.DataListCtrl(); this.ReadValuesCTRL = new Opc.Ua.Sample.Controls.ReadValueListCtrl(); this.ButtonsPN.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.SplitterPN)).BeginInit(); diff --git a/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteDlg.Designer.cs b/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteDlg.Designer.cs index 8dbd1b9298..6d9490479d 100644 --- a/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteDlg.Designer.cs +++ b/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteDlg.Designer.cs @@ -27,6 +27,8 @@ * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ +using Opc.Ua.Client.Controls; + namespace Opc.Ua.Sample.Controls { partial class WriteDlg @@ -64,7 +66,7 @@ namespace Opc.Ua.Sample.Controls this.WriteBTN = new System.Windows.Forms.Button(); this.SplitterPN = new System.Windows.Forms.SplitContainer(); this.BrowseCTRL = new Opc.Ua.Sample.Controls.BrowseTreeCtrl(); - this.WriteResultsCTRL = new Opc.Ua.Sample.Controls.DataListCtrl(); + this.WriteResultsCTRL = new Opc.Ua.Client.Controls.DataListCtrl(); this.WriteValuesCTRL = new Opc.Ua.Sample.Controls.WriteValueListCtrl(); this.MainPN = new System.Windows.Forms.Panel(); this.ButtonsPN.SuspendLayout(); diff --git a/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteValueListCtrl.cs b/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteValueListCtrl.cs index d5205d28c8..c9fdab1900 100644 --- a/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteValueListCtrl.cs +++ b/SampleApplications/Samples/Controls.Net4/Subscriptions/WriteValueListCtrl.cs @@ -391,7 +391,7 @@ namespace Opc.Ua.Sample.Controls } else { - value = GuiUtils2.EditValue(m_session, values[0].Value.Value, datatypeId, valueRank); + value = GuiUtils.EditValue(m_session, values[0].Value.Value, datatypeId, valueRank); } if (value != null) diff --git a/SampleApplications/Samples/Controls.Net4/UA Sample Controls.csproj b/SampleApplications/Samples/Controls.Net4/UA Sample Controls.csproj index 079e7f82ce..7d67808ea7 100644 --- a/SampleApplications/Samples/Controls.Net4/UA Sample Controls.csproj +++ b/SampleApplications/Samples/Controls.Net4/UA Sample Controls.csproj @@ -83,24 +83,12 @@ CallMethodDlg.cs - - Form - - - NodeIdValueEditDlg.cs - Form ClientForm.cs - - Form - - - SimpleValueEditDlg.cs - Form @@ -317,12 +305,6 @@ CreateSecureChannelDlg.cs - - UserControl - - - ReferenceTypeCtrl.cs - Form @@ -425,12 +407,6 @@ AttributeListCtrl.cs - - UserControl - - - DataListCtrl.cs - Form @@ -449,12 +425,6 @@ FindNodeDlg.cs - - Form - - - GuiUtils2.cs - @@ -475,18 +445,10 @@ CallMethodDlg.cs Designer - - NodeIdValueEditDlg.cs - Designer - ClientForm.cs Designer - - SimpleValueEditDlg.cs - Designer - SelectLocaleDlg.cs Designer @@ -632,10 +594,6 @@ CreateSecureChannelDlg.cs Designer - - Designer - ReferenceTypeCtrl.cs - SelectNodeDlg.cs Designer @@ -704,20 +662,16 @@ FindNodeDlg.cs Designer - - Designer - DataListCtrl.cs - - - GuiUtils2.cs - Designer - {d918c0f6-39bd-4ed0-8323-e5a2eb9a85da} Opc.Ua.Core + + {fe9eeb39-0698-4a19-b770-e66836ce0002} + Opc.Ua.Client.ComplexTypes + {15100583-bfef-431b-a1ea-1e5a843a39b1} Opc.Ua.Client diff --git a/SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj b/SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj new file mode 100644 index 0000000000..dc3932575c --- /dev/null +++ b/SampleApplications/Samples/NetCoreComplexClient/NetCoreComplexClient.csproj @@ -0,0 +1,54 @@ + + + + netcoreapp2.0 + NetCoreComplexClient + Exe + NetCoreComplexClient + OPC Foundation + OPC UA SDK + .Net Core Complex Client + Copyright © 2004-2019 OPC Foundation, Inc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/SampleApplications/Samples/NetCoreComplexClient/Opc.Ua.ComplexClient.Config.xml b/SampleApplications/Samples/NetCoreComplexClient/Opc.Ua.ComplexClient.Config.xml new file mode 100644 index 0000000000..72e8e42994 --- /dev/null +++ b/SampleApplications/Samples/NetCoreComplexClient/Opc.Ua.ComplexClient.Config.xml @@ -0,0 +1,99 @@ + + + UA Core Complex Client + urn:localhost:OPCFoundation:CoreComplexClient + http://opcfoundation.org/UA/CoreComplexClient + Client_1 + + + + + + X509Store + CurrentUser\My + CN=UA Core Complex Client, C=US, S=Arizona, O=OPC Foundation, DC=localhost + + + + + Directory + %LocalApplicationData%/OPC Foundation/pki/issuer + + + + + Directory + %LocalApplicationData%/OPC Foundation/pki/trusted + + + + + Directory + %LocalApplicationData%/OPC Foundation/pki/rejected + + + + false + + + + + + + 600000 + 1048576 + 4194304 + 65535 + 4194304 + 65535 + 300000 + 3600000 + + + + + + + 600000 + + + + opc.tcp://{0}:4840/UADiscovery + + + + + + + 10000 + + + + %LocalApplicationData%/Logs/Opc.Ua.CoreComplexClient.log.txt + true + + + + + + + + + + + + + + + + true + + \ No newline at end of file diff --git a/SampleApplications/Samples/NetCoreComplexClient/Program.cs b/SampleApplications/Samples/NetCoreComplexClient/Program.cs new file mode 100644 index 0000000000..fab79e95ae --- /dev/null +++ b/SampleApplications/Samples/NetCoreComplexClient/Program.cs @@ -0,0 +1,613 @@ +/* ======================================================================== + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + * ======================================================================*/ + + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Mono.Options; +using Newtonsoft.Json; +using Opc.Ua; +using Opc.Ua.Client; +using Opc.Ua.Client.ComplexTypes; +using Opc.Ua.Configuration; + +namespace NetCoreConsoleClient +{ + + public enum ExitCode : int + { + Ok = 0, + ErrorCreateApplication = 0x11, + ErrorDiscoverEndpoints = 0x12, + ErrorCreateSession = 0x13, + ErrorBrowseNamespace = 0x14, + ErrorCreateSubscription = 0x15, + ErrorMonitoredItem = 0x16, + ErrorAddSubscription = 0x17, + ErrorRunning = 0x18, + ErrorLoadTypeDictionary = 0x19, + ErrorReadComplexTypes = 0x1a, + ErrorJSONDecode = 0x1b, + ErrorNoKeepAlive = 0x30, + ErrorInvalidCommandLine = 0x100 + }; + + public class Program + { + public static int Main(string[] args) + { + Console.WriteLine(".Net Core OPC UA Complex Types Client sample"); + + // command line options + bool showHelp = false; + int stopTimeout = Timeout.Infinite; + bool autoAccept = false; + bool writeComplexInt = false; + bool noloadTypes = false; + bool verbose = false; + bool json = false; + + Mono.Options.OptionSet options = new Mono.Options.OptionSet { + { "h|help", "show this message and exit", h => showHelp = h != null }, + { "a|autoaccept", "auto accept certificates (for testing only)", a => autoAccept = a != null }, + { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t }, + { "w|writeint", "Read and increment all complex types with an Int32.", w => writeComplexInt = w != null}, + { "n|noloadtypes", "Load the type system dictionary from the server.", n => noloadTypes = n != null}, + { "v|verbose", "Verbose output.", v => verbose = v != null}, + { "j|json", "Print custom nodes as Json.", j => json = j != null}, + }; + + IList extraArgs = null; + try + { + extraArgs = options.Parse(args); + if (extraArgs.Count > 1) + { + foreach (string extraArg in extraArgs) + { + Console.WriteLine("Error: Unknown option: {0}", extraArg); + showHelp = true; + } + } + } + catch (OptionException e) + { + Console.WriteLine(e.Message); + showHelp = true; + } + + if (showHelp) + { + // show some app description message + Console.WriteLine("Usage: dotnet NetCoreConsoleClient.dll [OPTIONS] [ENDPOINTURL]"); + Console.WriteLine(); + + // output the options + Console.WriteLine("Options:"); + options.WriteOptionDescriptions(Console.Out); + return (int)ExitCode.ErrorInvalidCommandLine; + } + + string endpointURL; + if (extraArgs.Count == 0) + { + // use OPC UA .Net Sample server + endpointURL = "opc.tcp://localhost:51210/UA/SampleServer"; + } + else + { + endpointURL = extraArgs[0]; + } + + MySampleClient client = new MySampleClient(endpointURL, autoAccept, stopTimeout); + client.Verbose = verbose; + client.LoadTypeSystem = !noloadTypes; + client.WriteComplexInt = writeComplexInt; + client.PrintAsJson = json; + return (int)client.Run(); + } + } + + public class MySampleClient + { + const int ReconnectPeriod = 10; + public ExitCode ExitCode { get; set; } + public bool Verbose { get; set; } = false; + public bool WriteComplexInt { get; set; } = false; + public bool PrintAsJson { get; set; } = false; + public bool LoadTypeSystem { get; set; } = false; + + public MySampleClient( + string endpointURL, + bool autoAccept, + int stopTimeout) + { + _endpointURL = endpointURL; + _autoAccept = autoAccept; + _clientRunTime = stopTimeout <= 0 ? Timeout.Infinite : stopTimeout * 1000; + } + + public ExitCode Run() + { + Session session; + + try + { + session = ConsoleSampleClient().Result; + } + catch (Exception ex) + { + Utils.Trace("ServiceResultException:" + ex.Message); + Console.WriteLine("Exception: {0}", ex.Message); + return ExitCode; + } + + ManualResetEvent quitEvent = new ManualResetEvent(false); + try + { + Console.CancelKeyPress += (sender, eArgs) => + { + quitEvent.Set(); + eArgs.Cancel = true; + }; + } + catch + { + } + + // Test the session reconnecthandler + bool eventResult = quitEvent.WaitOne(5000); + if (!eventResult) + { + Console.WriteLine(" --- Start simulated reconnect... --- "); + _reconnectHandler = new SessionReconnectHandler(); + _reconnectHandler.BeginReconnect(session, 1000, Client_ReconnectComplete); + } + + // wait for timeout or Ctrl-C + quitEvent.WaitOne(_clientRunTime); + + // return error conditions + if (session.KeepAliveStopped) + { + ExitCode = ExitCode.ErrorNoKeepAlive; + return ExitCode; + } + + ExitCode = ExitCode.Ok; + return ExitCode; + } + + private async Task ConsoleSampleClient() + { + Console.WriteLine("1 - Create an Application Configuration."); + ExitCode = ExitCode.ErrorCreateApplication; + + ApplicationInstance application = new ApplicationInstance + { + ApplicationName = "UA Core Complex Client", + ApplicationType = ApplicationType.Client, + ConfigSectionName = "Opc.Ua.ComplexClient" + }; + + // load the application configuration. + ApplicationConfiguration config = await application.LoadApplicationConfiguration(false); + + // check the application certificate. + bool haveAppCertificate = await application.CheckApplicationInstanceCertificate(false, 0); + if (!haveAppCertificate) + { + throw new Exception("Application instance certificate invalid!"); + } + + if (haveAppCertificate) + { + config.ApplicationUri = Utils.GetApplicationUriFromCertificate(config.SecurityConfiguration.ApplicationCertificate.Certificate); + if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates) + { + _autoAccept = true; + } + config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); + } + else + { + Console.WriteLine(" WARN: missing application certificate, using unsecure connection."); + } + + Console.WriteLine("2 - Discover endpoints of {0}.", _endpointURL); + ExitCode = ExitCode.ErrorDiscoverEndpoints; + var selectedEndpoint = CoreClientUtils.SelectEndpoint(_endpointURL, haveAppCertificate, 15000); + Console.WriteLine(" Selected endpoint uses: {0}", + selectedEndpoint.SecurityPolicyUri.Substring(selectedEndpoint.SecurityPolicyUri.LastIndexOf('#') + 1)); + + Console.WriteLine("3 - Create a session with OPC UA server."); + ExitCode = ExitCode.ErrorCreateSession; + var endpointConfiguration = EndpointConfiguration.Create(config); + var endpoint = new ConfiguredEndpoint(null, selectedEndpoint, endpointConfiguration); + _session = await Session.Create(config, endpoint, false, "OPC UA Console Client", 60000, new UserIdentity(new AnonymousIdentityToken()), null); + + // register keep alive handler + _session.KeepAlive += Client_KeepAlive; + + Console.WriteLine("4 - Browse for all custom type variables."); + ExitCode = ExitCode.ErrorReadComplexTypes; + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var allVariableNodes = BrowseAllVariables(); + var allCustomTypeVariables = allVariableNodes.Where(n => ((VariableNode)n).DataType == DataTypeIds.Structure).ToList(); + allCustomTypeVariables.AddRange(allVariableNodes.Where(n => ((VariableNode)n).DataType.NamespaceIndex != 0).ToList()); + stopWatch.Stop(); + + Console.WriteLine($" -- Browse all nodes took {stopWatch.ElapsedMilliseconds}ms."); + Console.WriteLine($" -- Browsed {allVariableNodes.Count} nodes, from which {allCustomTypeVariables.Count} are custom type variables."); + + if (LoadTypeSystem) + { + Console.WriteLine("5 - Load the server type dictionary."); + ExitCode = ExitCode.ErrorLoadTypeDictionary; + + stopWatch.Reset(); + stopWatch.Start(); + + var complexTypeSystem = new ComplexTypeSystem(_session); + await complexTypeSystem.Load(); + + stopWatch.Stop(); + + Console.WriteLine($"Load type system took {stopWatch.ElapsedMilliseconds}ms."); + + Console.WriteLine($"Custom types defined for this session:"); + foreach (var type in complexTypeSystem.GetDefinedTypes()) + { + Console.WriteLine($"{type.Namespace}.{type.Name}"); + } + + Console.WriteLine($"Loaded {_session.DataTypeSystem.Count} dictionaries:"); + foreach (var dictionary in _session.DataTypeSystem) + { + Console.WriteLine($" + {dictionary.Value.Name}"); + foreach (var type in dictionary.Value.DataTypes) + { + Console.WriteLine($" -- {type.Key}:{type.Value}"); + } + } + } + else + { + Console.WriteLine("4 - Not loading the server type dictionary."); + } + + foreach (VariableNode variableNode in allCustomTypeVariables) + { + try + { + var value = _session.ReadValue(variableNode.NodeId); + + CastInt32ToEnum(variableNode, value); + Console.WriteLine($" -- {variableNode}:{value}"); + + var extensionObject = value.Value as ExtensionObject; + if (extensionObject != null) + { + var complexType = extensionObject.Body as BaseComplexType; + if (complexType != null) + { + foreach (var item in complexType.GetPropertyEnumerator()) + { + if (Verbose) + { + Console.WriteLine($" -- -- {item.Name}:{complexType[item.Name]}"); + } + if (WriteComplexInt && item.PropertyType == typeof(Int32)) + { + var data = complexType[item.Name]; + if (data != null) + { + complexType[item.Name] = (Int32)data + 1; + } + Console.WriteLine($" -- -- Write: {item.Name}, {complexType[item.Name]}"); + WriteValue(_session, variableNode.NodeId, value); + } + } + } + } + + if (PrintAsJson) + { + PrintValueAsJson(variableNode.BrowseName.Name, value); + } + } + catch (ServiceResultException sre) + { + if (sre.StatusCode == StatusCodes.BadUserAccessDenied) + { + Console.WriteLine($" -- {variableNode}: Access denied!"); + } + } + } + + Console.WriteLine("6 - Create a subscription with publishing interval of 1 second."); + ExitCode = ExitCode.ErrorCreateSubscription; + var subscription = new Subscription(_session.DefaultSubscription) { PublishingInterval = 1000 }; + + Console.WriteLine("7 - Add all custom values and the server time to the subscription."); + ExitCode = ExitCode.ErrorMonitoredItem; + var list = new List { + new MonitoredItem(subscription.DefaultItem) + { + DisplayName = "ServerStatusCurrentTime", StartNodeId = "i="+Variables.Server_ServerStatus_CurrentTime.ToString() + } + }; + list.ForEach(i => i.Notification += OnNotification); + + foreach (var customVariable in allCustomTypeVariables) + { + var newItem = new MonitoredItem(subscription.DefaultItem) + { + DisplayName = customVariable.DisplayName.Text, + StartNodeId = ExpandedNodeId.ToNodeId(customVariable.NodeId, _session.NamespaceUris) + }; + newItem.Notification += OnComplexTypeNotification; + list.Add(newItem); + } + + subscription.AddItems(list); + + Console.WriteLine("8 - Add the subscription to the session."); + ExitCode = ExitCode.ErrorAddSubscription; + _session.AddSubscription(subscription); + subscription.Create(); + + Console.WriteLine("9 - Running...Press Ctrl-C to exit..."); + ExitCode = ExitCode.ErrorRunning; + + return _session; + } + + /// + /// Browse all variables in the objects folder. + /// + private IList BrowseAllVariables() + { + var result = new List(); + var nodesToBrowse = new ExpandedNodeIdCollection(); + nodesToBrowse.Add(ObjectIds.ObjectsFolder); + + while (nodesToBrowse.Count > 0) + { + var nextNodesToBrowse = new ExpandedNodeIdCollection(); + foreach (var node in nodesToBrowse) + { + try + { + var organizers = _session.NodeCache.FindReferences( + node, + ReferenceTypeIds.Organizes, + false, + false); + var components = _session.NodeCache.FindReferences( + node, + ReferenceTypeIds.HasComponent, + false, + false); + var properties = _session.NodeCache.FindReferences( + node, + ReferenceTypeIds.HasProperty, + false, + false); + nextNodesToBrowse.AddRange(organizers + .Where(n => n is ObjectNode) + .Select(n => n.NodeId).ToList()); + nextNodesToBrowse.AddRange(components + .Where(n => n is ObjectNode) + .Select(n => n.NodeId).ToList()); + result.AddRange(organizers.Where(n => n is VariableNode)); + result.AddRange(components.Where(n => n is VariableNode)); + result.AddRange(properties.Where(n => n is VariableNode)); + } + catch (ServiceResultException sre) + { + if (sre.StatusCode == StatusCodes.BadUserAccessDenied) + { + Console.WriteLine($"Access denied: Skip node {node}."); + } + } + } + nodesToBrowse = nextNodesToBrowse; + } + return result; + } + + private void Client_KeepAlive(Session sender, KeepAliveEventArgs e) + { + if (e.Status != null && ServiceResult.IsNotGood(e.Status)) + { + Console.WriteLine("{0} {1}/{2}", e.Status, sender.OutstandingRequestCount, sender.DefunctRequestCount); + + if (_reconnectHandler == null) + { + Console.WriteLine("--- RECONNECTING ---"); + _reconnectHandler = new SessionReconnectHandler(); + _reconnectHandler.BeginReconnect(sender, ReconnectPeriod * 1000, Client_ReconnectComplete); + } + } + } + + private void Client_ReconnectComplete(object sender, EventArgs e) + { + // ignore callbacks from discarded objects. + if (!Object.ReferenceEquals(sender, _reconnectHandler)) + { + return; + } + + _session = _reconnectHandler.Session; + _reconnectHandler.Dispose(); + _reconnectHandler = null; + + Console.WriteLine("--- RECONNECTED ---"); + } + + /// + /// Helper to cast a enumeration node value to an enumeration type. + /// + private void CastInt32ToEnum(VariableNode variableNode, DataValue value) + { + if (value.Value?.GetType() == typeof(Int32)) + { + // test if this is an enum datatype? + Type systemType = _session.Factory.GetSystemType( + NodeId.ToExpandedNodeId(variableNode.DataType, _session.NamespaceUris) + ); + if (systemType != null) + { + value.Value = Enum.ToObject(systemType, value.Value); + } + } + } + + private void WriteValue(Session session, NodeId variableId, DataValue value) + { + WriteValue nodeToWrite = new WriteValue(); + nodeToWrite.NodeId = variableId; + nodeToWrite.AttributeId = Attributes.Value; + nodeToWrite.Value = new DataValue(); + nodeToWrite.Value.WrappedValue = value.WrappedValue; + + WriteValueCollection nodesToWrite = new WriteValueCollection(); + nodesToWrite.Add(nodeToWrite); + + // read the attributes. + StatusCodeCollection results = null; + DiagnosticInfoCollection diagnosticInfos = null; + + ResponseHeader responseHeader = session.Write( + null, + nodesToWrite, + out results, + out diagnosticInfos); + + ClientBase.ValidateResponse(results, nodesToWrite); + ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToWrite); + + // check for error. + if (StatusCode.IsBad(results[0])) + { + throw ServiceResultException.Create(results[0], 0, diagnosticInfos, responseHeader.StringTable); + } + } + + private void PrintValueAsJson(string name, DataValue value) + { + var jsonEncoder = new JsonEncoder(_session.MessageContext, false); + jsonEncoder.WriteDataValue(name, value); + var textbuffer = jsonEncoder.CloseAndReturnText(); + // prettify + using (var stringWriter = new StringWriter()) + { + try + { + using (var stringReader = new StringReader(textbuffer)) + { + var jsonReader = new JsonTextReader(stringReader); + var jsonWriter = new JsonTextWriter(stringWriter) + { + Formatting = Formatting.Indented, + Culture = CultureInfo.InvariantCulture + }; + jsonWriter.WriteToken(jsonReader); + Console.WriteLine(stringWriter.ToString()); + } + } + catch (Exception ex) + { + Console.WriteLine("Failed to format the JSON output:", ex.Message); + Console.WriteLine(textbuffer); + Console.WriteLine(stringWriter.ToString()); + ExitCode = ExitCode.ErrorJSONDecode; + throw ex; + } + } + } + + private void OnNotification(MonitoredItem item, MonitoredItemNotificationEventArgs e) + { + foreach (var value in item.DequeueValues()) + { + Console.WriteLine("{0}: {1}, {2}, {3}", item.DisplayName, value.Value, value.SourceTimestamp, value.StatusCode); + } + } + + private void OnComplexTypeNotification(MonitoredItem item, MonitoredItemNotificationEventArgs e) + { + foreach (var value in item.DequeueValues()) + { + Console.WriteLine("{0}: {1}, {2}", item.DisplayName, value.SourceTimestamp, value.StatusCode); + if (Verbose) + { + Console.WriteLine(value); + } else if (PrintAsJson) + { + PrintValueAsJson(item.DisplayName, value); + } + } + } + + private void CertificateValidator_CertificateValidation(CertificateValidator validator, CertificateValidationEventArgs e) + { + if (e.Error.StatusCode == StatusCodes.BadCertificateUntrusted) + { + e.Accept = _autoAccept; + if (_autoAccept) + { + Console.WriteLine("Accepted Certificate: {0}", e.Certificate.Subject); + } + else + { + Console.WriteLine("Rejected Certificate: {0}", e.Certificate.Subject); + } + } + } + + private Session _session; + private SessionReconnectHandler _reconnectHandler; + private string _endpointURL; + private bool _autoAccept = false; + private int _clientRunTime = Timeout.Infinite; + + } + +} diff --git a/SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj b/SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj index 0e5d69c06f..51c2a220c3 100644 --- a/SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj +++ b/SampleApplications/Samples/NetCoreConsoleClient/NetCoreConsoleClient.csproj @@ -15,11 +15,29 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleApplications/Workshop/Aggregation/UA Aggregation.sln b/SampleApplications/Workshop/Aggregation/UA Aggregation.sln index d73acf8d0c..5b52774fa3 100644 --- a/SampleApplications/Workshop/Aggregation/UA Aggregation.sln +++ b/SampleApplications/Workshop/Aggregation/UA Aggregation.sln @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Configuration", "..\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Server", "..\..\SDK\Opc.Ua.Server\Opc.Ua.Server.csproj", "{54E066C7-E4B0-4911-8B90-D7FD88D9304F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "..\..\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{DEF30692-973F-40BC-BD2B-C1A167F71F1F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -69,8 +71,15 @@ Global {54E066C7-E4B0-4911-8B90-D7FD88D9304F}.Debug|Any CPU.Build.0 = Debug|Any CPU {54E066C7-E4B0-4911-8B90-D7FD88D9304F}.Release|Any CPU.ActiveCfg = Release|Any CPU {54E066C7-E4B0-4911-8B90-D7FD88D9304F}.Release|Any CPU.Build.0 = Release|Any CPU + {DEF30692-973F-40BC-BD2B-C1A167F71F1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DEF30692-973F-40BC-BD2B-C1A167F71F1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DEF30692-973F-40BC-BD2B-C1A167F71F1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DEF30692-973F-40BC-BD2B-C1A167F71F1F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7F2BCD7F-A64E-48B3-82BC-1C951D63EAD9} + EndGlobalSection EndGlobal diff --git a/SampleApplications/Workshop/DataTypes/Client/DataTypes Client.csproj b/SampleApplications/Workshop/DataTypes/Client/DataTypes Client.csproj index cbc8027fa2..01e9b7d470 100644 --- a/SampleApplications/Workshop/DataTypes/Client/DataTypes Client.csproj +++ b/SampleApplications/Workshop/DataTypes/Client/DataTypes Client.csproj @@ -118,6 +118,10 @@ {a247d2ee-14fc-463d-a9ba-6cff1ef22b7a} UA Client Controls + + {a3c69716-df28-4626-8c18-fb70f36c81e1} + Opc.Ua.Client.ComplexTypes + {7c7ad60d-c2de-460f-84ef-fa4a890104ef} Opc.Ua.Client diff --git a/SampleApplications/Workshop/DataTypes/Client/MainForm.cs b/SampleApplications/Workshop/DataTypes/Client/MainForm.cs index 77fef75176..4f9f9b7cc2 100644 --- a/SampleApplications/Workshop/DataTypes/Client/MainForm.cs +++ b/SampleApplications/Workshop/DataTypes/Client/MainForm.cs @@ -36,6 +36,7 @@ using System.IO; using Opc.Ua; using Opc.Ua.Client; using Opc.Ua.Client.Controls; +using Opc.Ua.Client.ComplexTypes; namespace Quickstarts.DataTypes { @@ -138,6 +139,12 @@ namespace Quickstarts.DataTypes ReferenceTypeIds.Organizes, ReferenceTypeIds.Aggregates, ReferenceTypeIds.HierarchicalReferences); + + if (m_session != null) + { + var typeSystem = new ComplexTypeSystem(m_session); + typeSystem.Load().Wait(); + } } catch (Exception exception) { diff --git a/SampleApplications/Workshop/DataTypes/Client/MainForm.resx b/SampleApplications/Workshop/DataTypes/Client/MainForm.resx index b83303927f..1fca67793d 100644 --- a/SampleApplications/Workshop/DataTypes/Client/MainForm.resx +++ b/SampleApplications/Workshop/DataTypes/Client/MainForm.resx @@ -112,18 +112,18 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + 132, 17 - + 235, 17 \ No newline at end of file diff --git a/SampleApplications/Workshop/Reference/UA Reference.sln b/SampleApplications/Workshop/Reference/UA Reference.sln index 08ba029783..8c017fac29 100644 --- a/SampleApplications/Workshop/Reference/UA Reference.sln +++ b/SampleApplications/Workshop/Reference/UA Reference.sln @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Sample", "..\..\Samp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UA Sample Controls", "..\..\Samples\Controls.Net4\UA Sample Controls.csproj", "{92AE819B-4938-4502-AC32-67063F9893CD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "..\..\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{C4C7053D-A51B-414E-8B73-1DA29D1BF46A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,6 +88,10 @@ Global {92AE819B-4938-4502-AC32-67063F9893CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {92AE819B-4938-4502-AC32-67063F9893CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {92AE819B-4938-4502-AC32-67063F9893CD}.Release|Any CPU.Build.0 = Release|Any CPU + {C4C7053D-A51B-414E-8B73-1DA29D1BF46A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4C7053D-A51B-414E-8B73-1DA29D1BF46A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4C7053D-A51B-414E-8B73-1DA29D1BF46A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4C7053D-A51B-414E-8B73-1DA29D1BF46A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Stack/Opc.Ua.Core/Stack/Configuration/ApplicationConfiguration.cs b/Stack/Opc.Ua.Core/Stack/Configuration/ApplicationConfiguration.cs index b14d646e29..0ab3727632 100644 --- a/Stack/Opc.Ua.Core/Stack/Configuration/ApplicationConfiguration.cs +++ b/Stack/Opc.Ua.Core/Stack/Configuration/ApplicationConfiguration.cs @@ -176,7 +176,7 @@ namespace Opc.Ua /// Creates the message context from the configuration. ///
/// A new instance of a ServiceMessageContext object. - public ServiceMessageContext CreateMessageContext() + public ServiceMessageContext CreateMessageContext(bool clonedFactory=false) { ServiceMessageContext messageContext = new ServiceMessageContext(); @@ -190,8 +190,10 @@ namespace Opc.Ua messageContext.NamespaceUris = new NamespaceTable(); messageContext.ServerUris = new StringTable(); - messageContext.Factory = EncodeableFactory.GlobalFactory; - + if (clonedFactory) + { + messageContext.Factory = new EncodeableFactory(EncodeableFactory.GlobalFactory); + } return messageContext; } diff --git a/Stack/Opc.Ua.Core/Types/BuiltIn/ExtensionObject.cs b/Stack/Opc.Ua.Core/Types/BuiltIn/ExtensionObject.cs index 9f5ebeb75f..8da8e66d26 100644 --- a/Stack/Opc.Ua.Core/Types/BuiltIn/ExtensionObject.cs +++ b/Stack/Opc.Ua.Core/Types/BuiltIn/ExtensionObject.cs @@ -12,14 +12,14 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Xml; +using System.Linq; using System.Reflection; using System.Runtime.Serialization; -using System.Linq; +using System.Text; +using System.Xml; namespace Opc.Ua -{ +{ /// /// An object used to wrap data types that the receiver may not understand. /// @@ -271,7 +271,7 @@ namespace Opc.Ua /// [DataContract(Namespace = Namespaces.OpcUaXsd)] public class ExtensionObject : IFormattable - { + { #region Constructors /// /// Initializes the object with default values. @@ -280,11 +280,11 @@ namespace Opc.Ua /// Initializes the object with default values. /// public ExtensionObject() - { - m_typeId = ExpandedNodeId.Null; - m_encoding = ExtensionObjectEncoding.None; - m_body = null; - m_context = MessageContextExtension.CurrentContext; + { + m_typeId = ExpandedNodeId.Null; + m_encoding = ExtensionObjectEncoding.None; + m_body = null; + m_context = MessageContextExtension.CurrentContext; } /// @@ -296,11 +296,14 @@ namespace Opc.Ua /// /// Thrown when the value is null public ExtensionObject(ExtensionObject value) - { - if (value == null) throw new ArgumentNullException("value"); + { + if (value == null) + { + throw new ArgumentNullException("value"); + } TypeId = value.TypeId; - Body = Utils.Clone(value.Body); + Body = Utils.Clone(value.Body); } /// @@ -310,7 +313,7 @@ namespace Opc.Ua public ExtensionObject(ExpandedNodeId typeId) { TypeId = typeId; - Body = null; + Body = null; } /// @@ -323,9 +326,9 @@ namespace Opc.Ua if (encodeable != null) { - m_typeId = null; + m_typeId = null; m_encoding = ExtensionObjectEncoding.EncodeableObject; - m_body = encodeable; + m_body = encodeable; } else { @@ -342,14 +345,14 @@ namespace Opc.Ua /// Initializes the object with an encodeable object. /// public ExtensionObject(ExpandedNodeId typeId, object body) - { + { TypeId = typeId; - Body = body; + Body = body; } [OnSerializing()] private void UpdateContext(StreamingContext context) - { + { m_context = MessageContextExtension.CurrentContext; } @@ -359,13 +362,13 @@ namespace Opc.Ua [OnDeserializing()] private void Initialize(StreamingContext context) { - m_typeId = ExpandedNodeId.Null; - m_encoding = ExtensionObjectEncoding.None; - m_body = null; - m_context = MessageContextExtension.CurrentContext; + m_typeId = ExpandedNodeId.Null; + m_encoding = ExtensionObjectEncoding.None; + m_body = null; + m_context = MessageContextExtension.CurrentContext; } #endregion - + #region Public Properties /// /// The data type node id for the extension object. @@ -373,7 +376,7 @@ namespace Opc.Ua /// The type id. public ExpandedNodeId TypeId { - get { return m_typeId; } + get { return m_typeId; } set { m_typeId = value; } } @@ -381,11 +384,11 @@ namespace Opc.Ua /// The encoding to use when the deserializing/serializing the body. /// /// The encoding for the embedd object. - public ExtensionObjectEncoding Encoding + public ExtensionObjectEncoding Encoding { - get - { - return m_encoding; + get + { + return m_encoding; } } @@ -405,17 +408,17 @@ namespace Opc.Ua /// Thrown when the body is not one of the types listed above public object Body { - get { return m_body; } - - set - { + get { return m_body; } + + set + { m_body = value; if (m_body == null) { m_encoding = ExtensionObjectEncoding.None; } - + else if (m_body is IEncodeable) { m_encoding = ExtensionObjectEncoding.EncodeableObject; @@ -440,7 +443,7 @@ namespace Opc.Ua } } #endregion - + #region Overridden Methods /// /// Determines if the specified object is equal to the . @@ -450,7 +453,7 @@ namespace Opc.Ua /// true if the specified is equal to the current embeded object; otherwise, false. /// public override bool Equals(object obj) - { + { if (Object.ReferenceEquals(obj, null)) { return IsNull(this); @@ -469,12 +472,12 @@ namespace Opc.Ua { return false; } - + return Utils.IsEqual(this.m_body, value.m_body); } - + return false; - } + } /// /// Returns a unique hashcode for the embeded object. @@ -482,20 +485,20 @@ namespace Opc.Ua /// /// A hash code for the current embeded object. /// - public override int GetHashCode() - { - if (this.m_body != null) - { - return this.m_body.GetHashCode(); - } - - if (this.m_typeId != null) - { - return this.m_typeId.GetHashCode(); - } + public override int GetHashCode() + { + if (this.m_body != null) + { + return this.m_body.GetHashCode(); + } - return 0; - } + if (this.m_typeId != null) + { + return this.m_typeId.GetHashCode(); + } + + return 0; + } /// /// Converts the value to a human readable string. @@ -527,14 +530,19 @@ namespace Opc.Ua { return String.Format(formatProvider, "Byte[{0}]", ((byte[])m_body).Length); } - + if (m_body is XmlElement) { return String.Format(formatProvider, "<{0}>", ((XmlElement)m_body).Name); } - + + if (m_body is IFormattable) + { + return String.Format(formatProvider, "{0}", ((IFormattable)m_body).ToString(null, formatProvider)); + } + if (m_body is IEncodeable) - { + { StringBuilder body = new StringBuilder(); PropertyInfo[] properties = m_body.GetType().GetProperties(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance); @@ -570,7 +578,7 @@ namespace Opc.Ua return String.Format(formatProvider, "{0}", body); } - + if (!NodeId.IsNull(this.m_typeId)) { return String.Format(formatProvider, "{{{0}}}", this.m_typeId); @@ -578,11 +586,11 @@ namespace Opc.Ua return "(null)"; } - + throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format)); } #endregion - + #region ICloneable Members /// /// Makes a deep copy of the object. @@ -610,7 +618,7 @@ namespace Opc.Ua public static bool IsNull(ExtensionObject extension) { if (extension != null && extension.m_body != null) - { + { return false; } @@ -664,31 +672,31 @@ namespace Opc.Ua output.SetValue(element, ii); } } - + return output; } #endregion - + #region Private Members [DataMember(Name = "TypeId", Order = 1, IsRequired = false, EmitDefaultValue = true)] private NodeId XmlEncodedTypeId { - get - { + get + { // must use the XML encoding id if encoding in an XML stream. IEncodeable encodeable = m_body as IEncodeable; if (encodeable != null) { - return ExpandedNodeId.ToNodeId(encodeable.XmlEncodingId, m_context.NamespaceUris); + return ExpandedNodeId.ToNodeId(encodeable.XmlEncodingId, m_context.NamespaceUris); } - return ExpandedNodeId.ToNodeId(m_typeId, m_context.NamespaceUris); + return ExpandedNodeId.ToNodeId(m_typeId, m_context.NamespaceUris); } - set - { - m_typeId = NodeId.ToExpandedNodeId(value, m_context.NamespaceUris); + set + { + m_typeId = NodeId.ToExpandedNodeId(value, m_context.NamespaceUris); } } @@ -702,10 +710,10 @@ namespace Opc.Ua { return null; } - + // create encoder. XmlEncoder encoder = new XmlEncoder(m_context); - + // write body. encoder.WriteExtensionObjectBody(m_body); @@ -728,10 +736,10 @@ namespace Opc.Ua // create decoder. XmlDecoder decoder = new XmlDecoder(value, m_context); - + // read body. Body = decoder.ReadExtensionObjectBody(m_typeId); - + // clear the type id for encodeables. IEncodeable encodeable = m_body as IEncodeable; @@ -739,7 +747,7 @@ namespace Opc.Ua { m_typeId = null; } - + // close decoder. try { @@ -755,7 +763,7 @@ namespace Opc.Ua } } #endregion - + #region Private Fields private ExpandedNodeId m_typeId; private ExtensionObjectEncoding m_encoding; @@ -799,7 +807,7 @@ namespace Opc.Ua Json = 4 } #endregion - + #region ExtensionObjectCollection Class /// /// A collection of ExtensionObjects. @@ -817,7 +825,7 @@ namespace Opc.Ua /// /// Initializes an empty collection. /// - public ExtensionObjectCollection() {} + public ExtensionObjectCollection() { } /// /// Initializes the collection from another collection. @@ -826,8 +834,8 @@ namespace Opc.Ua /// Initializes the collection from another collection. /// /// The collection containing the objects to copy into this new instance - public ExtensionObjectCollection(IEnumerable collection) : base(collection) {} - + public ExtensionObjectCollection(IEnumerable collection) : base(collection) { } + /// /// Initializes the collection with the specified capacity. /// @@ -835,9 +843,9 @@ namespace Opc.Ua /// Initializes the collection with the specified capacity. /// /// Max capacity of the collection - public ExtensionObjectCollection(int capacity) : base(capacity) {} + public ExtensionObjectCollection(int capacity) : base(capacity) { } #endregion - + #region Static Members /// /// Converts an array of ExtensionObjects to a collection. diff --git a/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs b/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs index f25f95a6f5..788869da24 100644 --- a/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs +++ b/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs @@ -882,13 +882,13 @@ namespace Opc.Ua fieldName = "Body"; } + if (m_commaRequired) + { + m_writer.Write(","); + } + if (!String.IsNullOrEmpty(fieldName)) { - if (m_commaRequired) - { - m_writer.Write(","); - } - m_writer.Write("\""); m_writer.Write(fieldName); m_writer.Write("\":"); @@ -1952,7 +1952,7 @@ namespace Opc.Ua case BuiltInType.LocalizedText: { WriteLocalizedText(null, (LocalizedText)value); return; } case BuiltInType.ExtensionObject: { WriteExtensionObject(null, (ExtensionObject)value); return; } case BuiltInType.DataValue: { WriteDataValue(null, (DataValue)value); return; } - case BuiltInType.Enumeration: { WriteInt32(null, (int)value); return; } + case BuiltInType.Enumeration: { WriteEnumerated(null, (Enum)value); return; } } } diff --git a/Stack/Opc.Ua.Core/Types/Schemas/StandardTypes.bsd b/Stack/Opc.Ua.Core/Types/Schemas/StandardTypes.bsd index be13f6d5ef..c938653135 100644 --- a/Stack/Opc.Ua.Core/Types/Schemas/StandardTypes.bsd +++ b/Stack/Opc.Ua.Core/Types/Schemas/StandardTypes.bsd @@ -68,7 +68,7 @@ A 32-bit unsigned integer. - + A 64-bit signed integer. diff --git a/Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs b/Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs index 0727110b9a..d36652c880 100644 --- a/Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs +++ b/Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs @@ -2171,6 +2171,11 @@ namespace Opc.Ua return ((StatusCode)value).Code.ToString(); } + case BuiltInType.ExtensionObject: + { + return ((ExtensionObject)value).ToString(); + } + case BuiltInType.Null: { return null; @@ -2656,15 +2661,15 @@ namespace Opc.Ua return output; } - #endregion +#endregion - #region Private Fields +#region Private Fields private BuiltInType m_builtInType; private int m_valueRank; private static readonly TypeInfo s_Unknown = new TypeInfo(); - #endregion +#endregion - #region Scalars Class +#region Scalars Class /// /// Constants for scalar types. /// @@ -2796,9 +2801,9 @@ namespace Opc.Ua /// public static readonly TypeInfo DiagnosticInfo = new TypeInfo(BuiltInType.DiagnosticInfo, ValueRanks.Scalar); } - #endregion +#endregion - #region Arrays Class +#region Arrays Class /// /// Constants for one dimensional array types. /// @@ -2930,9 +2935,9 @@ namespace Opc.Ua /// public static readonly TypeInfo DiagnosticInfo = new TypeInfo(BuiltInType.DiagnosticInfo, ValueRanks.OneDimension); } - #endregion +#endregion - #region IFormattable Members +#region IFormattable Members /// /// Formats the type information as a string. /// @@ -2968,6 +2973,6 @@ namespace Opc.Ua throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format)); } - #endregion +#endregion } } diff --git a/UA Core Library.sln b/UA Core Library.sln index 82806a6bbd..0ca0fe2906 100644 --- a/UA Core Library.sln +++ b/UA Core Library.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GlobalDiscoveryClientLibrar EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GlobalDiscoveryServerLibrary", "SampleApplications\Samples\GDS\ServerCommon\GlobalDiscoveryServerLibrary.csproj", "{B64C8C45-7323-4353-A01C-81803F368799}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "SampleApplications\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{DF09806C-8A26-49C8-8AE9-256708F35473}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {B64C8C45-7323-4353-A01C-81803F368799}.Debug|Any CPU.Build.0 = Debug|Any CPU {B64C8C45-7323-4353-A01C-81803F368799}.Release|Any CPU.ActiveCfg = Release|Any CPU {B64C8C45-7323-4353-A01C-81803F368799}.Release|Any CPU.Build.0 = Release|Any CPU + {DF09806C-8A26-49C8-8AE9-256708F35473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF09806C-8A26-49C8-8AE9-256708F35473}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF09806C-8A26-49C8-8AE9-256708F35473}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF09806C-8A26-49C8-8AE9-256708F35473}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/UA Global Discovery Server.sln b/UA Global Discovery Server.sln index 6fcefeb7a0..07b733fde0 100644 --- a/UA Global Discovery Server.sln +++ b/UA Global Discovery Server.sln @@ -47,6 +47,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution version.props = version.props EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "SampleApplications\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{1C0A9B7C-ECBB-469F-B73F-A8CC93B4A87D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -105,6 +107,10 @@ Global {E331581C-1DEB-40DA-9BD7-19DDE8449653}.Debug|Any CPU.Build.0 = Debug|Any CPU {E331581C-1DEB-40DA-9BD7-19DDE8449653}.Release|Any CPU.ActiveCfg = Release|Any CPU {E331581C-1DEB-40DA-9BD7-19DDE8449653}.Release|Any CPU.Build.0 = Release|Any CPU + {1C0A9B7C-ECBB-469F-B73F-A8CC93B4A87D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C0A9B7C-ECBB-469F-B73F-A8CC93B4A87D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C0A9B7C-ECBB-469F-B73F-A8CC93B4A87D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C0A9B7C-ECBB-469F-B73F-A8CC93B4A87D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/UA Quickstart Applications.sln b/UA Quickstart Applications.sln index ab0f6c9fe9..143072d682 100644 --- a/UA Quickstart Applications.sln +++ b/UA Quickstart Applications.sln @@ -113,6 +113,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UA Server Controls", "Sampl {17B6F98C-B58C-419F-AE58-63B9883F211A} = {17B6F98C-B58C-419F-AE58-63B9883F211A} EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "SampleApplications\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{A3C69716-DF28-4626-8C18-FB70F36C81E1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -259,6 +261,10 @@ Global {80056988-44E7-4EF4-9F59-50BCF215CB03}.Debug|Any CPU.Build.0 = Debug|Any CPU {80056988-44E7-4EF4-9F59-50BCF215CB03}.Release|Any CPU.ActiveCfg = Release|Any CPU {80056988-44E7-4EF4-9F59-50BCF215CB03}.Release|Any CPU.Build.0 = Release|Any CPU + {A3C69716-DF28-4626-8C18-FB70F36C81E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3C69716-DF28-4626-8C18-FB70F36C81E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3C69716-DF28-4626-8C18-FB70F36C81E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3C69716-DF28-4626-8C18-FB70F36C81E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -299,6 +305,7 @@ Global {4A1B6008-293A-4C85-8D33-4194A446AAF5} = {5465661E-783E-4350-98D8-DDE8AB935E21} {A247D2EE-14FC-463D-A9BA-6CFF1EF22B7A} = {5465661E-783E-4350-98D8-DDE8AB935E21} {80056988-44E7-4EF4-9F59-50BCF215CB03} = {5465661E-783E-4350-98D8-DDE8AB935E21} + {A3C69716-DF28-4626-8C18-FB70F36C81E1} = {5465661E-783E-4350-98D8-DDE8AB935E21} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2FB5EF9F-9A65-428F-8817-13DF5E39423B} diff --git a/UA-NetStandard.sln b/UA-NetStandard.sln index b891b42e0a..2b50c3fe40 100644 --- a/UA-NetStandard.sln +++ b/UA-NetStandard.sln @@ -37,6 +37,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .travis.yml = .travis.yml appveyor.yml = appveyor.yml NuGet.Config = NuGet.Config + nuget\Opc.Ua.Client.ComplexTypes.nuspec = nuget\Opc.Ua.Client.ComplexTypes.nuspec + nuget\Opc.Ua.Client.ComplexTypes.Symbols.nuspec = nuget\Opc.Ua.Client.ComplexTypes.Symbols.nuspec nuget\Opc.Ua.nuspec = nuget\Opc.Ua.nuspec nuget\Opc.Ua.Symbols.nuspec = nuget\Opc.Ua.Symbols.nuspec README.md = README.md @@ -54,6 +56,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreConsoleClient", "Sam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreConsoleServer", "SampleApplications\Samples\NetCoreConsoleServer\NetCoreConsoleServer.csproj", "{F7880521-6662-43A0-B28E-219AA8D28A49}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Client.ComplexTypes", "SampleApplications\SDK\Opc.Ua.Client.ComplexTypes\Opc.Ua.Client.ComplexTypes.csproj", "{FE9EEB39-0698-4A19-B770-E66836CE0002}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreComplexClient", "SampleApplications\Samples\NetCoreComplexClient\NetCoreComplexClient.csproj", "{5D4F1065-F75E-478A-9FEA-3A3276500FF8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -209,6 +215,30 @@ Global {F7880521-6662-43A0-B28E-219AA8D28A49}.Release|x64.Build.0 = Release|Any CPU {F7880521-6662-43A0-B28E-219AA8D28A49}.Release|x86.ActiveCfg = Release|Any CPU {F7880521-6662-43A0-B28E-219AA8D28A49}.Release|x86.Build.0 = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|x64.ActiveCfg = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|x64.Build.0 = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|x86.ActiveCfg = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Debug|x86.Build.0 = Debug|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|Any CPU.Build.0 = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|x64.ActiveCfg = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|x64.Build.0 = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|x86.ActiveCfg = Release|Any CPU + {FE9EEB39-0698-4A19-B770-E66836CE0002}.Release|x86.Build.0 = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|x64.Build.0 = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Debug|x86.Build.0 = Debug|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|Any CPU.Build.0 = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|x64.ActiveCfg = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|x64.Build.0 = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|x86.ActiveCfg = Release|Any CPU + {5D4F1065-F75E-478A-9FEA-3A3276500FF8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/appveyor.yml b/appveyor.yml index 3af1c37b17..e4debe0e85 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,7 @@ #---------------------------------# # version format -version: 1.3.351.{build}-{branch} +version: 1.3.358.{build}-{branch} # branches to build diff --git a/nuget/Opc.Ua.Client.ComplexTypes.Symbols.nuspec b/nuget/Opc.Ua.Client.ComplexTypes.Symbols.nuspec new file mode 100644 index 0000000000..4441d3d3f6 --- /dev/null +++ b/nuget/Opc.Ua.Client.ComplexTypes.Symbols.nuspec @@ -0,0 +1,30 @@ + + + + OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes.Symbols + 1.04.358.0 + OPC UA .Net Standard Complex Type Library Symbols + This package contains the OPC UA complex type client symbols and is targeting the .NET Standard Library. + OPC Foundation + en-US + https://github.com/OPCFoundation/UA-.NETStandard + https://opcfoundation.org/wp-content/themes/opc/images/logo.jpg + https://opcfoundation.org/license/redistributables/1.3/ + OPCFoundation OPC-UA netstandard ios linux dotnet net netcore uwp + + + + + + + + + + + + + + + + + diff --git a/nuget/Opc.Ua.Client.ComplexTypes.nuspec b/nuget/Opc.Ua.Client.ComplexTypes.nuspec new file mode 100644 index 0000000000..a2953680b9 --- /dev/null +++ b/nuget/Opc.Ua.Client.ComplexTypes.nuspec @@ -0,0 +1,28 @@ + + + + OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes + 1.04.358.0 + OPC UA .Net Standard Complex Type Library + This package contains the OPC UA complex type client and is targeting the .NET Standard Library. + OPC Foundation + en-US + https://github.com/OPCFoundation/UA-.NETStandard + https://opcfoundation.org/wp-content/themes/opc/images/logo.jpg + https://opcfoundation.org/license/redistributables/1.3/ + OPCFoundation OPC-UA netstandard ios linux dotnet net netcore uwp + + + + + + + + + + + + + + + diff --git a/nuget/Opc.Ua.Symbols.nuspec b/nuget/Opc.Ua.Symbols.nuspec index ee8e57cc0d..410bafc210 100644 --- a/nuget/Opc.Ua.Symbols.nuspec +++ b/nuget/Opc.Ua.Symbols.nuspec @@ -2,7 +2,7 @@ OPCFoundation.NetStandard.Opc.Ua.Symbols - 1.04.354-preview180731 + 1.04.358.0 OPC UA .Net Standard Library Symbols This package contains the OPC UA reference implementation symbols and is targeting the .NET Standard Library. OPC Foundation diff --git a/nuget/Opc.Ua.nuspec b/nuget/Opc.Ua.nuspec index 2713bb2f2a..9aac333f95 100644 --- a/nuget/Opc.Ua.nuspec +++ b/nuget/Opc.Ua.nuspec @@ -2,7 +2,7 @@ OPCFoundation.NetStandard.Opc.Ua - 1.04.354-preview180731 + 1.04.358.0 OPC UA .Net Standard Library This package contains the OPC UA reference implementation and is targeting the .NET Standard Library. OPC Foundation diff --git a/testclientserver.sh b/testclientserver.sh index 1ebbc74f69..3c543044b7 100755 --- a/testclientserver.sh +++ b/testclientserver.sh @@ -1,5 +1,5 @@ #!/bin/bash -echo Test the .Net Core console server and console client +echo Test the .Net Core server and complex client workdir=$(pwd) testresult=0 testresulthttps=0 @@ -14,6 +14,11 @@ echo build client rm -r obj dotnet build NetCoreConsoleClient.csproj cd "$workdir" +cd ../NetCoreComplexClient +echo build client +rm -r obj +dotnet build NetCoreComplexClient.csproj +cd "$workdir" cd SampleApplications/Samples/NetCoreConsoleServer echo start server @@ -25,10 +30,13 @@ grep -m 1 "start" <(tail -f ./server.log --pid=$serverpid) tail -f ./server.log --pid=$serverpid & cd "$workdir" -cd SampleApplications/Samples/NetCoreConsoleClient +cd SampleApplications/Samples/NetCoreComplexClient echo start client for tcp connection -dotnet run --no-restore --no-build --project NetCoreConsoleClient.csproj -t 20 -a & +dotnet run --no-restore --no-build --project NetCoreComplexClient.csproj -t 10 -a -v -j & clientpid="$!" +cd "$workdir" + +cd SampleApplications/Samples/NetCoreConsoleClient echo start client for https connection dotnet run --no-restore --no-build --project NetCoreConsoleClient.csproj -t 20 -a https://localhost:51212 & httpsclientpid="$!"