Results 1 to 7 of 7

Thread: UI visual help

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    UI visual help

    Hi!

    I am just in the final stages of completing my application and thought, why not make the UI more cooler?

    I'm using .NET 2.0

    What I want to do is this:

    my application has a systray icon, so it sits in the taskbar. What I want is that when a certain event occurs, I want a small window to pop up in the task bar area and then fading away (transparency is easy)

    The issue I have is that I do not know how to make a small winform "pop up" at the taskbar area, is there a way to do this?

    Need an example?

    in WMP 9/10 for example, when you minimize WMP to the taskbar, when it moves to the next track/playlist - a small notification window appears telling you the name of the track currently playing and so on, then it fades away after a few seconds - this is what I pretty much want.

    does anyone have any suggestions?

    Thanks!

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: UI visual help

    jmcillhinney created something you might like, it's VB.NET though.

    http://www.vbforums.com/showthread.p...ighlight=toast
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: UI visual help

    Thanks, if there are any more then please post them!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: UI visual help

    That example of mine will handle popping-up and transparency. If I can remember how it works properly you should be able to change the animation method after the form has popped up so that it will fade out rather than sliding back down again. If you want other examples I've seen a few on the Web. I'd search for "toast", as that is the "cool" name for that type of window. Also, it's not difficult to achieve yourself using a Timer. You set the form's initial Location based on the WorkingArea of the PrimaryScreen, then just decement the Top property using a Timer until the whole form is showing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: UI visual help

    thanks
    Well currently just playing around
    Made a new form
    then im running that new form in a new thread to prevent the main form UI from hanging
    then what I done was that in a for loop, it would sleep the thread for 100 ms for example
    enable the timer to be 8 seconds, then fade it away and kill off the thread

    but for some reason once its faded in (opacity = 1.0) it just disappears and trying to figure out why.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: UI visual help

    yeh ok i figured out why

    so now im going for your idea of the timers
    should work!...

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: UI visual help

    I created the following form class in C# 2005 Express. I added a Timer in the designer and set the Interval to 15. I also set the Form's StartPosition to Manual. Note that the only real difference in C# 2003 would be that you'd use the Closing event instead of the ForClosing.
    Code:
        public partial class Form1 : Form
        {
            private bool opened = false;
            private bool closing = false;
            private bool closed = false;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
    
                // Initially position the form below the system tray.
                this.Location = new Point(workingArea.Width - this.Width, workingArea.Height);
                this.timer1.Start();
            }
    
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (!this.opened || this.closing)
                {
                    // Don't close the form yet.
                    e.Cancel = true;
                }
                else if (!closed)
                {
                    // Start fading the form out.
                    this.closing = true;
                    this.timer1.Interval = 30;
                    this.timer1.Start();
                    e.Cancel = true;
                }
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (!this.opened)
                {
                    // Slide the form up.
                    this.Top -= 5;
    
                    if (this.Bottom <= Screen.PrimaryScreen.WorkingArea.Height)
                    {
                        // The form is fully visible.
                        this.timer1.Stop();
                        this.opened = true;
                    }
                }
                else
                {
                    // Fade the form out.
                    this.Opacity -= .05;
    
                    if (this.Opacity <= 0.0)
                    {
                        // The form is fully faded.
                        this.timer1.Stop();
                        this.closing = false;
                        this.closed = true;
                        this.Close();
                    }
                }
            }
        }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width