Click here to Skip to main content
15,896,154 members
Articles / Mobile Apps

Windows Mobile Password Safe

Rate me:
Please Sign up or sign in to vote.
4.87/5 (58 votes)
12 Jan 2009CPOL16 min read 161.6K   3.1K   139  
A password safe with a touch screen UI introducing Fluid Controls.
using System;

using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using System.Windows.Forms;
using System.Drawing;
using Fluid.Drawing.GdiPlus;
using PasswordSafe.Classes;
using PasswordSafe.Properties;

namespace PasswordSafe
{
    public class ButtonPanel : FluidPanel
    {

        public const int ButtonWidth = 50;
        public const int ButtonHeight = 36;
        const int ButtonTop = 8;
        const int Space = 8;

        protected override void InitControl()
        {
            Theme theme = Theme.Current;
            base.InitControl();
            Bounds = new System.Drawing.Rectangle(0, 0, 240, 40);
            BackColor = theme.ButtonsBackColor;
            GradientFill = theme.ButtonsGradianted;
            GradientFillOffset = 25;

            buttons[0] = btn1 = new FluidButton("", Space, ButtonTop, ButtonWidth, ButtonHeight);
            buttons[1] = btn2 = new FluidButton("", Space + (Space + ButtonWidth) * 1, ButtonTop, ButtonWidth, ButtonHeight);
            buttons[2] = btn3 = new FluidButton("", Space + (Space + ButtonWidth) * 2, ButtonTop, ButtonWidth, ButtonHeight);
            buttons[3] = btn4 = new FluidButton("", Space + (Space + ButtonWidth) * 3, ButtonTop, ButtonWidth, ButtonHeight);


           

            buttons[0].Image = Resources.searchd;
            buttons[1].Image = Resources.undo24_d;
            buttons[2].Image = Resources.saved;
            buttons[3].Image = Resources.Lock;

            

            btn1.Command = "A";
            btn2.Command = "B";
            btn3.Command = "C";
            btn4.Command = "D";

            Color backColor = theme.ButtonsButtonBackColor;

            foreach (FluidButton b in buttons)
            {
                b.Anchor = AnchorStyles.None;
                b.Shape = ButtonShape.Flat;
                b.BackColor = backColor;
                b.ForeColor = Color.White;
            }

            Controls.Add(btn1);
            Controls.Add(btn2);
            Controls.Add(btn3);
            Controls.Add(btn4);

            ListBuilder.Instance.ModifiedChanged += new EventHandler(Instance_ModifiedChanged);

            MakeButtonsGlowing();

        }

        private void MakeButtonsGlowing()
        {
            foreach (FluidButton btn in buttons) btn.PressedBackColor = Color.DarkBlue;
        }

        void Instance_ModifiedChanged(object sender, EventArgs e)
        {
            btn3.Image = ListBuilder.Instance.Modified ? Resources.save : Resources.saved;
            btn2.Image = ListBuilder.Instance.Modified ? Resources.undo24 : Resources.undo24_d;
        }

        FluidButton[] buttons = new FluidButton[4];

        public FluidButton[] Buttons { get { return buttons; } }

        FluidButton btn1;
        FluidButton btn2;
        FluidButton btn3;
        FluidButton btn4;


        protected override void OnSizeChanged(System.Drawing.Size oldSize, System.Drawing.Size newSize)
        {
            base.OnSizeChanged(oldSize, newSize);
            if (btn1 == null) return;

            int ButtonWidth = ScaleX(ButtonPanel.ButtonWidth);
            int ButtonHeight = ScaleY(ButtonPanel.ButtonHeight);
            int ButtonTop = ScaleY(ButtonPanel.ButtonTop);

            if (Width > Height)
            {
                int Space = ScaleX(ButtonPanel.Space);
                btn1.Bounds = new Rectangle(Space, ButtonTop, ButtonWidth, ButtonHeight);
                btn2.Bounds = new Rectangle(Space + (Space + ButtonWidth) * 1, ButtonTop, ButtonWidth, ButtonHeight);
                btn3.Bounds = new Rectangle(Space + (Space + ButtonWidth) * 2, ButtonTop, ButtonWidth, ButtonHeight);
                btn4.Bounds = new Rectangle(Space + (Space + ButtonWidth) * 3, ButtonTop, ButtonWidth, ButtonHeight);
            }
            else
            {
                int Space = ScaleY(ButtonPanel.Space);
                btn1.Bounds = new Rectangle(Space, ButtonTop, ButtonWidth, ButtonHeight);
                btn2.Bounds = new Rectangle(Space, ButtonTop + (ButtonTop + ButtonHeight) * 1, ButtonWidth, ButtonHeight);
                btn3.Bounds = new Rectangle(Space, ButtonTop + (ButtonTop + ButtonHeight) * 2, ButtonWidth, ButtonHeight);
                btn4.Bounds = new Rectangle(Space, ButtonTop + (ButtonTop + ButtonHeight) * 3, ButtonWidth, ButtonHeight);
            }
        }

        private System.Drawing.Rectangle Rectangle(int p, int ButtonTop, int ButtonWidth, int ButtonHeight)
        {
            throw new NotImplementedException();
        }
    }
}

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
Software Developer (Senior)
Germany Germany
MCPD
Enterprise Application Developer 3.5
Windows Developer 3.5
.ASP.NET Developer 3.5
.NET 2.0 Windows Developer
.NET 2.0 Web Developer
.NET 2.0 Enterprise Application Developer


MCTS
.NET 3.5 Windows Forms Applications
.NET 3.5 ASP.NET Applications
.NET 3.5, ADO.NET Application Development
.NET 3.5 WCF
.NET 3.5 WPF
.NET 3.5 WF
Microsoft SQL Server 2008, Database Development
.NET 2.0 Windows Applications
.NET 2.0 Web Applications
.NET 2.0 Distributed Applications
SQL Server 2005
Sharepoint Services 3.0 Application Development
Windows Vista Client Configuration

Comments and Discussions