本文整理汇总了C#中IGraphicsContext.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext.DrawLine方法的具体用法?C# IGraphicsContext.DrawLine怎么用?C# IGraphicsContext.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphicsContext
的用法示例。
在下文中一共展示了IGraphicsContext.DrawLine方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IGraphicsContext GC)
{
Color oldColor = GC.Color;
Color primary = Color.Orchid;
if (Interface == null || Interface.Trim () == "")
{
primary = Color.Red;
}
GC.Color = primary;
if (Selected)
{
GC.Thickness = 5;
}
else
{
GC.Thickness = 2;
}
GC.DrawLine (_From, _To);
foreach (OperationPortLinkContactPointGlyph contact in ContactPoints)
{
switch (contact.WhichEnd)
{
case TransitionContactEnd.From: GC.Thickness = 3; break;
case TransitionContactEnd.To: GC.Thickness = 5; break;
default: throw new NotSupportedException ("Unknown TransitionContactEnd: " + contact.WhichEnd.ToString ());
}
IOperationGlyph operation = contact.Parent as IOperationGlyph;
if (operation != null)
{
GC.Color = primary; // FIXUP: operation.OperationColor;
contact.Draw (GC);
}
else
{
GC.Color = primary;
contact.Draw (GC);
}
}
string s = DisplayText ();
using (Brush brush = new System.Drawing.SolidBrush (Color.Black))
{
GC.DrawString (s, brush, 10, new Point ((_To.X + _From.X) / 2, (_To.Y + _From.Y) / 2), true);
}
GC.Color = oldColor;
}
示例2: Draw
public override void Draw(IGraphicsContext gc)
{
if (_SelectionBand.Width > 0 || _SelectionBand.Height > 0)
{
if (_DrawDirection)
{
gc.Color = Color.LightGray;
gc.DrawRectangle (_SelectionBand);
gc.DrawLine (StartPoint, EndPoint, Color.LightGray, Color.DarkGray);
gc.DrawTrianglePointer (StartPoint, EndPoint, 5, 5);
}
else
{
gc.Color = Color.Gray;
gc.DrawRectangle (_SelectionBand);
}
}
}
示例3: Draw
public override void Draw(IGraphicsContext GC)
{
Color oldColor = GC.Color;
Color primary = Color.Orchid;
if (!IsNotEmptyString (FromPortName) || !IsNotEmptyString (ToPortName) /* || !IsNotEmptyString (Interface) */)
{
primary = Color.Red;
}
GC.Color = primary;
if (Selected)
{
GC.Thickness = 5;
}
else
{
GC.Thickness = 2;
}
GC.DrawLine (_From, _To);
foreach (IPortLinkContactPointGlyph contact in ContactPoints)
{
switch (contact.WhichEnd)
{
case TransitionContactEnd.From: GC.Thickness = 3; break;
case TransitionContactEnd.To: GC.Thickness = 5; break;
default: throw new NotSupportedException ("Unknown TransitionContactEnd: " + contact.WhichEnd.ToString ());
}
IComponentGlyph component = contact.Parent as IComponentGlyph;
if (component != null)
{
GC.Color = component.ComponentColor;
contact.Draw (GC);
}
else
{
GC.Color = primary;
contact.Draw (GC);
}
}
string s = DisplayText ();
using (Brush brush = new System.Drawing.SolidBrush (Color.Black))
{
GC.DrawString (s, brush, 10, new Point ((_To.X + _From.X) / 2, (_To.Y + _From.Y) / 2), true);
}
GC.Color = oldColor;
}
示例4: Render
public void Render(IGraphicsContext context)
{
// Value range is the size between max and min track bar value.
// Ex: Min = 50, Max = 150. Value range = 100 + 1 (because we include 50 and 100)
_valueRange = (Maximum - Minimum) + 1;
// Get track bar value relative to value range (value - minimum value).
// Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50.
_valueRelativeToValueRange = Value - Minimum;
// Draw background
context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);
// Return if value range is zero
if (_valueRange == 0)
return;
// Draw fader track
float trackX = context.BoundsWidth / 2;
float trackY = Margin;
float trackY2 = context.BoundsHeight - Margin;
// Draw shadow track
context.DrawLine(new BasicPoint(trackX + 1, trackY + 1), new BasicPoint(trackX + 1, trackY2 + 1), new BasicPen(new BasicBrush(_centerLineShadowColor), 1));
// Draw track
context.DrawLine(new BasicPoint(trackX, trackY), new BasicPoint(trackX, trackY2), new BasicPen(new BasicBrush(_centerLineColor), 1));
// Get the track height (remove margin from top and bottom)
_trackHeight = context.BoundsHeight - (Margin * 2);
// Get tick width
float tickHeight = _trackHeight / _valueRange;
// Get the percentage of the value relative to value range (needed to draw the fader).
// We need to divide the value relative to value range to the value range to get the ratio.
// Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50. Value range = 100. Value ratio = 0.5
_valueRatio = (_valueRelativeToValueRange / _valueRange);
// Calculate fader position
// We need to invert the values (i.e. max is on top, min is bottom)
//float valueY = (valueRatio * trackHeight) + Margin;
float valueY = _trackHeight - (_valueRatio * _trackHeight) + Margin;
float faderY = valueY + ((tickHeight - FaderHeight) / 2);
float tickCenterY = valueY + (tickHeight / 2);
// Create fader rectangle
_rectFader = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY, FaderWidth, FaderHeight);
// // Draw tick zone (for debug)
// //RectangleF rectTickZone = new RectangleF(valueX, 0, tickWidth, Height);
// //g.FillRectangle(Brushes.DarkGray, rectTickZone);
var rectFaderShadowTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 1, FaderWidth, 8);
var rectFaderShadowBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 8 + 1, FaderWidth, 8);
var rectFaderShadowCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 4 + 1, FaderWidth, FaderHeight - 8);
context.DrawEllipsis(rectFaderShadowTop, _brushFaderShadowColor, _penTransparent);
context.DrawEllipsis(rectFaderShadowBottom, _brushFaderShadowColor, _penTransparent);
context.DrawRectangle(rectFaderShadowCenter, _brushFaderShadowColor, _penTransparent);
// Draw fader outline (with 8px border)
var rectFaderTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY, FaderWidth, 8);
var rectFaderBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + FaderHeight - 8, FaderWidth, 8);
var rectFaderBottomCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + FaderHeight - 10, FaderWidth, 6);
var rectFaderCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + 4, FaderWidth, FaderHeight - 8);
context.DrawEllipsis(rectFaderTop, _brushFaderGradient, _penTransparent);
context.DrawEllipsis(rectFaderBottom, _brushFaderShadowColor1, _penTransparent);
context.DrawRectangle(rectFaderCenter, _brushFaderColor2, _penTransparent);
context.DrawRectangle(rectFaderBottomCenter, _brushFaderShadowColor1, _penTransparent);
// Draw fader inside (with 4px border)
var rectFaderInsideBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 8, FaderWidth - 2, 4);
var rectFaderInsideBottomCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 12, FaderWidth - 2, FaderHeight - 24);
var rectFaderInsideTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 4, FaderWidth - 2, 8);
var rectFaderInsideTopCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 8, FaderWidth - 2, FaderHeight - 24);
context.DrawEllipsis(rectFaderInsideTop, _brushFaderShadowColor1, _penTransparent);
context.DrawEllipsis(rectFaderInsideTopCenter, _brushFaderShadowGradient, _penTransparent);
context.DrawEllipsis(rectFaderInsideBottom, _brushFaderColor2, _penTransparent);
context.DrawRectangle(rectFaderInsideBottomCenter, _brushFaderColor2, _penTransparent);
context.DrawLine(new BasicPoint((context.BoundsWidth / 2) - (FaderWidth / 2), tickCenterY), new BasicPoint((context.BoundsWidth / 2) - (FaderWidth / 2) + FaderWidth, tickCenterY), _penMiddleLineColor);
}
示例5: Render
public void Render(IGraphicsContext context)
{
// Value range is the size between max and min track bar value.
// Ex: Min = 50, Max = 150. Value range = 100 + 1 (because we include 50 and 100)
_valueRange = (Maximum - Minimum) + 1;
// Get track bar value relative to value range (value - minimum value).
// Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50.
_valueRelativeToValueRange = Value - Minimum;
// Draw background
context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);
// Return if value range is zero
if (_valueRange == 0)
return;
// Draw fader track
float trackX = Margin; // add margin from left
float trackX2 = context.BoundsWidth - Margin; // add margin from right
float trackY = context.BoundsHeight / 2; // right in the center
context.DrawLine(new BasicPoint(trackX + 1, trackY + 1), new BasicPoint(trackX2 + 1, trackY + 1), _penCenterLineShadow);
context.DrawLine(new BasicPoint(trackX, trackY), new BasicPoint(trackX2, trackY), _penCenterLine);
// Get the track width (remove margin from left and right)
_trackWidth = context.BoundsWidth - (Margin * 2);
// Get tick width
float tickWidth = _trackWidth / _valueRange;
// Get the percentage of the value relative to value range (needed to draw the fader).
// We need to divide the value relative to value range to the value range to get the ratio.
// Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50. Value range = 100. Value ratio = 0.5
_valueRatio = (_valueRelativeToValueRange / _valueRange);
// Get the value X coordinate by multiplying the value ratio to the track bar width (removed 3 pixels from left
// and right). Add margin from left.
float valueX = (_valueRatio * _trackWidth) + Margin; // this gives the LEFT x for our zone
float faderX = valueX + ((tickWidth - FaderWidth) / 2);
float tickCenterX = valueX + (tickWidth / 2);
// Create fader rectangle
_rectFader = new BasicRectangle(faderX, (context.BoundsHeight / 2) - (FaderHeight / 2), FaderWidth, FaderHeight);
//// Draw tick zone (for debug)
////RectangleF rectTickZone = new RectangleF(valueX, 0, tickWidth, Height);
////g.FillRectangle(Brushes.DarkGray, rectTickZone);
// Draw fader outline (with 8px border)
//var rectFaderLeft = new BasicRectangle(faderX, (context.BoundsHeight / 2) - (FaderHeight / 2), 8, FaderHeight);
//var rectFaderRight = new BasicRectangle(faderX + FaderWidth - 8, (context.BoundsHeight / 2) - (FaderHeight / 2), 8, FaderHeight);
var rectFaderCenter = new BasicRectangle(faderX + 4, (context.BoundsHeight / 2) - (FaderHeight / 2), FaderWidth - 8, FaderHeight);
//context.DrawEllipsis(rectFaderLeft, new BasicGradientBrush(_faderColor1, _faderColor, 90), new BasicPen());
//context.DrawEllipsis(rectFaderLeft, new BasicGradientBrush(new BasicColor(255, 0, 0), new BasicColor(0, 0, 255), 90), new BasicPen());
//context.DrawEllipsis(rectFaderRight, new BasicGradientBrush(_faderColor1, _faderColor, 90), new BasicPen());
//context.DrawEllipsis(rectFaderRight, new BasicGradientBrush(new BasicColor(0, 255, 0), new BasicColor(255, 0, 255), 90), new BasicPen());
context.DrawEllipsis(rectFaderCenter, _brushFaderColor2, _penShadowColor1);
//context.DrawEllipsis(rectFaderCenter, new BasicBrush(_faderColor), new BasicPen());
// Draw fader inside (with 4px border)
//var rectFaderInsideLeft = new BasicRectangle(faderX + 2, (context.BoundsHeight / 2) - (FaderHeight / 2) + 2, 4, FaderHeight - 4);
//var rectFaderInsideRight = new BasicRectangle(faderX + FaderWidth - 6, (context.BoundsHeight / 2) - (FaderHeight / 2) + 2, 4, FaderHeight - 4);
//context.DrawEllipsis(rectFaderInsideLeft, new BasicGradientBrush(_faderShadowColor, _faderShadowColor, 90), new BasicPen());
//context.DrawEllipsis(rectFaderInsideRight, new BasicGradientBrush(_faderShadowColor, _faderShadowColor, 90), new BasicPen());
context.DrawLine(new BasicPoint(tickCenterX, (context.BoundsHeight / 2) - (FaderHeight / 2)), new BasicPoint(tickCenterX, (context.BoundsHeight / 2) - (FaderHeight / 2) + FaderHeight), _penShadowColor1);
}
示例6: Render
public void Render(IGraphicsContext context)
{
Frame = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
var rectBackground = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
//context.DrawRectangle(rectBackground, _brushBackground, _penTransparent);
const float padding = 2;
const float checkPadding = padding + 4;
var rectForeground = new BasicRectangle(padding, padding, context.BoundsWidth - (padding * 2), context.BoundsHeight - (padding * 2));
context.DrawRectangle(rectForeground, _brushTransparent, _penBorder);
if (_value)
{
context.DrawLine(new BasicPoint(checkPadding, checkPadding), new BasicPoint(context.BoundsWidth - checkPadding, context.BoundsHeight - checkPadding), _penForeground);
context.DrawLine(new BasicPoint(context.BoundsWidth - checkPadding, checkPadding), new BasicPoint(checkPadding, context.BoundsHeight - checkPadding), _penForeground);
}
}
示例7: Draw
public override void Draw(IGraphicsContext GC)
{
using (GC.PushGraphicsState ())
{
bool isOk;
bool usePrimary;
Color primary;
DashStyle dashStyle;
usePrimary = PrimaryInformation (out isOk, out primary, out dashStyle);
GC.Color = primary;
int thickness = 2;
if (Selected)
{
thickness = 5;
}
Color fromColor;
Color toColor;
DrawContactPoints (GC, isOk, usePrimary, primary, out fromColor, out toColor);
GC.Thickness = thickness;
GC.DrawLine (_From, _To, fromColor, toColor, dashStyle);
ArrayList contextList = GetDisplayTextAsContextList (GC);
int startX = (_To.X + _From.X) / 2;
int startY = (_To.Y + _From.Y) / 2;
bool isMoreHorizontal = Math.Abs (_To.X - _From.X) > Math.Abs (_To.Y - _From.Y);
bool positiveWidthAdjust;
bool positiveHeightAdjust;
if (isMoreHorizontal)
{
positiveWidthAdjust = false;
positiveHeightAdjust = true;
}
else
{
positiveWidthAdjust = false;
positiveHeightAdjust = false;
}
GC.DrawString (contextList, new Point (startX, startY), positiveWidthAdjust, positiveHeightAdjust, true);
}
}
示例8: DrawAlbumCoverZone
//.........这里部分代码省略.........
// Check if the album cover is already in the pile
bool albumCoverFound = false;
foreach (var arg in _workerUpdateAlbumArtPile)
{
// Match by file path
if (arg.AudioFile.FilePath.ToUpper() == audioFile.FilePath.ToUpper())
{
albumCoverFound = true;
}
}
// Add to the pile only if the album cover isn't already in it
if (!albumCoverFound)
{
// Add item to update album art worker pile
var arg = new SongGridViewBackgroundWorkerArgument();
arg.AudioFile = audioFile;
arg.LineIndex = row;
arg.RectAlbumArt = new BasicRectangle(0, 0, heightWithPadding, heightWithPadding);
_workerUpdateAlbumArtPile.Add(arg);
}
}
catch(Exception ex)
{
Console.WriteLine("SongGridViewControl - Failed to load cache image: {0}" , ex);
}
}
// There are at least two lines; is there an album cover to display?
if (imageAlbumCover == null)
{
// There is no album cover to display; display only text.
// Set string format
//stringFormat.Alignment = StringAlignment.Center;
//stringFormat.Trimming = StringTrimming.EllipsisWord;
sizeArtistName = context.MeasureText(audioFile.ArtistName, new BasicRectangle(0, 0, widthAvailableForText, heightWithPadding), _theme.FontNameAlbumArtTitle, _theme.FontSize + 2);
sizeAlbumTitle = context.MeasureText(audioFile.AlbumTitle, new BasicRectangle(0, 0, widthAvailableForText, heightWithPadding), _theme.FontNameAlbumArtSubtitle, _theme.FontSize);
// Display the album title at the top of the zome
rectArtistNameText = new BasicRectangle(_theme.Padding - HorizontalScrollBar.Value, y + _theme.Padding, widthAvailableForText, heightWithPadding);
rectAlbumTitleText = new BasicRectangle(_theme.Padding - HorizontalScrollBar.Value, y + _theme.Padding + sizeArtistName.Height, widthAvailableForText, heightWithPadding);
displayArtistNameAndAlbumTitle = true;
useAlbumArtOverlay = true;
}
else
{
// There is an album cover to display with more than 2 lines.
// Set string format
//stringFormat.Alignment = StringAlignment.Near;
//stringFormat.Trimming = StringTrimming.EllipsisWord;
float widthRemainingForText = _columns[0].Width - (_theme.Padding * 3) - heightWithPadding;
sizeArtistName = context.MeasureText(audioFile.ArtistName, new BasicRectangle(0, 0, widthRemainingForText, heightWithPadding), _theme.FontNameAlbumArtTitle, _theme.FontSize + 2);
sizeAlbumTitle = context.MeasureText(audioFile.AlbumTitle, new BasicRectangle(0, 0, widthRemainingForText, heightWithPadding), _theme.FontNameAlbumArtSubtitle, _theme.FontSize);
// Try to center the cover art + padding + max text width
//float maxWidth = Math.Max(sizeArtistName.Width, sizeAlbumTitle.Width);
float albumCoverX = _theme.Padding - 2; // (_columns[0].Width - heightWithPadding - _theme.Padding - _theme.Padding - maxWidth) / 2;
float artistNameY = _theme.Padding + 1; // (albumCoverZoneHeight - sizeArtistName.Height - sizeAlbumTitle.Height) / 2;
// Display the album title at the top of the zome
rectArtistNameText = new BasicRectangle(albumCoverX + heightWithPadding + _theme.Padding - HorizontalScrollBar.Value, y + artistNameY, widthRemainingForText, heightWithPadding);
rectAlbumTitleText = new BasicRectangle(albumCoverX + heightWithPadding + _theme.Padding - HorizontalScrollBar.Value, y + artistNameY + sizeArtistName.Height + (_theme.Padding / 8f), widthRemainingForText, heightWithPadding);
rectAlbumCoverArt = new BasicRectangle(albumCoverX - HorizontalScrollBar.Value, y + _theme.Padding, heightWithPadding, heightWithPadding);
displayArtistNameAndAlbumTitle = widthRemainingForText > 20;
useAlbumArtOverlay = true;
}
// Display album cover
if (imageAlbumCover != null)
context.DrawImage(rectAlbumCoverArt, new BasicRectangle(0, 0, imageAlbumCover.ImageSize.Width, imageAlbumCover.ImageSize.Height), imageAlbumCover.Image);
//context.DrawImage(rectAlbumCoverArt, new BasicRectangle(0, 0, rectAlbumCoverArt.Width, rectAlbumCoverArt.Height), imageAlbumCover.Image);
// if (useAlbumArtOverlay)
// {
// // Draw artist name and album title background
// var rectArtistNameBackground = new BasicRectangle(rectArtistNameText.X - (_theme.Padding / 2), rectArtistNameText.Y - (_theme.Padding / 4), sizeArtistName.Width + _theme.Padding, sizeArtistName.Height + (_theme.Padding / 2));
// var rectAlbumTitleBackground = new BasicRectangle(rectAlbumTitleText.X - (_theme.Padding / 2), rectAlbumTitleText.Y - (_theme.Padding / 4), sizeAlbumTitle.Width + _theme.Padding, sizeAlbumTitle.Height + (_theme.Padding / 2));
// var brushTextBackground = new BasicBrush(new BasicColor(0, 0, 0, 30));
// context.DrawRectangle(rectArtistNameBackground, brushTextBackground, penTransparent);
// context.DrawRectangle(rectAlbumTitleBackground, brushTextBackground, penTransparent);
// }
if (displayArtistNameAndAlbumTitle)
{
context.DrawText(audioFile.ArtistName, rectArtistNameText, _theme.HeaderTextColor, _theme.FontNameAlbumArtTitle, _theme.FontSize + 2);
context.DrawText(audioFile.AlbumTitle, rectAlbumTitleText, _theme.HeaderTextColor, _theme.FontNameAlbumArtSubtitle, _theme.FontSize);
}
// Draw horizontal line to distinguish albums
// Part 1: Draw line over grid
pen = new BasicPen(new BasicBrush(new BasicColor(180, 180, 180)), 1);
context.DrawLine(new BasicPoint(_columns[0].Width, y), new BasicPoint(Frame.Width, y), pen);
// Part 2: Draw line over album art zone, in a lighter color
pen = new BasicPen(new BasicBrush(new BasicColor(115, 115, 115)), 1);
context.DrawLine(new BasicPoint(0, y), new BasicPoint(_columns[0].Width, y), pen);
}
}