Hello
I am fairly new to the iX Developer and have a question.
I have a screen used in 2 instances (ans aliases) and would like to change the color attributes of some of the Text entries or other visualization elements based on instance.
I know I could create "Dummy variables" for each instance use them like constants and than using the number in the Variable as value for color change in the #Alias on the screen.
Is there a more "elegant" and a rather more straight way to do so using script functions.
Thanks in Advance
J
Changing Text color based on instance id number
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Changing Text color based on instance id number
You would have to somehow execute code that checks to see what instance you are on. You can execute via a button push or when a screen is opened. Then I would set a tag based on the instance.
The tag could then be used in the Dynamics of a on screen control to change the color.
The tag could then be used in the Dynamics of a on screen control to change the color.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Changing Text color based on instance id number
Well,
What code checks for the active instance?
Sorry for the stupid question. But I am really new to the iX developer.
What code checks for the active instance?
Sorry for the stupid question. But I am really new to the iX developer.
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Changing Text color based on instance id number
This code gets the active instance: this.InstanceName;
Unfortunately I cannot provide you with C# programming consulting services. I can only help with iX Developer related C# questions. Writing if statements and the such are out of this forums scope.
If you have never programmed in C# I suggest you take a course on it.
Unfortunately I cannot provide you with C# programming consulting services. I can only help with iX Developer related C# questions. Writing if statements and the such are out of this forums scope.
If you have never programmed in C# I suggest you take a course on it.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Changing Text color based on instance id number
Thank, you . This was what I needed to know.
Re: Changing Text color based on instance id number
Hi!
Here is a little example with changing things based on instance with scripts.
The Motor_Faceplate has three instance (Motor_1, Motor_2, Motor_3).
In the example we change the Name, Font Color of the Name, The Fill Color of the Name, The Motor base color and Hide the Analog Setpoint for the Motor 2.
The first image from left is the base faceplate, second Motor 1 and so on...
Sorry for the ugly color combinations
Best Regards
Here is a little example with changing things based on instance with scripts.
The Motor_Faceplate has three instance (Motor_1, Motor_2, Motor_3).
In the example we change the Name, Font Color of the Name, The Fill Color of the Name, The Motor base color and Hide the Analog Setpoint for the Motor 2.
The first image from left is the base faceplate, second Motor 1 and so on...
Code: Select all
public partial class Motor_Faceplate
{
void Motor_Faceplate_Opened(System.Object sender, System.EventArgs e)
{
// Set Instance Name to Header (remove underscore)
txtMotorName.Text = this.InstanceName.Replace('_', ' ');
// Check instance
switch(this.InstanceName)
{
case "Motor_1":
txtMotorName.FontColor = new BrushCF(Color.Blue);
txtMotorName.Fill = new BrushCF(Color.DarkGray);
recMotorBase.Fill = new BrushCF(Color.Blue);
break;
case "Motor_2":
txtMotorName.FontColor = new BrushCF(Color.Green);
txtMotorName.Fill = new BrushCF(Color.Red);
recMotorBase.Fill = new BrushCF(Color.Green);
txtSetpoint.Visible = false;
break;
case "Motor_3":
txtMotorName.FontColor = new BrushCF(Color.Aqua);
txtMotorName.Fill = new BrushCF(Color.White);
recMotorBase.Fill = new BrushCF(Color.Aqua);
break;
}
}
}
Best Regards
Re: Changing Text color based on instance id number
Edmund,
Thanks a lot
J
Thanks a lot
J