C# Class ComponentFactory.Krypton.Toolkit.CommonHelper

Set of common helper routines for the Toolkit
Afficher le fichier Open project: ComponentFactory/Krypton

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat void

ApplyPadding() public static méthode

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.
Résultat System.Drawing.Rectangle

ApplyPadding() public static méthode

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.
Résultat System.Drawing.Rectangle

ApplyPadding() public static méthode

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.
Résultat System.Drawing.Size

ApplyPadding() public static méthode

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.
Résultat System.Drawing.Size

BlackenColor() public static méthode

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.
Résultat Color

BoolToString() public static méthode

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

ButtonStyleToPalette() public static méthode

Convert from ButtonStyle to PaletteButtonStyle.
public static ButtonStyleToPalette ( ButtonStyle style ) : PaletteButtonStyle
style ButtonStyle ButtonStyle to convert.
Résultat PaletteButtonStyle

CheckContextMenuForShortcut() public static méthode

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.
Résultat bool

ClientMouseMessageToScreenPt() public static méthode

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.
Résultat Point

ColorDepth() public static méthode

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

ColorToBlackAndWhite() public static méthode

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

ColorToString() public static méthode

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

ContentStyleFromLabelStyle() public static méthode

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

CreateInstance() public static méthode

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.
Résultat object

DesignMode() public static méthode

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

DestroyInstance() public static méthode

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.
Résultat void

DoubleToString() public static méthode

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

GetControlWithFocus() public static méthode

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.
Résultat System.Windows.Forms.Control

GetRightToLeftLayout() public static méthode

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.
Résultat bool

GetWindowBorders() public static méthode

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.
Résultat Padding

ImageToXmlCData() public static méthode

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.
Résultat void

IsFormMaximized() public static méthode

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

IsFormMinimized() public static méthode

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

LogOutput() public static méthode

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.
Résultat void

MakeCustomDateFormat() public static méthode

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

MergeColors() public static méthode

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.
Résultat Color

MergeColors() public static méthode

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.
Résultat Color

OrientateDrawBorders() public static méthode

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.
Résultat PaletteDrawBorders

OrientatePadding() public static méthode

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.
Résultat Padding

PaletteTextHintToRenderingHint() public static méthode

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

PerformOperation() public static méthode

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.
Résultat object

PointToString() public static méthode

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

RealClientRectangle() public static méthode

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

RemoveControlFromParent() public static méthode

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

ReverseOrientateDrawBorders() public static méthode

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.
Résultat PaletteDrawBorders

RoundedRectanglePath() public static méthode

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.
Résultat System.Drawing.Drawing2D.GraphicsPath

SeparatorStyleToMetricPadding() public static méthode

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

SizeToString() public static méthode

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

StringToBool() public static méthode

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

StringToColor() public static méthode

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

StringToDouble() public static méthode

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

StringToPoint() public static méthode

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

StringToSize() public static méthode

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

TextToXmlAttribute() public static méthode

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.
Résultat void

TextToXmlAttribute() public static méthode

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.
Résultat void

ValidContextMenuStrip() public static méthode

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.
Résultat bool

ValidKryptonContextMenu() public static méthode

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

VisualToOrientation() public static méthode

Convert from VisualOrientation to Orientation.
public static VisualToOrientation ( VisualOrientation orientation ) : Orientation
orientation VisualOrientation VisualOrientation value.
Résultat Orientation

WhitenColor() public static méthode

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.
Résultat Color

XmlAttributeToText() public static méthode

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.
Résultat string

XmlAttributeToText() public static méthode

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.
Résultat string

XmlCDataToImage() public static méthode

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