本文整理汇总了C#中System.Drawing.RectangleF.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.RectangleF.Offset方法的具体用法?C# System.Drawing.RectangleF.Offset怎么用?C# System.Drawing.RectangleF.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了System.Drawing.RectangleF.Offset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HistoryListView_DrawItem
void HistoryListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (e.ItemIndex < 0) return;
if (this.View == View.Tile)
{
// draw the background and focus rectangle for selected and non-selected states
if (this.SelectedIndices.Contains(e.ItemIndex))
{
e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
}
else
{
e.DrawBackground();
}
// draw icon
PastNotification pn = (PastNotification)e.Item.Tag;
int newX = e.Bounds.Left;
if (pn != null)
{
System.Drawing.Image img = PastNotificationManager.GetImage(pn);
using (img)
{
if (img != null)
{
int x = e.Bounds.Left + 1;
int y = e.Bounds.Top + 1;
e.Graphics.DrawImage(img, x, y);
newX = e.Bounds.Left + img.Width + this.Margin.Right;
}
}
}
// draw main text
System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);
string text = e.Item.Text.Replace("\r", " - ");
using (foreBrush)
{
e.Graphics.DrawString(text,
e.Item.Font,
foreBrush,
rect,
sf);
}
// draw subitems
System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
using (subBrush)
{
for (int i = 1; i < this.Columns.Count; i++)
{
if (i < e.Item.SubItems.Count)
{
text = e.Item.SubItems[i].Text.Replace("\r", " - ");
rect.Offset(0, e.Item.Font.Height);
e.Graphics.DrawString(text,
e.Item.Font,
subBrush,
rect,
sf);
}
}
}
}
else
{
// DO NOT call e.DrawDefault or the DrawSubItem event will not be fired
//e.DrawDefault = true;
}
}
示例2: GetScreenBounds
internal System.Drawing.RectangleF GetScreenBounds()
{
if (this.IsRoot || this.ParentElement == null)
{
PropState.ScreenBounds = this.Bounds;
}
else
{
this.ParentElement.UpdateTransforms();
this.UpdateProps();
if (!PropState.ScreenBounds.HasValue)
{
tmpBounds = this.Bounds;
tmpBounds.Offset(this.RotationCenter.X * this.ScaleVector.X, this.RotationCenter.Y * this.ScaleVector.Y);
if (this.ParentElement.TransState.LocationTransform != Matrix.Identity)
{
tmpVector1.X = tmpBounds.X;
tmpVector1.Y = tmpBounds.Y;
Vector2.Transform(ref tmpVector1, ref this.ParentElement.TransState.LocationTransform, out tmpVector2);
tmpBounds.X = tmpVector2.X;
tmpBounds.Y = tmpVector2.Y;
}
if (this.ParentElement.TransState.ScaleTransform != Matrix.Identity)
{
Vector2.Transform(ref PropState.Size, ref this.ParentElement.TransState.ScaleTransform, out tmpVector2);
tmpBounds.Width = tmpVector2.X;
tmpBounds.Height = tmpVector2.Y;
}
else
{
tmpBounds.Width = PropState.Size.X;
tmpBounds.Height = PropState.Size.Y;
}
PropState.ScreenBounds = tmpBounds;
}
}
return PropState.ScreenBounds.Value;
}
示例3: FeedListView_DrawItem
void FeedListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (this.View == View.Tile)
{
Feed feed = (Feed) e.Item.Tag;
// draw the background and focus rectangle for selected and non-selected states
e.DrawBackground();
if (e.Item.Selected)
{
e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
}
// draw icon
int newX = e.Bounds.Left;
/*
System.Drawing.Image img = this.imageList.Images[e.Item.ImageKey];
if (img != null)
{
int x = e.Bounds.Left;
int y = e.Bounds.Top;
e.Graphics.DrawImage(img, x, y);
newX = e.Bounds.Left + img.Width + this.Margin.Right;
img.Dispose();
}
* */
// draw main text
System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);
using (foreBrush)
{
e.Graphics.DrawString(feed.Name,
e.Item.Font,
foreBrush,
rect,
sf);
}
// draw subitems
System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
using (subBrush)
{
for (int i = 1; i < this.Columns.Count; i++)
{
if (i < e.Item.SubItems.Count)
{
rect.Offset(0, e.Item.Font.Height);
e.Graphics.DrawString(e.Item.SubItems[i].Text,
e.Item.Font,
subBrush,
rect,
sf);
}
}
}
}
else
{
e.DrawDefault = true;
}
}
示例4: ForwardListView_DrawItem
void ForwardListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (this.View == View.Tile)
{
int checkBoxAreaWidth = CHECKBOX_PADDING + CHECKBOX_SIZE + CHECKBOX_PADDING;
System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(e.Bounds.X + checkBoxAreaWidth, e.Bounds.Top, e.Bounds.Width - checkBoxAreaWidth, e.Bounds.Height);
// update information
DestinationBase fc = (DestinationBase)e.Item.Tag;
string display = Escape(fc.Display);
string address = Escape(fc.AddressDisplay);
string additional = Escape(fc.AdditionalDisplayInfo);
string tooltip = String.Format("{0}\r\n{1}{2}", fc.Display, fc.AddressDisplay, (!String.IsNullOrEmpty(fc.AdditionalDisplayInfo) ? String.Format("\r\n{0}", fc.AdditionalDisplayInfo) : null));
e.Item.ToolTipText = tooltip;
// NOTE: dont set the .Text or .SubItem properties here - it causes an erratic exception
bool drawEnabled = ShouldDrawEnabled(fc);
bool selected = this.SelectedIndices.Contains(e.ItemIndex);
// draw the background for selected states
if(drawEnabled && selected)
{
e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
}
else
{
e.DrawBackground();
}
// draw the focus rectangle
if (selected)
ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
// draw icon
int newX = bounds.X;
DestinationBase db = e.Item.Tag as DestinationBase;
if (db != null)
{
System.Drawing.Image img = db.GetIcon();
// size
if (img.Width > IMAGE_SIZE)
{
System.Drawing.Image resized = new System.Drawing.Bitmap(IMAGE_SIZE, IMAGE_SIZE);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(resized);
using (g)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(img, 0, 0, IMAGE_SIZE, IMAGE_SIZE);
}
img = resized;
}
if (img != null)
{
int x = bounds.X;
int y = bounds.Top;
if (drawEnabled)
e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, img.Width, img.Height));
else
ControlPaint.DrawImageDisabled(e.Graphics, img, x, y, System.Drawing.Color.Transparent);
newX += IMAGE_SIZE + this.Margin.Right;
}
}
// offset the text vertically a bit so it lines up with the icon better
System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, bounds.Top, bounds.Right - newX, e.Item.Font.Height);
rect.Offset(0, 4);
// draw main text
System.Drawing.Color textColor = (drawEnabled ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(textColor);
using (textBrush)
{
e.Graphics.DrawString(display,
e.Item.Font,
textBrush,
rect,
sf);
}
// draw additional information text
System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
using (subBrush)
{
// draw address display (line 2)
rect.Offset(0, e.Item.Font.Height);
e.Graphics.DrawString(address,
e.Item.Font,
subBrush,
rect,
sf);
// draw additional display (line 3)
rect.Offset(0, e.Item.Font.Height);
e.Graphics.DrawString(additional,
//.........这里部分代码省略.........