EpiShape

Is there a bug with EpiShape painting? Just changing the colors doesn’t work as intended.

I’ve tried fore, back and border colors.
I’ve tried turning off AppStyling
I’ve tried calling the Refresh() method

Do I need to override the OnPaint and do it myself? Surely not.

For EpiShapes you set the status property to one of the following

StatusTypes.Warning (yellow)
StatusTypes.Global (blue)
StatusTypes.OK (green)
StatusTypes.Stop (red)

4 Likes

I would expect that would be a published property

It is, just doesn’t show in the Properties Grid just do
mtlShape.Status = (one of the statuses above)

3 Likes

Thanks sir!

Jose, I’m wondering about a variation of the epiShape settings that I’ve come across :

epiShapeWarrantyBar.Status = ( Ice.Lib.Framework.StatusTypes )4;
epiShapeWarrantyBar.BackColor = System.Drawing.Color.Magenta;
epiShapeWarrantyBar.Refresh( );

This code, specifically the “4” in the Status line, produces a graduated “highlight” effect around the horizontal center of the shape, as shown in the middle shape :

StatusTypeHighLighted

Specifying the BackColor works with several colors that I’ve tested from the “Web” list of colors in the BackColor property drop-down list ( Blue, Green, Yellow, Red, Black, Magenta, OrangeRed, LightCoral ). Some don’t work, DarkGoldenRod is one that doesn’t. The compile fails if a BackColor is used that won’t display.

Also, if the Status is less than 4, the color is one of the following regardless of the BackColor setting :
0 = Green, 1 = Yellow, 2 = Red, 3 = Blue - all solid.
Haven’t yet found a way to get a solid color other than these four. Setting the status to 4 or above allows the other colors to be used, but also adds the “highlight”.

The code is from a Customization that was originally done in E9. The highlight effect I found just experimenting with the values. I’ve gone as high as 2048, but the highlight effect didn’t vary with the higher values.

My question is, are these intentional property settings, or perhaps the “old way” of doing it ?

If it’s intentional, it would be useful to call attention to a shape, as in the middle shape above. However, if it’s an unintentional aspect of the code, I wouldn’t want to put it in place only to have that highlight disappear at some time in the future.

Thanks, Ken

3 Likes

(Ice.Lib.Framework.StatusTypes) 4 is simply selecting the 4th item in the StatusTypes collection

2 Likes

Thanks for sharing another option to play with.

1 Like

Could someone provide a screenshot or some help about where you insert this code

I have created a new RowRule but where do I start inserting the code? Thanks

In the Script Editor, in this example, I used the Event Wizard to created an event when a Check box is checked and the status of the EpiShape change to Stop.

Hmm that I done wrong here? Code compiles but doesn’t seem to have an effect. I have declared my variables and set the GUIDs. I created a new EpiShape to mimic the Inactive Shape in case there was some kind of conflict there. Any ideas? I want it to return a red EpiShape on loading based on the setting of the Inactive field. I have managed to get it to change with clicking but I want it to execute when loading if possible.

I would move the code in your C_InactiveShape_Load(…) to

public void InitializeCustomCode()

I dont think you need to use Shape Load event.

1 Like

I cant really tell what type of event you’ve used there in the pic, perhaps pasting the code will help.

My first thought is, whatever event you are using, the value has not been read/set yet on the screen. Why not just put the event direct on the control’s change. If that’s what you’ve already done, then perhaps there is no change because the default state is the inactive state - in that case, just change your shape to default to the inactive state

I moved the code to public void InitializeCustomCode() as per Toby’s suggestion. I don’t need it to be triggered by a particular event, just whenever the inactive flag is checked. Thanks for your help.

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.Lib;
using Erp.BO;
using Ice.BO;
using Ice.Proxy.BO;
using Erp.Proxy.BO;
using Erp.UI;
using Ice.Adapters;
using Erp.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.UI.FormFunctions;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **

// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **
public EpiShape sInactive;
public EpiCheckBox cbInactive;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	sInactive = (EpiShape)csm.GetNativeControlReference("eda79e02-f3d1-4fc8-971e-5b1a46773931");
	cbInactive = (EpiCheckBox)csm.GetNativeControlReference("2291a737-ffa4-4a88-b179-9220d69150a1");

	if(cbInactive.Checked == true)
				{
					//sInactive.Enabled = true;
					sInactive.Status = StatusTypes.Stop;
				}
				else
				{
					sInactive.Status = StatusTypes.OK;
				}
		

		
	// End Wizard Added Custom Method Calls
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal


//	sInactive.Enabled = true;
	//sInactive.Status = StatusTypes.Stop;

	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
	}

}

The problem here is that the check is done once, and only once.

Replace your code with this in intiialize

var chk = (EpiCheckBox)csm.GetNativeControlReference("the guid to your chkbox");
chk.CheckedChanged += (o,e) =>
{
				if((o as EpiCheckBox).Checked == true)
				{
					//sInactive.Enabled = true;
					sInactive.Status = StatusTypes.Stop;
				}
				else
				{
					sInactive.Status = StatusTypes.OK;
				}
};
4 Likes

Awesome, thanks Chris. This worked

In case anyone is interested. You can make the whole shape a color of your choosing using this:

epiShapeIsGold.Enabled = true;
epiShapeIsGold.Status = (Ice.Lib.Framework.StatusTypes) 4;
epiShapeIsGold.BackColor = System.Drawing.Color.Gold;
epiShapeIsGold.Appearance.BackColor2 = System.Drawing.Color.Gold;

image

8 Likes

I’m trying to use this code to set the color of the ‘Inactive’ epishape to red instead of green when the checkbox Inactive is checked.

This is in part tracker

I copied the code above, but I’m failing… Here’s what I have

// **************************************************
// Custom code for PartTrackerForm
// Created: 10/9/2019 1:56:00 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
public EpiShape sInactive;
public EpiCheckBox cbInactive;
	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls
var chk = (EpiCheckBox)csm.GetNativeControlReference("2291a737-ffa4-4a88-b179-9220d69150a1");
chk.CheckedChanged += (o,e) =>
{
				if((o as EpiCheckBox).Checked == true)
				{
					//sInactive.Enabled = true;
					sInactive.Status = StatusTypes.Stop;
				}
				else
				{
					sInactive.Status = StatusTypes.OK;
				}
};
		// End Wizard Added Custom Method Calls
	}

And here’s the error I get when I attempt to bring a part into Part Tracker

Application Error

Exception caught in: App.PartTracker.PartTrackerForm.EP.LCPC.Customization.InactiveRED.CustomCode.1

Error Detail

Message: Object reference not set to an instance of an object.
Program: App.PartTracker.PartTrackerForm.EP.LCPC.Customization.InactiveRED.CustomCode.1.dll
Method: b__0

Client Stack Trace

at Script.b__0(Object o, EventArgs e)
at Infragistics.Win.UltraWinEditors.UltraCheckEditor.OnCheckedChanged()
at Infragistics.Win.UltraWinEditors.UltraCheckEditor.AfterCheckChangedHelper(CheckState newVal, EventArgs e)
at Infragistics.Win.UltraWinEditors.UltraCheckEditor.set_CheckState(CheckState value)
at Infragistics.Win.UltraWinEditors.UltraCheckEditor.set_Checked(Boolean value)
at Ice.Lib.Framework.EpiCheckBox.oDataView_EpiViewNotification(EpiDataView view, EpiNotifyArgs ar)
at Ice.Lib.Framework.EpiViewNotification.Invoke(EpiDataView view, EpiNotifyArgs args)
at Ice.Lib.Framework.EpiDataView.OnEpiViewNotification(EpiNotifyArgs e)
at Ice.Lib.Framework.EpiDataView.Notify(EpiNotifyArgs args)
at Erp.UI.App.PartTracker.Transaction.GetByID(String partNum)

I would use the data view notification do perform your changes vs the actual controls. Whenever possible use the underlying data view and try to interact with controls directly as little as possible. This is just an outline won’t compile but you want something like this. Use the Wizard to get the actual EpiNotification method.

private void dataView_EpiNotification(object send, args)
{
    if(dataview.Row > -1)
    {
         if((bool)dataview.dataView[dataview.Row]["my-boolean"])
         {
               shape.Status = StatusTypes.Stop;
         } else {
               shape.Status = StatusTypes.OK;
        }
    }
}

Sorry,
I don’t understand what this means. I’m not very familiar with the script editor and not at all familiar with data view notification.

I’m just trying to learn this.