本文整理汇总了C#中RightToLeft类的典型用法代码示例。如果您正苦于以下问题:C# RightToLeft类的具体用法?C# RightToLeft怎么用?C# RightToLeft使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RightToLeft类属于命名空间,在下文中一共展示了RightToLeft类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawBackgroundImage
public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (backgroundImageLayout == ImageLayout.Tile)
{
using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
{
if (scrollOffset != Point.Empty)
{
Matrix transform = brush.Transform;
transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
brush.Transform = transform;
}
g.FillRectangle(brush, clipRect);
return;
}
}
Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
{
rect.X += clipRect.Width - rect.Width;
}
using (SolidBrush brush2 = new SolidBrush(backColor))
{
g.FillRectangle(brush2, clipRect);
}
if (!clipRect.Contains(rect))
{
if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
{
rect.Intersect(clipRect);
g.DrawImage(backgroundImage, rect);
}
else if (backgroundImageLayout == ImageLayout.None)
{
rect.Offset(clipRect.Location);
Rectangle destRect = rect;
destRect.Intersect(clipRect);
Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
}
else
{
Rectangle rectangle4 = rect;
rectangle4.Intersect(clipRect);
Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
}
}
else
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
imageAttr.Dispose();
}
}
开发者ID:zhushengwen,项目名称:example-zhushengwen,代码行数:60,代码来源:CmbControlPaintEx.cs
示例2: CommonLayout
internal static LayoutOptions CommonLayout(Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
{
return new LayoutOptions {
client = LayoutUtils.DeflateRect(clientRectangle, padding), padding = padding, growBorderBy1PxWhenDefault = true, isDefault = isDefault, borderSize = 2, paddingSize = 0, maxFocus = true, focusOddEvenFixup = false, font = font, text = text, imageSize = Size.Empty, checkSize = 0, checkPaddingSize = 0, checkAlign = ContentAlignment.TopLeft, imageAlign = ContentAlignment.MiddleCenter, textAlign = textAlign,
hintTextUp = false, shadowedText = !enabled, layoutRTL = RightToLeft.Yes == rtl, textImageRelation = TextImageRelation.Overlay, useCompatibleTextRendering = false
};
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ButtonBaseAdapter.cs
示例3: TextEditBase
/// <summary>
/// Creates a new instance of TextEditBase class.
/// </summary>
public TextEditBase()
{
TextBox = new TextBox();
Width = 120;
Height = 20;
rtl = RightToLeft.Yes;
base.BackColor = SystemColors.Window;
TextBox.RightToLeft = rtl;
TextBox.BorderStyle = BorderStyle.None;
TextBox.AutoSize = false;
TextBox.MouseEnter += TextBox_MouseEnter;
TextBox.MouseLeave += TextBox_MouseLeave;
TextBox.GotFocus += TextBox_GotFocus;
TextBox.LostFocus += TextBox_LostFocus;
TextBox.SizeChanged += TextBox_SizeChanged;
TextBox.TextChanged += TextBox_TextChanged;
TextBox.MouseUp += InvokeMouseUp;
TextBox.MouseDown += InvokeMouseDown;
TextBox.MouseEnter += InvokeMouseEnter;
TextBox.MouseHover += InvokeMouseHover;
TextBox.MouseLeave += InvokeMouseLeave;
TextBox.MouseMove += InvokeMouseMove;
TextBox.KeyDown += InvokeKeyDown;
TextBox.KeyPress += InvokeKeyPress;
TextBox.KeyUp += InvokeKeyUp;
TextBox.Click += InvokeClick;
TextBox.DoubleClick += InvokeDoubleClick;
ThemeChanged += OnThemeChanged;
Controls.Add(TextBox);
}
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:36,代码来源:TextEditBase.cs
示例4: DropDownButtonBounds
/*
* DropDownButtonBounds
*/
/// <summary>
/// </summary>
/// <param name="clientRectangle"></param>
/// <param name="rightToLeft"></param>
/// <returns></returns>
public static Rectangle DropDownButtonBounds(Rectangle clientRectangle, RightToLeft rightToLeft)
{
Rectangle buttonBounds = Rectangle.Empty;
if (rightToLeft == RightToLeft.No)
{
buttonBounds = new Rectangle(
clientRectangle.Right - SystemInformation.VerticalScrollBarWidth,
clientRectangle.Top,
SystemInformation.VerticalScrollBarWidth,
clientRectangle.Height
);
}
else
{
buttonBounds = new Rectangle(
clientRectangle.Left,
clientRectangle.Top,
SystemInformation.VerticalScrollBarWidth,
clientRectangle.Height
);
}
return buttonBounds;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:34,代码来源:NuGenControlPaint.Control.cs
示例5: GetContentRectangle
/// <summary>
/// </summary>
public Rectangle GetContentRectangle(
Rectangle clientRectangle
, Rectangle arrowRectangle
, RightToLeft rightToLeft
)
{
Rectangle contentRectangle;
if (rightToLeft == RightToLeft.Yes)
{
contentRectangle = Rectangle.FromLTRB(
arrowRectangle.Right
, clientRectangle.Top
, clientRectangle.Right
, clientRectangle.Bottom
);
}
else
{
contentRectangle = Rectangle.FromLTRB(
clientRectangle.Left
, clientRectangle.Top
, arrowRectangle.Left
, clientRectangle.Bottom
);
}
return Rectangle.Inflate(contentRectangle, -6, -6);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:31,代码来源:NuGenSmoothSplitButtonLayoutManager.cs
示例6: ViewLayoutViewport
/// <summary>
/// Initialize a new instance of the ViewLayoutViewport class.
/// </summary>
/// <param name="paletteMetrics">Palette source for metrics.</param>
/// <param name="metricPadding">Metric used to get view padding.</param>
/// <param name="metricOvers">Metric used to get overposition.</param>
/// <param name="orientation">Orientation for the viewport children.</param>
/// <param name="alignment">Alignment of the children within the viewport.</param>
/// <param name="animateChange">Animate changes in the viewport.</param>
public ViewLayoutViewport(IPaletteMetric paletteMetrics,
PaletteMetricPadding metricPadding,
PaletteMetricInt metricOvers,
VisualOrientation orientation,
RelativePositionAlign alignment,
bool animateChange)
{
// Remember the source information
_paletteMetrics = paletteMetrics;
_metricPadding = metricPadding;
_metricOvers = metricOvers;
_orientation = orientation;
_alignment = alignment;
_animateChange = animateChange;
// Default other state
_offset = Point.Empty;
_extent = Size.Empty;
_rightToLeft = RightToLeft.No;
_rightToLeftLayout = false;
_fillSpace = false;
_counterAlignment = RelativePositionAlign.Far;
// Create a timer for animation effect
_animationTimer = new Timer();
_animationTimer.Interval = _animationInterval;
_animationTimer.Tick += new EventHandler(OnAnimationTick);
}
开发者ID:Cocotteseb,项目名称:Krypton,代码行数:37,代码来源:ViewLayoutViewport.cs
示例7: GetArrowRectangle
/// <summary>
/// </summary>
public Rectangle GetArrowRectangle(Rectangle clientRectangle, RightToLeft rightToLeft)
{
Point arrowLocation = new Point(clientRectangle.Left, clientRectangle.Top);
Size arrowSize = new Size(28, clientRectangle.Height);
if (rightToLeft == RightToLeft.No)
{
arrowLocation.X = clientRectangle.Right - arrowSize.Width;
}
return Rectangle.Inflate(new Rectangle(arrowLocation, arrowSize), -3, -6);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:NuGenSmoothSplitButtonLayoutManager.cs
示例8: PaintPopupLayout
internal static ButtonBaseAdapter.LayoutOptions PaintPopupLayout(Graphics g, bool show3D, int checkSize, Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
{
ButtonBaseAdapter.LayoutOptions options = ButtonBaseAdapter.CommonLayout(clientRectangle, padding, isDefault, font, text, enabled, textAlign, rtl);
options.shadowedText = false;
if (show3D)
{
options.checkSize = (int) ((checkSize * CheckableControlBaseAdapter.GetDpiScaleRatio(g)) + 1f);
return options;
}
options.checkSize = (int) (checkSize * CheckableControlBaseAdapter.GetDpiScaleRatio(g));
options.checkPaddingSize = 1;
return options;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:CheckBoxPopupAdapter.cs
示例9: Language
/// <summary>
/// Set default values of Language
/// </summary>
public Language()
{
_langCode = "en";
_langName = "English";
_author = "Dương Diệu Pháp";
_description = "English";
_minVersion = "3.5.0.0";
_fileName = "";
_isRightToLeftLayout = RightToLeft.No;
_Items = new LanguageItem<string, string>();
InitDefaultLanguageDictionary();
}
开发者ID:d2phap,项目名称:ImageGlass,代码行数:16,代码来源:Language.cs
示例10: GetGridPanelBounds
/// <summary>
/// </summary>
public Rectangle GetGridPanelBounds(Rectangle clientRectangle, RightToLeft rightToLeft)
{
if (rightToLeft == RightToLeft.Yes)
{
return new Rectangle(
clientRectangle.Left
, clientRectangle.Top + 1
, clientRectangle.Width - 1
, clientRectangle.Height - 1
);
}
return new Rectangle(
clientRectangle.Left + 1
, clientRectangle.Top + 1
, clientRectangle.Width - 1
, clientRectangle.Height - 1
);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:21,代码来源:NuGenSmoothThumbnailLayoutManager.cs
示例11: RTLContentAlignment
/*
* RTLContentAlignment
*/
/// <summary>
/// Converts the specified <see cref="ContentAlignment"/> to its right-to-left representation.
/// </summary>
/// <returns>
/// The specified <see cref="ContentAlignment"/> is converted only if right-to-left layout is specified;
/// otherwise, it is left as is.
/// </returns>
public static ContentAlignment RTLContentAlignment(ContentAlignment contentAlignment, RightToLeft rightToLeft)
{
if (rightToLeft == RightToLeft.Yes)
{
switch (contentAlignment)
{
case ContentAlignment.BottomLeft: return ContentAlignment.BottomRight;
case ContentAlignment.BottomRight: return ContentAlignment.BottomLeft;
case ContentAlignment.MiddleLeft: return ContentAlignment.MiddleRight;
case ContentAlignment.MiddleRight: return ContentAlignment.MiddleLeft;
case ContentAlignment.TopLeft: return ContentAlignment.TopRight;
case ContentAlignment.TopRight: return ContentAlignment.TopLeft;
default: return contentAlignment;
}
}
return contentAlignment;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:NuGenControlPaint.Control.cs
示例12: RightToLeftIndex
private static int RightToLeftIndex(RightToLeft rtl, PaletteRelativeAlign align)
{
switch (align)
{
case PaletteRelativeAlign.Near:
return (rtl == RightToLeft.Yes ? 2 : 0);
case PaletteRelativeAlign.Center:
return 1;
case PaletteRelativeAlign.Far:
return (rtl == RightToLeft.Yes ? 0 : 2);
default:
// Should never happen!
Debug.Assert(false);
throw new ArgumentOutOfRangeException("align");
}
}
开发者ID:Cocotteseb,项目名称:Krypton,代码行数:16,代码来源:RenderStandard.cs
示例13: DrawImagesAndText
/// <summary>
/// Draws the text and image objects at the specified location.
/// </summary>
/// <param name="graphics">The Graphics to draw on.</param>
/// <param name="captionRectangle">The drawing rectangle on a panel's caption.</param>
/// <param name="iSpacing">The spacing on a panel's caption</param>
/// <param name="imageRectangle">The rectangle of an image displayed on a panel's caption.</param>
/// <param name="image">The image that is displayed on a panel's caption.</param>
/// <param name="rightToLeft">A value indicating whether control's elements are aligned to support locales using right-to-left fonts.</param>
/// <param name="bDrawBackground">A value indicating whether the background of the images is displayed</param>
/// <param name="bIsClosable">A value indicating whether the xpanderpanel is closable</param>
/// <param name="bShowCloseIcon">A value indicating whether the close image is displayed</param>
/// <param name="imageClosePanel">The close image that is displayed on a panel's caption.</param>
/// <param name="foreColorCloseIcon">The foreground color of the close image that is displayed on a panel's caption.</param>
/// <param name="rectangleImageClosePanel">The rectangle of the close image that is displayed on a panel's caption.</param>
/// <param name="bShowExpandIcon">A value indicating whether the expand image is displayed</param>
/// <param name="imageExandPanel">The expand image that is displayed on a panel's caption.</param>
/// <param name="foreColorExpandIcon">The foreground color of the expand image displayed by this caption.</param>
/// <param name="rectangleImageExandPanel">the rectangle of the expand image displayed by this caption.</param>
/// <param name="fontCaption">The font of the text displayed on a panel's caption.</param>
/// <param name="captionForeColor">The foreground color of the text displayed on a panel's caption.</param>
/// <param name="strCaptionText">The text which is associated with this caption.</param>
protected static void DrawImagesAndText(
Graphics graphics,
Rectangle captionRectangle,
int iSpacing,
Rectangle imageRectangle,
Image image,
RightToLeft rightToLeft,
bool bDrawBackground,
bool bIsClosable,
bool bShowCloseIcon,
Image imageClosePanel,
Color foreColorCloseIcon,
ref Rectangle rectangleImageClosePanel,
bool bShowExpandIcon,
Image imageExandPanel,
Color foreColorExpandIcon,
ref Rectangle rectangleImageExandPanel,
Font fontCaption,
Color captionForeColor,
string strCaptionText)
{
//DrawImages
int iTextPositionX1 = iSpacing;
int iTextPositionX2 = captionRectangle.Right - iSpacing;
imageRectangle.Y = (captionRectangle.Height - imageRectangle.Height) / 2;
if (rightToLeft == RightToLeft.No)
{
if (image != null)
{
DrawImage(graphics, image, imageRectangle);
iTextPositionX1 += imageRectangle.Width + iSpacing;
iTextPositionX2 -= iTextPositionX1;
}
}
else
{
if ((bShowCloseIcon == true) && (imageClosePanel != null))
{
rectangleImageClosePanel = imageRectangle;
rectangleImageClosePanel.X = imageRectangle.X;
if (bIsClosable == true)
{
DrawChevron(graphics, imageClosePanel, rectangleImageClosePanel, foreColorCloseIcon, bDrawBackground, imageRectangle.Y);
}
iTextPositionX1 = rectangleImageClosePanel.X + rectangleImageClosePanel.Width;
}
if ((bShowExpandIcon == true) && (imageExandPanel != null))
{
rectangleImageExandPanel = imageRectangle;
rectangleImageExandPanel.X = imageRectangle.X;
if ((bShowCloseIcon == true) && (imageClosePanel != null))
{
rectangleImageExandPanel.X = iTextPositionX1 + (iSpacing / 2);
}
DrawChevron(graphics, imageExandPanel, rectangleImageExandPanel, foreColorExpandIcon, bDrawBackground, imageRectangle.Y);
iTextPositionX1 = rectangleImageExandPanel.X + rectangleImageExandPanel.Width;
}
}
//
// Draw Caption text
//
Rectangle textRectangle = captionRectangle;
textRectangle.X = iTextPositionX1;
textRectangle.Width -= iTextPositionX1 + iSpacing;
if (rightToLeft == RightToLeft.No)
{
if ((bShowCloseIcon == true) && (imageClosePanel != null))
{
rectangleImageClosePanel = imageRectangle;
rectangleImageClosePanel.X = captionRectangle.Right - iSpacing - imageRectangle.Width;
if (bIsClosable == true)
{
DrawChevron(graphics, imageClosePanel, rectangleImageClosePanel, foreColorCloseIcon, bDrawBackground, imageRectangle.Y);
}
iTextPositionX2 = rectangleImageClosePanel.X;
}
//.........这里部分代码省略.........
开发者ID:wuyanqing,项目名称:wc001,代码行数:101,代码来源:BasePanel.cs
示例14: RTLTranslateDropDownDirection
private ToolStripDropDownDirection RTLTranslateDropDownDirection(ToolStripDropDownDirection dropDownDirection, RightToLeft rightToLeft) {
switch (dropDownDirection) {
case ToolStripDropDownDirection.AboveLeft:
return ToolStripDropDownDirection.AboveRight;
case ToolStripDropDownDirection.AboveRight:
return ToolStripDropDownDirection.AboveLeft;
case ToolStripDropDownDirection.BelowRight:
return ToolStripDropDownDirection.BelowLeft;
case ToolStripDropDownDirection.BelowLeft:
return ToolStripDropDownDirection.BelowRight;
case ToolStripDropDownDirection.Right:
return ToolStripDropDownDirection.Left;
case ToolStripDropDownDirection.Left:
return ToolStripDropDownDirection.Right;
}
Debug.Fail("Why are we here");
// dont expect it to come to this but just in case here are the real defaults.
if (IsOnDropDown) {
return (rightToLeft == RightToLeft.Yes) ? ToolStripDropDownDirection.Left : ToolStripDropDownDirection.Right;
}
else {
return (rightToLeft == RightToLeft.Yes) ? ToolStripDropDownDirection.BelowLeft : ToolStripDropDownDirection.BelowRight;
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:27,代码来源:ToolStripDropDownItem.cs
示例15: FlatComboAdapter
/// <summary>
/// Constructeur
/// </summary>
/// <param name="comboBox">référence sur la combo à peindre</param>
/// <param name="smallButton">si true, dessiner un petit bouton pour le drop-down</param>
public FlatComboAdapter( ComboBox comboBox, bool smallButton ) {
this.comboBox = comboBox;
clientRect = comboBox.ClientRectangle;
origRightToLeft = comboBox.RightToLeft;
int dropDownButtonWidth = System.Windows.Forms.SystemInformation.HorizontalScrollBarArrowWidth;
outerBorder = new Rectangle( clientRect.Location, new Size( clientRect.Width - 1, clientRect.Height - 1 ) );
innerBorder = new Rectangle( outerBorder.X + 1, outerBorder.Y + 1, outerBorder.Width - dropDownButtonWidth - 2, outerBorder.Height - 2 );
innerInnerBorder = new Rectangle( innerBorder.X + 1, innerBorder.Y + 1, innerBorder.Width - 2, innerBorder.Height - 2 );
dropDownRect = new Rectangle( innerBorder.Right + 1, innerBorder.Y, dropDownButtonWidth, innerBorder.Height + 1 );
// fill in several pixels of the dropdown rect with white so that it looks like the combo button is thinner.
if ( smallButton ) {
whiteFillRect = dropDownRect;
whiteFillRect.Width = WhiteFillRectWidth;
dropDownRect.X += WhiteFillRectWidth;
dropDownRect.Width -= WhiteFillRectWidth;
}
if ( origRightToLeft == RightToLeft.Yes ) {
innerBorder.X = clientRect.Width - innerBorder.Right;
innerInnerBorder.X = clientRect.Width - innerInnerBorder.Right;
dropDownRect.X = clientRect.Width - dropDownRect.Right;
whiteFillRect.X = clientRect.Width - whiteFillRect.Right + 1; // since we're filling, we need to move over to the next px.
}
}
开发者ID:NicolasR,项目名称:Composants,代码行数:32,代码来源:ToolStripComboBoxHost.cs
示例16: MeasureString
/// <summary>
/// Pixel accurate measure of the specified string when drawn with the specified Font object.
/// </summary>
/// <param name="g">Graphics instance used to measure text.</param>
/// <param name="rtl">Right to left setting for control.</param>
/// <param name="text">String to measure.</param>
/// <param name="font">Font object that defines the text format of the string.</param>
/// <param name="trim">How to trim excess text.</param>
/// <param name="align">How to align multine text.</param>
/// <param name="prefix">How to process prefix characters.</param>
/// <param name="hint">Rendering hint.</param>
/// <param name="composition">Should draw on a composition element.</param>
/// <param name="disposeFont">Dispose of font when finished with it.</param>
/// <returns>A memento used to draw the text.</returns>
public static AccurateTextMemento MeasureString(Graphics g,
RightToLeft rtl,
string text,
Font font,
PaletteTextTrim trim,
PaletteRelativeAlign align,
PaletteTextHotkeyPrefix prefix,
TextRenderingHint hint,
bool composition,
bool disposeFont)
{
Debug.Assert(g != null);
Debug.Assert(text != null);
Debug.Assert(font != null);
if (g == null) throw new ArgumentNullException("g");
if (text == null) throw new ArgumentNullException("text");
if (font == null) throw new ArgumentNullException("font");
// An empty string cannot be drawn, so uses the empty memento
if (text.Length == 0)
return AccurateTextMemento.Empty;
// Create the format object used when measuring and drawing
StringFormat format = new StringFormat();
format.FormatFlags = StringFormatFlags.NoClip;
// Ensure that text reflects reversed RTL setting
if (rtl == RightToLeft.Yes)
format.FormatFlags = StringFormatFlags.DirectionRightToLeft;
// How do we position text horizontally?
switch (align)
{
case PaletteRelativeAlign.Near:
format.Alignment = (rtl == RightToLeft.Yes) ? StringAlignment.Far : StringAlignment.Near;
break;
case PaletteRelativeAlign.Center:
format.Alignment = StringAlignment.Center;
break;
case PaletteRelativeAlign.Far:
format.Alignment = (rtl == RightToLeft.Yes) ? StringAlignment.Near : StringAlignment.Far;
break;
default:
// Should never happen!
Debug.Assert(false);
break;
}
// Do we need to trim text that is too big?
switch (trim)
{
case PaletteTextTrim.Character:
format.Trimming = StringTrimming.Character;
break;
case PaletteTextTrim.EllipsisCharacter:
format.Trimming = StringTrimming.EllipsisCharacter;
break;
case PaletteTextTrim.EllipsisPath:
format.Trimming = StringTrimming.EllipsisPath;
break;
case PaletteTextTrim.EllipsisWord:
format.Trimming = StringTrimming.EllipsisWord;
break;
case PaletteTextTrim.Word:
format.Trimming = StringTrimming.Word;
break;
case PaletteTextTrim.Hide:
format.Trimming = StringTrimming.None;
break;
default:
// Should never happen!
Debug.Assert(false);
break;
}
// Setup the correct prefix processing
switch (prefix)
{
case PaletteTextHotkeyPrefix.None:
format.HotkeyPrefix = HotkeyPrefix.None;
break;
case PaletteTextHotkeyPrefix.Hide:
format.HotkeyPrefix = HotkeyPrefix.Hide;
break;
case PaletteTextHotkeyPrefix.Show:
//.........这里部分代码省略.........
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:101,代码来源:AccurateText.cs
示例17: DrawString
/// <summary>
/// Pixel accurate drawing of the requested text memento information.
/// </summary>
/// <param name="g">Graphics object used for drawing.</param>
/// <param name="brush">Brush for drawing text with.</param>
/// <param name="rect">Rectangle to draw text inside.</param>
/// <param name="rtl">Right to left setting for control.</param>
/// <param name="orientation">Orientation for drawing text.</param>
/// <param name="memento">Memento containing text context.</param>
/// <param name="state">State of the source element.</param>
/// <param name="composition">Should draw on a composition element.</param>
/// <returns>True if draw succeeded; False is draw produced an error.</returns>
public static bool DrawString(Graphics g,
Brush brush,
Rectangle rect,
RightToLeft rtl,
VisualOrientation orientation,
bool composition,
PaletteState state,
AccurateTextMemento memento)
{
Debug.Assert(g != null);
Debug.Assert(memento != null);
// Cannot draw with a null graphics instance
if (g == null)
throw new ArgumentNullException("g");
// Cannot draw with a null memento instance
if (memento == null)
throw new ArgumentNullException("memento");
bool ret = true;
// Is there a valid place to be drawn into
if ((rect.Width > 0) && (rect.Height > 0))
{
// Does the memento contain something to draw?
if (!memento.IsEmpty)
{
int translateX = 0;
int translateY = 0;
float rotation = 0f;
// Perform any transformations needed for orientation
switch (orientation)
{
case VisualOrientation.Bottom:
// Translate to opposite side of origin, so the rotate can
// then bring it back to original position but mirror image
translateX = rect.X * 2 + rect.Width;
translateY = rect.Y * 2 + rect.Height;
rotation = 180f;
break;
case VisualOrientation.Left:
// Invert the dimensions of the rectangle for drawing upwards
rect = new Rectangle(rect.X, rect.Y, rect.Height, rect.Width);
// Translate back from a quater left turn to the original place
translateX = rect.X - rect.Y - 1;
translateY = rect.X + rect.Y + rect.Width;
rotation = 270;
break;
case VisualOrientation.Right:
// Invert the dimensions of the rectangle for drawing upwards
rect = new Rectangle(rect.X, rect.Y, rect.Height, rect.Width);
// Translate back from a quater right turn to the original place
translateX = rect.X + rect.Y + rect.Height + 1;
translateY = -(rect.X - rect.Y);
rotation = 90f;
break;
}
// Apply the transforms if we have any to apply
if ((translateX != 0) || (translateY != 0))
g.TranslateTransform(translateX, translateY);
if (rotation != 0f)
g.RotateTransform(rotation);
try
{
if (composition)
DrawCompositionGlowingText(g, memento.Text, memento.Font, rect, state,
SystemColors.ActiveCaptionText, true);
else
g.DrawString(memento.Text, memento.Font, brush, rect, memento.Format);
}
catch
{
// Ignore any error from the DrawString, usually because the display settings
// have changed causing Fonts to be invalid. Our controls will notice the change
// and refresh the fonts but sometimes the draw happens before the fonts are
// regenerated. Just ignore message and everything will sort itself out. Trust me!
ret = false;
}
finally
{
// Remove the applied transforms
//.........这里部分代码省略.........
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:101,代码来源:AccurateText.cs
示例18: FlatComboAdapter
public FlatComboAdapter(ComboBox comboBox, bool smallButton) {
if (!isScalingInitialized) {
if (DpiHelper.IsScalingRequired) {
Offset2X = DpiHelper.LogicalToDeviceUnitsX(OFFSET_2PIXELS);
Offset2Y = DpiHelper.LogicalToDeviceUnitsY(OFFSET_2PIXELS);
}
isScalingInitialized = true;
}
clientRect = comboBox.ClientRectangle;
int dropDownButtonWidth = System.Windows.Forms.SystemInformation.HorizontalScrollBarArrowWidth;
outerBorder = new Rectangle(clientRect.Location, new Size(clientRect.Width - 1, clientRect.Height - 1));
innerBorder = new Rectangle(outerBorder.X + 1, outerBorder.Y + 1, outerBorder.Width - dropDownButtonWidth - 2, outerBorder.Height - 2);
innerInnerBorder = new Rectangle(innerBorder.X + 1, innerBorder.Y + 1, innerBorder.Width - 2, innerBorder.Height - 2);
dropDownRect = new Rectangle(innerBorder.Right + 1, innerBorder.Y, dropDownButtonWidth, innerBorder.Height+1);
// fill in several pixels of the dropdown rect with white so that it looks like the combo button is thinner.
if (smallButton) {
whiteFillRect = dropDownRect;
whiteFillRect.Width = WhiteFillRectWidth;
dropDownRect.X += WhiteFillRectWidth;
dropDownRect.Width -= WhiteFillRectWidth;
}
origRightToLeft = comboBox.RightToLeft;
if (origRightToLeft == RightToLeft.Yes) {
innerBorder.X = clientRect.Width - innerBorder.Right;
innerInnerBorder.X = clientRect.Width - innerInnerBorder.Right;
dropDownRect.X = clientRect.Width - dropDownRect.Right;
whiteFillRect.X = clientRect.Width - whiteFillRect.Right + 1; // since we're filling, we need to move over to the next px.
}
}
开发者ID:mind0n,项目名称:hive,代码行数:37,代码来源:ComboBox.cs
示例19: NuGenBoundsParams
/// <summary>
/// Initializes a new instance of the <see cref="NuGenBoundsParams"/> class.
/// </summary>
public NuGenBoundsParams(
Rectangle bounds
, ContentAlignment imageAlign
, Rectangle imageBounds
, RightToLeft rightToLeft
)
{
_bounds = bounds;
_imageAlign = imageAlign;
_imageBounds = imageBounds;
_rightToLeft = rightToLeft;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:15,代码来源:NuGenBoundsParams.cs
示例20: AllocateImageSpace
private static void AllocateImageSpace(StandardContentMemento memento,
IPaletteContent paletteContent,
IContentValues contentValues,
PaletteState state,
Rectangle displayRect,
RightToLeft rtl,
ref Size[,] allocation)
{
// By default, we cannot draw the image
memento.DrawImage = false;
// Get the image details
memento.Image = contentValues.GetImage(state);
memento.ImageTransparentColor = contentValues.GetImageTransparentColor(state);
// Is there any image to be drawn?
if (memento.Image != null)
{
try
{
// Cache the size of the image
memento.ImageRect.Size = memento.Image.Size;
// Check for enough space to show all of the image
if ((displayRect.Width >= memento.ImageRect.Width) &&
(displayRect.Height >= memento.ImageRect.Height))
{
// Convert from alignment enums to integers
int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentImageH(state));
int alignVIndex = (int)paletteContent.GetContentImageV(state);
// Bump the allocated space in the destination grid cell
allocation[alignHIndex, alignVIndex].Width += memento.ImageRect.Width;
|
请发表评论