Here are the examples of the csharp api System.Drawing.Graphics.FillRectangle(System.Drawing.Brush, int, int, int, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
729 Examples
19
View Source File : ZColorPicker.cs
License : MIT License
Project Creator : 0xLaileb
License : MIT License
Project Creator : 0xLaileb
private void pictureBox3_Paint(object sender, PaintEventArgs e)
{
LinearGradientBrush Brush = new LinearGradientBrush(new Point(0, 0), new Point(0, pictureBox3.Height), ((ValueBox)pictureBox3.Tag).Color, Color.Black);
e.Graphics.FillRectangle(Brush, pictureBox3.ClientRectangle);
e.Graphics.FillRectangle(new SolidBrush(Color.DarkGray), 0, pictureBox3.Height * (1 - ((ValueBox)pictureBox3.Tag).Value) - 2, pictureBox3.Width, 4);
}
19
View Source File : CProgressBar.cs
License : Apache License 2.0
Project Creator : aequabit
License : Apache License 2.0
Project Creator : aequabit
protected override void OnPaint(PaintEventArgs e)
{
Rectangle rec = e.ClipRectangle;
rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
if (ProgressBarRenderer.IsSupported)
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle);
rec.Height = rec.Height - 4;
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(170, 0, 0)), 2, 2, rec.Width, rec.Height);
}
19
View Source File : BitmapExtensions.cs
License : MIT License
Project Creator : AlexanderPro
License : MIT License
Project Creator : AlexanderPro
public static Bitmap Dark(this Bitmap bitmap)
{
var newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
using (var graphics = Graphics.FromImage(newBitmap))
{
graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel);
var brush = new SolidBrush(Color.FromArgb(200, 0, 0, 0));
graphics.FillRectangle(brush, 0, 0, bitmap.Width, bitmap.Height);
}
return newBitmap;
}
19
View Source File : Shape.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
private void DrawResizingSquares(Graphics g, Rectangle frame)
{
int squareSize = (SelectionMargin - 4);
for (int row = 0; row < 3; row++)
{
for (int column = 0; column < 3; column++)
{
if (row != 1 || column != 1) // It's not the center point
{
int x = frame.X + (frame.Width * column / 2) - squareSize / 2;
int y = frame.Y + (frame.Height * row / 2) - squareSize / 2;
g.FillRectangle(Brushes.White, x, y, squareSize, squareSize);
g.DrawRectangle(selectionSquarePen, x, y, squareSize, squareSize);
}
}
}
}
19
View Source File : TreeColumn.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
internal static void DrawDropMark(Graphics gr, Rectangle rect)
{
gr.FillRectangle(SystemBrushes.HotTrack, rect.X-1, rect.Y, 2, rect.Height);
}
19
View Source File : PDFGraphics.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
private static XImage ImageToXImage(Image image)
{
Image image2 = new Bitmap(image.Width, image.Height);
Graphics gfx = Graphics.FromImage(image2);
gfx.FillRectangle(new SolidBrush(Color.White), 0, 0, image2.Width, image2.Height);
gfx.DrawImageUnscaled(image, 0, 0);
return XImage.FromGdiPlusImage(image2);
}
19
View Source File : PngExporter.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
public static void Export(PlotModel model, string fileName, int width, int height, Brush background = null)
{
using (var bm = new Bitmap(width, height))
{
using (Graphics g = Graphics.FromImage(bm))
{
if (background != null)
{
g.FillRectangle(background, 0, 0, width, height);
}
var rc = new GraphicsRenderContext { RendersToScreen = false };
rc.SetGraphicsTarget(g);
model.Update();
model.Render(rc, width, height);
bm.Save(fileName, ImageFormat.Png);
}
}
}
19
View Source File : Main.cs
License : MIT License
Project Creator : AlturosDestinations
License : MIT License
Project Creator : AlturosDestinations
private void DrawBoundingBoxes(IEnumerable<YoloTrackingItem> items)
{
var imageInfo = this.GetCurrentImage();
//Load the image(probably from your stream)
var image = Image.FromFile(imageInfo.Path);
using (var font = new Font(FontFamily.GenericSansSerif, 16))
using (var canvas = Graphics.FromImage(image))
{
foreach (var item in items)
{
var x = item.X;
var y = item.Y;
var width = item.Width;
var height = item.Height;
var brush = this.GetBrush(item.Confidence);
var penSize = image.Width / 100.0f;
using (var pen = new Pen(brush, penSize))
{
canvas.DrawRectangle(pen, x, y, width, height);
canvas.FillRectangle(brush, x - (penSize / 2), y - 15, width + penSize, 25);
}
}
foreach (var item in items)
{
canvas.DrawString(item.ObjectId.ToString(), font, Brushes.White, item.X, item.Y - 12);
}
canvas.Flush();
}
var oldImage = this.pictureBox1.Image;
this.pictureBox1.Image = image;
oldImage?.Dispose();
}
19
View Source File : Main.cs
License : MIT License
Project Creator : AlturosDestinations
License : MIT License
Project Creator : AlturosDestinations
private void DrawBoundingBoxes(List<YoloItem> items, YoloItem selectedItem = null)
{
var imageInfo = this.GetCurrentImage();
//Load the image(probably from your stream)
var image = Image.FromFile(imageInfo.Path);
using (var canvas = Graphics.FromImage(image))
{
foreach (var item in items)
{
var x = item.X;
var y = item.Y;
var width = item.Width;
var height = item.Height;
var brush = this.GetBrush(item.Confidence);
var penSize = image.Width / 100.0f;
using (var pen = new Pen(brush, penSize))
using (var overlayBrush = new SolidBrush(Color.FromArgb(150, 255, 255, 102)))
{
if (item.Equals(selectedItem))
{
canvas.FillRectangle(overlayBrush, x, y, width, height);
}
canvas.DrawRectangle(pen, x, y, width, height);
}
}
canvas.Flush();
}
var oldImage = this.pictureBox1.Image;
this.pictureBox1.Image = image;
oldImage?.Dispose();
}
19
View Source File : DiffOverview.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private void RenderImage()
{
if (m_Image != null)
{
m_Image.Dispose();
m_Image = null;
}
int iWidth = ClientSize.Width;
int iHeight = ClientSize.Height;
if (iWidth > 0 && iHeight > 0 && m_View != null && m_View.Lines != null)
{
//Draw a bitmap in memory that we can render from
m_Image = new Bitmap(iWidth, iHeight);
Graphics G = Graphics.FromImage(m_Image);
SolidBrush B = new SolidBrush(BackColor);
G.FillRectangle(B, 0, 0, iWidth, iHeight);
const float c_fGutter = 2.0F;
//Make sure each line is at least 1 pixel high
float fLineHeight = (float)Math.Max(1.0, GetPixelLineHeightF(1));
DiffViewLines Lines = m_View.Lines;
int iNumLines = Lines.Count;
for (int i = 0; i < iNumLines; i++)
{
DiffViewLine L = Lines[i];
if (L.Edited)
{
B.Color = DiffOptions.GetColorForEditType(L.EditType);
float fY = GetPixelLineHeightF(i);
G.FillRectangle(B, c_fGutter, fY, iWidth - 2 * c_fGutter, fLineHeight);
}
}
B.Dispose();
G.Dispose();
}
}
19
View Source File : AnnotateMarginControl.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
protected override void OnPaint(PaintEventArgs e)
{
if (DesignMode)
return;
StringFormat sfr = new StringFormat();
sfr.Alignment = StringAlignment.Far;
StringFormat sfl = new StringFormat();
sfl.Trimming = StringTrimming.EllipsisCharacter;
sfl.FormatFlags = StringFormatFlags.NoWrap;
using (Font f = new Font(Font.FontFamily, 7F))
using (Pen border = new Pen(Color.Gray))
using (Brush textColor = new SolidBrush(Color.Black))
using (Brush selectedTextColor = new SolidBrush(SystemColors.HighlightText))
using (Brush grayBg = new LinearGradientBrush(new Point(0, 0), new Point(Width, 0), BackColor, Color.LightGray))
using (Brush blueBg = new LinearGradientBrush(new Point(0, 0), new Point(Width, 0), BackColor, Color.LightBlue))
using (Brush selectedBg = new SolidBrush(SystemColors.Highlight))
using (SolidBrush localBg = new SolidBrush(SystemColors.Info))
{
foreach (AnnotateRegion region in _regions)
{
// We try to draw a few regions above and below to fix up drawing
// when the actual editor is smaller than our view.
// (E.g. navigation bar for C# editor)
if (region.EndLine < _firstLine-4)
continue;
if (region.StartLine > _lastLine+4)
break;
Rectangle rect = GetRectangle(region);
if (!e.ClipRectangle.IntersectsWith(rect))
continue;
if (IsSelected(region))
e.Graphics.FillRectangle(selectedBg, rect);
else
{
if (region.Hovered)
e.Graphics.FillRectangle(blueBg, rect);
else if (region.Source.Revision >= 0)
e.Graphics.FillRectangle(grayBg, rect);
else
e.Graphics.FillRectangle(localBg, rect);
}
e.Graphics.DrawRectangle(border, rect);
AnnotateSource src = region.Source;
if (src.Revision >= 0)
{
string revisionString = src.Revision.ToString();
string dateString = src.Time.ToShortDateString();
float rectTop = rect.Top + 2; // top padding of 2px
float revisionWidth = e.Graphics.MeasureString(revisionString, f).Width;
float dateWidth = e.Graphics.MeasureString(dateString, f).Width;
// Calculate the author field based on the fields to the left and right of it
// because we use ellipsis trimming when it's too small
float authorWidth = Width - revisionWidth - dateWidth - 8; // left+right padding of both revision and date means 2+2+2+2 = 8
Brush color = IsSelected(region) ? selectedTextColor : textColor;
e.Graphics.DrawString(revisionString, f, color, new RectangleF(3, rectTop, revisionWidth, LineHeight), sfr);
// TODO: decide if this is the best way
// If the authorWidth is negative, don't attempt to show the author. This case should only
// occur with very long ShortDateStrings, or very long revision strings.
if (authorWidth > 0)
e.Graphics.DrawString(src.Author, f, color, new RectangleF(revisionWidth + 5, rectTop, authorWidth, LineHeight), sfl);
e.Graphics.DrawString(dateString, f, color, new RectangleF(Width - dateWidth - 2, rectTop, dateWidth, LineHeight), sfr);
}
}
Rectangle clip = e.ClipRectangle;
using (SolidBrush sb = new SolidBrush(BackColor))
{
if (_regions.Count > 0)
{
Rectangle rect = GetRectangle(_regions[0]);
if (e.ClipRectangle.Top < rect.Top)
e.Graphics.FillRectangle(sb, clip.X, clip.Y, clip.Width, rect.Top - clip.Y);
rect = GetRectangle(_regions[_regions.Count - 1]);
if (e.ClipRectangle.Bottom > rect.Bottom)
e.Graphics.FillRectangle(sb, clip.X, rect.Bottom + 1, rect.Width, clip.Y+clip.Height - rect.Bottom - 1);
}
else
e.Graphics.FillRectangle(sb, clip);
}
}
}
19
View Source File : CheckoutProject.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
Image CreateIcon(ImageList imgList, int index)
{
Bitmap bmp = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
using (Graphics g = Graphics.FromImage(bmp))
using( SolidBrush sb = new SolidBrush(BackColor))
{
g.FillRectangle(sb, 0, 0, 16, 16);
imgList.Draw(g, 0, 0, 16, 16, index);
}
return bmp;
}
19
View Source File : BitmapHelper.cs
License : Apache License 2.0
Project Creator : AnkiUniversal
License : Apache License 2.0
Project Creator : AnkiUniversal
public static Bitmap FillBitmap(int width, int height, Color color)
{
Bitmap Bmp = new Bitmap(width, height);
using (Graphics gfx = Graphics.FromImage(Bmp))
using (SolidBrush brush = new SolidBrush(color))
{
gfx.FillRectangle(brush, 0, 0, width, height);
}
return Bmp;
}
19
View Source File : LifetimeAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderEmbodiedBuildings(Graphics graphics)
{
var plotBounds = EmbodiedBuildingsPlotBounds.Clone();
plotBounds.Width /= 2;
plotBounds.X += plotBounds.Width;
var newMaxValue = EmbodiedBuildingsPlotBounds.Height;
plotBounds.Height = Data.EmbodiedBuildings.Scale(AxisMax, newMaxValue);
plotBounds.Y += (newMaxValue - plotBounds.Height);
plotBounds.Offset(-1, -1);
graphics.FillRectangle(Style.BuildingsBrush, plotBounds);
return plotBounds;
}
19
View Source File : LifetimeAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderEmbodiedSystems(Graphics graphics)
{
var plotBounds = EmbodiedSystemsPlotBounds.Clone();
plotBounds.Width /= 2;
plotBounds.X += plotBounds.Width;
var newMaxValue = EmbodiedSystemsPlotBounds.Height;
plotBounds.Height = Data.EmbodiedSystems.Scale(AxisMax, newMaxValue);
plotBounds.Offset(-1, 1);
graphics.FillRectangle(Style.SystemsBrush, plotBounds);
return plotBounds;
}
19
View Source File : LifetimeAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderOperationBuildings(Graphics graphics)
{
var plotBounds = OperationBuildingsPlotBounds.Clone();
plotBounds.Width /= 2;
var newMaxValue = OperationBuildingsPlotBounds.Height;
plotBounds.Height = Data.OperationBuildings.Scale(AxisMax, newMaxValue);
plotBounds.Y += (newMaxValue - plotBounds.Height);
plotBounds.Offset(1, -1);
graphics.FillRectangle(Style.BuildingsBrush, plotBounds);
return plotBounds;
}
19
View Source File : LifetimeAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderOperationSystems(Graphics graphics)
{
var plotBounds = OperationSystemsPlotBounds.Clone();
plotBounds.Width /= 2;
var newMaxValue = OperationSystemsPlotBounds.Height;
plotBounds.Height = Data.OperationSystems.Scale(AxisMax, newMaxValue);
plotBounds.Offset(1, 1);
graphics.FillRectangle(Style.SystemsBrush, plotBounds);
return plotBounds;
}
19
View Source File : MonthlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
private void RenderOperationBuildings(Graphics graphics)
{
var plotBounds = OperationBuildingsPlotBounds.CloneInflate(-1, -1); // allow a bit of whitespace
var columnWidth = plotBounds.Width / 12;
var x = plotBounds.Left;
foreach (var value in Data.OperationBuildingsMonthly)
{
var height = value.Scale(AxisMax, plotBounds.Height);
var y = plotBounds.Y + (plotBounds.Height - height);
var columnBounds = new RectangleF(x, y, columnWidth, height);
graphics.FillRectangle(Style.BuildingsBrush, columnBounds);
graphics.DrawRectangleF(new Pen(Color.White), columnBounds);
// Value label
var format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
var textHeight = GH_FontServer.MeasureString(value.ToString(), SmallFont).Height;
var valueLabelBounds = new RectangleF(x, y - 2 * textHeight, columnWidth, 2 * textHeight);
graphics.DrawString(PlotCaption(value), SmallFont, TextBrush, valueLabelBounds, format);
x += columnWidth;
}
RenderMonthLabelsBuildingsRow(graphics, plotBounds);
}
19
View Source File : MonthlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
private void RenderOperationSystems(Graphics graphics)
{
var plotBounds = OperationSystemsPlotBounds.CloneInflate(-1, -1); // allow a bit of whitespace
var columnWidth = plotBounds.Width / 12;
var x = plotBounds.Left;
foreach (var value in Data.OperationSystemsMonthly)
{
var height = value.Scale(AxisMax, plotBounds.Height);
var y = plotBounds.Y;
var columnBounds = new RectangleF(x, y, columnWidth, height);
graphics.FillRectangle(Style.SystemsBrush, columnBounds);
graphics.DrawRectangleF(new Pen(Color.White), columnBounds);
// Value label
var format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
var textHeight = GH_FontServer.MeasureString(value.ToString(), SmallFont).Height;
var valueLabelBounds = new RectangleF(x, y + height, columnWidth, textHeight * 2);
graphics.DrawString(PlotCaption(value), SmallFont, TextBrush, valueLabelBounds, format);
x += columnWidth;
}
RenderMonthLabelsSystemsRow(graphics, plotBounds);
}
19
View Source File : MonthlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
private void RenderEmbodiedSystems(Graphics graphics)
{
var plotBounds = EmbodiedSystemsPlotBounds.CloneInflate(-1, -1); // allow a bit of whitespace
var columnWidth = plotBounds.Width / 12;
var x = plotBounds.Left;
foreach (var value in Data.EmbodiedSystemsMonthly)
{
var height = value.Scale(AxisMax, plotBounds.Height);
var y = plotBounds.Y;
var columnBounds = new RectangleF(x, y, columnWidth, height);
graphics.FillRectangle(Style.SystemsBrush, columnBounds);
graphics.DrawRectangleF(new Pen(Color.White), columnBounds);
// Value label
var format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
var textHeight = GH_FontServer.MeasureString(value.ToString(), SmallFont).Height;
var valueLabelBounds = new RectangleF(x, y + height, columnWidth, textHeight * 2);
graphics.DrawString(PlotCaption(value), SmallFont, TextBrush, valueLabelBounds, format);
x += columnWidth;
}
RenderMonthLabelsSystemsRow(graphics, plotBounds);
}
19
View Source File : MonthlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
private void RenderEmbodiedBuildings(Graphics graphics)
{
var plotBounds = EmbodiedBuildingsPlotBounds.CloneInflate(-1, -1); // allow a bit of whitespace
var columnWidth = plotBounds.Width / 12;
var x = plotBounds.Left;
foreach (var value in Data.EmbodiedBuildingsMonthly)
{
var height = value.Scale(AxisMax, plotBounds.Height);
var y = plotBounds.Y + (plotBounds.Height - height);
var columnBounds = new RectangleF(x, y, columnWidth, height);
graphics.FillRectangle(Style.BuildingsBrush, columnBounds);
graphics.DrawRectangleF(new Pen(Color.White), columnBounds);
// Value label
var format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
var textHeight = GH_FontServer.MeasureString(value.ToString(), SmallFont).Height;
var valueLabelBounds = new RectangleF(x, y - 2 * textHeight, columnWidth, 2 * textHeight);
graphics.DrawString(PlotCaption(value), SmallFont, TextBrush, valueLabelBounds, format);
x += columnWidth;
}
RenderMonthLabelsBuildingsRow(graphics, plotBounds);
}
19
View Source File : YearlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderEmbodiedBuildings(Graphics graphics)
{
var plotBounds = EmbodiedBuildingsPlotBounds.Clone();
plotBounds.Width /= 2;
plotBounds.X += plotBounds.Width;
var newMaxValue = EmbodiedBuildingsPlotBounds.Height;
plotBounds.Height = Data.EmbodiedBuildingsYearly.Scale(AxisMax, newMaxValue);
plotBounds.Y += (newMaxValue - plotBounds.Height);
plotBounds.Offset(-1, -1);
graphics.FillRectangle(Style.BuildingsBrush, plotBounds);
return plotBounds;
}
19
View Source File : YearlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderEmbodiedSystems(Graphics graphics)
{
var plotBounds = EmbodiedSystemsPlotBounds.Clone();
plotBounds.Width /= 2;
plotBounds.X += plotBounds.Width;
var newMaxValue = EmbodiedSystemsPlotBounds.Height;
plotBounds.Height = Data.EmbodiedSystemsYearly.Scale(AxisMax, newMaxValue);
plotBounds.Offset(-1, 1);
graphics.FillRectangle(Style.SystemsBrush, plotBounds);
return plotBounds;
}
19
View Source File : YearlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderOperationBuildings(Graphics graphics)
{
var plotBounds = OperationBuildingsPlotBounds.Clone();
plotBounds.Width /= 2;
var newMaxValue = OperationBuildingsPlotBounds.Height;
plotBounds.Height = Data.OperationBuildingsYearly.Scale(AxisMax, newMaxValue);
plotBounds.Y += (newMaxValue - plotBounds.Height);
plotBounds.Offset(1, -1);
graphics.FillRectangle(Style.BuildingsBrush, plotBounds);
return plotBounds;
}
19
View Source File : YearlyAmrPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
protected RectangleF RenderOperationSystems(Graphics graphics)
{
var plotBounds = OperationSystemsPlotBounds.Clone();
plotBounds.Width /= 2;
var newMaxValue = OperationSystemsPlotBounds.Height;
plotBounds.Height = Data.OperationSystemsYearly.Scale(AxisMax, newMaxValue);
plotBounds.Offset(1, 1);
graphics.FillRectangle(Style.SystemsBrush, plotBounds);
return plotBounds;
}
19
View Source File : KpiPlot.cs
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
License : GNU General Public License v3.0
Project Creator : architecture-building-systems
public void Render(ResultsPlotting results, Graphics graphics, RectangleF bounds, bool selected)
{
// save bounds for Contains method - when user clicks on the plot
_bounds = bounds;
var brush = new SolidBrush(Color.Black);
var pen = new Pen(_properties.Color, _penWidth);
// draw box
var box = new RectangleF(bounds.Location, bounds.Size);
box.Inflate(-_penWidth / 2, -_penWidth / 2); // make sure lines fit _inside_ box
graphics.DrawRectangle(pen, box.Left, box.Top, box.Width, box.Height);
graphics.FillRectangle(new SolidBrush(_properties.Color), box);
if (selected)
{
// draw black selected bar on top
var selectionBounds = bounds.Clone();
selectionBounds.Height = _penWidth;
graphics.FillRectangle(new SolidBrush(Color.Black), selectionBounds);
}
// center data in the box
var data = Data(results);
var dataSize = GH_FontServer.MeasureString(data, _boldFont);
var dataX = bounds.Left + (bounds.Width - dataSize.Width) / 2;
var dataY = bounds.Top + bounds.Height / 2 - (float) dataSize.Height / 2;
graphics.DrawString(data, _boldFont, brush, dataX, dataY);
// center unit below data
var unitX = bounds.Left + (bounds.Width - GH_FontServer.StringWidth(UnitText, _standardFont)) / 2;
var unitY = dataY + dataSize.Height;
graphics.DrawString(UnitText, _standardFont, brush, unitX, unitY);
}
19
View Source File : WindowsProgressBar.cs
License : MIT License
Project Creator : arsium
License : MIT License
Project Creator : arsium
protected override void OnPaint(PaintEventArgs e)
{
this.BackColor = Color.FromArgb(250, 250, 250);
Rectangle rec = e.ClipRectangle;
rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
if (ProgressBarRenderer.IsSupported)
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle);
rec.Height = rec.Height - 4;
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0, 173, 239)), 2, 2, rec.Width, rec.Height);
}
19
View Source File : MyProgressBar.cs
License : GNU General Public License v2.0
Project Creator : Asixa
License : GNU General Public License v2.0
Project Creator : Asixa
protected override void OnPaint(PaintEventArgs e)
{
var rec = e.ClipRectangle;
rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
if (ProgressBarRenderer.IsSupported)
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle);
rec.Height = rec.Height - 4;
e.Graphics.FillRectangle(Brushes.DodgerBlue, 2, 2, rec.Width, rec.Height);
}
19
View Source File : PlotPane.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
protected override void OnPaint(PaintEventArgs e)
{
//const int TXT_H_MARGIN = 8;
var gr = e.Graphics;
var lineWidth = m_Chart.VRulerWidth;
// + TXT_H_MARGIN;// (int)(fSize.Width + TXT_H_MARGIN);//H margin
var halfLineHeight = m_VLineSpaceHeight / 2;
var rulerX = m_Chart.VRulerPosition == VRulerPosition.Right ? this.Width - lineWidth : 0;
//Ruler bar
gr.FillRectangle(m_Chart.RulerStyle.BackBrush, new Rectangle(rulerX, 0, lineWidth, Height));
var pen = m_Chart.GridLinePen;
var lineCount = this.Height/m_VLineSpaceHeight;
var linePrice = (m_VRulerMaxScale - m_VRulerMinScale)/lineCount;
var price = m_VRulerMinScale;
var y = this.Height;
while (y >= 0)
{
if (m_Chart.VRulerPosition == VRulerPosition.Right)
gr.DrawLine(pen, 0, y, this.Width - lineWidth, y);
else
gr.DrawLine(pen, lineWidth, y, this.Right, y);
gr.DrawString(scaleValueToString(price), m_Chart.RulerStyle.Font, m_Chart.RulerStyle.ForeBrush,
rulerX + (TimeSeriesChart.VRULLER_HPADDING/2), y - halfLineHeight + (VLINE_SPACE_PADDING/2));
y -= m_VLineSpaceHeight;
price += linePrice;
}
using (var warpPen = getGridPen(m_Chart.GridLineTimeGapStyle))
{
foreach (var tick in m_Chart.m_TimeScalePane.Ticks)
{
if (tick.Warp)
{
gr.DrawLine(warpPen, tick.X - 1, 0, tick.X - 1, Height);
gr.DrawLine(warpPen, tick.X + 1, 0, tick.X + 1, Height);
}
if (tick.DayChange)
using (var dayChgPen = getGridPen(m_Chart.GridLineDayChangeStyle))
gr.DrawLine(dayChgPen, tick.X, 0, tick.X, Height);
else
gr.DrawLine(pen, tick.X, 0, tick.X, Height);
}
}
//Vertical cursor line
gr.DrawLine(m_Chart.VCursorLinePen, m_Chart.m_TimeScalePane.MouseCursorX, 0,
m_Chart.m_TimeScalePane.MouseCursorX, Height);
base.OnPaint(e);
}
19
View Source File : TimeScalePane.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
protected internal override void Paint(System.Drawing.Graphics gr)
{
using (var font = new Font("Verdana", 6f))
using (var sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
gr.FillRectangle(Pane.Chart.TimeScaleSelectStyle.BackBrush, this.Region);
gr.DrawString(m_Text, font, Pane.Chart.TimeScaleSelectStyle.ForeBrush, this.Region, sf);
}
}
19
View Source File : CellElement.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
protected virtual void PaintBackground(System.Drawing.Graphics gr)
{
using (var brush = getBrush(m_Style))
{
gr.FillRectangle(brush, Region);
}
}
19
View Source File : CommentElement.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
protected internal override void Paint(System.Drawing.Graphics gr)
{
var reg = Region;
reg.Inflate(-2,-2);
gr.FillRectangle(Brushes.Beige, reg);
gr.DrawLine(Pens.Gray, reg.X, reg.Y, reg.X, reg.Bottom);
gr.DrawLine(Pens.Gray, reg.Left, reg.Y, reg.Right, reg.Y);
using(var pen = new Pen(Color.Black))
{
pen.Width = 2f;
gr.DrawLine(pen, reg.Right, reg.Y, reg.Right, reg.Bottom);
gr.DrawLine(pen, reg.Left, reg.Bottom, reg.Right, reg.Bottom);
}
using (StringFormat fmt = new StringFormat())
{
fmt.Alignment = StringAlignment.Near;
var treg = reg;
treg.Inflate(-2, -2);
gr.DrawString(Text, m_Host.Font, Brushes.Black, treg, fmt);
}
}
19
View Source File : NetCanvas.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
public void FillRectangle(IPALCanvasBrush brush, Rectangle rect) => m_Graphics.FillRectangle(((NetBrush)brush).GDIBrush, rect);
19
View Source File : NetCanvas.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
public void FillRectangle(IPALCanvasBrush brush, RectangleF rect) => m_Graphics.FillRectangle(((NetBrush)brush).GDIBrush, rect);
19
View Source File : CandleBuySellView.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
protected internal override void Paint(System.Drawing.Graphics gr)
{
var hf = CandleView.BAR_WIDTH / 2;
if (m_View.Kind== ViewKind.SideBySide)
{
var hh = Host.Height / Host.Zoom;
gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, hf, m_Lay_BuyHeight);
gr.FillRectangle(Brushes.Red, this.Left+hf, hh - m_Lay_SellHeight, hf, m_Lay_SellHeight);
}
else if (m_View.Kind== ViewKind.Stacked)
{
var hh = Host.Height / Host.Zoom;
gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
gr.FillRectangle(Brushes.Red, this.Left, hh - m_Lay_BuyHeight-m_Lay_SellHeight, CandleView.BAR_WIDTH, m_Lay_SellHeight);
}
else//centered
{
var mid = (Host.Height / 2) / Host.Zoom;
gr.FillRectangle(Brushes.Green, this.Left, mid - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
gr.FillRectangle(Brushes.Red, this.Left, mid, CandleView.BAR_WIDTH, m_Lay_SellHeight);
}
}
19
View Source File : VideoCutterTimeline.cs
License : MIT License
Project Creator : bartekmotyl
License : MIT License
Project Creator : bartekmotyl
private void VideoCutterTimeline_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(brushBackground, ClientRectangle);
TimelineTooltip timelineTooltip = null;
var infoAreaHeight = 30;
var infoAreaRect = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, infoAreaHeight);
e.Graphics.FillRectangle(brushBackgroundInfoArea, infoAreaRect);
if (Length != 0)
{
var pixelStart = ((float)offset / Length) * ClientRectangle.Width;
var pixelEnd = ((float)PixelToPosition(ClientRectangle.Width)/Length) * ClientRectangle.Width;
e.Graphics.FillRectangle(brushBackgroundInfoAreaOffset, pixelStart, 0, pixelEnd - pixelStart, infoAreaHeight);
}
if (Length != 0)
{
var time = TimeSpan.FromMilliseconds(Position);
var text = string.Format($"{GlobalStrings.VideoCutterTimeline_Time}: {time:hh\\:mm\\:ss\\:fff} ");
if (HoverPosition != null)
{
var hoverTime = TimeSpan.FromMilliseconds(HoverPosition.Value);
text = text + string.Format($" {GlobalStrings.VideoCutterTimeline_HoveredTime}: {hoverTime:hh\\:mm\\:ss\\:fff} ");
}
PaintStringInBox(e.Graphics, null, Brushes.LightGray, text, infoAreaRect, 10);
}
e.Graphics.TranslateTransform(0, infoAreaHeight);
int timeLineHeight = ClientRectangle.Height - infoAreaHeight;
if (SelectionStart != null && SelectionEnd != null)
{
var pixelsStart = PositionToPixel((long?)SelectionStart.Value);
var pixelsEnd = PositionToPixel((long?)SelectionEnd.Value);
var selectionRect = new Rectangle(pixelsStart, 0, pixelsEnd - pixelsStart, timeLineHeight);
e.Graphics.FillRectangle(brushBackgroundSelected, selectionRect);
}
if (Length != 0)
{
float pixelsPerSecond = PixelsPerMilliseconds() * 1000.0f;
for (long position = 0; position <= Length; position += 1000)
{
var time = TimeSpan.FromMilliseconds(position);
var posXPixel = (position - offset) * PixelsPerMilliseconds();
if (posXPixel >= -ClientRectangle.Width && posXPixel <= ClientRectangle.Width)
{
e.Graphics.DrawLine(penTickSeconds, (int)posXPixel, 3 * (timeLineHeight / 4), (int)posXPixel, timeLineHeight);
if (time.Seconds == 0)
e.Graphics.DrawLine(penTickMinute, (int)posXPixel, timeLineHeight / 2, (int)posXPixel, timeLineHeight);
string text;
if (time.TotalHours > 1)
text = string.Format($"{time:hh\\:mm\\:ss}");
else
text = string.Format($"{time:mm\\:ss}");
var size = e.Graphics.MeasureString(text, this.Font);
if (pixelsPerSecond > size.Width + 5)
{
var rect = new Rectangle((int)posXPixel, (int)(timeLineHeight - size.Height), 100, 15);
e.Graphics.DrawString(text, this.Font, penTickSeconds.Brush, rect, StringFormat.GenericDefault);
}
}
}
if (SelectionStart != null)
{
var pixel = PositionToPixel(SelectionStart.Value);
e.Graphics.FillRectangle(brushSelectionMarker, pixel, 0, 2, timeLineHeight);
PaintUpperHalfTriangle(e.Graphics, brushSelectionMarker, pixel, 8, 8, true);
PaintBottomHalfTriangle(e.Graphics, brushSelectionMarker, pixel, 8, 8, true, timeLineHeight);
}
if (SelectionEnd != null)
{
var pixel = PositionToPixel(SelectionEnd.Value);
e.Graphics.FillRectangle(brushSelectionMarker, pixel, 0, 2, timeLineHeight);
PaintUpperHalfTriangle(e.Graphics, brushSelectionMarker, pixel, 8, 8, false);
PaintBottomHalfTriangle(e.Graphics, brushSelectionMarker, pixel, 8, 8, false, timeLineHeight);
}
var positionPixel = PositionToPixel(Position);
PaintTriangle(e.Graphics, brushPosition, positionPixel+1, 8, 8);
e.Graphics.FillRectangle(brushPosition, positionPixel, 0, 2, timeLineHeight);
if (HoverPosition != null)
{
var pixel = PositionToPixel(HoverPosition);
if (selectionStartMoveController.IsDragStartPossible(pixel) || selectionStartMoveController.IsDragInProgress())
{
timelineTooltip = new TimelineTooltip() { X = pixel, Text = GlobalStrings.VideoCutterTimeline_MoveClipStart };
}
if (selectionEndMoveController.IsDragStartPossible(pixel) || selectionEndMoveController.IsDragInProgress())
{
timelineTooltip = new TimelineTooltip() { X = pixel, Text = GlobalStrings.VideoCutterTimeline_MoveClipEnd };
}
e.Graphics.FillRectangle(brushHoverPosition, pixel, 0, 2, timeLineHeight);
PaintTriangle(e.Graphics, brushHoverPosition, PositionToPixel(HoverPosition)+1, 8, 8);
string tooltipSetClipOverrideText = null;
if (ModifierKeys == Keys.Shift)
tooltipSetClipOverrideText = GlobalStrings.VideoCutterTimeline_SetClipFromHereTillEnd;
else if (ModifierKeys == Keys.Control)
tooltipSetClipOverrideText = GlobalStrings.VideoCutterTimeline_SetClipFromStartTillHere;
if (SelectionStart == null)
{
timelineTooltip = new TimelineTooltip() { X = pixel, Text = tooltipSetClipOverrideText ?? GlobalStrings.VideoCutterTimeline_SetClipStartHere };
}
else if (SelectionEnd == null && HoverPosition.Value > SelectionStart.Value)
{
timelineTooltip = new TimelineTooltip() { X = pixel, Text = tooltipSetClipOverrideText ?? GlobalStrings.VideoCutterTimeline_SetClipEndHere };
}
}
e.Graphics.ResetTransform();
if (timelineTooltip != null)
{
PaintStringInBox(e.Graphics, Brushes.LightYellow, Brushes.Gray, timelineTooltip.Text, infoAreaRect, timelineTooltip.X);
}
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : berryelectronics
License : MIT License
Project Creator : berryelectronics
private void drawEditorArea(int width, int height)
{
int offsetX = editorOffsetX;
int offsetY = editorOffsetY;
int xPosition = offsetX;
int yPosition = offsetY;
//Draw empty rectangle first to clear area!
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize * 73, drawingRectangleSize * 73);
pinsel.Color = Color.Black;
//Draw grid
Pen pen = new Pen(Color.FromArgb(255, 0, 0, 0));
// Vertical Lines
for (int i = 0; i < height + 1; i++)
{
z.DrawLine(pen, xPosition, yPosition, xPosition, yPosition + drawingRectangleSize * width);
xPosition = xPosition + drawingRectangleSize;
}
xPosition = offsetX;
// Horizontal Lines
for (int i = 0; i < width + 1; i++)
{
z.DrawLine(pen, xPosition, yPosition, xPosition + drawingRectangleSize * height, yPosition);
yPosition = yPosition + drawingRectangleSize;
}
yPosition = offsetY;
// Fill only the needed squares
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
if (drawingAreaBuffer[j, i] == true)
{
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
xPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition = offsetY;
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : berryelectronics
License : MIT License
Project Creator : berryelectronics
private void timerMouseDown_Tick(object sender, EventArgs e)
{
int mouseX = this.PointToClient(Cursor.Position).X; //replaced IS FLIPPED!
int mouseY = this.PointToClient(Cursor.Position).Y; //replaced IS FLIPPED!
int offsetX = editorOffsetX;
int offsetY = editorOffsetY;
int xPixelPosition = offsetX;
int yPixelPosition = offsetY;
int xPosition, yPosition;
//Test is it actually inside the drawing area:
if (mouseX > offsetX && mouseX < (offsetX + drawingRectangleSize * currentEditorHeight) && mouseY > offsetY && mouseY < (offsetY + drawingRectangleSize * currentEditorWidth))
{
xPixelPosition = (int)(mouseX - offsetX) / drawingRectangleSize;
yPixelPosition = (int)(mouseY - offsetY) / drawingRectangleSize;
if (editorMouseDownLastX == -1 || editorMouseDownLastY == -1)
{
editorMouseDownLastX = xPixelPosition;
editorMouseDownLastY = yPixelPosition;
}
if (xPixelPosition != editorMouseDownLastX || yPixelPosition != editorMouseDownLastY)
{
//Fill new Data
for (int i = 0; i < editorBrushWidth; i++)
{
for (int j = 0; j < editorBrushWidth; j++)
{
if ((xPixelPosition + i) >= currentEditorHeight) break;
if ((yPixelPosition + j) >= currentEditorWidth) break;
drawingAreaBuffer[(xPixelPosition + i), (yPixelPosition + j)] = editorModeAddPixel;
xPosition = offsetX + drawingRectangleSize * (xPixelPosition + i);
yPosition = offsetY + drawingRectangleSize * (yPixelPosition + j);
if (editorModeAddPixel)
{
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
else
{
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
pinsel.Color = Color.Black;
z.DrawRectangle(stift, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
}
}
editorMouseDownLastX = xPixelPosition;
editorMouseDownLastY = yPixelPosition;
}
}
/*
int mouseX = this.PointToClient(Cursor.Position).X; //replaced IS FLIPPED!
int mouseY = this.PointToClient(Cursor.Position).Y; //replaced IS FLIPPED!
int offsetX = editorOffsetX;
int offsetY = editorOffsetY;
int xPosition = offsetX;
int yPosition = offsetY;
for (int i = 0; i < currentEditorWidth; i++) //replaced IS FLIPPED!
{
for (int j = 0; j < currentEditorHeight; j++) //replaced IS FLIPPED!
{
//Checks if Mouseclick was within boundaries of that "pixel"
if (xPosition < mouseX && yPosition < mouseY && (xPosition + drawingRectangleSize) > mouseX && (yPosition + drawingRectangleSize) > mouseY)
{
//Console.WriteLine("Clicked! On Field X: " + j + " and Y: " + i + " | " + editorMouseDownLastX + " " + editorMouseDownLastY);
if (j != editorMouseDownLastX || i != editorMouseDownLastY)
{
if (editorModeAddPixel)
{
drawingAreaBuffer[j, i] = true;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
else
{
drawingAreaBuffer[j, i] = false;
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
pinsel.Color = Color.Black;
z.DrawRectangle(stift, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
editorMouseDownLastX = j;
editorMouseDownLastY = i;
}
}
xPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition += drawingRectangleSize;
}
*/
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : berryelectronics
License : MIT License
Project Creator : berryelectronics
private void drawEditorArea(int width, int height)
{
int offsetX = editorOffsetX;
int offsetY = editorOffsetY;
int xPosition = offsetX;
int yPosition = offsetY;
//Draw empty rectangle first to clear area!
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize * 41, drawingRectangleSize * 41);
pinsel.Color = Color.Black;
//Draw grid
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
if (drawingAreaBuffer[j, i] == true)
{
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
else
{
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
pinsel.Color = Color.Black;
z.DrawRectangle(stift, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
xPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition += drawingRectangleSize;
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : berryelectronics
License : MIT License
Project Creator : berryelectronics
private void drawEditorArea2(int width, int height)
{
int offsetX = editorOffsetX;
int offsetY = editorOffsetY;
int xPosition = offsetX;
int yPosition = offsetY;
//Draw empty rectangle first to clear area!
pinsel.Color = BackColor;
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize * 41, drawingRectangleSize * 41);
pinsel.Color = Color.Black;
//Draw grid
Pen pen = new Pen(Color.FromArgb(255, 0, 0, 0));
// Vertical Lines
for (int i = 0; i < height + 1; i++)
{
z.DrawLine(pen, xPosition, yPosition, xPosition, yPosition + drawingRectangleSize * width);
xPosition = xPosition + drawingRectangleSize;
}
xPosition = offsetX;
// Horizontal Lines
for (int i = 0; i < width + 1; i++)
{
z.DrawLine(pen, xPosition, yPosition, xPosition + drawingRectangleSize * height, yPosition);
yPosition = yPosition + drawingRectangleSize;
}
yPosition = offsetY;
// Fill only the needed squares
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
if (drawingAreaBuffer[j, i] == true)
{
z.FillRectangle(pinsel, xPosition, yPosition, drawingRectangleSize, drawingRectangleSize);
}
xPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition += drawingRectangleSize;
}
xPosition = offsetX;
yPosition = offsetY;
//Draw Red Lines over it
// Vertical Lines
for (int i = 0; i < height + 1; i++)
{
if (i == 0 || (i % 8) == 0)
{
pen.Color = Color.FromArgb(255, 255, 0, 0);
}
else if (i == 1 || (i % 8) == 1)
{
pen.Color = Color.FromArgb(255, 0, 0, 0);
}
z.DrawLine(pen, xPosition, yPosition, xPosition, yPosition + drawingRectangleSize * width);
xPosition = xPosition + drawingRectangleSize;
}
xPosition = offsetX;
// Horizontal Lines
for (int i = 0; i < width + 1; i++)
{
if (i == 0 || (i % 8) == 0)
{
pen.Color = Color.FromArgb(255, 255, 0, 0);
}
else if (i == 1 || (i % 8) == 1)
{
pen.Color = Color.FromArgb(255, 0, 0, 0);
}
z.DrawLine(pen, xPosition, yPosition, xPosition + drawingRectangleSize * height, yPosition);
yPosition = yPosition + drawingRectangleSize;
}
yPosition = offsetY;
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : berryelectronics
License : MIT License
Project Creator : berryelectronics
private void clearEditor()
{
pinsel.Color = BackColor;
z.FillRectangle(pinsel, 0, 0, ClientRectangle.Width, ClientRectangle.Height);
pinsel.Color = Color.Black;
}
19
View Source File : GeneticVisualAbstractor.cs
License : MIT License
Project Creator : Binomica-Labs
License : MIT License
Project Creator : Binomica-Labs
public Bitmap MultiVisualize()
{
UpdateStatusBar("Calculating nucleotide ratios...");
ratioImage = RatioImage();
if (loadedDNALength > 50000)
{
UpdateStatusBar("Calculating ladder size...");
ladderImage = GenerateLadderDNA();
}
UpdateStatusBar("Abstracting pixel perfect column...");
visualAbstraction1 = visualizeDNA(loadedNucleotides);
UpdateStatusBar("Abstracting 20bp column...");
AbstractDNA(20);
visualAbstraction20 = visualizeDNA(abstractedNucleotides);
UpdateStatusBar("Abstracting 40bp column..."); //iterate through a set of filter values and produce an image for that corresponding abstraction
AbstractDNA(40);
visualAbstraction40 = visualizeDNA(abstractedNucleotides);
UpdateStatusBar("Abstracting 80bp column...");
AbstractDNA(80);
visualAbstraction80 = visualizeDNA(abstractedNucleotides);
UpdateStatusBar("Abstracting 100bp column...");
AbstractDNA(100);
visualAbstraction100 = visualizeDNA(abstractedNucleotides);
UpdateStatusBar("Abstracting 200bp column...");
AbstractDNA(200);
visualAbstraction200 = visualizeDNA(abstractedNucleotides);
UpdateStatusBar("Abstracting 400bp column...");
AbstractDNA(400);
visualAbstraction400 = visualizeDNA(abstractedNucleotides);
Bitmap combinedVisualAbstraction = new Bitmap((visualAbstraction1.Width +
visualAbstraction20.Width +
visualAbstraction40.Width +
visualAbstraction80.Width +
visualAbstraction100.Width +
visualAbstraction200.Width +
visualAbstraction400.Width +
ratioImage.Width +
200),
visualAbstraction1.Height);
using (Graphics g = Graphics.FromImage(combinedVisualAbstraction))
{
using (SolidBrush brush = new SolidBrush(Color.FromArgb(0, 0, 0)))
{
g.FillRectangle(brush, 0, 0, combinedVisualAbstraction.Width, combinedVisualAbstraction.Height);
}
if (ladderImage != null)
{
g.DrawImage(ladderImage, visualAbstraction1.Width + 5, 0);
}
g.DrawImage(visualAbstraction1, visualAbstraction1.Width * 2 + 6, 0);
g.DrawImage(visualAbstraction20, visualAbstraction1.Width * 3 + 11, 0);
g.DrawImage(visualAbstraction40, visualAbstraction1.Width * 4 + 16, 0); //sreplacedch all the abstraction images together in order of increasing filter size on one large image
g.DrawImage(visualAbstraction80, visualAbstraction1.Width * 5 + 21, 0); //make a new image large enough to fit all 7 data columns + 5 pixels of spacer between each
g.DrawImage(visualAbstraction100, visualAbstraction1.Width * 6 + 26, 0); //ladder image is the only image touching the actual data columns
g.DrawImage(visualAbstraction200, visualAbstraction1.Width * 7 + 31, 0);
g.DrawImage(visualAbstraction400, visualAbstraction1.Width * 8 + 36, 0);
g.DrawImage(ratioImage, 100, 0);
}
visualAbstraction1.Dispose();
visualAbstraction20.Dispose();
visualAbstraction40.Dispose();
visualAbstraction80.Dispose();
visualAbstraction100.Dispose();
visualAbstraction200.Dispose();
visualAbstraction400.Dispose();
ratioImage.Dispose();
if (ladderImage != null)
{
ladderImage.Dispose();
}
return combinedVisualAbstraction;
}
19
View Source File : RulerPainter.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Bluegrams
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Bluegrams
protected void PaintRulerCanvas()
{
using (Brush brush = new SolidBrush(settings.Theme.Background))
{
if (resizeMode.HasFlag(FormResizeMode.Horizontal))
{
g.FillRectangle(brush, 0, 0, c.Width, drawWidth);
}
if (resizeMode.HasFlag(FormResizeMode.Vertical))
{
g.FillRectangle(brush, 0, 0, drawWidth, c.Height);
}
}
}
19
View Source File : ColorValueControl.cs
License : GNU Affero General Public License v3.0
Project Creator : bonimy
License : GNU Affero General Public License v3.0
Project Creator : bonimy
protected virtual void DrawColorValue(PaintEventArgs e)
{
if (e is null)
{
throw new ArgumentNullException(nameof(e));
}
var color = SelectedColor;
if (!Enabled)
{
var colorF = (ColorF)color;
var gray = colorF.Grayscale();
color = (Color)gray;
}
using (var brush = new SolidBrush(color))
{
e.Graphics.FillRectangle(brush, ClientRectangle);
}
}
19
View Source File : ImageUtils.cs
License : MIT License
Project Creator : Bphots
License : MIT License
Project Creator : Bphots
public Bitmap CaptureArea(Bitmap bmp, Rectangle rect, Point[] clipPoints, bool textInWhite = false)
{
Bitmap bitmap = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppRgb);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.FillRectangle(textInWhite ? Brushes.Black : Brushes.White, 0, 0, rect.Width, rect.Height);
using (GraphicsPath graphicsPath = new GraphicsPath())
{
if (clipPoints.Length != 0)
{
graphicsPath.AddPolygon(clipPoints);
graphics.SetClip(graphicsPath);
}
}
graphics.DrawImage(bmp, 0, 0, rect, GraphicsUnit.Pixel);
}
return bitmap;
}
19
View Source File : BitmapExtension.cs
License : MIT License
Project Creator : Bphots
License : MIT License
Project Creator : Bphots
public static Bitmap RotateImage(this Bitmap rotateMe, float angle, bool textInWhite = false)
{
angle = -angle;
var normalizedRotationAngle = NormalizeAngle(angle);
double widthD = rotateMe.Width, heightD = rotateMe.Height;
var newWidthD = Math.Cos(normalizedRotationAngle)*widthD + Math.Sin(normalizedRotationAngle)*heightD;
var newHeightD = Math.Cos(normalizedRotationAngle)*heightD + Math.Sin(normalizedRotationAngle)*widthD;
var newWidth = (int) Math.Ceiling(newWidthD);
var newHeight = (int) Math.Ceiling(newHeightD);
if (newWidth < newHeight)
{
var temp = newWidth;
newWidth = newHeight;
newHeight = temp;
}
using (var bmp = new Bitmap(newWidth, newHeight))
{
using (var g = Graphics.FromImage(bmp))
g.DrawImageUnscaled(rotateMe, (newWidth - rotateMe.Width) / 2, (newHeight - rotateMe.Height) / 2,
bmp.Width, bmp.Height);
//Now, actually rotate the image
var rotatedImage = new Bitmap(bmp.Width, bmp.Height);
using (var g = Graphics.FromImage(rotatedImage))
{
g.FillRectangle(textInWhite ? Brushes.Black : Brushes.White, 0, 0, rotatedImage.Width, rotatedImage.Height);
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
//set the rotation point as the center into the matrix
g.RotateTransform(angle); //rotate
g.TranslateTransform(-bmp.Width / 2, -bmp.Height / 2); //restore rotation point into the matrix
g.DrawImage(bmp, new Point(0, 0)); //draw the image on the new bitmap
}
return rotatedImage;
}
}
19
View Source File : OcrEngine.cs
License : MIT License
Project Creator : Bphots
License : MIT License
Project Creator : Bphots
public Bitmap ExtendImage(Bitmap bmp)
{
var bitmap = new Bitmap((int)(bmp.Width * 1.1), bmp.Height, PixelFormat.Format32bppRgb);
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.FillRectangle(Brushes.White, 0, 0, bitmap.Width, bitmap.Height);
graphics.DrawImage(bmp, (float)(0.05 * bitmap.Width), 0, new Rectangle(0, 0, bitmap.Width, bitmap.Height),
GraphicsUnit.Pixel);
}
return bitmap;
}
19
View Source File : LineChart.cs
License : GNU Lesser General Public License v3.0
Project Creator : ccbpm
License : GNU Lesser General Public License v3.0
Project Creator : ccbpm
public void Draw()
{
int i ;
float x , y , x0 , y0 ;
//首先要创建图片的大小
//p.Response.ContentType = "image/jpeg" ;
//p.Response.ContentType = "image/jpeg" ;
g.FillRectangle ( new SolidBrush ( Color.White ) , 0 , 0 , ImageWidth , ImageHeight ) ;
///画一个矩形
g.DrawRectangle ( new Pen( Color.Black , 1) , ChartInset , ChartInset , ChartWidth , ChartHeight );
//写出图片上面的图片内容文字
Font fon= new Font( "宋体" , 14 );
g.DrawString( replacedle , fon , BlackBrush , ImageWidth/4, 10 );
#region 沿Y坐标写入Y标签
for ( i = 0 ; i <= YPontNum ; i++ )
{
x = ChartInset ;
y = ChartHeight + ChartInset - ( i * ChartHeight / YPontNum ) ;
string myLabel = ( Yorigin + ( YMaxCash * i / YPontNum ) ).ToString ( ) ;
g.DrawString(myLabel , axesFont , BlackBrush , 5 , y - 6 ) ;
g.DrawLine ( BlackPen , x + 2 , y , x - 2 , y ) ; /// 让其显示一个 dot 在图上。 有两个基本很近的点组合成的。
if (IsShowGirde && i > 0 )
{
g.DrawLine ( this.GradePen , ChartInset , y , ChartInset + ChartWidth , y) ;
}
}
g.RotateTransform ( 180 ) ;
g.TranslateTransform ( 0 , - ChartHeight ) ;
g.TranslateTransform ( - ChartInset , ChartInset ) ;
g.ScaleTransform ( - 1 , 1);
/// 如果要显示gride .
#endregion
#region 画出图表中的数据
DataPoint prevPoint = new DataPoint();
prevPoint.valid = false ;
foreach ( DataPoint myPoint in chartValues )
{
if ( prevPoint.valid == true )
{
// Xorigin = 2;
// Yorigin=2;
// x0 = ChartWidth * ( prevPoint.x - Xorigin ) /ImageWidth;
// y0 = ChartHeight*( prevPoint.y - Yorigin )/ImageHeight;
//
// x = ChartWidth * ( myPoint.x - Xorigin ) / ImageWidth ;
// y = ChartHeight * ( myPoint.y - Yorigin ) / ImageHeight ;
x0 = prevPoint.x ;
y0 = prevPoint.y ;
x = myPoint.x ;
y = myPoint.y ;
g.DrawLine ( RedPen , x0 , y0 , x , y );
//g.FillEllipse(BlackBrush , x0 - 2 , y0 - 2, 2 , 2 ) ;
//g.FillEllipse( BlackBrush , x - 2 , y - 2 , 2 , 2 );
g.FillEllipse(BlackBrush , x0-2, y0-2, 4, 4 ) ;
g.FillEllipse( BlackBrush , x-2 , y-2, 4 , 4);
//g.FillEllipse( BlackBrush , x0 , y0 , 1 , 1 ) ;
//g.FillEllipse( BlackBrush , x , y , 1 , 1 );
if (this.IsShowLab)
{
g.DrawString( myPoint.KJNY+";"+myPoint.Cash.ToString(), new Font("宋体",10), BlackBrush , x,y );
//g.DrawString( "abc", new Font("宋体",10), BlackBrush , x,y );
//g.RotateTransform ( 180 ) ;
//g.TranslateTransform ( 0 , - ImageHeight ) ;
//g.TranslateTransform ( - ChartInset , ChartInset ) ;
//g.ScaleTransform ( - 1 , 1);
}
}
prevPoint = myPoint ;
}
#endregion
#region 最后以图片形式来浏览
string fileName=DBAccess.GenerOID().ToString()+".Jpeg";
b.Save( ExportFilePath+ fileName, ImageFormat.Jpeg);
this.ImageUrl=System.Web.HttpContext.Current.Request.ApplicationPath+"/Temp/" + fileName;
#endregion
}
19
View Source File : FrmInfo.cs
License : MIT License
Project Creator : ChDC
License : MIT License
Project Creator : ChDC
private void drawMemoryUsage(float value)
{
Control control = lblMemory;
Bitmap b = new Bitmap(control.Width, control.Height);
Graphics g = Graphics.FromImage(b);
//draw background
g.FillRectangle(new SolidBrush(Color.FromArgb(28, 28, 29)), 0, 0, control.Width, control.Height);
// draw usage rect
int width = (int)(control.Width * value);
Rectangle rect = new Rectangle(0, 0, width, control.Height);
//LinearGradientBrush brush = new LinearGradientBrush(control.ClientRectangle, Color.FromArgb(17, 160, 255), Color.FromArgb(23,174,254), LinearGradientMode.Vertical);
//brush.SetSigmaBellShape(0.5f);
//g.FillRectangle(brush, rect);
g.FillRectangle(new SolidBrush(Color.FromArgb(0, 186, 255)), rect);
// border
g.DrawRectangle(new Pen(Color.FromArgb(28, 28, 29), 3), 0, 0, control.Width-2, control.Height-2);
g.Dispose();
control.BackgroundImage = b;
}
19
View Source File : components.cs
License : BSD 2-Clause "Simplified" License
Project Creator : chengse66
License : BSD 2-Clause "Simplified" License
Project Creator : chengse66
private void toolstrip_color_draw_item(object o, DrawItemEventArgs e)
{
if (0 <= e.Index)
{
components_color color = item_color.Items[e.Index] as components_color;
Rectangle rectangle = e.Bounds;
SolidBrush brush = new SolidBrush(color.color);
e.DrawBackground();
e.Graphics.FillRectangle(brush, rectangle.Left + 1, rectangle.Top + 1, rectangle.Height - 2, rectangle.Height - 2);
e.Graphics.DrawString(color.name, filter.Font, Brushes.Black, new RectangleF(rectangle.Left + rectangle.Height, rectangle.Top + 1, rectangle.Width - rectangle.Height, rectangle.Height));
if (DrawItemState.Focus == e.State)
e.DrawFocusRectangle();
brush.Dispose();
}
}
See More Examples