Single Popup for multiple screens.

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
UncleJoe89
Posts: 1
Joined: Sat Sep 20, 2014 4:58 am

Single Popup for multiple screens.

Post by UncleJoe89 »

Hi,

I am trying to create one popup screen and use it to pass values to different external tags.
Instead of creating several different popup windows, Can I create just one, and use it for all the external tags.

Cheers

John

donatzx
Posts: 2
Joined: Mon Mar 18, 2019 9:26 am

Re: Single Popup for multiple screens.

Post by donatzx »

This is a very dated post, but I was also trying to do this recently and eventually got it to work.

I've created a single popup called "Select_Station" that contains 4 buttons which is called in 3 different locations from my HMI screen. As an on-click action, a variable "Popup_StationType" is set to a value of 1, 2, or 3 to determine where in the HMI the popup was called from.

The comparison method could become quite bulky depending on the number of times the popup needs to be reused, but it works.

Code: Select all

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;
    
    
    public partial class Select_Station
    {
		//the value of Popup_StationType is set on button click to call popup
		//stationNum indicates which button was pressed inside of the popup
		//the appropriate tag is set to stationNum after a comparison of Popup_StationType
		void SetStation(int stationNum)
		{
			if (Globals.Tags.Popup_StationType.Value == 1) 
			{
				Globals.Tags.FeedConfig_InfeedStationNum.Value = stationNum;
			}
			else if (Globals.Tags.Popup_StationType.Value == 2)
			{
				Globals.Tags.FeedConfig_OutfeedStationNum.Value = stationNum;
			}
			else if (Globals.Tags.Popup_StationType.Value == 3)
			{
				Globals.Tags.OpConfig_StationNum.Value = stationNum;
			}
		}
		//the value is passed into stationNum
		void Button_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(1);
		}
		
		void Button1_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(2);
		}
		
		void Button2_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(3);
		}
		
		void Button3_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(4);
		}
    }
}

donatzx
Posts: 2
Joined: Mon Mar 18, 2019 9:26 am

Re: Single Popup for multiple screens.

Post by donatzx »

This can be done by setting up a function in your popup window's script.
Here's an example:

Code: Select all

    public partial class Select_Station
    {
		//the value of Popup_StationType is set on button click to call popup
		//stationNum indicates which button was pressed inside of the popup (4 choices)
		//the appropriate tag is set to stationNum after a comparison of Popup_StationType
		void SetStation(int stationNum)
		{
			if (Globals.Tags.Popup_StationType.Value == 1) 
			{
				Globals.Tags.FeedConfig_InfeedStationNum.Value = stationNum;
			}
			else if (Globals.Tags.Popup_StationType.Value == 2)
			{
				Globals.Tags.FeedConfig_OutfeedStationNum.Value = stationNum;
			}
			else if (Globals.Tags.Popup_StationType.Value == 3)
			{
				Globals.Tags.OpConfig_StationNum.Value = stationNum;
			}
		}
		//the value is passed into stationNum
		void Button_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(1);
		}
		
		void Button1_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(2);
		}
		
		void Button2_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(3);
		}
		
		void Button3_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
		{
			SetStation(4);
		}
    }

Post Reply