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;

namespace Fluid.Controls
{
    // TODO: Make System.ComponentModel.Generic.BindingList derived!!
    public class FluidControlCollection : IList<FluidControl>
    {
        public FluidControlCollection(IContainer container)
            : base()
        {
            this.container = container;
        }

        private IContainer container;

        private List<FluidControl> controls = new List<FluidControl>();

        /// <summary>
        /// Occurs when the collection has changed.
        /// </summary>
        protected virtual void OnNotifyChanged()
        {
            if (NotifyChanged != null) NotifyChanged(this, EventArgs.Empty);
        }

        /// <summary>
        /// Notify that something has happened to the collection or it's ITouchControl properties.
        /// </summary>
        public void NotifyChange()
        {
            OnNotifyChanged();
        }

        /// <summary>
        /// Occurs when the collection has changed.
        /// </summary>
        public event EventHandler NotifyChanged;

        #region ICollection<ISmartControl> Members

        public void Add(FluidControl item)
        {
            controls.Add(item);
            item.Container = container;
            OnControlAdded(item);
            OnNotifyChanged();
        }

        public void Insert(int index, FluidControl control)
        {
            controls.Insert(index, control);
            control.Container = container;
            OnControlAdded(control);
            OnNotifyChanged();
        }

        public event EventHandler<ControlEventArgs> ControlAdded;


        private void OnControlAdded(FluidControl control)
        {
            Size size = container.Bounds.Size;
            control.Container = container;
            control.Scale(container.ScaleFactor);
            control.OnControlAdded(container);
            INotifyControlAdded notify = container as INotifyControlAdded;
            if (notify != null) notify.ControlAdded(control);
            if (ControlAdded != null)
            {
                ControlEventArgs e = new ControlEventArgs(control);
                ControlAdded(this, e);
            }
        }

        private void OnControlRemoved(FluidControl control)
        {
            SizeF f = container.ScaleFactor;
            SizeF scale = new SizeF(1f / f.Width, 1f / f.Height);
            control.Container = null;
            control.Scale(scale);
        }

        private void RemoveControls()
        {
            SizeF f = container.ScaleFactor;
            SizeF scale = new SizeF(1f / f.Width, 1f / f.Height);
            foreach (FluidControl c in this)
            {
                c.Scale(scale);
                c.Container = null;
            }
        }

        public void Clear()
        {
            RemoveControls();
            controls.Clear();
            OnNotifyChanged();
        }

        public bool Contains(FluidControl item)
        {
            return controls.Contains(item);
        }

        public void CopyTo(FluidControl[] array, int arrayIndex)
        {
            controls.CopyTo(array, arrayIndex);
            OnNotifyChanged();
        }

        public int Count
        {
            get { return controls.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(FluidControl control)
        {
            OnControlRemoved(control);
            bool result = controls.Remove(control);
            if (result) OnNotifyChanged();
            return result;
        }

        #endregion

        #region IEnumerable<ISmartControl> Members

        public IEnumerator<FluidControl> GetEnumerator()
        {
            return controls.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return controls.GetEnumerator();
        }

        #endregion

        internal int IndexOf(FluidControl control)
        {
            return controls.IndexOf(control);
        }

        #region IList<ISmartControl> Members

        int IList<FluidControl>.IndexOf(FluidControl item)
        {
            return controls.IndexOf(item);
        }



        public void RemoveAt(int index)
        {
            FluidControl c = this[index];
            OnControlRemoved(c);
            controls.RemoveAt(index);
        }

        public FluidControl this[int index]
        {
            get { return controls[index]; }
            set { controls[index] = value; }
        }

        #endregion
    }
}

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
Web01 | 2.8.140709.1 | Last Updated 12 Jan 2009
Article Copyright 2009 by Thomas Gerber
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid