Click here to Skip to main content
Click here to Skip to main content

GmailNotifierControl: A Gmail Notifier like control

By , 6 Jun 2005
 

Sample Image - GmailNotifierInfo.jpg

Introduction

I've been using Gmail for something like 8 months, and all I can say is that the Gmail team did a good work. I also liked the Gmail Notifier, the way it acts... I decided thus to create my own Gmail Notifier like control, so as to use it in apps I write.

Using the code

The GmailNotifierControl is made of a picture box, a label, one or two timers (I could have used only one but the code wouldn't have been that clear) and a [ThatsItControl :)]. The control exposes some properties visible under the Misc... section in the VS IDE, and a method, all of which are listed below:

  • GmailImage: The image to show in the control.
  • Info: The text to display.
  • Interval: The time to sleep before moving the control up or down.
  • NotifyText: The text to display in the notify icon of the control.
  • Pitch: The number of pixels by which the control is moved vertically (in the Y axis).
  • TimeOut: The duration of visibility of the info, after that duration the control hides.
  • ShowInfo(): Shows the info set in the control.

The code itself is easy to understand, just see by yourself:

private void tmrMove_Tick(object sender, System.EventArgs e)
{
    int nTaskBarHeight = Screen.PrimaryScreen.Bounds.Bottom - 
                         Screen.PrimaryScreen.WorkingArea.Bottom;
    if(!bHide) //Show the Info Box
    {
        this.Show();
        if ( this.Top > Screen.PrimaryScreen.Bounds.Bottom - 
           (this.Height + nTaskBarHeight )) //screen limit - TaskBarSize
        {    
            this.TopMost = false;
            this.Top -= nPitch;
            this.Refresh();
            bFinished = false;
        }
        else 
        {
            this.TopMost = true;
            bFinished = true;
            this.Refresh();
            bHide = true;
        }
    }
    else if (!bFinished) //Hide It
    {
        if ( this.Top < Screen.PrimaryScreen.Bounds.Bottom )
        {    
            this.TopMost = false;
            this.Top += nPitch;
            this.Refresh();
            bFinished = false;
        }
        else 
        {
            this.TopMost = true;
            this.Hide();
            bFinished = true;
            bHide = false;
        }
    }
    if (bFinished)
        tmrMove.Stop();
    if (bHide && bFinished)
        tmrEnd.Start();
}

In order to have the properties in the same category in the IDE, I used this:

   [Category("Misc..."), 
    Description("The TimeOut in milliseconds of GmailNotifierControl Info")]
    public int TimeOut
    {
        get
        {
        return this.nTimeOut / 1000;
        }
        set
        {
        this.nTimeOut = value * 1000;
        this.tmrEnd.Interval = value * 1000;
        }
    }
    
    [Category("Misc..."), 
     Description("The text to show in the GmailNotifierControl")]
    public string Info
    {
        get
        {
        return this.strInfo;
        }
        set
        {
        this.lblInfo.Text = value;
        this.strInfo = value;
        this.Refresh();
        }
    }

Points of Interest

I have tried to override some form specific properties like opacity, just to get them together in the Misc... category but couldn't. I would also like to refine this control, so any contribution, any suggestions, would be welcome.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

eRRaTuM
Software Developer (Senior)
Morocco Morocco
Member
In his studies, eRRaTuM discovered C/C++.he appreciated it.
When he met ORACLE products, in his job, he fell in love.
He uses C# .net & MS SQL.
 
He created a "F.R.I.E.N.D.S" like soap movie, melting all of the above.
Went back in the university.
After he took courses of Artificial Vision & Imagery, he finished his studies with a successful License Plate Recognition project.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralRe: Use at commercial product?membereRRaTuM25 Aug '08 - 4:37 
Feel free!
All I ask is a notification, I mean once your product is done, just a screen capture of the Control at work Smile | :)
good luck Big Grin | :-D
 
:: YOU make history ::

GeneralOpacitymembermishariy19 Oct '05 - 6:06 
How do I change the opacity and movement speed?
 
I changed the values in the control but that doesn't seem to matter...?
GeneralRe: OpacitymembereRRaTuM27 Oct '05 - 1:35 
The opacity is not directly accessible, use the max opacity property instead; the movement speed can be exposed as a public accessor in the gmailNotifier code itself.
good luck
 
:: YOU make history ::
^_^
GeneralWider menu barsmemberPhebous16 Jun '05 - 8:43 
I have a menu bar which is of double height. The pop-up appear right above a single height menu bar. I would think that Screen.PrimaryScreen.WorkingArea.Bottom would refer to the actual working area but I guess not. I do know it is possible since I have OWA uses a similar pop-up and it does take into account the actual height of the menu bar. Does anybody have any insights on this?
 
Phebous...
GeneralRe: Wider menu barsmembereRRaTuM17 Jun '05 - 6:09 
Hi, the value Screen.PrimaryScreen.WorkingArea changes every app launch,
Try for example, launching the app with the explorer bar size bigger, it would give you the right value.
try MessageBoxing Screen.PrimaryScreen.WorkingArea.Size.ToString()!
 
:: YOU make history ::
^_^
QuestionDoes it miss something?membereRRaTuM8 Jun '05 - 4:55 
I m looking forward to know if the article does miss something, any comment is wellcome!!!
 
:: YOU make history ::
^_^
Generallittle changesussTylorDurden6 Jun '05 - 22:24 
Hey,
 
if you change
 
( this.Top > Screen.PrimaryScreen.Bounds.Bottom - (this.Height + 30))
 

into this
 

if ( this.Top > Screen.PrimaryScreen.WorkingArea.Bottom - (this.Height)
 
then you dont have to advise the height of the taskbar.
But the i have still one problem,
-> the Window is above the taskbar.
 
regards
GeneralRe: little changemembereRRaTuM7 Jun '05 - 0:11 
Thanks,
I made some changes, the 30 is now replaced by
int nTaskBarHeight = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom;
and the GmailNotifierControl appears now behind the TaskBar and TopMost Smile | :) .
 
:: YOU make history ::
^_^

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 6 Jun 2005
Article Copyright 2005 by eRRaTuM
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid