Click here to Skip to main content
15,881,882 members
Articles / Mobile Apps / Windows Mobile

Task assigner with Windows Mobile and a Web Service

Rate me:
Please Sign up or sign in to vote.
4.23/5 (12 votes)
7 Dec 2008CPOL3 min read 54.7K   1.1K   35  
Send messages, commands, tasks etc., to all employees from a central administration point.
namespace RRaveCon.OutLookControl
{
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    internal class ToolTip : UserControl
    {
        public ToolTip()
        {
            base.Visible = false;
            base.BackColor = SystemColors.Info;
            base.ForeColor = Color.Black;
            base.Text = "";
        }

        public void MoveTo(Point pt)
        {
            int num = base.Parent.Width - 20;
            Graphics graphics = base.CreateGraphics();
            string[] strArray = this.Text.Split(new char[] { '\n' });
            int num2 = 6;
            int num3 = 8;
            foreach (string str in strArray)
            {
                SizeF ef = graphics.MeasureString(str, this.Font);
                num3 = ((int) Math.Min((float) num, Math.Max(ef.Width, (float) num3))) + 8;
                num2 += (int) ef.Height;
                int length = str.Length;
                int startIndex = 0;
                while (ef.Width > num)
                {
                    int num6 = 0;
                    do
                    {
                        num6++;
                    }
                    while (graphics.MeasureString(str.Substring(startIndex, num6), this.Font).Width < num);
                    int num7 = (startIndex + num6) - 1;
                    while (num7 > (startIndex + 1))
                    {
                        if (char.IsWhiteSpace(str[num7]))
                        {
                            break;
                        }
                        num7--;
                    }
                    if (num7 == (startIndex + 1))
                    {
                        num7 = (startIndex + num6) - 1;
                        while (num7 < length)
                        {
                            if (char.IsWhiteSpace(str[num7]))
                            {
                                break;
                            }
                            num7++;
                        }
                    }
                    startIndex = num7;
                    ef = graphics.MeasureString(str.Substring(startIndex), this.Font);
                    num2 += (int) ef.Height;
                }
            }
            pt.Y -= num2;
            if (pt.Y < 0)
            {
                pt.Y = 0;
            }
            pt.X -= num3 / 2;
            if ((pt.X + num3) > num)
            {
                pt.X -= (pt.X + num3) - num;
            }
            if (pt.X <= 0)
            {
                pt.X = 10;
            }
            graphics.Dispose();
            base.Height = num2;
            base.Width = num3;
            base.Location = pt;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Rectangle clientRectangle = base.ClientRectangle;
            clientRectangle.Width--;
            clientRectangle.Height--;
            e.Graphics.DrawRectangle(new Pen(Color.Black), clientRectangle);
            clientRectangle.X += 4;
            clientRectangle.Y += 2;
            clientRectangle.Width -= 4;
            clientRectangle.Height -= 2;
            e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(base.ForeColor), clientRectangle);
        }

        public void Show(Point pt)
        {
            this.MoveTo(pt);
            base.Visible = true;
            base.BringToFront();
        }
    }
}

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
Team Leader
Singapore Singapore
- B.Sc. degree in Computer Science.
- 4+ years experience in Visual C#.net and VB.net
- Obsessed in OOP style design and programming.
- Designing and developing Network security tools.
- Designing and developing a client/server application for sharing files among users in a way other than FTP protocol.
- Designing and implementing GSM gateway applications and bulk messaging.
- Windows Mobile and Symbian Programming
- Having knowledge with ERP solutions

The summary of my skills:
C#, VB.Net#,ASP.net, VC++, Java, WPF,WCF, Oracle, SQL Server, MS Access, Windows NT administration

Cheers
RRave
MCPD,MCTS
http://codegain.com

Comments and Discussions