Click here to Skip to main content
15,881,139 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 158.7K   3.1K   139  
A password safe with a touch screen UI introducing Fluid Controls.
using System;
using System.Collections.Generic;
using System.Text;
using Color = System.Drawing.Color;

namespace Fluid.Drawing.GdiPlus
{
    public class ImageAttributesPlus
    {
        public ImageAttributesPlus()
        {
            nativeImageAttr = new GpImageAttributes();
            lastResult = GdiPlus.GdipCreateImageAttributes(out nativeImageAttr);
        }

        ~ImageAttributesPlus()
        {
            GdiPlus.GdipDisposeImageAttributes(nativeImageAttr);
        }

        ImageAttributesPlus Clone()
        {
            GpImageAttributes clone;

            SetStatus(GdiPlus.GdipCloneImageAttributes(
                                                nativeImageAttr,
                                                out clone));

            return new ImageAttributesPlus(clone, lastResult);
        }

        GpStatus SetToIdentity(ColorAdjustType type)
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesToIdentity(nativeImageAttr, type));
        }

        GpStatus Reset(ColorAdjustType type )
        {
            return SetStatus(GdiPlus.GdipResetImageAttributes(nativeImageAttr,type));
        }

        //Status
        //SetColorMatrix(
        //     ColorMatrix colorMatrix,
        //    ColorMatrixFlags mode = ColorMatrixFlagsDefault,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesColorMatrix(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        colorMatrix,
        //                                        null,
        //                                        mode));
        //}

        //Status ClearColorMatrix(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesColorMatrix(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        null,
        //                                        null,
        //                                        ColorMatrixFlagsDefault));
        //}

        //Status
        //SetColorMatrices(
        //     ColorMatrix *colorMatrix,
        //     ColorMatrix *grayMatrix,
        //    ColorMatrixFlags mode = ColorMatrixFlagsDefault,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesColorMatrix(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        colorMatrix,
        //                                        grayMatrix,
        //                                        mode));
        //}

        //Status ClearColorMatrices(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesColorMatrix(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        null,
        //                                        null,
        //                                        ColorMatrixFlagsDefault));
        //}

        //Status SetThreshold(
        //    float threshold,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesThreshold(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        threshold));
        //}

        //Status ClearThreshold(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesThreshold(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        0.0));
        //}

        public GpStatus SetGamma( float gamma,ColorAdjustType type)
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesGamma(
                                                nativeImageAttr,
                                                type,
                                                true,
                                                gamma));
        }

        public GpStatus ClearGamma(
            ColorAdjustType type
            )
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesGamma(
                                                nativeImageAttr,
                                                type,
                                                false,
                                                0.0f));
        }

        public GpStatus SetNoOp(
            ColorAdjustType type
            )
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesNoOp(
                                                nativeImageAttr,
                                                type,
                                                true));
        }

        public GpStatus ClearNoOp(
            ColorAdjustType type
            )
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesNoOp(
                                                nativeImageAttr,
                                                type,
                                                false));
        }

        public GpStatus SetColorKey(
             Color colorLow,
             Color colorHigh,
            ColorAdjustType type
            )
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesColorKeys(
                                                nativeImageAttr,
                                                type,
                                                true,
                                                colorLow.ToArgb(),
                                                colorHigh.ToArgb()));
        }

        public GpStatus ClearColorKey(
            ColorAdjustType type
            )
        {
            return SetStatus(GdiPlus.GdipSetImageAttributesColorKeys(
                                                nativeImageAttr,
                                                type,
                                                false,
                                                0,
                                                0));
        }

        //Status SetOutputChannel(
        //    ColorChannelFlags channelFlags,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesOutputChannel(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        channelFlags));
        //}

        //Status ClearOutputChannel(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesOutputChannel(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        ColorChannelFlagsLast));
        //}

        //Status SetOutputChannelColorProfile(
        //     WCHAR *colorProfileFilename,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesOutputChannelColorProfile(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        colorProfileFilename));
        //}

        //Status ClearOutputChannelColorProfile(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesOutputChannelColorProfile(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        null));
        //}

        //Status SetRemapTable(
        //    UINT mapSize, 
        //     ColorMap *map,
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesRemapTable(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        true,
        //                                        mapSize,
        //                                        map));
        //}

        //Status ClearRemapTable(
        //    ColorAdjustType type = ColorAdjustTypeDefault
        //    )
        //{
        //    return SetStatus(NativeMethods.GdipSetImageAttributesRemapTable(
        //                                        nativeImageAttr,
        //                                        type,
        //                                        false,
        //                                        0,
        //                                        null));
        //}

        //Status SetBrushRemapTable(UINT mapSize, 
        //                           ColorMap *map)
        //{
        //    return this.SetRemapTable(mapSize, map, ColorAdjustTypeBrush);
        //}

        //Status ClearBrushRemapTable()
        //{
        //    return this.ClearRemapTable(ColorAdjustTypeBrush);
        //}

        //Status SetWrapMode(WrapMode wrap, 
        //                    Color& color = Color(), 
        //                   BOOL clamp = false) 
        //{
        //    ARGB argb = color.ToArgb();

        //    return SetStatus(NativeMethods.GdipSetImageAttributesWrapMode(
        //                       nativeImageAttr, wrap, argb, clamp));
        //}

        //// The flags of the palette are ignored.

        //Status GetAdjustedPalette(OUT ColorPalette* colorPalette,
        //                          ColorAdjustType colorAdjustType)  
        //{
        //    return SetStatus(NativeMethods.GdipGetImageAttributesAdjustedPalette(
        //                       nativeImageAttr, colorPalette, colorAdjustType));
        //}

        GpStatus GetLastStatus()
        {
            GpStatus lastStatus = lastResult;
            lastResult = GpStatus.Ok;

            return lastStatus;
        }



        internal ImageAttributesPlus(GpImageAttributes imageAttr, GpStatus status)
        {
            SetNativeImageAttr(imageAttr);
            lastResult = status;
        }

        internal void SetNativeImageAttr(GpImageAttributes nativeImageAttr)
        {
            this.nativeImageAttr = nativeImageAttr;
        }

        GpStatus SetStatus(GpStatus status)
        {
            if (status != GpStatus.Ok)
                return (lastResult = status);
            else
                return status;
        }


        internal GpImageAttributes nativeImageAttr;
        private GpStatus lastResult;
    }
}

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