This is a migrated thread and some comments may be shown as answers.

FlashWindow like functionality on a tabbed ToolWindow

12 Answers 333 Views
Dock
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 17 Nov 2009, 10:33 AM

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

12 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 20 Nov 2009, 01:43 PM
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.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 21 Nov 2009, 04:10 PM
Thanks, Nikolay I'll give it a try.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 22 Nov 2009, 06:29 PM
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
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 22 Jul 2010, 03:28 PM
Have Problems getting this to work again in Q2 2010 ...

Regards
Erwin
0
Nikolay
Telerik team
answered on 27 Jul 2010, 08:47 PM
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
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 28 Jul 2010, 03:56 PM
Thanks, Nikolay - works perfectly.

Kind Regards
Erwin
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 15 Oct 2010, 05:18 PM
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
0
Accepted
Nikolay
Telerik team
answered on 21 Oct 2010, 11:57 AM
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
0
Accepted
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 23 Oct 2010, 03:15 PM
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();
            }
        }
    }
}

0
Nikolay
Telerik team
answered on 28 Oct 2010, 04:21 PM
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
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 16 Dec 2010, 04:29 PM
The provided Code crashes (Stack Overflow) again with Telerik 2010 Q3 SP1.
0
Nikolay
Telerik team
answered on 22 Dec 2010, 01:45 PM
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.
Tags
Dock
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Nikolay
Telerik team
erwin
Top achievements
Rank 1
Veteran
Iron
Share this question
or