using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Reflection; using System.IO; namespace Netron.Diagramming.Core { public class ImagePalette { public const string PropertiesFileName = "PropertiesHS.png"; #region Fields const string mNameSpace = "Netron.Diagramming.Core"; static Image mAlignObjectsBottom = GetImage("AlignObjectsBottomHS.png"); static Image mAlignObjectsCenteredHorizontal = GetImage("AlignObjectsCenteredHorizontalHS.png"); static Image mAlignObjectsCenteredVertical = GetImage("AlignObjectsCenteredVerticalHS.png"); static Image mAlignObjectsLeft = GetImage("AlignObjectsLeftHS.png"); static Image mAlignObjectsRight = GetImage("AlignObjectsRightHS.png"); static Image mAlignObjectsTop = GetImage("AlignObjectsTopHS.png"); static Image mArrow = GetImage("StandardArrow.png"); static Image mBringForward = GetImage("BringForwardHS.png"); static Image mBringToFront = GetImage("BringToFrontHS.png"); static Image mBucketFill = GetImage("BucketFill.bmp", Color.Magenta); static Image mClassShape = GetImage("ClassShape.png"); static Image mCenterAlignment = GetImage( "CenterAlignment.bmp", Color.Silver); static Image mConnection = GetImage("Connection.png"); static Image mDrawEllipse = GetImage("DrawEllipse.png"); static Image mDrawRectangle = GetImage("DrawRectangle.png"); static Image mFont = GetImage("FontDialogHS.png"); static Image mGroup = GetImage("Group.png"); static Image mLeftAlignment = GetImage( "LeftAlignment.bmp", Color.Silver); static Image mMoveConnector = GetImage("ConnectorMover.png"); static Image mNewDocumnet = GetImage("NewDocumentHS.png"); static Image mOutline = GetImage( "PenDraw.bmp", Color.Magenta); static Image mProperties = GetImage("PropertiesHS.png"); static Image mRedo = GetImage("Edit_RedoHS.png"); static Image mRightAlignment = GetImage( "RightAlignment.bmp", Color.Silver); static Image mSendBackwards = GetImage("SendBackwardHS.png"); static Image mSendToBack = GetImage("SendToBackHS.png"); static Image mShortcut = GetImage("Shortcut.bmp"); static Image mUndo = GetImage("Edit_UndoHS.png"); static Image mUngroup = GetImage("Ungroup.png"); #endregion #region Properties // ------------------------------------------------------------------ /// /// Gets the image that represents aligning the bottom edges of /// objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsBottom { get { return mAlignObjectsBottom; } } // ------------------------------------------------------------------ /// /// Gets the image that represents horizontally aligning the center /// of objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsCenteredHorizontal { get { return mAlignObjectsCenteredHorizontal; } } // ------------------------------------------------------------------ /// /// Gets the image that represents vertically aligning the center /// of objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsCenteredVertical { get { return mAlignObjectsCenteredVertical; } } // ------------------------------------------------------------------ /// /// Gets the image that represents aligning the left edge of objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsLeft { get { return mAlignObjectsLeft; } } // ------------------------------------------------------------------ /// /// Gets the image that represents aligning the right edge of objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsRight { get { return mAlignObjectsRight; } } // ------------------------------------------------------------------ /// /// Gets the image that represents aligning the top edge of objects. /// // ------------------------------------------------------------------ public static Image AlignObjectsTop { get { return mAlignObjectsTop; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a arrow (standard cursor arrow). /// // ------------------------------------------------------------------ public static Image Arrow { get { return mArrow; } } // ------------------------------------------------------------------ /// /// Gets the image that represents bringing an object all the way to /// to the front in the z-order. /// // ------------------------------------------------------------------ public static Image BringToFront { get { return mBringToFront; } } // ------------------------------------------------------------------ /// /// Gets the image that represents bring an object forward in the /// z-order. /// // ------------------------------------------------------------------ public static Image BringForward { get { return mBringForward; } } // ------------------------------------------------------------------ /// /// Gets an image of a bucket of color - used to illustrate fill /// color. /// // ------------------------------------------------------------------ public static Image BucketFill { get { return mBucketFill; } } // ------------------------------------------------------------------ /// /// Gets the image that represents text being centered. /// // ------------------------------------------------------------------ public static Image CenterAlignment { get { return mCenterAlignment; } } // ------------------------------------------------------------------ /// /// Gets the class shape image. /// // ------------------------------------------------------------------ public static Image ClassShape { get { return mClassShape; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a connection line. /// // ------------------------------------------------------------------ public static Image Connection { get { return mConnection; } } // ------------------------------------------------------------------ /// /// Gets the image that represents an ellipse. /// // ------------------------------------------------------------------ public static Image DrawEllipse { get { return mDrawEllipse; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a rectangle. /// // ------------------------------------------------------------------ public static Image DrawRectangle { get { return mDrawRectangle; } } // ------------------------------------------------------------------ /// /// Gets the image that represents font. /// // ------------------------------------------------------------------ public static Image Font { get { return mFont; } } // ------------------------------------------------------------------ /// /// Gets the image that represents grouping objects together.. /// // ------------------------------------------------------------------ public static Image Group { get { return mGroup; } } // ------------------------------------------------------------------ /// /// Gets the image that represents text being aligned to the left. /// // ------------------------------------------------------------------ public static Image LeftAlignment { get { return mLeftAlignment; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a connection line. /// // ------------------------------------------------------------------ public static Image MoveConnector { get { return mMoveConnector; } } // ------------------------------------------------------------------ /// /// Gets the image that represents creating a new diagram. /// // ------------------------------------------------------------------ public static Image NewDocument { get { return mNewDocumnet; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a pen drawing a line with a /// color - used to illustrate line color. /// // ------------------------------------------------------------------ public static Image Outline { get { return mOutline; } } // ------------------------------------------------------------------ /// /// Gets the image that represents properties. /// // ------------------------------------------------------------------ public static Image Properties { get { return mProperties; } } // ------------------------------------------------------------------ /// /// Gets the image that represents redoing a command. /// // ------------------------------------------------------------------ public static Image Redo { get { return mRedo; } } // ------------------------------------------------------------------ /// /// Gets the image that represents text being aligned to the right. /// // ------------------------------------------------------------------ public static Image RightAlignment { get { return mRightAlignment; } } // ------------------------------------------------------------------ /// /// Gets the image that represents sending an object back in the /// z-order. /// // ------------------------------------------------------------------ public static Image SendBackwards { get { return mSendBackwards; } } // ------------------------------------------------------------------ /// /// Gets the image that represents sending an object all the way back /// in the z-order. /// // ------------------------------------------------------------------ public static Image SendToBack { get { return mSendToBack; } } // ------------------------------------------------------------------ /// /// Gets the image that represents a shortcut to a file or resource. /// // ------------------------------------------------------------------ public static Image Shortcut { get { return mShortcut; } } // ------------------------------------------------------------------ /// /// Gets the image that represents undoing a command. /// // ------------------------------------------------------------------ public static Image Undo { get { return mUndo; } } // ------------------------------------------------------------------ /// /// Gets the image that represents ungrouping objects. /// // ------------------------------------------------------------------ public static Image Ungroup { get { return mUngroup; } } #endregion #region Helpers // ------------------------------------------------------------------ /// /// Gets the image from the embedded resources for the specified /// filename and sets the image's transparent color to the one /// specified.. /// /// string: The filename from the embedded /// resources. /// Color: The transparent color /// for the image. /// Image // ------------------------------------------------------------------ static Image GetImage(string filename, Color transparentColor) { Bitmap bmp = GetImage(filename); bmp.MakeTransparent(transparentColor); return bmp; } // ------------------------------------------------------------------ /// /// Gets the image from the embedded resources for the specified /// filename. /// /// string: The filename from the embedded /// resources. /// Image // ------------------------------------------------------------------ static Bitmap GetImage(string filename) { return new Bitmap(GetStream(filename)); } // ------------------------------------------------------------------ /// /// Returns a Stream from the manifest resources for the specified /// filename. /// /// string /// Stream // ------------------------------------------------------------------ public static Stream GetStream(string filename) { return Assembly.GetExecutingAssembly().GetManifestResourceStream( mNameSpace + ".Resources." + filename); } #endregion } }