Page 1 of 1

Some styles giving error

PostPosted: Thu Dec 14, 2017 12:44 pm
by DannyC
Hi,
I've been using the following forum post about styles to fiddle about giving a different style for different databases
viewtopic.php?f=26&t=870

I have it working, so it's a nice nifty little visual difference.
Some of the styles available are giving an error - it seems to be specifically after the Sales Order module is open, and another module is opened. I am opening System Configuration.
Style Error1.png
Style Error1.png (7.61 KiB) Viewed 3713 times


Not all styles show the error but it is occurring on the following (haven't tested all styles). I'm in 7.0.175.
Aero
ModClay
IG
LucidDream
Nautilus
Office2007Black

Re: Some styles giving error

PostPosted: Thu Dec 14, 2017 6:07 pm
by SBarnes
Hi Danny,

I tried all the ones on your list under 7.157 and didn't get a single error, perhaps its related to another plugin that could be loading?

Re: Some styles giving error

PostPosted: Fri Dec 15, 2017 11:53 am
by SBarnes
I can now produce the error also if you open two sales order screens at the same time you get the error it's something to do with the tabs at the top.

Quotes does the same thing, inventory doesn't.

If you undock the first sales windows it will open a second one ok.

Re: Some styles giving error  Topic is solved

PostPosted: Sat Dec 16, 2017 2:30 pm
by Mike.Sheen
This is logged as DEV-6401

The cause is trying to colourise the tab for the MDI Parent tab control for per warehouse colours - the font being set was 0 for some styles (supposedly because that style does not have the required appearance set).

A work around to this is to override the draw filter for the MDI Parent tab control, and check for an invalid font size and set it to a good value.

Attached is a plugin which does this - tested with 7.1.0, but should work with previous versions.

Note that I had to add a reference to Jiwa.exe and Infragistics4.Win.UltraWinTabbedMdi.v13.1 on the Assembly References tab.

Re: Some styles giving error

PostPosted: Sat Dec 16, 2017 3:14 pm
by SBarnes
Hi Mike

Yes that fixes the problem, I just tried it under 7.157 so it works under multiple versions, just for completeness here is the class converted to c# as well, given that's what the original plugin was in that I wrote.

Code: Select all
public class TabbedMDIDrawFilter : Infragistics.Win.IUIElementDrawFilter {
   
    //  This class is used to set the colour of the MDI tab to be the warehouse colour
    private Jiwa.MainForm _MDIForm;
   
    internal Jiwa.MainForm MDIForm {
        get {
            return _MDIForm;
        }
        set {
            _MDIForm = value;
        }
    }
   
    public bool DrawElement(Infragistics.Win.DrawPhase drawPhase, ref Infragistics.Win.UIElementDrawParams drawParams) {
        Rectangle elementRect;
        System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
        System.Drawing.Color warehouseColour;
        if ((_MDIForm.UltraTabbedMdiManager1.TabGroups.Count > 0)) {
            foreach (Infragistics.Win.UltraWinTabbedMdi.MdiTab tab in _MDIForm.UltraTabbedMdiManager1.TabGroups[0].Tabs) {
                if ((tab.UIElement != null) && tab.UIElement.Equals(drawParams.Element))
            {
                    if (tab.Tag != null && !tab.IsSelected)
               {
                        warehouseColour = (System.Drawing.Color)tab.Tag;
               
                        myBrush = new System.Drawing.SolidBrush(warehouseColour);
                        //  Get the element's rectangle
                        elementRect = drawParams.Element.Rect;
                        drawParams.Graphics.FillRectangle(myBrush, elementRect);
                        //  draw tab caption
                        System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
                        System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(JiwaFinancials.Jiwa.JiwaApplication.Manager.ContrastColour(warehouseColour));
                        Infragistics.Win.AppearanceData appData = new Infragistics.Win.AppearanceData();
                        Infragistics.Win.AppearancePropFlags requestedProps = Infragistics.Win.AppearancePropFlags.FontData;
                        tab.ResolveAppearance(ref appData, ref requestedProps);
                        if ((appData.FontData.SizeInPoints == 0)) {
                            //  This is the change to the standard draw filter for the MDI Tab control - just check for an invalid font size and set it
                            appData.FontData.SizeInPoints = 8;
                        }
                       
                        Font font = new Font(appData.FontData.Name, appData.FontData.SizeInPoints);
                        drawParams.Graphics.DrawString(tab.Text, font, drawBrush, (elementRect.X + 18), (elementRect.Y + 2), drawFormat);
                        return true;
                    }
                   
                    break;
                }
               
            }
           
        }
       
        return false;
    }
   
    public Infragistics.Win.DrawPhase GetPhasesToFilter(ref Infragistics.Win.UIElementDrawParams drawParams) {
        if (((drawParams.Element.GetType() == typeof(Infragistics.Win.UltraWinTabs.TabItemUIElement))
                    || ((drawParams.Element.GetType() == typeof(Infragistics.Win.ImageAndTextUIElement.ImageAndTextDependentImageUIElement))
                    || (drawParams.Element.GetType() == typeof(Infragistics.Win.ImageAndTextUIElement.ImageAndTextDependentTextUIElement))))) {
            return Infragistics.Win.DrawPhase.BeforeDrawForeground;
        }
        else {
            return Infragistics.Win.DrawPhase.None;
        }
       
    }
   
    public TabbedMDIDrawFilter(Jiwa.MainForm MDIForm) {
        _MDIForm = MDIForm;
    }
}

Re: Some styles giving error

PostPosted: Mon Dec 18, 2017 7:37 pm
by Mike.Sheen
SBarnes wrote:Yes that fixes the problem, I just tried it under 7.157 so it works under multiple versions, just for completeness here is the class converted to c# as well, given that's what the original plugin was in that I wrote.


Thanks, Stuart - for providing the code converted to C# - I was tempted to initially provide C# code, but I know from experience DannyC (the OP of this topic) prefers VB.NET, so I went with that.

As a side note - It's interesting how Infragistics structured their draw filters using phases, and one can indicate which phases a draw filter should be invoked with. Something to consider for us at Jiwa in future when implementing plugin customisation capabilities - rather than having specific events raised when actions occur, perhaps a similar approach to use phases to invoke provided methods at phases of a documents lifecycle - so instead of ReadStart, ReadEnd, SaveStart, SaveEnding, SaveEnd and so on events those could instead be phases. Just an idle thought...

Re: Some styles giving error

PostPosted: Thu Dec 21, 2017 9:07 am
by SBarnes
Hi Mike,

Interesting idea but it would also help if you could see what the values were (state was) at a previous phase but I suppose it would be fairly easy to do with a list of serialised XML copies that could then be de-serialised for comparisons.