本文整理汇总了C#中IGraphicsContext.DrawEllipsis方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext.DrawEllipsis方法的具体用法?C# IGraphicsContext.DrawEllipsis怎么用?C# IGraphicsContext.DrawEllipsis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphicsContext
的用法示例。
在下文中一共展示了IGraphicsContext.DrawEllipsis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: DrawCell
private void DrawCell(IGraphicsContext context, int row, int col, AudioFile audioFile, DrawCellState state)
{
var rect = new BasicRectangle();
var brush = new BasicBrush();
var brushGradient = new BasicGradientBrush();
var penTransparent = new BasicPen();
var column = _songCache.ActiveColumns[col];
if (column.Visible)
{
if (column.Title == "Now Playing")
{
// Draw now playing icon
if ((_mode == SongGridViewMode.AudioFile && audioFile != null && audioFile.Id == _nowPlayingAudioFileId) ||
(_mode == SongGridViewMode.Playlist && _items[row].PlaylistItemId == _nowPlayingPlaylistItemId))
{
// Which size is the minimum? Width or height?
int availableWidthHeight = column.Width - 4;
if (_songCache.LineHeight <= column.Width)
availableWidthHeight = _songCache.LineHeight - 4;
else
availableWidthHeight = column.Width - 4;
// Calculate the icon position
float iconNowPlayingX = ((column.Width - availableWidthHeight) / 2) + state.OffsetX - HorizontalScrollBar.Value;
float iconNowPlayingY = state.OffsetY + ((_songCache.LineHeight - availableWidthHeight) / 2);
// Create NowPlaying rect (MUST be in integer)
_rectNowPlaying = new BasicRectangle((int)iconNowPlayingX, (int)iconNowPlayingY, availableWidthHeight, availableWidthHeight);
state.NowPlayingSongFound = true;
// Draw outer circle
brushGradient = new BasicGradientBrush(_theme.NowPlayingIndicatorBackgroundColor, _theme.NowPlayingIndicatorBackgroundColor, _timerAnimationNowPlayingCount % 360);
context.DrawEllipsis(_rectNowPlaying, brushGradient, penTransparent);
// Draw inner circle
rect = new BasicRectangle((int)iconNowPlayingX + 4, (int)iconNowPlayingY + 4, availableWidthHeight - 8, availableWidthHeight - 8);
brush = new BasicBrush(_theme.NowPlayingBackgroundColor);
context.DrawEllipsis(rect, brush, penTransparent);
}
}
else if (column.Title == "Album Cover")
{
DrawAlbumCoverZone(context, row, audioFile, state);
}
else if (audioFile != null)
{
// Print value depending on type
var propertyInfo = audioFile.GetType().GetProperty(column.FieldName);
if (propertyInfo != null)
{
string value = string.Empty;
try
{
if (propertyInfo.PropertyType.FullName == "System.String")
{
value = propertyInfo.GetValue(audioFile, null).ToString();
}
else if (propertyInfo.PropertyType.FullName.Contains("Int64") &&
propertyInfo.PropertyType.FullName.Contains("Nullable"))
{
long? longValue = (long?)propertyInfo.GetValue(audioFile, null);
if (longValue.HasValue)
value = longValue.Value.ToString();
}
else if (propertyInfo.PropertyType.FullName.Contains("DateTime") &&
propertyInfo.PropertyType.FullName.Contains("Nullable"))
{
DateTime? dateTimeValue = (DateTime?)propertyInfo.GetValue(audioFile, null);
if (dateTimeValue.HasValue)
value = dateTimeValue.Value.ToShortDateString() + " " + dateTimeValue.Value.ToShortTimeString();
}
else if (propertyInfo.PropertyType.FullName.Contains("System.UInt32"))
{
uint uintValue = (uint)propertyInfo.GetValue(audioFile, null);
value = uintValue.ToString();
}
else if (propertyInfo.PropertyType.FullName.Contains("System.Int32"))
{
int intValue = (int)propertyInfo.GetValue(audioFile, null);
value = intValue.ToString();
}
else if (propertyInfo.PropertyType.FullName.Contains("Sessions.Sound.AudioFileFormat"))
{
AudioFileFormat theValue = (AudioFileFormat)propertyInfo.GetValue(audioFile, null);
value = theValue.ToString();
}
}
catch
{
// Do nothing
}
//// The last column always take the remaining width
//int columnWidth = column.Width;
//if (b == _songCache.ActiveColumns.Count - 1)
//{
// // Calculate the remaining width
// int columnsWidth = 0;
// for (int c = 0; c < _songCache.ActiveColumns.Count - 1; c++)
// {
//.........这里部分代码省略.........