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.Drawing.GdiPlus
{
    public class GraphicsPath : IDisposable
    {
        public GraphicsPath() : this(FillMode.Alternate) { }
        public GraphicsPath(FillMode fillMode)
        {
            nativePath = null;
            lastResult = GdiPlus.GdipCreatePath(fillMode, out nativePath);
        }


        ~GraphicsPath()
        {
            Dispose(true);
        }

        public void Clear()
        {
            GdiPlus.GdipDeletePath(nativePath);
            GdiPlus.GdipCreatePath(FillMode.Alternate, out nativePath);
        }


        private void SetStatus(GpStatus gpStatus)
        {
            if (gpStatus != GpStatus.Ok) throw GdiPlusStatusException.Exception(gpStatus);
        }

        public GraphicsPath Clone()
        {
            GpPath clonepath = null;

            SetStatus(GdiPlus.GdipClonePath(nativePath, out clonepath));

            return new GraphicsPath(clonepath);
        }

        // Reset the path object to empty (and fill mode to FillModeAlternate)

        public void Reset()
        {
            SetStatus(GdiPlus.GdipResetPath(nativePath));
        }

        private FillMode GetFillMode()
        {
            FillMode fillmode = FillMode.Alternate;

            SetStatus(GdiPlus.GdipGetPathFillMode(nativePath, out fillmode));

            return fillmode;
        }

        private void SetFillMode(FillMode fillmode)
        {
            SetStatus(GdiPlus.GdipSetPathFillMode(nativePath, fillmode));
        }

        public FillMode FillMode
        {
            get
            {
                return GetFillMode();
            }
            set
            {
                SetFillMode(value);
            }
        }

        public void StartFigure()
        {
            SetStatus(GdiPlus.GdipStartPathFigure(nativePath));
        }

        public void CloseFigure()
        {
            SetStatus(GdiPlus.GdipClosePathFigure(nativePath));
        }

        public void CloseAllFigures()
        {
            SetStatus(GdiPlus.GdipClosePathFigures(nativePath));
        }


        public void GetLastPoint(out PointF lastPoint)
        {
            SetStatus(GdiPlus.GdipGetPathLastPoint(nativePath,
                                                              out lastPoint));
        }

        public void AddLine(PointF pt1, PointF pt2)
        {
            AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
        }

        public void AddLine(float x1, float y1, float x2, float y2)
        {
            SetStatus(GdiPlus.GdipAddPathLine(nativePath, x1, y1, x2, y2));
        }

        public void AddLines(PointF[] points)
        {
            SetStatus(GdiPlus.GdipAddPathLine2(nativePath, points, points.Length));
        }

        public void AddLine(Point p1, Point p2)
        {
            AddLines(new Point[] { p1, p2 });
        }

        public void AddLine(int x1, int y1, int x2, int y2)
        {
            Point p1 = new Point(x1, y1);
            Point p2 = new Point(x2, y1);
            AddLine(p1, p2);
        }

        public void AddLinesArray(Point[] points)
        {
            SetStatus(GdiPlus.GdipAddPathLine2I(nativePath, points, points.Length));
        }

        public void AddLines(params Point[] points)
        {
            SetStatus(GdiPlus.GdipAddPathLine2I(nativePath, points, points.Length));
        }

        public void AddArc(RectangleF rect, float startAngle, float sweepAngle)
        {
            AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
        }

        public void AddArc(
            float x,
            float y,
            float width,
            float height,
            float startAngle,
            float sweepAngle)
        {
            SetStatus(GdiPlus.GdipAddPathArc(nativePath, x, y, width, height, startAngle, sweepAngle));
        }

        public void AddArc(Rectangle rect,  float startAngle, float sweepAngle)
        {
            AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
        }

        public void AddArc(int x,
                   int y,
                   int width,
                   int height,
                   float startAngle,
                   float sweepAngle)
        {
            SetStatus(GdiPlus.GdipAddPathArcI(nativePath, x,y,width,height,startAngle,sweepAngle));
        }



        public void AddBeziers(PointF[] points)
        {
            int count = points.Length;
            count -= (count - 4) % 3;
            SetStatus(GdiPlus.GdipAddPathBeziers(nativePath, points, count));
        }



        public void AddBeziers(Point[] points)
        {
            SetStatus(GdiPlus.GdipAddPathBeziersI(nativePath, points, points.Length));
        }


        public void AddRectangle(RectangleF rect)
        {
            SetStatus(GdiPlus.GdipAddPathPolygon(nativePath,
                                                              new PointF[]
                                                              {
                                                                  new PointF(rect.X, rect.Y),
                                                                  new PointF(rect.X, rect.Y + rect.Height),
                                                                  new PointF(rect.X + rect.Width, rect.Y + rect.Height),
                                                                  new PointF(rect.X + rect.Width, rect.Y),
                                                              },
                                                              4));
        }

        public void AddRectangles(RectangleF[] rects)
        {
            SetStatus(GdiPlus.GdipAddPathRectangles(nativePath, rects, rects.Length));
        }


        public void AddRectangles(Rectangle[] rects)
        {
            SetStatus(GdiPlus.GdipAddPathRectanglesI(nativePath,  rects, rects.Length));
        }

        public void AddEllipse(RectangleF rect)
        {
            AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
        }

        public void AddEllipse(float x, float y, float width, float height)
        {
            SetStatus(GdiPlus.GdipAddPathEllipse(nativePath, x, y, width, height));
        }

        public void AddEllipse(Rectangle rect)
        {
            AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
        }

        public void AddEllipse(int x, int y, int width, int height)
        {
            SetStatus(GdiPlus.GdipAddPathEllipseI(nativePath, x, y, width, height));
        }

        public void AddPie(RectangleF rect, float startAngle, float sweepAngle)
        {
            AddPie(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
        }

        public void AddPie(float x,
                   float y,
                   float width,
                   float height,
                   float startAngle,
                   float sweepAngle)
        {
            SetStatus(GdiPlus.GdipAddPathPie(nativePath, x, y, width,
                                                        height, startAngle,
                                                        sweepAngle));
        }

        public void AddPie(Rectangle rect,
                   float startAngle,
                   float sweepAngle)
        {
            AddPie(rect.X,
                          rect.Y,
                          rect.Width,
                          rect.Height,
                          startAngle,
                          sweepAngle);
        }

        public void AddPie(int x,
                   int y,
                   int width,
                   int height,
                   float startAngle,
                   float sweepAngle)
        {
            SetStatus(GdiPlus.GdipAddPathPieI(nativePath, x, y, width, height, startAngle, sweepAngle));
        }


        public void AddPath(GraphicsPath addingPath, bool connect)
        {
            GpPath nativePath2 = null;
            if (addingPath != null) nativePath2 = addingPath.nativePath;

            SetStatus(GdiPlus.GdipAddPathPath(nativePath, nativePath2, connect));
        }



        public int GetPointCount()
        {
            int count = 0;

            SetStatus(GdiPlus.GdipGetPointCount(nativePath, out count));

            return count;
        }

        public void GetPathTypes(byte[] types)
        {
            SetStatus(GdiPlus.GdipGetPathTypes(nativePath, types, types.Length));
        }

        public void GetPathPoints(PointF[] points)
        {
            SetStatus(GdiPlus.GdipGetPathPoints(nativePath, points, points.Length));
        }

        public void GetPathPoints(Point[] points)
        {
            SetStatus(GdiPlus.GdipGetPathPointsI(nativePath, points, points.Length));
        }

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

            return lastStatus;
        }

        public bool IsVisible(GraphicsPlus g, PointF point)
        {
            return IsVisible(g, point.X, point.Y);
        }

        public bool IsVisible(GraphicsPlus g, float x, float y)
        {
            bool ret;
            SetStatus(GdiPlus.GdipIsVisiblePathPoint(nativePath, x, y, g.nativeGraphics, out ret));
            return ret;
        }

        public bool IsVisible(GraphicsPlus g, Point point)
        {
            return IsVisible(g, point.X, point.Y);
        }

        public bool IsVisible(GraphicsPlus g, int x, int y)
        {
            bool ret;
            GdiPlus.GdipIsVisiblePathPoint(nativePath, x, y, g.nativeGraphics, out ret);
            return ret;
        }

        public bool IsOutlineVisible(GraphicsPlus g, PointF point, PenPlus pen)
        {
            return IsOutlineVisible(g, point.X, point.Y, pen);
        }

        public bool IsOutlineVisible(GraphicsPlus g, float x, float y, PenPlus pen)
        {
            bool ret;
            SetStatus(GdiPlus.GdipIsOutlineVisiblePathPoint(nativePath, x, y, pen.nativePen, g.nativeGraphics, out ret));
            return ret;
        }

        public bool IsOutlineVisible(GraphicsPlus g, Point point, PenPlus pen)
        {
            return IsOutlineVisible(g, point.X, point.Y, pen);
        }



        public GraphicsPath(GraphicsPath path)
        {
            GpPath clonepath = null;
            SetStatus(GdiPlus.GdipClonePath(path.nativePath, out clonepath));
            SetNativePath(clonepath);
        }

        protected GraphicsPath(GpPath nativePath)
        {
            lastResult = GpStatus.Ok;
            SetNativePath(nativePath);
        }

        void SetNativePath(GpPath nativePath)
        {
            this.nativePath = nativePath;
        }


        internal GpPath nativePath;
        protected GpStatus lastResult;

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
            }
            if ((IntPtr)nativePath != IntPtr.Zero)
            {
                GdiPlus.GdipDeletePath(nativePath);
                nativePath = new GpPath();
            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

    }
}

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)

Share

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