+ All Categories
Home > Documents > Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen...

Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen...

Date post: 30-Dec-2019
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
19
1 Kollmorgen | September 2013 Kollmorgen Visualization Builder Developer Controls Guide Edition A, September 2013 Keep all manuals as a product component during the life span of the product. Pass all manuals to future users / owners of the product.
Transcript
Page 1: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

1 Kollmorgen | September 2013

Kollmorgen Visualization Builder™

Developer Controls Guide

Edition A, September 2013

Keep all manuals as a product component during the life span of the product. Pass all manuals to future users / owners of the product.

Page 2: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 2

Record of Document Revisions

Foreword

Kollmorgen Visualization Builder allows using and creating third party controls in order to enhance application functionality and additional customization. This document describes different technologies and includes configuration examples. To understand and use all the information in this document, .Net development skills are required.

Important Notice

Technical changes which improve the performance of the device may be made without prior notice!

Printed in the United States of America. This document is the intellectual property of Kollmorgen™. All rights reserved. No part of this work may be reproduced in any form (by photocopying, microfilm or any other method) or stored, processed, copied or distributed by electronic means without the written permission of Kollmorgen™.

Revision Remarks

9/10/2013 Preliminary edition

Page 3: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

3 Kollmorgen | September 2013

CONTENTS

1 TARGET PLATFORM .......................................................................................... 4

1.1 PC Target ................................................................................................ 4

1.2 Windows CE Target ................................................................................ 4

1.3 Limitations ............................................................................................... 4

2 ADDING CONTROLS TO THE KVB TOOLBOX ................................................ 5

2.1 Adding Controls to the Toolbox ............................................................... 5

2.2 Default Controls and Installed Controls .................................................. 7

3 WPF CONTROLS ................................................................................................ 8

3.1 WPF User Controls ................................................................................. 8

3.2 WPF Custom Controls ............................................................................ 8

3.3 Creating a WPF User Control with Tag Connection .............................. 9

3.4 Creating a WPF Custom Control with Tag Connection ....................... 11

4 WINDOWS FORMS CONTROLS ...................................................................... 13

4.1 Creating a Windows Forms User Control for a PC Target .................... 13

4.2 Creating a Windows Forms User Control for a CE Target .................... 16

5 TROUBLESHOOTING ....................................................................................... 18

Page 4: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

4 Kollmorgen | September 2013

1 TARGET PLATFORM

Different technologies are used for third party controls depending on the target platform for the Kollmorgen Visualization Builder (KVB) application. The target can be either PC or Windows CE.

Windows CE has no support for vector graphic (WPF) and only uses .Net Compact Framework which is a subset or the .Net Framework used on a PC. Windows CE does not natively support GDI+, so GDI+ related functionality was removed from .Net Compact Framework.

1.1 PC Target

Two different technologies can be used for a PC target:

Standard Windows forms and GDI+

WPF (Windows Presentation Foundation)

WPF uses vector graphics, and the appearance of the control is described in XAML. Since KVB is a WPF application, it is recommended to use WPF when developing customized controls or user controls for a PC target. Controls developed in WPF can bind to a tag value in KVB, in opposite to Windows forms controls, that cannot be bound to tag values.

1.2 Windows CE Target

Windows CE only uses the .Net Compact Framework (a subsector the .Net Framework used on a PC), and does not support vector graphics (WPF). Windows CE does not natively support GDI+, so GDI+ related functionality was removed from the .Net Compact Framework.

1.3 Limitations

Some of the limitations regarding third party controls are listed below:

Control Designers (a designer class that can extend design time support) are currently not supported.

TypeConverters in a separate design dll are not supported.

Complex property editing in the property grid is not supported. All complex properties have to be set up in script.

.Net Compact Framework controls can include design dll and so called AssmetaData dll to handle attributes that are not supported in Windows CE. Currently this is not supported by KVB. Because of this, it is important to always test the code on the target platform.

The Script Editor allows scripting against properties and methods that are not supported in Windows CE. Because of this, it is important to always test the code on the target platform.

Page 5: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

5 Kollmorgen | September 2013

2 ADDING CONTROLS TO THE KVB TOOLBOX

Third party controls can be added to the Objects toolbox in KVB. Follow the steps below:

2.1 Adding Controls to the Toolbox

1. Select the Objects group on the Home ribbon tab and fully expand the Objects toolbox by clicking the lower right arrow

2. Click Add Control.

Page 6: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 6

3. Select controls to add among the default controls, or click Browse to add customized controls.

4. Click Ok.

The added controls are now available under Additional Controls in the Objects toolbox.

Page 7: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

7 Kollmorgen | September 2013

2.2 Default Controls and Installed Controls

Default controls include controls added by the user and the .Net 4 controls installed with the .Net Framework. Installed controls include all controls that are installed in the GAC (Global Assembly Cache) on your computer.

Note: Third party controls that are used in a project are not copied to the project folder. This means that it is not possible to open a project with third party controls on another PC without installing the controls. But the application will work in runtime on another target, since references are copied to the output folder when building the project.

Page 8: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

8 Kollmorgen | September 2013

3 WPF CONTROLS

WPF (Windows Presentation Foundation) uses vector graphics, and the appearance of the control is described in XAML. Since KVB is a WPF application, it is recommended to use WPF when developing customized controls or user controls for a PC target. Controls developed in WPF can bind to a tag value in KVB.

User controls and custom controls are supported in WPF.

3.1 WPF User Controls

A WPF user control can be described as a composition of different user interface controls. Creating a WPF user control is similar to creating a window:

You have a XAML file and C# class file for a user control.

The class file extends the user control class, adding additional behavior and properties.

The XAML file encapsulates the composing controls; styles, templates, animations and whatever necessary for “Look & Feel”.

Since the WPF user control is a just composition, it is really easy to create. It does not require a lot of WPF UI model knowledge.

3.2 WPF Custom Controls

WPF custom controls are more flexible, but are more complicated than a user control, and require a profound understanding of the WPF user interface model.

A number of certain user interface controls, such as button, progress bar or speedometer has to be extended.

The appearance of the custom control has to be defined in XAML, as the custom control itself has no look.

Most of the controls in KVB are custom controls, which makes it possible to restyle them to various different layouts without changing the code files; just the XAML.

A rounded meter in different styles

Page 9: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

9 Kollmorgen | September 2013

3.3 Creating a WPF User Control with Tag Connection

The following example describes how to create a WPF user control that can be connected to a tag.

1. Start Visual Studio to create a new project, and select WPF User Control Library.

2. Add [DefaultProperty("Value")] to the class, to define which property the tag should set when then value is set.

3. Add a dependency property with same name as the attribute above: static read only DependencyProperty ValueProperty;

4. Add a static constructor and register the dependency property.

5. Create a Value property of type object.

6. Add a TextBox to the user control.

7. Add a binding to the TextProperty and bind to the ValueProperty

8. Remember to change ElementName to the name of your control

9. Compile and test by adding the control to the KVB toolbox.

Note: When an update is made, the existing control must be updated under C:\Users\Public\Documents\Kollmorgen Corporation\Kollmorgen Visualization Builder™ 2\Thirdparty

Page 10: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 10

Example Code

Page 11: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

11 Kollmorgen | September 2013

3.4 Creating a WPF Custom Control with Tag Connection

The following example describes how to create a WPF custom control that can be connected to a tag.

The complete code is included at the end of the example.

1. Start Visual Studio to create a new project, and select WPF Custom Control Library.

2. Add [DefaultProperty("Value")] to the class, to define which property the tag should set when then value is set.

3. Add a dependency property with same name as the attribute above: static readonly DependencyProperty ValueProperty;

4. Add a static constructor and register the dependency property.

5. Create a Value property of type string.

6. Replace the code inside the ControlTemplate tag with the following code in the generic.xaml file located in the Themes folder.

Page 12: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 12

Note the binding on the TextBox text property. The text is bound to the value property that is of type string. If value property is of a different type, a Value converter may be needed.

7. Compile and test by adding the control to the KVB toolbox.

8. Note: When an update is made, the existing control must be updated under C:\Users\Public\Documents\Kollmorgen Corporation\Kollmorgen Visualization Builder™ 2\Thirdparty

Example Code

Page 13: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

13 Kollmorgen | September 2013

4 WINDOWS FORMS CONTROLS

4.1 Creating a Windows Forms User Control for a PC Target

The following example describes how to create a Windows Forms user control designated for a PC target.

1. Start Visual Studio to create a new project, and select Windows Forms Control Library.

2. Add a TextBox and a Button to the design surface.

3. Add Event Handler for Button click.

4. Add Event Handler for TextBox lost focus.

5. Add a Value Property and INotifyPropertyChanged implementation:

Page 14: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 14

6. Use the following code to connect the control to a tag value in KVB:

Page 15: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

15 Kollmorgen | September 2013

The code shows how the value is set on the user control when the tag changes its value, and how the tag value is changed when the user control changes its value.

Page 16: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

Kollmorgen | September 2013 16

4.2 Creating a Windows Forms User Control for a CE Target

The following example describes how-to create a Windows Forms user control designated for a CE target (an operator panel).

1. Start Visual Studio 2005 or 2008 to create a new Smart Device Project.

2. Select Windows CE for Target platform.

3. Select Control Library.

Page 17: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

17 Kollmorgen | September 2013

4. Use the same code as in the Creating a Windows Forms User Control for a PC Target example.

Note: Always test your code on the target platform, as properties/methods currently not supported may be included in the code. See Limitations for details.

Page 18: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

18 Kollmorgen | September 2013

5 TROUBLESHOOTING

Sometimes when using third party controls a build error indicating that a reference is missing may occur when building the project. Try to add that dll to Project\ReferenceAssemblies to solve the problem.

Page 19: Kollmorgen Visualization Builder · 2017-10-14 · 1 Kollmorgen | September 2013 Kollmorgen Visualization Builder™ Developer Controls Guide Edition A, September 2013 Keep all manuals

About Kollmorgen

Kollmorgen is a leading provider of motion systems and components for machine builders. Through world-class knowledge in motion, industry-leading quality and deep expertise in linking and integrating standard and custom products, Kollmorgen delivers breakthrough solutions that are unmatched in performance, reliability and ease-of-use, giving machine builders an irrefutable marketplace advantage.

For assistance with your application needs, visit www.kollmorgen.com or contact us at:

North America

Kollmorgen

203A West Rock Road Radford, VA 24141 USA

Web: www.kollmorgen.com Mail: [email protected] Phone: 1-540-633-3545 Fax: 1-540-639-4162

Europe

Kollmorgen

Pempelfurtstraße 1 40880 Ratingen, Germany

Web: www.kollmorgen.com Mail: [email protected] Phone: + 49-2102-9394-0 Fax: + 49 -2102-9394-3155

Asia

Kollmorgen

Rm 2205, Scitech Tower, China 22 Jianguomen Wai Street

Web: www.kollmorgen.com Mail: [email protected] Phone: + 86-400-666-1802 Fax: +86-10-6515-0263


Recommended