C# Class ComponentFactory.Krypton.Toolkit.CommonHelper

Set of common helper routines for the Toolkit
显示文件 Open project: ComponentFactory/Krypton

Public Methods

Method Description
AddControlToParent ( Control parent, Control c ) : void

Add the provided control to a parent collection.

ApplyPadding ( Orientation orientation, Rectangle rect, Padding padding ) : Rectangle

Return the provided rectangle with orientation specific padding applied.

ApplyPadding ( VisualOrientation orientation, Rectangle rect, Padding padding ) : Rectangle

Return the provided rectangle with visual orientation specific padding applied.

ApplyPadding ( Orientation orientation, Size size, Padding padding ) : Size

Return the provided size with orientation specific padding applied.

ApplyPadding ( VisualOrientation orientation, Size size, Padding padding ) : Size

Return the provided size with visual orientation specific padding applied.

BlackenColor ( Color color1, float percentR, float percentG, float percentB ) : Color

Blacken a provided color by applying per channel percentages.

BoolToString ( bool b ) : string

Convert a Boolean to a culture invariant string value.

ButtonStyleToPalette ( ButtonStyle style ) : PaletteButtonStyle

Convert from ButtonStyle to PaletteButtonStyle.

CheckContextMenuForShortcut ( ContextMenuStrip cms, Message &msg, Keys keyData ) : bool

Check a short cut menu for a matching short and invoke that item if found.

ClientMouseMessageToScreenPt ( Message m ) : Point

Convert a client mouse position inside a windows message into a screen position.

ColorDepth ( ) : int

Get the number of bits used to define the color depth of the display.

ColorToBlackAndWhite ( Color color ) : Color

Convert the color to a black and white color.

ColorToString ( Color c ) : string

Convert a Color to a culture invariant string value.

ContentStyleFromLabelStyle ( LabelStyle style ) : PaletteContentStyle

Find the appropriate content style to match the incoming label style.

CreateInstance ( Type itemType, IDesignerHost host ) : object

Create new instance of specified type within the designer host, if provided.

DesignMode ( Component c ) : bool

Discover if the component is in design mode.

DestroyInstance ( object instance, IDesignerHost host ) : void

Destroy instance of an object using the provided designer host.

DoubleToString ( double d ) : string

Convert a double to a culture invariant string value.

GetControlWithFocus ( Control control ) : Control

Search the hierarchy of the provided control looking for one that has the focus.

GetRightToLeftLayout ( Control control ) : bool

Gets the form level right to left setting.

GetWindowBorders ( CreateParams cp ) : Padding

Gets the size of the borders requested by the real window.

ImageToXmlCData ( XmlWriter xmlWriter, string name, Image image ) : void

Convert a Image to a culture invariant string value.

IsFormMaximized ( Form f ) : bool

Discover if the provided Form is currently maximized.

IsFormMinimized ( Form f ) : bool

Discover if the provided Form is currently minimized.

LogOutput ( string str ) : void

Output some debug data to a log file that exists in same directory as the application.

MakeCustomDateFormat ( string format ) : string

Ensure that a single character format string is treated as a custom format.

MergeColors ( Color color1, float percent1, Color color2, float percent2 ) : Color

Merge two colors together using relative percentages.

MergeColors ( Color color1, float percent1, Color color2, float percent2, Color color3, float percent3 ) : Color

Merge three colors together using relative percentages.

OrientateDrawBorders ( PaletteDrawBorders borders, VisualOrientation orientation ) : PaletteDrawBorders

Apply an orientation to the draw border edges to get a correct value.

OrientatePadding ( VisualOrientation orientation, Padding padding ) : Padding

Modify the incoming padding to reflect the visual orientation.

PaletteTextHintToRenderingHint ( PaletteTextHint hint ) : TextRenderingHint

Convert from palette rendering hint to actual rendering hint.

PerformOperation ( System.Operation op, object parameter ) : object

Perform operation in a worker thread with wait dialog in main thread.

PointToString ( Point s ) : string

Convert a Point to a culture invariant string value.

RealClientRectangle ( IntPtr handle ) : Rectangle

Gets the real client rectangle of the list.

RemoveControlFromParent ( Control c ) : void

Remove the provided control from its parent collection.

ReverseOrientateDrawBorders ( PaletteDrawBorders borders, VisualOrientation orientation ) : PaletteDrawBorders

Apply a reversed orientation so that when orientated again it comes out with the original value.

RoundedRectanglePath ( Rectangle rect, int rounding ) : GraphicsPath

Create a graphics path that describes a rounded rectangle.

SeparatorStyleToMetricPadding ( SeparatorStyle separatorStyle ) : PaletteMetricPadding

Get the correct metric padding for the provided separator style.

SizeToString ( Size s ) : string

Convert a Size to a culture invariant string value.

StringToBool ( string s ) : bool

Convert a culture invariant string value to a Boolean.

StringToColor ( string s ) : Color

Convert a culture invariant string value to a Color.

StringToDouble ( string s ) : double

Convert a culture invariant string value to a double.

StringToPoint ( string s ) : Point

Convert a culture invariant string value to a Point.

StringToSize ( string s ) : Size

Convert a culture invariant string value to a Size.

TextToXmlAttribute ( XmlWriter xmlWriter, string name, string value ) : void

Only persist the provided name/value pair as an Xml attribute if the value is not null or empty.

TextToXmlAttribute ( XmlWriter xmlWriter, string name, string value, string def ) : void

Only persist the provided name/value pair as an Xml attribute if the value is not null/empty and not the default.

ValidContextMenuStrip ( ContextMenuStrip cms ) : bool

Decide if the context menu strip should be displayed.

ValidKryptonContextMenu ( KryptonContextMenu kcm ) : bool

Decide if the KryptonContextMenu should be displayed.

VisualToOrientation ( VisualOrientation orientation ) : Orientation

Convert from VisualOrientation to Orientation.

WhitenColor ( Color color1, float percentR, float percentG, float percentB ) : Color

Whiten a provided color by applying per channel percentages.

XmlAttributeToText ( XmlReader xmlReader, string name ) : string

Read the named attribute value but if no attribute is found then an empty string.

XmlAttributeToText ( XmlReader xmlReader, string name, string def ) : string

Read the named attribute value but if no attribute is found then return the provided default.

XmlCDataToImage ( XmlReader xmlReader ) : Image

Convert a culture invariant string value into an Image.

Private Methods

Method Description
HasABorder ( PaletteDrawBorders borders ) : bool
HasAllBorders ( PaletteDrawBorders borders ) : bool
HasBottomBorder ( PaletteDrawBorders borders ) : bool
HasLeftBorder ( PaletteDrawBorders borders ) : bool
HasNoBorders ( PaletteDrawBorders borders ) : bool
HasOneBorder ( PaletteDrawBorders borders ) : bool
HasRightBorder ( PaletteDrawBorders borders ) : bool
HasTopBorder ( PaletteDrawBorders borders ) : bool
IsOverrideState ( PaletteState state ) : bool
IsOverrideStateExclude ( PaletteState state, PaletteState exclude ) : bool
SwapRectangleSizes ( Rectangle &rect ) : void

Method Details

AddControlToParent() public static method

Add the provided control to a parent collection.
public static AddControlToParent ( Control parent, Control c ) : void
parent System.Windows.Forms.Control Parent control.
c System.Windows.Forms.Control Control to be added.
return void

ApplyPadding() public static method

Return the provided rectangle with orientation specific padding applied.
public static ApplyPadding ( Orientation orientation, Rectangle rect, Padding padding ) : Rectangle
orientation Orientation Orientation to apply padding with.
rect System.Drawing.Rectangle Starting rectangle.
padding Padding Padding to be applied.
return System.Drawing.Rectangle

ApplyPadding() public static method

Return the provided rectangle with visual orientation specific padding applied.
public static ApplyPadding ( VisualOrientation orientation, Rectangle rect, Padding padding ) : Rectangle
orientation VisualOrientation Orientation to apply padding with.
rect System.Drawing.Rectangle Starting rectangle.
padding Padding Padding to be applied.
return System.Drawing.Rectangle

ApplyPadding() public static method

Return the provided size with orientation specific padding applied.
public static ApplyPadding ( Orientation orientation, Size size, Padding padding ) : Size
orientation Orientation Orientation to apply padding with.
size System.Drawing.Size Starting size.
padding Padding Padding to be applied.
return System.Drawing.Size

ApplyPadding() public static method

Return the provided size with visual orientation specific padding applied.
public static ApplyPadding ( VisualOrientation orientation, Size size, Padding padding ) : Size
orientation VisualOrientation Orientation to apply padding with.
size System.Drawing.Size Starting size.
padding Padding Padding to be applied.
return System.Drawing.Size

BlackenColor() public static method

Blacken a provided color by applying per channel percentages.
public static BlackenColor ( Color color1, float percentR, float percentG, float percentB ) : Color
color1 Color Color.
percentR float Percentage of red to keep.
percentG float Percentage of green to keep.
percentB float Percentage of blue to keep.
return Color

BoolToString() public static method

Convert a Boolean to a culture invariant string value.
public static BoolToString ( bool b ) : string
b bool Boolean to convert.
return string

ButtonStyleToPalette() public static method

Convert from ButtonStyle to PaletteButtonStyle.
public static ButtonStyleToPalette ( ButtonStyle style ) : PaletteButtonStyle
style ButtonStyle ButtonStyle to convert.
return PaletteButtonStyle

CheckContextMenuForShortcut() public static method

Check a short cut menu for a matching short and invoke that item if found.
public static CheckContextMenuForShortcut ( ContextMenuStrip cms, Message &msg, Keys keyData ) : bool
cms System.Windows.Forms.ContextMenuStrip ContextMenuStrip instance to check.
msg System.Windows.Forms.Message Windows message that generated check.
keyData Keys Keyboard shortcut to check.
return bool

ClientMouseMessageToScreenPt() public static method

Convert a client mouse position inside a windows message into a screen position.
public static ClientMouseMessageToScreenPt ( Message m ) : Point
m System.Windows.Forms.Message Window message.
return Point

ColorDepth() public static method

Get the number of bits used to define the color depth of the display.
public static ColorDepth ( ) : int
return int

ColorToBlackAndWhite() public static method

Convert the color to a black and white color.
public static ColorToBlackAndWhite ( Color color ) : Color
color Color Base color.
return Color

ColorToString() public static method

Convert a Color to a culture invariant string value.
public static ColorToString ( Color c ) : string
c Color Color to convert.
return string

ContentStyleFromLabelStyle() public static method

Find the appropriate content style to match the incoming label style.
public static ContentStyleFromLabelStyle ( LabelStyle style ) : PaletteContentStyle
style LabelStyle LabelStyle enumeration.
return PaletteContentStyle

CreateInstance() public static method

Create new instance of specified type within the designer host, if provided.
public static CreateInstance ( Type itemType, IDesignerHost host ) : object
itemType System.Type Type of the item to create.
host IDesignerHost Designer host used if provided.
return object

DesignMode() public static method

Discover if the component is in design mode.
public static DesignMode ( Component c ) : bool
c System.ComponentModel.Component Component to test.
return bool

DestroyInstance() public static method

Destroy instance of an object using the provided designer host.
public static DestroyInstance ( object instance, IDesignerHost host ) : void
instance object Reference to item for destroying.
host IDesignerHost Designer host used if provided.
return void

DoubleToString() public static method

Convert a double to a culture invariant string value.
public static DoubleToString ( double d ) : string
d double Double to convert.
return string

GetControlWithFocus() public static method

Search the hierarchy of the provided control looking for one that has the focus.
public static GetControlWithFocus ( Control control ) : Control
control System.Windows.Forms.Control Top of the hierarchy to search.
return System.Windows.Forms.Control

GetRightToLeftLayout() public static method

Gets the form level right to left setting.
public static GetRightToLeftLayout ( Control control ) : bool
control System.Windows.Forms.Control Control for which the setting is needed.
return bool

GetWindowBorders() public static method

Gets the size of the borders requested by the real window.
public static GetWindowBorders ( CreateParams cp ) : Padding
cp System.Windows.Forms.CreateParams Window style parameters.
return Padding

ImageToXmlCData() public static method

Convert a Image to a culture invariant string value.
public static ImageToXmlCData ( XmlWriter xmlWriter, string name, Image image ) : void
xmlWriter System.Xml.XmlWriter Xml writer to save information into.
name string Name of image to save.
image Image Image to persist.
return void

IsFormMaximized() public static method

Discover if the provided Form is currently maximized.
public static IsFormMaximized ( Form f ) : bool
f System.Windows.Forms.Form Form reference.
return bool

IsFormMinimized() public static method

Discover if the provided Form is currently minimized.
public static IsFormMinimized ( Form f ) : bool
f System.Windows.Forms.Form Form reference.
return bool

LogOutput() public static method

Output some debug data to a log file that exists in same directory as the application.
public static LogOutput ( string str ) : void
str string String to output.
return void

MakeCustomDateFormat() public static method

Ensure that a single character format string is treated as a custom format.
public static MakeCustomDateFormat ( string format ) : string
format string Incoming format.
return string

MergeColors() public static method

Merge two colors together using relative percentages.
public static MergeColors ( Color color1, float percent1, Color color2, float percent2 ) : Color
color1 Color First color.
percent1 float Percentage of first color to use.
color2 Color Second color.
percent2 float Percentage of second color to use.
return Color

MergeColors() public static method

Merge three colors together using relative percentages.
public static MergeColors ( Color color1, float percent1, Color color2, float percent2, Color color3, float percent3 ) : Color
color1 Color First color.
percent1 float Percentage of first color to use.
color2 Color Second color.
percent2 float Percentage of second color to use.
color3 Color Third color.
percent3 float Percentage of third color to use.
return Color

OrientateDrawBorders() public static method

Apply an orientation to the draw border edges to get a correct value.
public static OrientateDrawBorders ( PaletteDrawBorders borders, VisualOrientation orientation ) : PaletteDrawBorders
borders PaletteDrawBorders Border edges to be drawn.
orientation VisualOrientation How to adjsut the border edges.
return PaletteDrawBorders

OrientatePadding() public static method

Modify the incoming padding to reflect the visual orientation.
public static OrientatePadding ( VisualOrientation orientation, Padding padding ) : Padding
orientation VisualOrientation Orientation to apply to padding.
padding Padding Padding to be modified.
return Padding

PaletteTextHintToRenderingHint() public static method

Convert from palette rendering hint to actual rendering hint.
public static PaletteTextHintToRenderingHint ( PaletteTextHint hint ) : TextRenderingHint
hint PaletteTextHint Palette rendering hint.
return TextRenderingHint

PerformOperation() public static method

Perform operation in a worker thread with wait dialog in main thread.
public static PerformOperation ( System.Operation op, object parameter ) : object
op System.Operation Delegate of operation to be performed.
parameter object Parameter to be passed into the operation.
return object

PointToString() public static method

Convert a Point to a culture invariant string value.
public static PointToString ( Point s ) : string
s Point Size to convert.
return string

RealClientRectangle() public static method

Gets the real client rectangle of the list.
public static RealClientRectangle ( IntPtr handle ) : Rectangle
handle System.IntPtr Window handle of the control.
return System.Drawing.Rectangle

RemoveControlFromParent() public static method

Remove the provided control from its parent collection.
public static RemoveControlFromParent ( Control c ) : void
c System.Windows.Forms.Control Control to be removed.
return void

ReverseOrientateDrawBorders() public static method

Apply a reversed orientation so that when orientated again it comes out with the original value.
public static ReverseOrientateDrawBorders ( PaletteDrawBorders borders, VisualOrientation orientation ) : PaletteDrawBorders
borders PaletteDrawBorders Border edges to be drawn.
orientation VisualOrientation How to adjsut the border edges.
return PaletteDrawBorders

RoundedRectanglePath() public static method

Create a graphics path that describes a rounded rectangle.
public static RoundedRectanglePath ( Rectangle rect, int rounding ) : GraphicsPath
rect System.Drawing.Rectangle Rectangle to become rounded.
rounding int The rounding factor to apply.
return System.Drawing.Drawing2D.GraphicsPath

SeparatorStyleToMetricPadding() public static method

Get the correct metric padding for the provided separator style.
public static SeparatorStyleToMetricPadding ( SeparatorStyle separatorStyle ) : PaletteMetricPadding
separatorStyle SeparatorStyle Separator style.
return PaletteMetricPadding

SizeToString() public static method

Convert a Size to a culture invariant string value.
public static SizeToString ( Size s ) : string
s System.Drawing.Size Size to convert.
return string

StringToBool() public static method

Convert a culture invariant string value to a Boolean.
public static StringToBool ( string s ) : bool
s string String to convert.
return bool

StringToColor() public static method

Convert a culture invariant string value to a Color.
public static StringToColor ( string s ) : Color
s string String to convert.
return Color

StringToDouble() public static method

Convert a culture invariant string value to a double.
public static StringToDouble ( string s ) : double
s string String to convert.
return double

StringToPoint() public static method

Convert a culture invariant string value to a Point.
public static StringToPoint ( string s ) : Point
s string String to convert.
return Point

StringToSize() public static method

Convert a culture invariant string value to a Size.
public static StringToSize ( string s ) : Size
s string String to convert.
return System.Drawing.Size

TextToXmlAttribute() public static method

Only persist the provided name/value pair as an Xml attribute if the value is not null or empty.
public static TextToXmlAttribute ( XmlWriter xmlWriter, string name, string value ) : void
xmlWriter System.Xml.XmlWriter Xml writer to save information into.
name string Attribute name.
value string Attribute value.
return void

TextToXmlAttribute() public static method

Only persist the provided name/value pair as an Xml attribute if the value is not null/empty and not the default.
public static TextToXmlAttribute ( XmlWriter xmlWriter, string name, string value, string def ) : void
xmlWriter System.Xml.XmlWriter Xml writer to save information into.
name string Attribute name.
value string Attribute value.
def string Default value.
return void

ValidContextMenuStrip() public static method

Decide if the context menu strip should be displayed.
public static ValidContextMenuStrip ( ContextMenuStrip cms ) : bool
cms System.Windows.Forms.ContextMenuStrip Reference to context menu strip.
return bool

ValidKryptonContextMenu() public static method

Decide if the KryptonContextMenu should be displayed.
public static ValidKryptonContextMenu ( KryptonContextMenu kcm ) : bool
kcm KryptonContextMenu Reference to context menu strip.
return bool

VisualToOrientation() public static method

Convert from VisualOrientation to Orientation.
public static VisualToOrientation ( VisualOrientation orientation ) : Orientation
orientation VisualOrientation VisualOrientation value.
return Orientation

WhitenColor() public static method

Whiten a provided color by applying per channel percentages.
public static WhitenColor ( Color color1, float percentR, float percentG, float percentB ) : Color
color1 Color Color.
percentR float Percentage of red to keep.
percentG float Percentage of green to keep.
percentB float Percentage of blue to keep.
return Color

XmlAttributeToText() public static method

Read the named attribute value but if no attribute is found then an empty string.
public static XmlAttributeToText ( XmlReader xmlReader, string name ) : string
xmlReader XmlReader Xml reader to load information from.
name string Attribute name.
return string

XmlAttributeToText() public static method

Read the named attribute value but if no attribute is found then return the provided default.
public static XmlAttributeToText ( XmlReader xmlReader, string name, string def ) : string
xmlReader XmlReader Xml reader to load information from.
name string Attribute name.
def string Default value.
return string

XmlCDataToImage() public static method

Convert a culture invariant string value into an Image.
public static XmlCDataToImage ( XmlReader xmlReader ) : Image
xmlReader XmlReader Xml reader to load information from.
return Image