Hello,I need to open a screen from string like this "Neo.ApplicationFramework.Generated.Screen1", where "Screen1" is the name of the screen, how to do that ?The screen to open can change dynamically, so I cannot used the code Globals.Screen1.Show();

I need a function like this :

void ShowByScreenName(string strScreenName);

Sorry for my English,

Thanks for you help,

Arnaud

Ron L.

Post subject: Re: How to open screen with the name of screen ?

Posted: Mon Sep 19, 2011 1:41 pm

Joined: Fri Jul 15, 2011 3:21 pmPosts: 214

Arnaud,

Here is the approach I would take to dynamically change screens at run-time.

I would create a Tag and use it to select different screens. The tag can be mapped to to an address on a PLC if that makes more sense for your system. For this example, I'll call the tag, "ScreenTag".

Click on the [...] button under the "Action" column.

Attachment:

tag_action.jpg [ 82.58 KiB | Viewed 12899 times ]

Here you can configure the properties of the "ScreenTag" to change screens depending on the value of the tag. For the attached screen shot, if I wanted to change to "Screen1", I would set the "ScreenTag" to be a value of 1.

Attachment:

screen_dynamic_tag_props.jpg [ 69.67 KiB | Viewed 12899 times ]

If you now wanted to change to "Screen1" using script, the code would look like this.

Code:

Globals.Tags.ScreenTag.Value = 1;

_________________Best Regards,

Beijer Electronics, Inc.Ron Lloyd | Applications Engineer

Arnaud J.

Post subject: Re: How to open screen with the name of screen ?

Posted: Tue Sep 20, 2011 12:01 am

Joined: Mon Sep 19, 2011 4:51 amPosts: 6

Hi Ron,

I would like something more generic, because tomorrow if I add a new screen I should not forget to change the screen tag, so your solution is not very good for the "maintenance" of the project. I should modify something like 60 screens to implement your solution...So if you have a function to open a screen with the screen name it's better for our project.

Thanks,

Ron L.

Post subject: Re: How to open screen with the name of screen ?

Posted: Tue Sep 20, 2011 4:57 am

Joined: Fri Jul 15, 2011 3:21 pmPosts: 214

There should be a way to do what you're asking for with the C# Reflection classes. I'll look into this in the next couple days and see if I can come up with some sample code. I've done something similar before where I converted strings to Tags.

_________________Best Regards,

Beijer Electronics, Inc.Ron Lloyd | Applications Engineer

Ron L.

Post subject: Re: How to open screen with the name of screen ?

Posted: Wed Sep 21, 2011 4:27 pm

Joined: Fri Jul 15, 2011 3:21 pmPosts: 214

Here is some code I placed inside a Scrip Module that will do what you're looking for.

Code:

//--------------------------------------------------------------// Press F1 to get help about using script.// To access an object that is not located in the current class, start the call with Globals.// When using events and timers be cautious not to generate memoryleaks,// please see the help for more information.//---------------------------------------------------------------

namespace Neo.ApplicationFramework.Generated{ using System.Windows.Forms; using System; using System.Drawing; using Neo.ApplicationFramework.Tools; using Neo.ApplicationFramework.Common.Graphics.Logic; using Neo.ApplicationFramework.Controls; using Neo.ApplicationFramework.Interfaces;

Hi Ron! I'm trying to use Your script convert String to Tag, but IX throws error like "The type or namespace name GlobalDataItem could not be found.....".

P.S. added using Neo.ApplicationFramework.Generated; using System.Reflection;the same error.

What kind of library should I add?

val_pilats

Post subject: Re: How to open screen with the name of screen ?

Posted: Fri Feb 10, 2012 6:58 am

Joined: Tue Jan 17, 2012 2:47 amPosts: 9

val_pilats wrote:

Hi Ron! I'm trying to use Your script convert String to Tag, but IX throws error like "The type or namespace name GlobalDataItem could not be found.....".

P.S. added using Neo.ApplicationFramework.Generated; using System.Reflection;the same error.

What kind of library should I add?

Figured out.

using Neo.ApplicationFramework.Tools.OpcClient;

Ron L.

Post subject: Re: How to open screen with the name of screen ?

Posted: Mon Jan 21, 2013 3:41 pm

Joined: Fri Jul 15, 2011 3:21 pmPosts: 214

Came up with some code related to this topic to display a Screen or an Alias of a screen using strings.

Code:

namespace Neo.ApplicationFramework.Generated{ using System.Windows.Forms; using System; using System.Drawing; using Neo.ApplicationFramework.Tools; using Neo.ApplicationFramework.Common.Graphics.Logic; using Neo.ApplicationFramework.Controls; using Neo.ApplicationFramework.Interfaces;

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum