FlashWindow like functionality on a tabbed ToolWindow

13 posts, 2 answers
  1. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 17 Nov 2009 Link to this post


    In my app, I have a tool window that displays some statistics. I would like to implement something equivalent to FlashWindowEx in case some trigger values are hit. Alternatively, just changing the Colour of the ToolWindwo / Tab would be sufficient.

    Regards
    Erwin
  2. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 20 Nov 2009 Link to this post

    Hello erwin,

    Thank you for the question.

    I am attaching a sample project which demonstrates how you can implement a 'flash manager'. The FlashManager in the project accepts instances of FillPrimitive, but you can make your own flash manager which accepts BorderPrimitives.

    I hope this helps. If you have additional questions, feel free to contact me.

    Best wishes,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 21 Nov 2009 Link to this post

    Thanks, Nikolay I'll give it a try.
  5. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 22 Nov 2009 Link to this post

    Nikolay,

    I've implemented your code in my app (the functionality is now in my base class for all my tool windows) and works perfectly.
    Thanks for your support.

    Erwin
  6. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 22 Jul 2010 Link to this post

    Have Problems getting this to work again in Q2 2010 ...

    Regards
    Erwin
  7. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 27 Jul 2010 Link to this post

    Hi erwin,

    Thank you for getting back to us.

    In Q2 2010 the FillPrimitive of the tab that is not selected in RadDock is Hidden. This is why you are not getting the expected behavior. You need to set the Visibility property of the animated FillPrimitive to Visible in the StartFlashing method and then you need to reset this property in the StopFlashing method. In addition, you may want to modify the GradientPercentage and GradientPercentage2 properties. I am attaching an updated version of the sample project.

    I hope this helps.

    Sincerely yours,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 28 Jul 2010 Link to this post

    Thanks, Nikolay - works perfectly.

    Kind Regards
    Erwin
  9. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 15 Oct 2010 Link to this post

    Hello Nikolay

    with the current Version of RadControls for Windows Forms (2010 Q2 SP2) the proposed code leads to a Stack Overflow Exception when clicking the Autohide Button.

    Regards
    Erwin
  10. Answer
    Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 21 Oct 2010 Link to this post

    Hello erwin,

    Thank you for writing.

    When a ToolWindow is put in AutoHide mode, the FillPrimitive of the of ToolWindow tab loses its ElementTree and its FlashManager should be stopped. Please note that the tab of the AutoHide window is not the tab of the window when it is in Docked mode. So, you need to create a new FlashManager for the FillPrimitive of the AutoHideTab. Please note that a new FlashManager should be created when the ToolWindow is redocked, because the FillPrimitive instance that should be animated is new.

    I hope this helps.

    All the best,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Answer
    erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 23 Oct 2010 Link to this post

    Thanks Nikolay,

    Chekcing the ElementTree in the TransactionBlockEnded event handler was the missing bit. Also solved a bunch of other problems I had before when the tool window was closed or re-docked etc. Used to check for these events and call StopFlashing() in several places - the code is much cleaner now.

    One has to be very careful about the order of events, your sample code for example does not work when you first autohide and then start the flashing.

    This is the code that I came up with so far. It inherits from the Telerik Tool Window. You can call StartFlashing() or StopFlashing() on it, plus it stops when it becomes the active window.
    using System;
      
    using Telerik.WinControls.UI.Docking;
    using Telerik.WinControls.Primitives;
      
    namespace Octopus2.Controls
    {
        class FlashingToolWindow : ToolWindow
        {
            FlashManager flashManager = null;
            FillPrimitive fill = null;
            bool initialized = false;
            bool windowShouldFlash = false;
      
      
            public void StartFlashing()
            {
      
                windowShouldFlash = true;
      
                if (this.DockState == DockState.Docked || this.DockState == DockState.AutoHide||this.DockState==DockState.Floating)
                {
                    fill = null;
      
                    if (this.DockState == DockState.Docked||this.DockState == DockState.Floating)
                    {
                        if (this.TabStrip.HasChildren)
                        {
                            fill = (FillPrimitive)this.TabStripItem.Children[0];
                        }
                    }
      
                    if (this.DockState == DockState.AutoHide)
                    {
                        if (this.AutoHideTab.Children.Count > 0)
                        {
                            fill = (FillPrimitive)this.AutoHideTab.Children[0];
                        }
                    }
      
                    if (fill != null)
                    {
                        flashManager = new FlashManager(fill);
                        flashManager.StartFlashing();
                    }
      
                    if (!initialized)
                    {
                        initialized = true;
                        this.DockManager.ActiveWindowChanged += new DockWindowEventHandler(DockManager_ActiveWindowChanged);
                        this.DockManager.TransactionBlockEnded += new EventHandler(DockManager_TransactionBlockEnded);
                    }
                }
            }
      
      
            void DockManager_TransactionBlockEnded(object sender, EventArgs e)
            {
                //
                // the TabStripItem or the AutoHideTab may no longer be available when docking changes
                //
                if (fill != null)
                {
                    if (fill.ElementTree == null)
                    {
                        if (flashManager != null)
                        {
                            flashManager.StopFlashing();
                            flashManager = null;
                        }
      
                        if (windowShouldFlash)
                        {
                            StartFlashing();
                        }
                    }
                }
            }
      
            void DockManager_ActiveWindowChanged(object sender, DockWindowEventArgs e)
            {
                if (e.DockWindow.Name == this.Name)
                {
                    StopFlashing();
                }
            }
      
            public void StopFlashing()
            {
                windowShouldFlash = false;
                  
                if (flashManager != null)
                {
                    flashManager.StopFlashing();
                }
            }
        }
    }

  12. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 28 Oct 2010 Link to this post

    Hello erwin,

    Thank you for writing back.

    I am glad to hear that your case is resolved. If you have additional questions, feel free to contact me.

    Best wishes,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 16 Dec 2010 Link to this post

    The provided Code crashes (Stack Overflow) again with Telerik 2010 Q3 SP1.
  14. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 22 Dec 2010 Link to this post

    Hello erwin,

    Thank you for writing.

    Could you please describe the exact case in which the issue occurs? I tried several scenarios, but I was not able to get the Stack Overflow exception. This information will allow me to investigate the case further.

    All the best,
    Nikolay
    the Telerik team
    Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
Back to Top
UI for WinForms is Visual Studio 2017 Ready