Displaying tool window images correctly on tab strips

1 posts, 0 answers
  1. Phil
    Phil avatar
    1 posts
    Member since:
    Oct 2009

    Posted 17 Feb 2010 Link to this post

     

    I have been attempting to work around a known issue and limitation of the RadDock control when displaying images assigned to tool windows on tab strips. My understanding, please correct me if this is not the case, is that images assigned to tool windows are rotated by 180 degrees when shown on a tab strip and are not shown at all when in auto hide mode.

    In the application I am writing I am attempting to produce a user interface similar to that of visual studio. I am therefore looking to show the image of my tool windows followed by there names whenever they are shown on tab strips. I have contacted Telerik support who provided me with the basis for the below code. The code shown is my implementation of an event handler for the TransactionCommitted event of a RadDock control which I believe achieves my goal.

    I was wondering if others have come across this problem and how they went about solving it.

    Note: The event handler will need to be added to the RadDock control before adding any tool windows. If your adding tool windows before your event handlers you will need to rotate the images of your tool windows by 180 degrees.

            private void TransactionCommitted(object sender, RadDockTransactionEventArgs e)  
            {  
                foreach (DockWindow window in e.Transaction.AssociatedWindows)  
                {  
                    if ((e.Transaction.TransactionType == DockTransactionType.AutoHide) && (e.Transaction.TargetState == DockState.AutoHide))  
                    {  
                        PropertyInfo propInfo = typeof(ToolWindow).GetProperty("AutoHideTab", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);  
                        TabStripItem tabStripItem = (TabStripItem)propInfo.GetValue((ToolWindow)window, null);  
     
                        tabStripItem.Image = window.Image;  
     
                        foreach (TabStripItem item in tabStripItem.ParentTabStrip.Items)  
                        {  
                            switch (((AutoHideTransaction)e.Transaction).Position)  
                            {  
                                case AutoHidePosition.Right:  
                                case AutoHidePosition.Top:  
                                    item.ImagePrimitive.AngleTransform = 180;  
                                    item.TextImageRelation = TextImageRelation.TextBeforeImage;  
                                    break;  
     
                                default:  
                                    item.ImagePrimitive.AngleTransform = 0;  
                                    item.TextImageRelation = TextImageRelation.ImageBeforeText;  
                                    break;  
                            }  
                        }  
                    }  
                    else if ((e.Transaction.TargetState == DockState.Docked) || (e.Transaction.TargetState == DockState.Floating))  
                    {  
                        ((ToolWindow)window).TabStripItem.ImagePrimitive.AngleTransform = 180;  
                    }  
                }  
            } 

     

     

Back to Top