Click here to Skip to main content
15,897,273 members
Articles / Mobile Apps

Pocket Fuzzy Quotient Calculator

Rate me:
Please Sign up or sign in to vote.
2.95/5 (21 votes)
23 Apr 2004CPOL2 min read 49.8K   437   10  
The Pocket Fuzzy Quotient Calculator is a .NET Compact Framework sample application that calculates your FQ based on your mood.
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;

namespace FuzzyQuotient
{
	/// <summary>
	/// Summary description for AutoScrollPanel.
	/// </summary>
    public class AutoScrollPanel : Panel
    {
        public Panel Contents
        {
            get { return contents; }
        }
        Panel contents;
        VScrollBar vScroll;

        public AutoScrollPanel()
        {
            // create a scroll bar
            this.vScroll = new VScrollBar();
            this.vScroll.Parent = this;
            this.vScroll.Visible = true;
            this.vScroll.Minimum = 0;
            this.vScroll.SmallChange = 20;
            this.vScroll.ValueChanged += new EventHandler (this.scrollbar_ValueChanged);

            // create the contents panel that holds the controls to be scrolled
            this.contents = new Panel();
            this.contents.Parent = this;
            this.contents.Width = this.ClientSize.Width - this.vScroll.Size.Width;
        }

        private void scrollbar_ValueChanged (object o, EventArgs e)
        {
            if (o == this.vScroll)
            {
                //By decreasing the top y coordinate
                //the contents panel appears to scroll
                this.contents.Top = -this.vScroll.Value;
                this.Update();
            }
        }

        void CheckScrollBars()
        {
            this.vScroll.Visible = this.contents.Size.Height > this.ClientSize.Height;
        }

        protected override void OnResize (EventArgs e)
        {
            this.contents.Width = this.ClientSize.Width - this.vScroll.Size.Width;

            this.vScroll.Bounds = new Rectangle (this.ClientSize.Width - this.vScroll.Size.Width,
                0,
                this.vScroll.Size.Width,
                this.ClientSize.Height);

            if (this.ClientSize.Height >= 0)
                this.vScroll.LargeChange = this.ClientSize.Height;

            CheckScrollBars();
        }

        public void SetScrollHeight(int height)
        {
            this.contents.Height = height;

            this.vScroll.Maximum = this.contents.Size.Height;

            CheckScrollBars();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions