I have a Classic UX customization utilizing an EpiButton, 2 row rules and a UD field. My row rules state that if UD field is true, I want the button’s backcolor to be red and text to be “Remove Urgent Material”. The 2nd row rules states that if UD field is false, I want the button’s backcolor to be silver and text to be “Set Urgent Material”.
The text is changing like a charm. However, the color is not changing. Yes, I have UseOSThemes set to false and UseAppStyling = false on the button properties.
What am I missing?
private void SetButtonProperties(EpiButton button, System.Drawing.Color color, string caption)
{
button.UseAppStyling = false;
button.BackColor = color;
button.Text = caption;
}
private void CreateRowRuleJobMtlHotMtl_cEquals_true()
{
// Description: BtnHotMtlChangeColor
// **** begin autogenerated code ****
RuleAction[] ruleActions = new RuleAction[0];
// Create RowRule and add to the EpiDataView.
// Dummy Context Object
object contextObject = null;
RowRule rrCreateRowRuleJobMtlHotMtl_cEquals_true = new RowRule("JobMtl.HotMtl_c", RuleCondition.Equals, true, new RowRuleActionDelegate2(this.JobMtlHotMtl_cEqualstrue_CustomRuleAction), contextObject);
((EpiDataView)(this.oTrans.EpiDataViews["JobMtl"])).AddRowRule(rrCreateRowRuleJobMtlHotMtl_cEquals_true);
// **** end autogenerated code ****
}
private void JobMtlHotMtl_cEqualstrue_CustomRuleAction(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
// ** RowRuleDelegateArgs Properties: args.Arg1, args.Arg2, args.Context, args.Row
// ** put custom Rule Action logic here
//btnHotMtl.Text = "Remove Urgent Material";
//btnHotMtl.BackColor = System.Drawing.Color.Red;
SetButtonProperties(btnHotMtl, System.Drawing.Color.Red, "Remove Urgent Material");
}
private void CreateRowRuleJobMtlHotMtl_cEquals_false()
{
// Description: BtnHotMtlUnsetColor
// **** begin autogenerated code ****
RuleAction[] ruleActions = new RuleAction[0];
// Create RowRule and add to the EpiDataView.
// Dummy Context Object
object contextObject = null;
RowRule rrCreateRowRuleJobMtlHotMtl_cEquals_false = new RowRule("JobMtl.HotMtl_c", RuleCondition.Equals, false, new RowRuleActionDelegate2(this.JobMtlHotMtl_cEqualsfalse_CustomRuleAction), contextObject);
((EpiDataView)(this.oTrans.EpiDataViews["JobMtl"])).AddRowRule(rrCreateRowRuleJobMtlHotMtl_cEquals_false);
// **** end autogenerated code ****
}
private void JobMtlHotMtl_cEqualsfalse_CustomRuleAction(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
// ** RowRuleDelegateArgs Properties: args.Arg1, args.Arg2, args.Context, args.Row
// ** put custom Rule Action logic here
//btnHotMtl.Text = "Set Urgent Material";
//btnHotMtl.BackColor = System.Drawing.Color.Green;
SetButtonProperties(btnHotMtl, System.Drawing.Color.Green, "Set Urgent Material");
}
The UseVisualStyleBackColor threw an error but just changing the button.BackColor = color to button.Appearance.BackColor = color is the winner, winner, chicken dinner.!!!
You want to give your button a binding JobMtl.btnHot for example, buttons and shapes can have fake bindings for the Row Rule Engine to work with them.
Now you can add a regular action, and have it run on JobMtl.btnHot, you will just need to modify the wizard generated code because you will not see the btnHot as a field in Wizard Script Editor.
Just assign it the OK Color or something else, once the code is generated replace the color with your custom ControlSettings.
But also consider Epicor native behaviour, perhaps a colored button isn’t the way, perhaps you want a Shape? Perhaps a Shape and a Checkbox next to it that can be toggled and the shape can become Red or Gray.
Further Reading:
Funny, I was just doing a Custom Color yesterday, because @jgiese.wci loves LimeGreen and hates Epicors default Green
For sure, your colors on the Dispatch Dashboards are like eye-candy to look at, even someone color blind would appreciate them I agree those are good choices.
I use pixie all the time, its bound to my PATH all I need to type is pixie in terminal.