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 Fluid.Controls;
using System.Drawing;
using PasswordSafe.Xml;
using PasswordSafe.Classes;
using PasswordSafe.Properties;

namespace PasswordSafe
{
    public class Pages : NavigationPanel
    {
        protected override void InitControl()
        {
            base.InitControl();
            BackColor = Color.Empty;

            categoriesPage = new PageControl("Categories");
            passwordsPage = new PageControl("Category");
            detailPage = new PageControl("Details");

            categoriesPage.Control = new CategoriesListBox();
            passwordsPage.Control = new PasswordsListBox();
            detailPage.Control = new DetailListBox();

            Image plusImage = Resources.plus;
            Image minusImage = Resources.minus;

            FluidButton newCategoryButton = new FluidButton(plusImage);
            newCategoryButton.Click += new EventHandler(newCategoryButton_Click);
            categoriesPage.Buttons.Add(newCategoryButton);

            FluidButton newPasswordButton = new FluidButton(plusImage);
            newPasswordButton.Click += new EventHandler(newPasswordButton_Click);
            passwordsPage.Buttons.Add(newPasswordButton);

            FluidButton delPasswordButton = new FluidButton(minusImage);
            delPasswordButton.Click += new EventHandler(delPasswordButton_Click);
            detailPage.Buttons.Add(delPasswordButton);

            FluidButton editCategoryBtn = new FluidButton();
            this.editCategoryBtn = editCategoryBtn;
            editCategoryBtn.Width = 40;
            editCategoryBtn.BackColor = Color.Empty;
            editCategoryBtn.Text = "Edit";
            categoriesPage.BackButton = editCategoryBtn;
            editCategoryBtn.Click += new EventHandler(editCategoryBtn_Click);


            Pages.Add(categoriesPage);
            Pages.Add(passwordsPage);
            Pages.Add(detailPage);

            SelectedIndex = 0;

            categoriesListBox = categoriesPage.Control as CategoriesListBox;
            passwordsListBox = passwordsPage.Control as PasswordsListBox;
            detailListBox = detailPage.Control as DetailListBox;

            categoriesListBox.CategorySelected += new EventHandler(categoriesListBox_CategorySelected);
            passwordsListBox.PasswordSelected += new EventHandler(categoryListBox_PasswordSelected);

        }

        public NotifyList Categories { get { return categoriesListBox.Categories; } }

        public NotifyList Passwords { get { return passwordsListBox.Passwords; } }

        public FluidButton editCategoryBtn;

        void editCategoryBtn_Click(object sender, EventArgs e)
        {
            categoriesListBox.EditMode ^= true;
        }


        PasswordData passwordToRemove;

        void delPasswordButton_Click(object sender, EventArgs e)
        {
            passwordToRemove = passwordsListBox.SelectedPassword;
            if (passwordToRemove != null)
            {
                MessageDialog dialog = new MessageDialog();
                dialog.Message = "Delete Password?";
                dialog.Result += new EventHandler<Fluid.Classes.DialogEventArgs>(dialog_Result);
                dialog.ShowModal(ShowTransition.FromBottom);


            }
        }

        void dialog_Result(object sender, Fluid.Classes.DialogEventArgs e)
        {
            switch (e.Result)
            {
                case System.Windows.Forms.DialogResult.OK:
                    ListBuilder.Instance.DeletePassword(passwordToRemove);
                    UpdatePasswords();
                    this.GoBack();
                    break;
            }
        }


        void newPasswordButton_Click(object sender, EventArgs e)
        {
            NavigateForward();
        }

        public void NavigateForward()
        {
            PasswordCategory category = categoriesListBox.SelectedCategory;
            PasswordData password = ListBuilder.Instance.CreateNewPassword(category);
            selectedPassword = password;
            if (password != null)
            {
                detailPage.Title = "Edit New Password";
                detailListBox.Details = ListBuilder.Instance.GetDetails(password, true);
                Forward();
            }
        }

        void newCategoryButton_Click(object sender, EventArgs e)
        {
            CategoriesPanel cp = CategoriesPanel.Instance;
            cp.UpdateData();
            cp.ShowMaximized(ShowTransition.FromBottom);
        }

        CategoriesListBox categoriesListBox;
        PasswordsListBox passwordsListBox;
        DetailListBox detailListBox;

        void categoryListBox_PasswordSelected(object sender, EventArgs e)
        {
            selectedPassword = passwordsListBox.SelectedPassword;
            UpdateDetails();
        }
       

        private void UpdateDetails()
        {
            PasswordsListBox lb = passwordsListBox;
            PasswordData password = lb.SelectedPassword;
            if (password != null)
            {
                detailPage.Title = password.Name;
                detailListBox.Details = ListBuilder.Instance.GetDetails(password, true);
                Forward();
            }
        }


        void categoriesListBox_CategorySelected(object sender, EventArgs e)
        {
            selectedCategory = categoriesListBox.SelectedCategory;
            if (UpdatePasswords()) Forward();
        }

        private NotifyList GetPasswordList()
        {
            CategoriesListBox lb = categoriesListBox;
            PasswordCategory category = lb.SelectedCategory;

            if (category != null)
            {
                passwordsPage.Title = category.Title;
                return ListBuilder.Instance.GetPasswords(category, false);
            }
            return null;
        }

        private SearchPanel searchPanel;

        public void ShowSearchPanel()
        {
            if (this.SelectedIndex == 1)
            {
                searchPanel = SearchPanel.Instance;
                searchPanel.Show(ShowTransition.FromBottom);
            }
        }


        protected override void BeforeNavigate(int index, bool back)
        {
            if (searchPanel != null) searchPanel.Close(ShowTransition.None);
            base.BeforeNavigate(index, back);
            if (back)
            {
                switch (index)
                {
                    case 0: CheckCategoriesList(); break;
                    case 1: CheckPasswordsList(); break;
                    case 2: CheckDetailsList(); break;
                }
            }
        }


        private void CheckCategoriesList()
        {
            if (passwordsListBox.Passwords.Modified)
            {
                passwordsListBox.Passwords.Modified = false;
                UpdateCategories();
                if (selectedCategory != null) categoriesListBox.SelectedItemIndex = categoriesListBox.Categories.IndexOf(selectedCategory);
                categoriesListBox.EnsureVisible(categoriesListBox.SelectedItemIndex);
            }
        }

        private void UpdateCategories()
        {
        }

        private void CheckDetailsList()
        {

        }

        /// <summary>
        /// The PasswordData that was selected before navigating to the details.
        /// </summary>
        private PasswordData selectedPassword;

        /// <summary>
        /// The PasswordCategory that was selected before navigating to the details.
        /// </summary>
        private PasswordCategory selectedCategory;


        private bool UpdatePasswords()
        {
            CategoriesListBox lb = categoriesListBox;
            PasswordCategory category = lb.SelectedCategory;

            if (category != null)
            {
                passwordsPage.Title = category.Title;
                passwordsListBox.Passwords = ListBuilder.Instance.GetPasswords(category, true);
                passwordsPage.Buttons[0].Visible = !category.ReadOnly;
                return true;
            }
            return false;
        }

        private void CheckPasswordsList()
        {
            if (detailListBox.Details.Modified)
            {
                detailListBox.Details.Modified = false;
                UpdatePasswords();
                if (selectedPassword != null)
                {
                    passwordsListBox.SelectedItemIndex = passwordsListBox.Passwords.IndexOf(selectedPassword);
                    passwordsListBox.EnsureVisible(passwordsListBox.SelectedItemIndex);
                }
            }
        }

        private PageControl categoriesPage;
        private PageControl passwordsPage;
        private PageControl detailPage;

        public bool CategoryEdit
        {
            get { return categoriesListBox.EditMode; }
            set { categoriesListBox.EditMode = value; }
        }

    }
}

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
Web03 | 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