Some styles giving error  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Some styles giving error

Postby DannyC » Thu Dec 14, 2017 12:44 pm

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 2009 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
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Some styles giving error

Postby SBarnes » Thu Dec 14, 2017 6:07 pm

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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Some styles giving error

Postby SBarnes » Fri Dec 15, 2017 11:53 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Some styles giving error  Topic is solved

Postby Mike.Sheen » Sat Dec 16, 2017 2:30 pm

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.
Attachments
Plugin Style workaround.xml
Sample Plugin
(34.65 KiB) Downloaded 88 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Some styles giving error

Postby SBarnes » Sat Dec 16, 2017 3:14 pm

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;
    }
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Some styles giving error

Postby Mike.Sheen » Mon Dec 18, 2017 7:37 pm

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...
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Some styles giving error

Postby SBarnes » Thu Dec 21, 2017 9:07 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 32 guests