public Drawer(Panel panel, int _xGridSquareSize, int _yGridSquareSize) { g = panel.CreateGraphics(); xGridSquareSize = _xGridSquareSize; yGridSquareSize = _yGridSquareSize; with = new DrawerUtensils(); }
public override void Draw(Panel panel) // 畫出橢圓形 { Pen myPen = new Pen(Color.Black, 1); Brush myBrush = new SolidBrush(Color.LightGray); StringFormat drawFormat = new StringFormat(); // 設定字形的位置 drawFormat.Alignment = StringAlignment.Center; // 水平置中 drawFormat.LineAlignment = StringAlignment.Center; // 垂直置中 rect = new Rectangle(coordinate, size); panel.CreateGraphics().FillEllipse(myBrush, rect); panel.CreateGraphics().DrawEllipse(myPen, rect); panel.CreateGraphics().DrawString(myID, new Font("Arial", 16), new SolidBrush(Color.Black), rect, drawFormat); myPen.Dispose(); myBrush.Dispose(); }
public void DrawCross(Panel panel) { Graphics g = panel.CreateGraphics(); Pen _pen = new Pen(Color.Black, _linewidth); g.DrawLine(_pen, new Point(_innerMargin, _innerMargin), new Point(_square - _innerMargin, _square - _innerMargin)); g.DrawLine(_pen, new Point(_innerMargin, _square - _innerMargin), new Point(_square - _innerMargin, _innerMargin)); }
public Vista(Panel areaDibujo) { g = areaDibujo.CreateGraphics(); anchura = areaDibujo.Width; altura = areaDibujo.Height; }
/// <summary> /// 地图描边 /// </summary> /// <param name="panel"></param> /// <param name="map"></param> public static void DrawMap(Panel panel, ModelMap map) { #region 勾画地图 var g = panel.CreateGraphics(); #region 画横线 for (int ri = 0; ri <= map.Row; ri++) { g.DrawLine(new Pen(Color.Black), 0, ri * map.Box.Height, map.Column * map.Box.Width, ri * map.Box.Height); } #endregion #region 画竖线 for (int ci = 0; ci <= map.Column; ci++) { g.DrawLine(new Pen(Color.Black), ci * map.Box.Width, 0, ci * map.Box.Height, map.Row * map.Box.Width); } #endregion #region 勾画方块 foreach (var b in map.Body) { DrawMapBox(panel, map.Color, b.Abscissa, b.Ordinate, map.Box.Width, map.Box.Height); } #endregion #endregion }
private void DrawCross(Panel panel) { Graphics g = panel.CreateGraphics(); Pen _pen = new Pen(Color.Black, _linewidth); g.DrawLine(_pen, new Point(_margin1, _margin1), new Point(_square - _margin1, _square - _margin1)); g.DrawLine(_pen, new Point(_margin1, _square - _margin1), new Point(_square - _margin1, _margin1)); }
public Vista(Panel areaDibujo, Color c1) { g = areaDibujo.CreateGraphics(); colorLapiz = c1; anchura = areaDibujo.Width; altura = areaDibujo.Height; }
public static void Draw( string text, int[] pixels) { var form = new Form { TopMost = true, Visible = true, Width = 29 * tileSize, Height = 29 * tileSize }; var panel = new Panel { Dock = DockStyle.Fill }; panel.BackColor = Color.Black; form.Controls.Add(panel); var graphics = panel.CreateGraphics(); for(int index=0; index < pixels.Length; index++){ int col = index % characerSize; int row = index / characerSize; Color color = Color.FromArgb(pixels[index], pixels[index], pixels[index]); var brush = new SolidBrush(color); graphics.FillRectangle(brush,col*tileSize,row*tileSize,tileSize,tileSize); } var point = new PointF(5, 5); var font = new Font(FontFamily.GenericSansSerif, 30 ); graphics.DrawString(text, font, new SolidBrush(Color.Red), point); Application.EnableVisualStyles(); Application.Run(form); }
public Vista(Panel areaDibujo) { this.g = areaDibujo.CreateGraphics(); this.colorLapiz = Color.Empty; ancho = areaDibujo.Width; alto = areaDibujo.Height; }
public Draw(Panel panel1,Panel panel2) { width = panel2.Width; height = panel2.Height; formGraphics = panel1.CreateGraphics(); formGraphics2 = panel2.CreateGraphics(); }
public void DrawRectangle(Pen pen, Panel canvas) { Graphics g = canvas.CreateGraphics(); g.DrawRectangle(pen, new Rectangle(X, Y, Width, Height)); g.Dispose(); pen.Dispose(); }
public void PrintPanel(Panel p) { Graphics mygraphics = p.CreateGraphics(); Size s = p.Size; mBitmap = new Bitmap(s.Width, s.Height, mygraphics); Graphics memoryGraphics = Graphics.FromImage(mBitmap); IntPtr dc1 = mygraphics.GetHdc(); IntPtr dc2 = memoryGraphics.GetHdc(); BitBlt(dc2, 0, 0, p.ClientRectangle.Width, p.ClientRectangle.Height, dc1, 0, 0, 13369376); mygraphics.ReleaseHdc(dc1); memoryGraphics.ReleaseHdc(dc2); saveFileDialog1.Filter = "图片文件(*.jpg)|*.jpg;"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { mBitmap.Save(saveFileDialog1.FileName, ImageFormat.Jpeg); } catch (Exception ee) { MessageBox.Show(ee.Message, "Error"); return; } MessageBox.Show("保存成功!", "提示"); } }
public Nodes(Panel panel1,Panel panel2) { formGraphics = panel1.CreateGraphics(); formGraphics.DrawRectangle(new Pen(Color.Blue, 5), panel1.ClientRectangle); formGraphics2 = panel2.CreateGraphics(); formGraphics2.DrawRectangle(new Pen(Color.Blue, 5), panel2.ClientRectangle); }
/// <summary> /// Заполняет область рисования указанным цветом /// </summary> /// <param name="pb">объект для рисования PictureBox, ссылочный</param> /// <param name="C">цвет для заливки</param> public static void fill_pictureBox(ref Panel pb, Color C) { using (Graphics G = pb.CreateGraphics()) { G.Clear(C); } }
public Vista(Panel areaDibujo, Color cl, Color cf) { g = areaDibujo.CreateGraphics(); ColorLapiz = cl; ColorFondo = cf; anchura = areaDibujo.Width; altura = areaDibujo.Height; }
public void Draw(Panel p, Color c, double x, double y) { var g = p.CreateGraphics(); var pen = new Pen(c); var point = new Point((int)(x * 8 + 150), (int)(y * 8 + 150)); var s = new System.Drawing.Size(2, 2); var circle = new Rectangle(point, s); g.DrawRectangle(pen, circle); }
public void DrawFrame(Panel panel) { System.Drawing.Graphics g = panel.CreateGraphics(); Pen myPen = new Pen(Color.Cyan); myPen.Width = 2; //g.DrawRectangle(myPen, new Rectangle(0, 0, 300, 300)); g.DrawLine(myPen, new Point(10, panel.Height - 10), new Point(panel.Width - 20, panel.Height - 10)); g.DrawLine(myPen, new Point(10, panel.Height-10), new Point(10, 0)); }
private void drawPages(Panel mainPanel) { Graphics g = mainPanel.CreateGraphics(); g.Clear(mainPanel.BackColor); g.FillRectangle(new SolidBrush(Color.LightBlue), new Rectangle(new Point(0, 0), new Size(pageWidth, pageHeight))); g.FillRectangle(new SolidBrush(Color.LightSkyBlue), new Rectangle(new Point(pageWidth, 0), new Size(pageWidth, pageHeight))); //g.DrawEllipse(new Pen(Color.DarkOliveGreen), 0, pageHeight - pageWidth, pageWidth * 2, pageWidth * 2); }
public override void Draw(Panel panel) // 畫出矩形 { Pen myPen = new Pen(Color.Black, 1); Brush myBrush = new SolidBrush(Color.LightGray); Rectangle[] rect = new Rectangle[3]; StringFormat drawFormat = new StringFormat(); // 設定字形的位置 drawFormat.Alignment = StringAlignment.Center; // 水平置中 drawFormat.LineAlignment = StringAlignment.Center; // 垂直置中 for (int i = 0; i < 3; i++) { rect[i] = new Rectangle(coordinate.X, coordinate.Y + (size.Height / 3) * i, size.Width, size.Height / 3); panel.CreateGraphics().FillRectangle(myBrush, rect[i]); panel.CreateGraphics().DrawRectangle(myPen, rect[i]); } panel.CreateGraphics().DrawString(myID, new Font("Arial", 16), new SolidBrush(Color.Black), rect[0], drawFormat); myPen.Dispose(); myBrush.Dispose(); base.Draw(panel); }
//default constructor public frmThreadGraphics() { InitializeComponent(); //populate the panel variable used for drawing panelDraw = pnlDraw; //create the graphics object graphics = panelDraw.CreateGraphics(); }//end default constructor
//method public void DrawRoom(System.Windows.Forms.Panel canvas, System.Drawing.Color color) { System.Drawing.Pen myPen = new System.Drawing.Pen(color); Graphics formGraphics; formGraphics = canvas.CreateGraphics(); formGraphics.DrawRectangle(myPen, new Rectangle(x1, y1, width, height)); myPen.Dispose(); formGraphics.Dispose(); }
//default constructor public frmThreadGraphics() { InitializeComponent(); //populate the panel variable used for drawing panelDraw = pnlDraw; //create the graphics object graphics = panelDraw.CreateGraphics(); }//end default constructor
private void SizeDialog() { int horizontalSpacing = (int)_textMargin.Width * 2; int verticalSpacing = ClientSize.Height - _inputTextBox.Top + (int)_textMargin.Height * 3; using (Graphics graphics = _primaryPanel.CreateGraphics()) { ClientSize = DialogHelper.SizeDialog(graphics, MainInstruction, Content, Screen.FromControl(this), new Font(Font, FontStyle.Bold), Font, horizontalSpacing, verticalSpacing, ClientSize.Width, 0); } }
internal void DrawCol(Panel PanelMethy) { this.Column = 100; Graphics g = PanelMethy.CreateGraphics(); for (int i = 1; i < Column; i++) { g.DrawLine(new Pen(Color.Black), PanelMethy.Width / Column * i, 0, PanelMethy.Width / Column * i, PanelMethy.Height); } }
internal void FillDiff(Panel PanelMethy, string fileName) { Graphics g = PanelMethy.CreateGraphics(); Square square = new Square(); for (int j = 0; j < Column; j++) { g.FillRectangle(new SolidBrush(square.JudgeGridD(0, j, fileName)), PanelMethy.Width / Column * j + 2, 1, 7, 8); } }
private int y; // stores y-coordinate #endregion Fields #region Constructors /* Constructor for Raindrop */ public Raindrop(Panel panel, Bucket theBucket, int x, int y, int width, int height) { raindropPanel = panel; // Set the panel raindropPanel.Paint += new PaintEventHandler(raindropPanel_Paint); // Set up the Paint Event g = raindropPanel.CreateGraphics(); // Create the Graphics object bucket = theBucket; // Set the bucket X = x; // Set the x-coordinate Y = y; // Set the y-coordinate Width = width; // Set the width Height = height; // Set the height }
public Screen(Panel p, Rectangle r) { G = p.CreateGraphics(); ScreenX = r.X; ScreenY = r.Y; ScreenWidth = r.Width; ScreenHeight = r.Height; ImageOffScreen = new Bitmap(ScreenWidth, ScreenHeight); GraphicsOffScreen = Graphics.FromImage(ImageOffScreen); }
// Tick Event handler for the Timer control. Handle fade in and fade out and paint progress bar. private void UpdateTimer_Tick(object sender, System.EventArgs e) { lblStatus.Text = m_sStatus; // Calculate opacity if (m_dblOpacityIncrement > 0) // Starting up splash screen { m_iActualTicks++; if (this.Opacity < 1) { this.Opacity += m_dblOpacityIncrement; } } else // Closing down splash screen { if (this.Opacity > 0) { this.Opacity += m_dblOpacityIncrement; } else { StoreIncrements(); UpdateTimer.Stop(); this.Close(); } } // Paint progress bar if (m_bFirstLaunch == false && m_dblLastCompletionFraction < m_dblCompletionFraction) { m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval; int width = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction); int height = pnlStatus.ClientRectangle.Height; int x = pnlStatus.ClientRectangle.X; int y = pnlStatus.ClientRectangle.Y; if (width > 0 && height > 0) { m_rProgress = new Rectangle(x, y, width, height); if (!pnlStatus.IsDisposed) { Graphics g = pnlStatus.CreateGraphics(); LinearGradientBrush brBackground = new LinearGradientBrush(m_rProgress, Color.FromArgb(58, 96, 151), Color.FromArgb(181, 237, 254), LinearGradientMode.Horizontal); g.FillRectangle(brBackground, m_rProgress); g.Dispose(); } int iSecondsLeft = 1 + (int)(TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000; m_sTimeRemaining = (iSecondsLeft == 1) ? string.Format("1 seg.") : string.Format("{0} seconds remaining", iSecondsLeft); } } //lblTimeRemaining.Text = m_sTimeRemaining; lblTimeRemaining.Text = ""; }
public Demon(int rows, int columns, int cellSide, Panel panel) { this.rows = rows; this.columns = columns; this.cellSide = cellSide; // create buffer resources buffer = new Bitmap(columns * cellSide, rows * cellSide); bufferGraphics = Graphics.FromImage(buffer); displayPanel = panel; displayGraphics = displayPanel.CreateGraphics(); CreateCells(); }
public void Draw(Panel panel) { Graphics g = panel.CreateGraphics(); for (int x = 0; x <= HorCellCount; x++) for (int y = 0; y <= VertCellCount; y++) { g.DrawLine(Color, x * CellWidth, 0, x * CellWidth, FullHeight); g.DrawLine(Color, 0, y * CellHeight, FullWidth, y * CellHeight); } g.Dispose(); }
/// <summary> /// Отрисовывает оси oX и oY с заданным масштабом /// </summary> /// <param name="pb">объект для рисования Panel</param> /// <param name="ppd">Масштаб</param> /// <param name="C"></param> public static void draw_grid(ref Panel pb, int ppd,Color C) { Graphics G = pb.CreateGraphics(); Pen P = new Pen(C); Point p1row = new Point(0, (pb.Height / 2) ); Point p2row = new Point(pb.Width, (pb.Height / 2) ); G.DrawLine(P, p1row, p2row); Point p1col = new Point( pb.Width/2 , 0 ); Point p2col = new Point( pb.Width/2 , pb.Width ); G.DrawLine(P, p1col, p2col); }
public TesterForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // drawg = drawarea.CreateGraphics(); reset(); }
public Screen(Panel p, Rectangle r) { g = p.CreateGraphics(); screenX = r.X; screenY = r.Y; screenWidth = r.Width; screenHeight = r.Height; imageOffScreen = new Bitmap(screenWidth, screenHeight); graphicsOffScreen = Graphics.FromImage(imageOffScreen); }
public static void DrawHistogram(int []Dist,Panel pnl, string color) { Graphics g = pnl.CreateGraphics(); float Max=Dist.Max(); g.Clear(pnl.BackColor); Pen pen=new Pen (Color.Red); for(int i=0;i<256;i++) { float normalized =(float)Dist[i] / Max; int finalvalue = (int)(normalized * 170.0); g.DrawLine(pen, i, 182, i, 182-finalvalue); } }
public FormMain() { InitializeComponent(); //Drawing Field canvas = new Panel(); canvas.Size = new Size(640, 480); this.toolStripContainer1.ContentPanel.Controls.Add(canvas); canvas.Dock = DockStyle.None; canvas.Visible = true; canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Canvas_OnMouseDown); canvas.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Canvas_OnMouseUp); canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Canvas_OnMouseMove); canvas.Paint += new System.Windows.Forms.PaintEventHandler(this.Canvas_OnPaint); Graphics gCanvas = canvas.CreateGraphics(); bmp = new Bitmap(canvas.Size.Width, canvas.Size.Height, gCanvas); gCanvas.Dispose(); // Paint canvas white Graphics gBmp = Graphics.FromImage(bmp); gBmp.FillRectangle(new SolidBrush(Color.White), 0, 0, bmp.Width, bmp.Height); gBmp.Dispose(); freedraw = new FreeDraw(); linedraw = new LineDraw(); rectdraw = new RectDraw(); floodfill = new FloodFill(); rectfill = new RectFill(); copyrect = new SelectRectToCopy(); stringdraw = new StringDraw(); saveFileDialog1.Filter = "Bitmap(*.bmp)|*.BMP|JPEG(*.JPG)|*.JPG|GIF(*.GIF)|*.GIF|All files(*.*)|*.*"; saveFileDialog1.FilterIndex = 1; openFileDialog1.Filter = "Bitmap(*.bmp)|*.BMP"; openFileDialog1.FilterIndex = 1; toolStripSplitBtnDevice.BackColor = Color.Empty; toolStripSplitBtnDevice.ToolTipText = ""; toolStripSplitBtnDevice.DropDown = dropdown; toolStripSplitBtnDevice.Image = DrawMethod.DeviceImage; toolStripLabel1.Text = "描画するツールを選択してください。"; btnSolidBrush.Click += new EventHandler(DeviceDropDown_OnSolidBrushButtonClick); btnHatchBrush.Click += new EventHandler(DeviceDropDown_OnHatchBrushButtonClick); btnTextureBrush.Click += new EventHandler(DeviceDropDown_OnTextureBrushButtonClick); btnLinearGradientBrush.Click += new EventHandler(DeviceDropDown_OnLinearGradientBrushButtonClick); }
private void sketchPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = sketchPanel.CreateGraphics(); g.Clear(Color.White); Pen pen = new Pen(new SolidBrush(Color.Black), 3); Pen penLight = new Pen(new SolidBrush(Color.Gray), 2); g.DrawRectangle(pen, ((numberOfNotes) * noteWidth + mafteachSol.Size.Width), 0, noteWidth, sketchPanel.Size.Height); g.DrawRectangle(penLight, ((numberOfNotes) * noteWidth + mafteachSol.Size.Width), sketchPanel.Size.Height / 8, noteWidth, sketchPanel.Size.Height * 6 / 8); if (cursorPointsBelowStaf) { if (mouseY > stafLine[13] && mouseY < stafLine[14]) { g.DrawLine(pen, numberOfNotes * noteWidth + mafteachSol.Size.Width, ((stafLine[13] + stafLine[14]) / 2), numberOfNotes * noteWidth + mafteachSol.Size.Width + noteWidth, ((stafLine[13] + stafLine[14]) / 2)); } } //refreshNotes(); }
public TemperatureGraph(Panel panel, int x, int y, int tempStart, ArrayList points, int padding = 25) { this.m_panel = panel; m_cntX = x; m_cntY = y; m_tempStart = tempStart; m_tempEnd = tempStart + y; m_padding = padding; m_width = panel.Width - 2 * m_padding; m_height = panel.Height - 2 * m_padding; CLICK_TRESHOLD = Convert.ToInt32(m_width / m_cntX / 12); m_graphics = m_panel.CreateGraphics(); m_penRed = new System.Drawing.Pen(System.Drawing.Color.Salmon, 2); m_penGray = new System.Drawing.Pen(System.Drawing.Color.LightGray, 2); m_penGreen = new System.Drawing.Pen(System.Drawing.Color.ForestGreen, 2); m_points = new ArrayList(); // add starting temperatures m_points = points; }
public Form1() { AllocConsole(); InitializeComponent(); //------------------------------------------------------------- this.button1 = new System.Windows.Forms.Button(); this.button1.Location = new System.Drawing.Point(13, 13); this.button2 = new System.Windows.Forms.Button(); this.button2.Location = new System.Drawing.Point(13, 42); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown1.Location = new System.Drawing.Point(13, 72); this.panel1 = new System.Windows.Forms.Panel(); this.panel1.Location = new System.Drawing.Point(13, 101); // Form1 this.ClientSize = new System.Drawing.Size(524, 424); this.Controls.Add(this.panel1); this.Controls.Add(this.numericUpDown1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); //------------------------------------------------------------- this.button1.Click += new System.EventHandler(this.btnLearn_Click); this.button1.Text = "Learn"; this.button2.Click += new System.EventHandler(this.btnClearAll_Click); this.button2.Text = "Clear"; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseDown); this.panel1.Width = this.Width; this.panel1.Height = this.Height; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.SendToBack(); this.numericUpDown1.DecimalPlaces = 1; this.numericUpDown1.Value = 0M; this.numericUpDown1.Increment = 0.1M; this.numericUpDown1.Minimum = 0M; this.numericUpDown1.Maximum = 1M; //------------------------------------------------------------- objGraphics = panel1.CreateGraphics(); WIDTH = panel1.Width; HEIGHT = panel1.Height; }
private void panel2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //get the color from the stored data Color drawColor = (Color)e.Data.GetData(typeof(Color)); //use the color to draw an ellipse Graphics g = panel2.CreateGraphics(); //allows drawing on the form try { // Draw the ellipse Brush br = new SolidBrush(drawColor); Rectangle rect = new Rectangle(e.X - panel1.Left - tpDragData.Left - tabControl1.Left - this.Left, e.Y - panel1.Top - tpDragData.Top - tabControl1.Top - this.Top - 30, 40, 30); g.FillEllipse(br, rect); } finally { g.Dispose(); //Need to dispose of graphics objects if //we are responsible for creating them } }
/// <summary>method: clearPanel /// clear all shapes from display on panel /// </summary> private void clearPanel() { pnlDrawOn.CreateGraphics().Clear(pnlDrawOn.BackColor); }
public void clear() { panel1.CreateGraphics().FillRectangle(Brushes.White, 0, 0, panel1.Width, panel1.Height); }
protected override void OnPaint(PaintEventArgs pe) { Graphics g = drawer.CreateGraphics(); x = drawer.Width / (lap + 1); y = drawer.Height / 20; // draw the pattern try { g.Clear(Color.White); float[] t = new float[lap]; string name = race.laps[1].d[drivers.SelectedIndex + 1].name; string team = race.laps[1].d[drivers.SelectedIndex + 1].team; int max = 1, min = 1; for (int c = 1; c < lap; c++) { t[c] = new float(); float time = race.laps[c].getConvertedTime(name, team); t[c] = time; if (t[max] < t[c]) { max = c; } if ((t[min] > t[c] || c == 1) && time != -1) { min = c; } //float time = t[c]; if (time == -1) { g.FillRectangle(Brushes.Red, x * c, drawer.Height - 20, x / 2, 20); } else { float p = race.laps[c].getPitTime(name, team); float h = (time - Lap.ConvertTime(best[rmin]));//((float)time/t[max]) p /= (Lap.ConvertTime(worst[rmax]) - Lap.ConvertTime(best[rmin])); h /= (Lap.ConvertTime(worst[rmax]) - Lap.ConvertTime(best[rmin])); g.FillRectangle(Brushes.Blue, x * c, (drawer.Height - 10) * (1 - h) + 5, x / 2, (drawer.Height - 10) * h); g.FillRectangle(Brushes.Yellow, x * c, (drawer.Height - 10) * (1 - h) + 5, x / 2, (drawer.Height - 10) * p); System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; if (dispTime.Checked) { using (Brush tempForeBrush = new System.Drawing.SolidBrush(Color.Black)) g.DrawString(race.laps[c].getLapTime(name, team), new Font("Arial", 7), tempForeBrush, x * c - 2, (drawer.Height - 10) * (1 - h) - 50, drawFormat); } } } dmin.Text = "Best: " + best[drivers.SelectedIndex + 1] + " (Lap" + bestLaps[drivers.SelectedIndex + 1] + ")"; dmax.Text = "Slowest: " + worst[drivers.SelectedIndex + 1] + " (Lap" + worstLaps[drivers.SelectedIndex + 1] + ")"; bmin.Text = "Best: " + best[rmin]; bmax.Text = "Driver: " + race.laps[1].d[rmin].name; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } finally { g.Dispose(); } base.OnPaint(pe); }
protected override void OnPaint(PaintEventArgs pe) { x = drawer.Width / (lap - 1); y = drawer.Height / 20; Graphics g = drawer.CreateGraphics(); String[] col = new string[20]; Pen myPen; col[0] = "Red"; col[1] = "Blue"; col[2] = "Green"; col[3] = "Yellow"; col[4] = "Violet"; col[5] = "Brown"; col[6] = "Orange"; col[7] = "LightBlue"; col[8] = "LightGreen"; col[9] = "DarkBlue"; col[10] = "Gold"; col[11] = "Crimson"; col[12] = "Khaki"; col[13] = "Magenta"; col[14] = "Chocolate"; col[15] = "Aqua"; col[16] = "LawnGreen"; col[17] = "Indigo"; col[18] = "DarkGray"; col[19] = "Pink"; // draw the pattern try { g.Clear(Color.White); // generate the points Point[] lsegs = new Point[1]; for (int c = 1; c < 21; c++) { if (selected == 0 || selected == c) { lsegs = new Point[lap]; float xt = x / 4, yt = y * (c - 1) + y / 2; lsegs[0] = new Point((int)xt, (int)yt); string name = race.laps[1].d[c].name; string team = race.laps[1].d[c].team; for (int i = 1; i < lap; i++) { int pos = race.laps[i].getPos(name, team); if (pos == 0) { pos = 30; } xt += x; yt = y * (pos - 1) + y / 2; lsegs[i] = new Point((int)xt, (int)yt); //lsegs[i] = new Point(lsegs[i-1].X + x, y*(pos-1) + y/2); } //Draw the lines myPen = new Pen(Color.FromName(col[c - 1]), (float)2.7); g.DrawLines(myPen, lsegs); //Draw labels on top of lines, instead of below lines for (int i = 1; i < lap; i++) { using (Brush tempForeBrush = new System.Drawing.SolidBrush(Color.Black)) g.DrawString(i.ToString(), new Font("Arial", 7), tempForeBrush, lsegs[i - 1].X + x / 2, 1 + (i % 2 == 0 || selected == 0 ? 0 : 8) + (selected == 0 ? selected : selected - 1) * y - 2); } //Array.Clear(lsegs, 0, lap); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } finally { g.Dispose(); } }
//********* Event Handlers ************ // Tick Event handler for the Timer control. Handle fade in and fade out. Also // handle the smoothed progress bar. private void timer1_Tick(object sender, System.EventArgs e) { lblStatus.Text = ms_sStatus; if (m_dblOpacityIncrement > 0) { m_iActualTicks++; if (this.Opacity < 1) { this.Opacity += m_dblOpacityIncrement; } } else { if (this.Opacity > 0) { this.Opacity += m_dblOpacityIncrement; } else { StoreIncrements(); // UPDATE : http://www.codeproject.com/KB/cs/prettygoodsplashscreen.aspx?df=100&forumid=26207&noise=2&mpp=50&select=1364609&fid=26207&fr=101#xx1364609xx timer1.Stop(); this.Close(); Debug.WriteLine("Called this.Close()"); } } if (m_bFirstLaunch == false && m_dblLastCompletionFraction < m_dblCompletionFraction) { m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval; int width = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction); int height = pnlStatus.ClientRectangle.Height; int x = pnlStatus.ClientRectangle.X; int y = pnlStatus.ClientRectangle.Y; if (width > 0 && height > 0) { m_rProgress = new Rectangle(x, y, width, height); // UPDATE : http://www.codeproject.com/KB/cs/prettygoodsplashscreen.aspx?df=100&forumid=26207&noise=2&mpp=50&select=1392388&fid=26207&fr=101#xx1392388xx //pnlStatus.Invalidate(m_rProgress); if (!pnlStatus.IsDisposed) { Graphics g = pnlStatus.CreateGraphics(); LinearGradientBrush brBackground = new LinearGradientBrush(m_rProgress, Color.FromArgb(58, 96, 151), Color.FromArgb(181, 237, 254), LinearGradientMode.Horizontal); g.FillRectangle(brBackground, m_rProgress); g.Dispose(); } int iSecondsLeft = 1 + (int)(TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000; // UPDATE :http://www.codeproject.com/KB/cs/prettygoodsplashscreen.aspx?df=100&forumid=26207&mpp=50&noise=1&fr=1&select=2771540&fid=26207#xx2771540xx if (iSecondsLeft == 1) { SetRemainintTimeCrossThread(string.Format("1 second remaining")); } else { SetRemainintTimeCrossThread(string.Format("{0} seconds remaining", iSecondsLeft)); } } } }
public void drawLine(int x1, int y1, int x2, int y2) { Graphics g = drawingPanel.CreateGraphics(); g.DrawLine(new Pen(new SolidBrush(drawingColor), 3), new Point(x1, y1), new Point(x2, y2)); }
/// <summary> /// Helper function to obtain array of rectangles from the /// division result of the division type of interest. Each rectangle /// is inflated by the amount specified in the third parameter. This /// is done to ensure the visibility of all rectangles. /// </summary> /// <param name="divResult">Ink Divider division result</param> /// <param name="divType">Division type</param> /// <param name="inflate">Number of Pixels by which the rectangles are inflated</param> /// <returns> Array of rectangles containing bounding boxes of /// division type specified by divType. The rectangles are in pixel unit.</returns> private Rectangle[] GetUnitBBoxes(DivisionResult divResult, InkDivisionType divType, int inflate) { // Declare the array of rectangles to hold the result Rectangle[] divRects; // Get the division units from the division result of division type DivisionUnits units = divResult.ResultByType(divType); // If there is at least one unit, we construct the rectangles if ((null != units) && (0 < units.Count)) { // We need to convert rectangles from ink units to // pixel units. For that, we need Graphics object // to pass to InkRenderer.InkSpaceToPixel method using (Graphics g = DrawArea.CreateGraphics()) { // Construct the rectangles divRects = new Rectangle[units.Count]; // InkRenderer.InkSpaceToPixel takes Point as parameter. // Create two Point objects to point to (Top, Left) and // (Width, Height) properties of ractangle. (Width, Height) // is used instead of (Right, Bottom) because (Right, Bottom) // are read-only properties on Rectangle Point ptLocation = new Point(); Point ptSize = new Point(); // Index into the bounding boxes int i = 0; // Iterate through the collection of division units to obtain the bounding boxes foreach (DivisionUnit unit in units) { // Get the bounding box of the strokes of the division unit divRects[i] = unit.Strokes.GetBoundingBox(); // The bounding box is in ink space unit. Convert them into pixel unit. ptLocation = divRects[i].Location; ptSize.X = divRects[i].Width; ptSize.Y = divRects[i].Height; // Convert the Location from Ink Space to Pixel Space myInkOverlay.Renderer.InkSpaceToPixel(g, ref ptLocation); // Convert the Size from Ink Space to Pixel Space myInkOverlay.Renderer.InkSpaceToPixel(g, ref ptSize); // Assign the result back to the corresponding properties divRects[i].Location = ptLocation; divRects[i].Width = ptSize.X; divRects[i].Height = ptSize.Y; // Inflate the rectangle by inflate pixels in both directions divRects[i].Inflate(inflate, inflate); // Increment the index ++i; } } // Relinquish the Graphics object } else { // Otherwise we return null divRects = null; } // Return the Rectangle[] object return(divRects); }
private void GameArea_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (pap == 0) { MD = true; GameArea_MouseMove(obj, e); } else if (pap == 1) { px = (sbyte)(e.X / Config.GS); py = (sbyte)(e.Y / Config.GS); paths[(int)Path.Value, cp] = px; paths[(int)Path.Value, cp + 1] = py; cp += 2; Status.Text = String.Concat("Select path point ", (cp - 2).ToString()); RectangleF rectf = new RectangleF(px * Config.GS, py * Config.GS, Config.GS, Config.GS); GameArea.CreateGraphics().DrawRectangle(Pens.Red, px * Config.GS, py * Config.GS, Config.GS, Config.GS); GameArea.CreateGraphics().DrawString("S", this.Font, Brushes.Red, rectf, sf); pap = 2; } else if (pap == 2) { if (cp > Config.MPL - 7) { pap = 0; paths[(int)Path.Value, cp] = (sbyte)(e.X / Config.GS); paths[(int)Path.Value, cp + 1] = (sbyte)(e.Y / Config.GS); paths[(int)Path.Value, cp + 2] = -1; paths[(int)Path.Value, 0] = (sbyte)(cp + 3); Status.Text = "Maximum path length reached"; Path.Enabled = true; pc++; PathHeader.Text = String.Concat("Paths: ", pc.ToString()); return; } if (e.X / Config.GS == px && e.Y / Config.GS < py) { paths[(int)Path.Value, cp] = 1; } else if (e.X / Config.GS < px && e.Y / Config.GS == py) { paths[(int)Path.Value, cp] = 2; } else if (e.X / Config.GS == px && e.Y / Config.GS > py) { paths[(int)Path.Value, cp] = 3; } else if (e.X / Config.GS > px && e.Y / Config.GS == py) { paths[(int)Path.Value, cp] = 4; } else // Either path point is the same as last point, or it is relatively diagonal { return; } px = (sbyte)(e.X / Config.GS); py = (sbyte)(e.Y / Config.GS); GameArea.CreateGraphics().DrawRectangle(Pens.Red, px * Config.GS, py * Config.GS, Config.GS, Config.GS); RectangleF rectf = new RectangleF(px * Config.GS, py * Config.GS, Config.GS, Config.GS); GameArea.CreateGraphics().DrawString((cp - 2).ToString(), this.Font, Brushes.Red, rectf, sf); cp++; if (e.Button == MouseButtons.Left) { Status.Text = String.Concat("Select path point ", (cp - 2).ToString()); return; } else { paths[(int)Path.Value, cp] = (sbyte)(e.X / Config.GS); paths[(int)Path.Value, cp + 1] = (sbyte)(e.Y / Config.GS); paths[(int)Path.Value, cp + 2] = -1; paths[(int)Path.Value, 0] = (sbyte)(cp + 3); Status.Text = "Ready"; Path.Enabled = true; pap = 0; pc++; PathHeader.Text = String.Concat("Paths: ", pc.ToString()); } } }