Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Windows Mobile Password Safe

, 12 Jan 2009
A password safe with a touch screen UI introducing Fluid Controls.
PasswordSafeExe.zip
PasswordSafeSource.zip
PasswordSafe
Fluditity
bin
Classes
vssver2.scc
Controls
enums
vssver2.scc
Events
vssver2.scc
Interfaces
vssver2.scc
vssver2.scc
Fluid.csproj.user
GdiPlus
mssccprj.scc
NativeMethods
vssver2.scc
vssver2.scc
Native
vssver2.scc
obj
Properties
vssver2.scc
vssver2.scc
PasswordSafe
bin
Release
Fluid.dll
passwords.pws
PasswordSafe.exe
Classes
vssver2.scc
Encryption
vssver2.scc
EventArgs
vssver2.scc
ListBoxes
vssver2.scc
PasswordSafe.csproj.user
Properties
vssver2.scc
Resources
lock.bmp
minus.png
props.bmp
save.bmp
saved.bmp
search.bmp
searchd.bmp
undo24.bmp
undo24_d.bmp
Untitled.png
vssver2.scc
security.ico
Templates
vssver2.scc
Themes
vssver2.scc
vssver2.scc
Xml
vssver2.scc
vssver2.scc
using System;

using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Fluid.Drawing.GdiPlus;

namespace Fluid.Controls
{
    /// <summary>
    /// EventArgs used for control painting.
    /// </summary>
    /// <remarks>
    /// FluidPaintEventArgs contains a Rectangle named ControlBounds. this Rectangle specifies the range where the control is allowed to 
    /// paint in the Graphics canvas. It is important to know that due to performance issues, the canvas region is not necassarily limited to that
    /// bounds, so the any control that paint using FluidPaintEventArgs must not use graphic operations that are not limited to the bounds, like
    /// Graphics.Clear(Color) which is very popularily used for windows controls to clear the backgound. Instead you must use 
    /// Graphics.FillRectangle(backgroundbrush, bounds).
    /// Also note, that you should rarily use temporarily created classed, even within "using..." block. Otherwhise the garbage collector would
    /// have to cleanup on occasion and this would slow down performance and animations. However, for usage of derived structs like Point or Rectangle,
    /// there is no restriction.
    /// </remarks>
    public class FluidPaintEventArgs : EventArgs
    {
        internal FluidPaintEventArgs()
            : base()
        {
        }

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="g">The graphics.</param>
        /// <param name="clip">The clip bounds for the control.</param>
        /// <param name="scaleFactor">The scale factor of the form.</param>
        public FluidPaintEventArgs(Graphics g, Rectangle bounds, SizeF scaleFactor)
            : base()
        {
            this.Graphics = g;
            this.ControlBounds = bounds;
            this.ScaleFactor = scaleFactor;
            Region = g.Clip;
        }

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="g">The graphics.</param>
        /// <param name="clip">The clip bounds for the control.</param>
        /// <param name="scaleFactor">The scale factor of the form.</param>
        /// <param name="doubleBuffered">Specifies wether the parent control uses double buffering.</param>
        public FluidPaintEventArgs(Graphics g, Rectangle clip, SizeF scaleFactor, bool doubleBuffered)
            : base()
        {
            this.Graphics = g;
            this.ControlBounds = clip;
            this.DoubleBuffered = true;
            this.ScaleFactor = scaleFactor;
            Region = g.Clip;
        }

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="g">The graphics.</param>
        /// <param name="clip">The clip bounds for the control.</param>
        /// <param name="scaleFactor">The scale factor of the form.</param>
        /// <param name="doubleBuffered">Specifies wether the parent control uses double buffering.</param>
        /// <param name="gp">The gdi plus class for painting.</param>
        public FluidPaintEventArgs(Graphics g, Rectangle clip, SizeF scaleFactor, bool doubleBuffered, GraphicsPlus gp)
            : base()
        {
            this.Graphics = g;
            this.ControlBounds = clip;
            this.DoubleBuffered = true;
            this.GdiPlus = gp;
            this.ScaleFactor = scaleFactor;
            Region = g.Clip;
        }

        /// <summary>
        /// Gets the region for checking the requirements to paint.
        /// Note, that each access of Graphic.Clip whould indeed create a new cloned instance, so g.Clip==g.Clip would always be false.
        /// This would cause a lot of classes being temporarily created. So this property can be used to get the Region without
        /// creating an instance at each access. 
        /// And it is urgently recommended for performance issues to always use this property instead!
        /// </summary>
        public Region Region { get; internal set; }

        /// <summary>
        /// Gets the graphics canvas.
        /// </summary>
        public Graphics Graphics { get; internal set; }

        /// <summary>
        /// Gets the GraphicsPlus class for painting if available.
        /// </summary>
        public GraphicsPlus GdiPlus { get; set; }

        /// <summary>
        /// Gets the bounds where the control should be painted in the canvas.
        /// </summary>
        /// <remarks>
        /// This is different to windows PaintEventArgs since fluid controls do not use a windows sub system where
        /// each control is a window and therefore has it's own graphic canvas. 
        /// </remarks>
        /// <example>
        /// use e.Graphics.FillRectangle(brush, e.ControlBounds) instead of e.Graphics.FillRectange(brush, ClientRectangle).
        /// </example>
        public Rectangle ControlBounds { get; internal set; }

        /// <summary>
        /// Gets whether the canvas uses double buffering.
        /// This flag can be used to determine wether to implement own double buffering for a control or to rely on
        /// the double buffering of the parent IFluidContainer control that raised the event.
        /// </summary>
        public bool DoubleBuffered { get; internal set; }

        /// <summary>
        /// Gets the scale factor of the form.
        /// </summary>
        /// <remarks>
        /// Windows mobile scales windows controls depending on the system settings so they have another size
        /// than the size specified in design mode.  This value can be used to paint the control depending on the scale factor.
        /// </remarks>
        public SizeF ScaleFactor { get; internal set; }

        /// <summary>
        /// Scales a value for the x axies depending on the ScaleFactor.
        /// </summary>
        /// <param name="size">The size to scale</param>
        /// <returns>The scaled value.</returns>
        public int ScaleX(int size)
        {
            return (int)(ScaleFactor.Width * size);
        }

        /// <summary>
        /// Scales a value for the y axies depending on the ScaleFactor.
        /// </summary>
        /// <param name="size">The size to scale</param>
        /// <returns>The scaled value.</returns>
        public int ScaleY(int size)
        {
            return (int)(ScaleFactor.Height * size);
        }

        /// <summary>
        /// Scales a size depending on the ScaleFactor.
        /// </summary>
        /// <param name="size">The size to scale</param>
        /// <returns>The scaled value.</returns>
        public Size Scale(Size size)
        {
            return new Size((int)(ScaleFactor.Width * size.Width), (int)(ScaleFactor.Height * size.Height));
        }

        /// <summary>
        /// Scales a Rectangle  depending on the ScaleFactor.
        /// </summary>
        /// <param name="size">The rectangle to scale</param>
        /// <returns>The scaled value.</returns>
        public Rectangle Scale(Rectangle r)
        {
            float w = ScaleFactor.Width;
            float h = ScaleFactor.Height;
            return new Rectangle(
                (int)(w * r.X),
                (int)(h * r.Y),
                (int)(w * r.Width),
                (int)(h * r.Height));
        }

    }
}

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)

About the Author

Thomas Gerber
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

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 12 Jan 2009
Article Copyright 2009 by Thomas Gerber
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid