/// <summary> /// Очищает область для рисования /// </summary> /// <param name="pbCanvas">ссылка на объект PictureBox для рисования</param> /// <param name="foreColor">цвет фона</param> public static void clearCanvas(ref PictureBox pbCanvas,Color foreColor) { using (Graphics G = pbCanvas.CreateGraphics()) { G.Clear(foreColor); } }
private void drawPicture() { Graphics g = picObrazek.CreateGraphics(); Pen p = new Pen(Color.Black, 1); g.Clear(Color.White); drawing.Draw(g, p); }
private void miDrawLine_Click(object sender, System.EventArgs e) { picDrawing.CreateGraphics().Clear(this.BackColor); Graphics g = picDrawing.CreateGraphics(); Pen p = new Pen(Color.Blue, 6); g.DrawLine(p, 100, 100, 50, 150); g.Dispose(); }
private void button1_Click(object sender, System.EventArgs e) { int r = 1; int c = 1; try{ r = Int32.Parse(textBoxR.Text); c = Int32.Parse(textBoxC.Text); } catch {} maze.Solve(r, c); maze.paint(pictureBox2.CreateGraphics()); this.Invalidate( ); }
public DrawGraphics(int[,] coords, bool[] numOfSorts, int[] numOfCells, Style styles, System.Windows.Forms.PictureBox e) { graphics = e.CreateGraphics(); int x = 0, y = 0; for (int i = 0; i < numOfSorts.Length; i++) { if (numOfSorts[i] == false) { continue; } pen = new Pen(styles.color[i], 1); bool frstCoord = true; for (int j = 0; j < numOfCells.Length; j++) { if (frstCoord) { x = numOfCells[j]; y = coords[i, j]; frstCoord = false; continue; } if (numOfCells[i] == 0) { continue; } graphics.DrawLine(pen, x, y, numOfCells[j] / 100, coords[i, j]); x = numOfCells[j]; y = coords[i, j]; } } }
private void ghettoEditionLogo_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { //TODO: SG - Add the shot noise back //try //{ // if (testSound.Status.Playing == false) // { // testSound.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default); // } // else // { // testSound.SetCurrentPosition(0); // testSound.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default); // } //} //catch (Microsoft.DirectX.DirectSound.SoundException Exc) //{ // MessageBox.Show("There has been an error while attempting to play a test sample; please review your Direct X settings and confirm the test sample is located with this executable. Direct X error message follows :: " + Exc.Message.ToString() + " " + Exc.ErrorCode.ToString() + " " + Exc.ErrorString.ToString()); //} Graphics g; // Sets g to a graphics object representing the drawing surface of the // control or form g is a member of. g = ghettoEditionLogo.CreateGraphics(); System.Drawing.SolidBrush shadow = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray); g.FillEllipse(shadow, new Rectangle((e.X + 1) - 5, (e.Y + 1) - 5, 10, 10)); System.Drawing.SolidBrush hole = new System.Drawing.SolidBrush(System.Drawing.Color.Black); g.FillEllipse(hole, new Rectangle(e.X - 5, e.Y - 5, 10, 10)); }
private void show() { while (true) { if (close) { return; } SizeF textSize; Graphics g = pictureBox1.CreateGraphics(); g.Clear(Color.White); Brush myBrush = Brushes.Blue; Font myFont = new Font("Tahoma", Convert.ToSingle(12), FontStyle.Bold); textSize = g.MeasureString(lb, myFont); myBrush = new HatchBrush(HatchStyle.Shingle, Color.Black, Color.Black); if (pictureBox1.Width - i < textSize.Width * -1) { i = 0; } HatchBrush hb = new HatchBrush(HatchStyle.Percent40, SystemColors.Control, SystemColors.Control); g.FillRectangle(hb, 0, 0, pictureBox1.Width, pictureBox1.Height); g.DrawString(lb, myFont, myBrush, pictureBox1.Width - i, (pictureBox1.Height - textSize.Height) / 2); Thread.Sleep(150); i = i + 4; } }
public void Redraw() { System.Drawing.Graphics gfx = ChartPic.CreateGraphics(); gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; gfx.Clear(System.Drawing.Color.White); if (Series != null) { //CacheMin = GetMin(); CacheMax = GetMax(); if (m_VerticalGrid) { DrawVerticalGrid(gfx, ChartPic.Size); } for (int i = 0; i < Series.Count; i++) { if (Series[i] != null) { DrawSerie(Series[i], gfx, ChartPic.Size); } } } }
public void reDrawSpinRight(bool clockwise) { spinClockwise2 = clockwise; Graphics g2 = record2.CreateGraphics(); Matrix myMatrix2 = new Matrix(); Point aPoint2 = new Point(125, 125); if (clockwise == true) { rotate2 = rotate2 + 1; rotate2 = rotate2 + 1; } else { rotate2 = rotate2 - 1; rotate2 = rotate2 - 1; } myMatrix2.RotateAt(rotate2, aPoint2); g2.Transform = myMatrix2; //g.DrawImage(this.BackgroundImage, 0,0,500,500); //g.DrawImage(this.BackgroundImage, 0,0,250,250); try { g2.DrawImage(record2.Image, 0, 0, 250, 250); } catch {} }
public void Draw(PictureBox _bmp) { Graphics graph = _bmp.CreateGraphics(); graph.Clear(Color.White); Parallel.ForEach(Particles, _particle => _particle.Draw()); }
public void Draw(object obj, EventArgs e) { Graphics g = trq.CreateGraphics(); g.Clear(Color.Gray); g.DrawEllipse(pen, 0, 0, (float)c.R, (float)c.R); }
private processOnRender _RenderMiniSnakeDel; // Delegate for RenderMiniSnake method. #endregion Fields #region Constructors public Render(PictureBox gameBoardPictureBox, PictureBox miniGameBoardPictureBox) { _RenderMiniSnakeDel = new processOnRender(RenderMiniSnake); //// _RenderFruitDel = new processOnRender2(RenderFruit); // _RenderMiniFruitDel = new processOnRender2(RenderMiniFruit); // Initialiaze delegates. _RenderInsectDel = new processOnRender3(RenderInsect); // _RenderMiniInsectDel = new processOnRender3(RenderMiniInsect); // _MyGraphics = gameBoardPictureBox.CreateGraphics(); // Initialize the graphics object for the gameboard. _MyMiniGraphics = miniGameBoardPictureBox.CreateGraphics(); // Initialize the graphics object for the mini gameboard. _MyBrush = new System.Drawing.SolidBrush(Color.Black); // Initialize the first brush. _MyBrush2 = new System.Drawing.SolidBrush(Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))))); // Initialize the 2nd brush. _Pen = new Pen(Color.Black, 2); // Initialize pen. _MiniSnakeGraphicalParts = new List<PictureBox>(); // New list of picturebox (for mini snake). _Fruit = new PictureBox(); // New PictureBox. _Fruit.Size = new System.Drawing.Size(12,12); // Definition of the picturebox size. _Fruit.Image = Snake.Properties.Resources.Fruit; // Initialize the fruit image. _MiniFruit = new PictureBox(); // New PictureBox. _MiniFruit.Size = new System.Drawing.Size(6, 6); // Definition of the picturebox size. _MiniFruit.Image = Snake.Properties.Resources.MiniFruit; // Initialize the mini fruit image. _Insect = new PictureBox(); // New PictureBox. _Insect.Size = new System.Drawing.Size(26,26); // Definition of the picturebox size. _Insect.Image = Snake.Properties.Resources.Insect; // Initialize the insect image. _MiniInsect = new PictureBox(); // New PictureBox. _MiniInsect.Size = new System.Drawing.Size(13,13); // Definition of the picturebox size. _MiniInsect.Image = Snake.Properties.Resources.MiniInsect; // Initialize the mini insect image. }
private void menuItem2_Click(object sender, System.EventArgs e) { FrameBuff s = new FrameBuff(PctGraph.Width, PctGraph.Height); s.Fill(Color.Red); s.Draw(PctGraph.CreateGraphics()); }
/// <summary> /// Рисует столбиковую диаграмму /// </summary> /// <param name="pbCanvas">Ccылка на объект PictoreBox для рисования</param> /// <param name="IC">Объект InitialCondition, задающий начальные условия</param> public static void drawDiagramm(ref PictureBox pbCanvas, utils.InitialConditions IC) { Color GlaphColor = Color.FromArgb(Globals.glob_colorRed, Globals.glob_colorGreen, Globals.glob_colorBlue); Point[] arr = new Point[IC.ctx.Xarr.GetLength(0)]; Point[] zeroVertexes = new Point[IC.ctx.Xarr.GetLength(0)]; Point pCenter = new Point(); pCenter.X = (int)((pbCanvas.Width / (Math.Abs(IC.Xmin) + Math.Abs(IC.Xmax))) * Math.Abs(IC.Xmin)); pCenter.Y = (int)((pbCanvas.Height / (Math.Abs(IC.Ymin) + Math.Abs(IC.Ymax))) * Math.Abs(IC.Ymax)); for (int i = 0; i < IC.ctx.Xarr.GetLength(0); i++) { arr[i].X = (int)(pCenter.X + 2 * (IC.ctx.Xarr[i] * IC.scaleX)); zeroVertexes[i].X = arr[i].X; } for (int j = 0; j < IC.ctx.Yarr.GetLength(0); j++) { arr[j].Y = (int)(pCenter.Y - 2 * (IC.ctx.Yarr[j] * IC.scaleY)); zeroVertexes[j].Y = pCenter.Y; } using (Graphics G = pbCanvas.CreateGraphics()) { using (Pen p = new Pen(GlaphColor)) { p.Width = 3; for (int i = 0; i < zeroVertexes.GetLength(0); i++) { G.DrawLine(p, arr[i], zeroVertexes[i]); } } } }
private void ArrangeTree() { using (Graphics gr = picTree.CreateGraphics()) { // Arrange the tree once to see how big it is. float xmin = 200, ymin = 200; root.Arrange(gr, ref xmin, ref ymin); // Arrange the tree again to center it horizontally. xmin = (this.ClientSize.Width - xmin) / 2; ymin = 10; root.Arrange(gr, ref xmin, ref ymin); } picTree.Refresh(); }
public void ShowTip(Point pt, BGE bge) { string s = bge.Date.ToString("MM/dd/yy ") + bge.Date.ToString("t", DateTimeFormatInfo.InvariantInfo); s += "\nReading: " + bge.Reading.ToString(); s += "\nCarbs in 4 Hours: " + bge.CarbsIn4.ToString(); int nHours = bge.MinutesSinceCarbs / 60; int nMinutes = bge.MinutesSinceCarbs - nHours * 60; s += "\nTime Since Carbs: " + nHours.ToString() + ":" + nMinutes.ToString("0#"); if (bge.Carbs > 0) { s += "\nCarbs: " + bge.Carbs.ToString(); } if (bge.InterpReading) { s += "\n**** INTERPOLATED ****\n" + bge.Comment; } else if (bge.Comment.Length > 0) { s += "\nComment: " + bge.Comment; } m_sTip = s; Graphics gr = m_pbxTip.CreateGraphics(); SizeF szf = gr.MeasureString(s, m_hFont); Size sz = new Size((int)Math.Floor(szf.Width), (int)Math.Floor(szf.Height)); this.Show(); this.SetBounds(pt.X - sz.Width / 2, pt.Y - sz.Height, sz.Width + 4, sz.Height + 4, BoundsSpecified.All); }
private void RenderGradient() { Bitmap b = new Bitmap(pctGradient.Width, pctGradient.Height); Graphics oCanvas = pctGradient.CreateGraphics(); pctGradient.Refresh(); if (!chkHorizontal.Checked) { for (int iYCoord = 0; iYCoord < pctGradient.Height; iYCoord++) { int iRed = scrRedTop.Value + iYCoord * (scrRedBottom.Value - scrRedTop.Value) / pctGradient.Height; int iGreen = scrGreenTop.Value + iYCoord * (scrGreenBottom.Value - scrGreenTop.Value) / pctGradient.Height; int iBlue = scrBlueTop.Value + iYCoord * (scrBlueBottom.Value - scrBlueTop.Value) / pctGradient.Height; int iAlpha = scrAlphaTop.Value + iYCoord * (scrAlphaBottom.Value - scrAlphaTop.Value) / pctGradient.Height; Pen oPen = new System.Drawing.Pen(Color.FromArgb(iAlpha, iRed, iGreen, iBlue)); oCanvas.DrawLine(oPen, 0, iYCoord, pctGradient.Width, iYCoord); } } else { for (int iXCoord = 0; iXCoord < pctGradient.Width; iXCoord++) { int iRed = scrRedTop.Value + iXCoord * (scrRedBottom.Value - scrRedTop.Value) / pctGradient.Width; int iGreen = scrGreenTop.Value + iXCoord * (scrGreenBottom.Value - scrGreenTop.Value) / pctGradient.Width; int iBlue = scrBlueTop.Value + iXCoord * (scrBlueBottom.Value - scrBlueTop.Value) / pctGradient.Width; int iAlpha = scrAlphaTop.Value + iXCoord * (scrAlphaBottom.Value - scrAlphaTop.Value) / pctGradient.Width; Pen oPen = new System.Drawing.Pen(Color.FromArgb(iAlpha, iRed, iGreen, iBlue)); oCanvas.DrawLine(oPen, iXCoord, 0, iXCoord, pctGradient.Height); } } }
public override PictureBox DrawShape(PictureBox pic, Point point) { Graphics g = Graphics.FromImage(pic.Image); g = pic.CreateGraphics(); g.DrawLine(myPen, firstLocation,point); pic.Image = pic.Image; return pic; }
public _Tool(PictureBox p, Bitmap bm) { image = bm; Pic = p; Graph = Graphics.FromImage(bm); TempGraph = p.CreateGraphics(); p.Image = bm; }
public void drawNode(PictureBox panel) { SolidBrush brush = new SolidBrush(colorNode); Graphics graphics = panel.CreateGraphics(); graphics.FillEllipse(brush, location.X, location.Y, size, size); label.Location = new Point((int)(location.X + 3),(int)(location.Y + 3)); panel.Controls.Add(label); label.Refresh(); }
public override PictureBox DrawShape(PictureBox pic, Point point) { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Math.Min(point.X, firstLocation.X), Math.Min(point.Y, firstLocation.Y), Math.Abs(point.X - firstLocation.X), Math.Abs(point.X - firstLocation.X)); Graphics g = Graphics.FromImage(pic.Image); //g.DrawRectangle(myPen, firstLocation.X,firstLocation.Y, Math.Abs(point.X - firstLocation.X),Math.Abs(point.Y - firstLocation.Y)); g = pic.CreateGraphics(); g.DrawRectangle(myPen, rect); pic.Image = pic.Image; return pic; }
/// <summary> /// 新建一个时钟上的指针对象 /// </summary> /// <param name="widthOfPen">指针宽度</param> /// <param name="length">指针长度</param> /// <param name="startPoint">指针中心点</param> /// <param name="startAngle">起始位置与12点钟方向的夹角(单位为弧度)</param> /// <param name="box">指针所在的容器</param> /// 创建人:卢君默 创建时间:2015-7-24 21:00:23 public Hand(int widthOfPen, int length, Point startPoint, float startAngle, PictureBox box) { pen = new Pen(Color.Black, widthOfPen); this.length = length; this.startAngle = startAngle; this.startPoint = startPoint; //这里先不指定端点的位置,每次划线的时候再计算点的位置 endPoint = new Point(); this.g = box.CreateGraphics(); }
public MyMap(PictureBox p, FormMapCopy formMap) { this.formMap = formMap; pictureBox = p; g = p.CreateGraphics(); pictureBox.MouseDown += pictureBox_MouseDown; pictureBox.MouseMove += pictureBox_MouseMove; pictureBox.Paint += pictureBox_Paint; pictureBox.Resize += pictureBox_Resize; }
private void Save(string picPath) { string ZFCEPath = AppDomain.CurrentDomain.BaseDirectory + "Results\\"; picPath = ZFCEPath + picPath; Graphics g = ptbNewPic.CreateGraphics(); Bitmap bt1 = new Bitmap(ptbNewPic.Image); Bitmap mybmp1 = new Bitmap(bt1, ptbNewPic.Width, ptbNewPic.Height); mybmp1.Save(picPath, ImageFormat.Jpeg); }
public Form1() { pictureBox1 = new PictureBox {Width = 500, Height = 500}; bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics graphics = Graphics.FromImage(bmp); ariaG = pictureBox1.CreateGraphics(); graphics.Clear(Color.White); InitializeComponent(); pictureBox1.Image = bmp; }
public void Create() { Map = new PictureBox(); Map.Width = 400 ; Map.Height = 400; Map.Location = new System.Drawing.Point(350, 13); Map.BackColor = System.Drawing.SystemColors.ActiveCaptionText; pen = new Pen(Color.Red); pen2 = new Pen(Color.Green); image1 = Map.CreateGraphics(); }
private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (lineInProgress) { lineInProgress = false; Graphics g = pictureBox1.CreateGraphics(); g.DrawLine(currentPen, startx, starty, e.X, e.Y); Line l = new Line(ColorTranslator.ToWin32(currentColor), startx, starty, e.X, e.Y); thisDrawing.add(l); } }
private static int getDPI() { int currentDPI = 0; using (PictureBox pic = new PictureBox()) { using (Graphics g = pic.CreateGraphics()) { currentDPI = (int)g.DpiX; } } return currentDPI; }
public void Draw(PictureBox pb) { Graphics graphics = pb.CreateGraphics(); graphics.Clear(pb.BackColor); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) if (data[i, j]) { graphics.FillRectangle( new SolidBrush(Color.Black), new Rectangle(j * 8, i * 8, 8, 8)); } }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); _images[0] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image1.jpg"); _images[0].KeywordString = "1,2,3"; _images[1] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image2.jpg"); _images[2] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image3.jpg"); _images[3] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image4.jpg"); _images[4] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image5.jpg"); _images[5] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image6.jpg"); _images[6] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image7.jpg"); _images[7] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image8.jpg"); _images[8] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image9.jpg"); _images[9] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image10.jpg"); _images[10] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image11.jpg"); _images[11] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image12.jpg"); _images[12] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image13.jpg"); _images[13] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image14.jpg"); _images[14] = new ImageItem(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\Image15.jpg"); //for (int i = 0; i < 15; i++) //{ // //_images[i].KeywordString = "keyword1, keyword2, some other keywords"; // //_images[i].KeywordString += String.Format(", this is image{0}", i); // ListViewItem lvi = new ListViewItem(new string[] { _images[i].FileName, _images[i].KeywordString, _images[i].FilePath }); // this._listViewImages.Items.Add(lvi); //} ScriptFile sf = new ScriptFile(@"H:\Programming\C#\Programs\Slideshow.NET\Test Files\TestScript1.scr"); _listViewScripts.Items.Add(new ListViewItem(new string[] { sf.PathAndFileName })); for (int i = 0; i < 15; i++) { sf.ImageItemCollection.AddImageItem(_images[i]); } PopulateListViewImages(sf, 0); this._comboBoxStretchType.DataSource = Enum.GetNames(typeof(StretchTypes)); this._pictureBoxGraphics = _pictureBoxPreview.CreateGraphics(); _fullScreen = new FullScreenForm(this); _fullScreen.Visible = false; _fullScreen.Bounds = Screen.PrimaryScreen.Bounds; // this._screenGraphics = _fullScreen.CreateGraphics(); }
public DrawerStandart(PictureBox _pBox) { pBox = _pBox; SizeX = pBox.Width; SizeY = pBox.Height; Graph = pBox.CreateGraphics(); PenBlack = new Pen(Color.Black, 2); PenBlue = new Pen(Color.Blue, 2); BrushWhite = new SolidBrush(Color.White); }
public void drawEdge(PictureBox panel) { Graphics graphics = panel.CreateGraphics(); System.Drawing.Drawing2D.AdjustableArrowCap bigArrow = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5); Pen pen = new Pen(colorEdge, 2.0F); pen.CustomEndCap = bigArrow; PointF startPoint = new PointF(startNode.location.X + Node.size/2, startNode.location.Y + Node.size/2); PointF endPoint = new PointF( endNode.location.X + Node.size/2, endNode.location.Y + Node.size/2); double R = Math.Sqrt(Math.Pow(startPoint.X - endPoint.X, 2.0) + Math.Pow(startPoint.Y - endPoint.Y, 2.0)); double size = Node.size / 2; endPoint.X = (float)((startPoint.X + ((R - size) / size) * endPoint.X) / (R / size)); endPoint.Y = (float)((startPoint.Y + ((R - size) / size) * endPoint.Y) / (R / size)); graphics.DrawLine(pen, startPoint, endPoint); panel.Controls.Add(label); }
private void timer1_Tick(object sender, EventArgs e) { try{ backBuffGraph.Clear(Pens.White.Color); backBuffGraph.Transform = ContrDocs.GetScreenMatrix(displayedDoc, ImageCurrent.Width, ImageCurrent.Height, imageZoom * zoomFactor, imageTranslation); backBuffGraph.DrawImage(renderImage, 0, 0); Graphics pbg = PictureBox1.CreateGraphics(); pbg.DrawImage(backBuffer, 0, 0); pbg.Dispose(); }catch { //Not being able to render the image is non-fatal and probably due to a simple change in state //or rounding errors. } }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // Prepare the Graphics elements for the drawing // picture1Graphics = picture1.CreateGraphics(); Color = new System.Drawing.Color(); BlackPen = new System.Drawing.Pen(Color.Black, 1); }
static public void DrawImgBorder(System.Windows.Forms.PictureBox img, System.Drawing.Color cBorderColor, int iBorderWidth) { Graphics g; Pen myPen = new Pen(cBorderColor, iBorderWidth); Point pt; Size sz; Single x1, y1; pt = img.Location; sz = img.Size; x1 = iBorderWidth / 2; y1 = iBorderWidth / 2; g = img.CreateGraphics(); g.DrawRectangle(myPen, x1, y1, sz.Width - iBorderWidth, sz.Height - iBorderWidth); }
public GraphicsHelper(PictureBox picBox) { m_PictureBox = picBox; m_Coordinator = new Coordinator(picBox.Width / 2, picBox.Height / 2, DEFAULT_SCALE); m_Buffer = new Bitmap(m_PictureBox.Width, m_PictureBox.Height); m_MainGraphicsObj = m_PictureBox.CreateGraphics(); m_BufferGraphics = Graphics.FromImage(m_Buffer); m_Brush = new SolidBrush(Color.Black); m_OuterBrush = new SolidBrush(Color.LightSalmon); m_Pen = new Pen(Color.LightGray); HighQuality = true; }
public static void SetupPictureBox(PictureBox mapPictureBox) { _floorArray = List2DFromCsv(FloorCsv); var doodadArray = List2DFromCsv(DoodadCsv); FloorCsv = "C:\\Users\\Nick\\Desktop\\FlashGame1\\assets\\maps\\" + MainForm.MapTextBox.Text + "\\mapCSV_Group1_collision.csv"; DoodadCsv = "C:\\Users\\Nick\\Desktop\\FlashGame1\\assets\\maps\\" + MainForm.MapTextBox.Text + "\\mapCSV_Group1_doodad.csv"; _mapImage = new Bitmap(_floorArray.Count * BlockSize, _floorArray[0].Count * BlockSize, PixelFormat.Format32bppArgb); ImageFromArray(_mapImage, _floorArray, FloorImage, 32); ImageFromArray(_mapImage, doodadArray, DoodadImage, 16); DrawInteractables(_mapImage); _graphics = mapPictureBox.CreateGraphics(); Console.WriteLine(@"Finished Loading"); Redraw(); }
/// <summary> /// Paints an Image in the specified position and size. /// </summary> /// <param name="mpicture">The control where to paint.</param> /// <param name="Picture">The image to paint.</param> /// <param name="X1">The position in the X axis.</param> /// <param name="Y1">The position in the Y axis.</param> /// <param name="Width1">The width used to paint the image.</param> /// <param name="Height1">The height used to paint the image.</param> public static void PaintPicture(PictureBox mpicture, object Picture, double X1, double Y1, double Width1, double Height1) { Rectangle rec = new Rectangle((int)Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsToPixelsX(X1), (int)Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsToPixelsY(Y1), (int)Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsToPixelsX(Width1), (int)Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsToPixelsY(Height1)); if (Picture is System.Drawing.Image) { System.Drawing.Image img = (System.Drawing.Image)Picture; mpicture.CreateGraphics().DrawImage(img, rec); //mpicture.CreateGraphics().drawi } else { //TODO: ToBeImplemented throw new System.Exception("Method or Property not implemented yet!"); } }
private void button1_Click(object sender, EventArgs e) { System.Drawing.Graphics g = Graph.CreateGraphics(); for (double j = 0; j < 1; j += 0.0833) { double i = j * 3.141590; Point p1 = new Point((int)(Graph.Size.Width / 2 - 1000 * Math.Cos(i)), (int)(Graph.Size.Height / 2 - 1000 * Math.Sin(i))); Point p2 = new Point((int)(Graph.Size.Width / 2 + 1000 * Math.Cos(i)), (int)(Graph.Size.Height / 2 + 1000 * Math.Sin(i))); Pen p = new Pen(Color.Black); if ((j == 0) || (Math.Abs(j - 0.5) < 0.02)) { p.Width = 3; } g.DrawLine(p, p1, p2); } for (int j = 1; j < 40; j++) { Pen p = new Pen(Color.Black); if (j % 4 == 0) { p.Width = 2; } g.DrawEllipse(p, (int)(Graph.Size.Width / 2 - j * 25), (int)(Graph.Size.Height / 2) - j * 25, j * 50, j * 50); } double start = -30, stop = 30, step = 0.01; Point PS = new Point((int)((Graph.Size.Width / 2) + f(start) * Math.Cos(start)), (int)((Graph.Size.Height / 2) - f(start) * Math.Sin(start))); Point PT; for (double j = start + step; j < stop; j += step) { Pen p = new Pen(Color.Red); p.Width = 2; PT = new Point((int)((Graph.Size.Width / 2) + f(j) * Math.Cos(j)), (int)((Graph.Size.Height / 2) - f(j) * Math.Sin(j))); if (Math.Abs(f(j) - f(j - step)) < 10000) { g.DrawLine(p, PS, PT); } PS = PT; // System.Threading.Thread.Sleep(1); } }
private void RenderCorners() { Bitmap b = new Bitmap(pctGradient.Width, pctGradient.Height); Graphics oCanvas = pctGradient.CreateGraphics(); oCanvas.SmoothingMode = SmoothingMode.HighQuality; pctGradient.Refresh(); int iRed1 = scrRed1.Value; int iGreen1 = scrGreen1.Value; int iBlue1 = scrBlue1.Value; int iAlpha1 = scrAlpha1.Value; int iRed2 = scrRed2.Value; int iGreen2 = scrGreen2.Value; int iBlue2 = scrBlue2.Value; int iAlpha2 = scrAlpha2.Value; int iDiameter = scrRadius.Value * 2; int iRadius = scrRadius.Value; Pen oPen = new System.Drawing.Pen(Color.FromArgb(iAlpha1, iRed1, iGreen1, iBlue1)); SolidBrush oBrush2 = new System.Drawing.SolidBrush(Color.FromArgb(iAlpha2, iRed2, iGreen2, iBlue2)); SolidBrush oBrush = new System.Drawing.SolidBrush(Color.FromArgb(iAlpha1, iRed1, iGreen1, iBlue1)); oCanvas.FillRectangle(oBrush2, 0, 0, pctGradient.Width, pctGradient.Height); oCanvas.FillPie(oBrush, new Rectangle(0, 0, iDiameter, iDiameter), 180f, 90f); oCanvas.FillPie(oBrush, new Rectangle(pctGradient.Width - iDiameter, 0, iDiameter, iDiameter), 270f, 90f); oCanvas.FillPie(oBrush, new Rectangle(0, pctGradient.Height - iDiameter, iDiameter, iDiameter), 90f, 90f); oCanvas.FillPie(oBrush, new Rectangle(pctGradient.Width - iDiameter, pctGradient.Height - iDiameter, iDiameter, iDiameter), 0f, 90f); oCanvas.FillRectangle(oBrush, iRadius, 0, pctGradient.Width - iDiameter, iRadius); oCanvas.FillRectangle(oBrush, 0, iRadius, iRadius, pctGradient.Height - iDiameter); oCanvas.FillRectangle(oBrush, pctGradient.Width - iRadius, iRadius, iRadius, pctGradient.Height - iDiameter); oCanvas.FillRectangle(oBrush, iRadius, pctGradient.Height - iRadius, pctGradient.Width - iDiameter, iRadius); oCanvas.FillRectangle(oBrush, iRadius, iRadius, pctGradient.Width - iDiameter, pctGradient.Height - iDiameter); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); _images[0] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image1.jpg"); _images[1] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image2.jpg"); _images[2] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image3.jpg"); _images[3] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image4.jpg"); _images[4] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image5.jpg"); _images[5] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image6.jpg"); _images[6] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image7.jpg"); _images[7] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image8.jpg"); _images[8] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image9.jpg"); _images[9] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image10.jpg"); _images[10] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image11.jpg"); _images[11] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image12.jpg"); _images[12] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image13.jpg"); _images[13] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image14.jpg"); _images[14] = new ImageItem(@"C:\Documents and Settings\Stan Dewan\My Documents\Programming\C#\Programs\Slideshow.NET\Test Files\Image15.jpg"); for (int i = 0; i < 15; i++) { _images[i].KeywordString = "keyword1, keyword2, some other keywords"; _images[i].KeywordString += String.Format(", this is image{0}", i); this._listViewImages.Items.Add(_images[i].PathAndFileName); } this._comboBoxStretchType.DataSource = Enum.GetNames(typeof(StretchTypes)); this._pictureBoxGraphics = _pictureBoxPreview.CreateGraphics(); _fullScreen = new FullScreenForm(this); _fullScreen.Visible = false; _fullScreen.Bounds = Screen.PrimaryScreen.Bounds; // this._screenGraphics = _fullScreen.CreateGraphics(); }
private void RenderCorners() { Bitmap b = new Bitmap(pctGradient.Width, pctGradient.Height); Graphics oCanvas = pctGradient.CreateGraphics(); oCanvas.SmoothingMode = SmoothingMode.HighQuality; //pctGradient.Refresh(); int iDiameter = scrRadius.Value * 2; int iRadius = scrRadius.Value; SolidBrush[] oBrush = new SolidBrush[4]; oBrush[0] = new System.Drawing.SolidBrush(Color.FromArgb(miAlpha[0], miRed[0], miGreen[0], miBlue[0])); oBrush[1] = new System.Drawing.SolidBrush(Color.FromArgb(miAlpha[1], miRed[1], miGreen[1], miBlue[1])); oBrush[2] = new System.Drawing.SolidBrush(Color.FromArgb(miAlpha[2], miRed[2], miGreen[2], miBlue[3])); oBrush[3] = new System.Drawing.SolidBrush(Color.FromArgb(miAlpha[3], miRed[3], miGreen[3], miBlue[3])); int iColourIndexY = 0; int iColourIndexX = 0; int iBrush; for (int y = 0; y < pctGradient.Height; y += iRadius) { iColourIndexX = 0; for (int x = 0; x < pctGradient.Width; x += iRadius) { iBrush = (iColourIndexX + iColourIndexY) % 2; oCanvas.FillRectangle(oBrush[iBrush], x, y, iRadius + 1, iRadius + 1); iColourIndexX++; } iColourIndexY++; } oCanvas.FillRectangle(oBrush[3], 75, 75, 400, 400); oCanvas.FillRectangle(oBrush[2], 5 * iRadius, 6 * iRadius, iRadius + 1, iRadius + 1); }
public void Mjpegsmallcam2(PictureBox picturebox) { ////////////////////////SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); // // Required for Windows Form Designer support // //pic2x = Screen.PrimaryScreen.Bounds.Width; //pic2y = Screen.PrimaryScreen.Bounds.Height; pic2x = picturebox.Width; pic2y = picturebox.Height; pic2posx = picturebox.Bounds.X; pic2posy = picturebox.Bounds.Y; g = picturebox.CreateGraphics(); ////////////////Cursor.Hide(); MouseXY = System.Windows.Forms.Cursor.Position; //op = new Options(); //op = op.ReadOptionsFromFile(); mjpg = new MjpegStream[Robot.Robot1.o.Streams + 1]; t = new Thread[Robot.Robot1.o.Streams + 1]; picturebox.BackColor = ColorTranslator.FromHtml(Robot.Robot1.o.BgColor); //Are there enough streams provided to match the number requested? if ((Robot.Robot1.o.Url.Length - 1) < Robot.Robot1.o.Streams) Robot.Robot1.o.Streams = Robot.Robot1.o.Url.Length - 1; //Create and start the MJPEG threads. for (int i = 0; i <= Robot.Robot1.o.Streams; i++) { mjpg[i] = new MjpegStream(Robot.Robot1.o.Url[i]); mjpg[i].BmpEvt += new MjpegStream.BmpHandler(PaintBmp); mjpg[i].WebEx += new MjpegStream.WebExceptionHandler(PaintException); t[i] = new Thread(new ThreadStart(mjpg[i].FetchStream)); t[i].Name = Convert.ToString(i); t[i].Start(); } }
public void reDrawSpin(bool clockwise, bool left) { if (left == true) { spinClockwise1 = clockwise; } else { spinClockwise2 = clockwise; } //Graphics g = this.CreateGraphics(); Graphics g1 = record1.CreateGraphics(); //System.Drawing.Pen aPen = new Pen(Color.Red); //g.DrawRectangle(aPen,100,100,100,100); Matrix myMatrix1 = new Matrix(); Point aPoint1 = new Point(125, 125); if (left == true) { //Point aPoint = new Point(250,250); if (clockwise == true) { rotate1 = rotate1 + 1; rotate1 = rotate1 + 1; } else { rotate1 = rotate1 - 1; rotate1 = rotate1 - 1; } } myMatrix1.RotateAt(rotate1, aPoint1); g1.Transform = myMatrix1; //============== /*Graphics g2 = record2.CreateGraphics(); * Matrix myMatrix2 = new Matrix(); * Point aPoint2 = new Point(125,125); * * if (left == false) * { * if (clockwise == true) * { * rotate2 = rotate2 + 1; * rotate2 = rotate2 + 1; * } * else * { * rotate2 = rotate2 - 1; * rotate2 = rotate2 - 1; * } * } * myMatrix2.RotateAt(rotate2,aPoint2); * g2.Transform = myMatrix2; * //g.DrawImage(this.BackgroundImage, 0,0,500,500); * //g.DrawImage(this.BackgroundImage, 0,0,250,250); */ try { g1.DrawImage(record1.Image, 0, 0, 250, 250); //g2.DrawImage(record2.Image, 0,0,250,250); } catch {} }
public Grid(PictureBox grid) { ListOfComponents = new List<Flowly.ComponentDrawn>(); Graphic = grid.CreateGraphics(); this.grid = grid; }
private Draw(PictureBox pictureBox) { this.graphics = pictureBox.CreateGraphics(); }
static void Main() { int Height = Screen.PrimaryScreen.WorkingArea.Height; int Width = Screen.PrimaryScreen.WorkingArea.Width; Form MainForm = new Form(); MainForm.AutoSize = true; MainForm.MinimumSize = new Size(Width,Height); MainForm.Activate(); MainForm.BackColor = System.Drawing.Color.White; MainForm.Top = Screen.PrimaryScreen.WorkingArea.Top; MainForm.Left = Screen.PrimaryScreen.WorkingArea.Left; MainForm.Show(); PictureBox pb = new PictureBox(); MainForm.Controls.Add(pb); pb.Size = new Size(Width, Height); pb.Show(); pb.BackColor = System.Drawing.Color.White; int i; Random random = new Random(); // double randomNumber = random.Next(0, 255); // // double color = (double)random.Next(0,255); Point ptStart = new Point(random.Next(0, Width), random.Next(0, Height)); System.Drawing.Graphics Drawer = pb.CreateGraphics(); for (i=0; i<50000; i++) { //// //// double randomNumber = random.Next(0, 255); //// //// double color = (double)random.Next(0,255); // Pen pn = new Pen( System.Drawing.Color.FromArgb((int)Math.Round((double)random.Next(0,255),0), (int)Math.Round((double)random.Next(0,255),0), (int)Math.Round((double)random.Next(0,255),0), random.Next(0,10) )); Point ptEnd = ptStart; int rndX = random.Next(0, Width); int rndY = random.Next(0, Height); ptEnd = new Point( rndX, rndY ); while (ptEnd.X == pb.ClientRectangle.X | ptEnd.Y == pb.ClientRectangle.Y | ptEnd.X == pb.ClientRectangle.Right | ptEnd.Y == pb.ClientRectangle.Bottom) { if (ptEnd.X == pb.ClientRectangle.X) ptEnd.X = ptEnd.X + 1; if (ptEnd.Y == pb.ClientRectangle.Y) ptEnd.Y = ptEnd.Y + 1; if (ptEnd.X == pb.ClientRectangle.Right) ptEnd.X = ptEnd.X - 1; if (ptEnd.Y == pb.ClientRectangle.Bottom) ptEnd.Y = ptEnd.Y - 1; } Drawer.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; Drawer.DrawBezier(pn, ptStart, new Point(random.Next(0, Width), random.Next(0, Height)), new Point(random.Next(0, Width), random.Next(0, Height)), ptEnd); //Point[] pts = {ptStart, new Point(random.Next(0, Width), random.Next(0, Height)), // new Point(random.Next(0, Width), random.Next(0, Height)), // ptEnd}; //Drawer.DrawPolygon(pn,pts); ptStart = ptEnd; //pn.Dispose(); Thread.Sleep(10); pb.Refresh(); } }
private void DrawToPictureBox(ISymbol pSym, PictureBox pBox) { IGeometry pGeometry = null; IntPtr hDC; IEnvelope pEnvelope; pEnvelope = new EnvelopeClass(); // Reset the PictureBox pBox.CreateGraphics().Clear(pBox.BackColor); try { if (pSym is IMarkerSymbol) { pEnvelope.PutCoords(pBox.Width / 2, pBox.Height / 2, pBox.Width / 2, pBox.Height / 2); IArea pArea = pEnvelope as IArea; pGeometry = pArea.Centroid; } else if (pSym is ILineSymbol) { pEnvelope.PutCoords(0, pBox.Height / 2, pBox.Width, pBox.Height / 2); IPolyline pPolyline = new PolylineClass(); pPolyline.FromPoint = pEnvelope.LowerLeft; pPolyline.ToPoint = pEnvelope.UpperRight; pGeometry = pPolyline; } else if (pSym is IFillSymbol) { if (pSym is SimpleFillSymbol) { pEnvelope.PutCoords(5, 5, pBox.Width - 5, pBox.Height - 5); pGeometry = pEnvelope; } else if (pSym is MultiLayerFillSymbol) { IMultiLayerFillSymbol pMultiLayerFillSymbol = pSym as IMultiLayerFillSymbol; //For mLayers As Integer = 0 To pMultiLayerFillSymbol.LayerCount - 1 if (pMultiLayerFillSymbol.get_Layer(0) is PictureFillSymbol) { IPictureFillSymbol pPictureFillSymbol = pMultiLayerFillSymbol.get_Layer(0) as IPictureFillSymbol; Bitmap m = Bitmap.FromHbitmap(new IntPtr(pPictureFillSymbol.Picture.Handle)); //m.MakeTransparent(System.Drawing.ColorTranslator.FromOle(pPictureFillSymbol.Color.RGB)) pBox.Image = m; return; } else if (pMultiLayerFillSymbol.get_Layer(0) is SimpleFillSymbol) { pEnvelope.PutCoords(5, 5, pBox.Width - 5, pBox.Height - 5); pGeometry = pEnvelope; } else if (pMultiLayerFillSymbol.get_Layer(0) is GradientFillSymbol) { IGradientFillSymbol pGradientFillSymbol = pMultiLayerFillSymbol.get_Layer(0) as IGradientFillSymbol; IAlgorithmicColorRamp pRamp = pGradientFillSymbol.ColorRamp as IAlgorithmicColorRamp; System.Drawing.Rectangle rect = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), new System.Drawing.Size(pBox.Width, pBox.Height)); LinearGradientBrush lgBrush = new LinearGradientBrush(rect, System.Drawing.ColorTranslator.FromOle(pRamp.FromColor.RGB), System.Drawing.ColorTranslator.FromOle(pRamp.ToColor.RGB), 45); Graphics g = pBox.CreateGraphics(); g.FillRectangle(lgBrush, rect); rect.Width = rect.Width - 1; rect.Height = rect.Height - 1; g.DrawRectangle(new Pen(ColorTranslator.FromOle(pGradientFillSymbol.Outline.Color.RGB), (float)pGradientFillSymbol.Outline.Width), rect); } } else if (pSym is PictureFillSymbol) { IPictureFillSymbol pPictureFillSymbol = pSym as IPictureFillSymbol; Bitmap m = Bitmap.FromHbitmap(new IntPtr(pPictureFillSymbol.Picture.Handle)); //m.MakeTransparent(System.Drawing.ColorTranslator.FromOle(pPictureFillSymbol.Color.RGB)) pBox.Image = m; return; } } hDC = GetDC(pBox.Handle); pSym.SetupDC(hDC.ToInt32(), null); pSym.ROP2 = esriRasterOpCode.esriROPCopyPen; if (pGeometry != null) pSym.Draw(pGeometry); pSym.ResetDC(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void Move(PictureBox pictureBox) { this.x += x; this.y += y; Draw(pictureBox.CreateGraphics()); }
/// <summary> /// Xóa điểm khỏi pictureBox /// </summary> /// <param name="pictureBox"></param> public void Clear(PictureBox pictureBox) { Graphics G = pictureBox.CreateGraphics(); G.SmoothingMode=SmoothingMode.AntiAlias; Rectangle rectangle = new Rectangle(this.x-this.r, this.y-this.r, this.r*2, this.r*2); TextRenderer.DrawText(G, this.textInside, new Font("Arial", this.r,FontStyle.Bold), rectangle, pictureBox.BackColor); G.DrawEllipse(new Pen(pictureBox.BackColor), rectangle); }
private void button1_Click(object sender, System.EventArgs e) { const double bi = 10.0; double mu = 0.001; double a1, b1, c1, d1, e1, f1; double xpred, ypred, x, y; VectorWay[0] = Double.Parse(BegXtextBox.Text); VectorWay[1] = Double.Parse(BegYtextBox.Text); xpred = VectorWay[0]; ypred = VectorWay[1]; g = SpuskWay.CreateGraphics(); x = xpred; y = ypred; a = Double.Parse(X12.Text); b = Double.Parse(X22.Text); c = Double.Parse(X1X2.Text); d = Double.Parse(X1.Text); E = Double.Parse(X2.Text); f = Double.Parse(K.Text); do { mu *= bi; a1 = a; b1 = b; c1 = c; d1 = d; e1 = E; f1 = f; for (int i = 0; i < schogr; i++) { if (func(dopogr[i][0], dopogr[i][1], dopogr[i][2], dopogr[i][3], dopogr[i][4], dopogr[i][5], x, y) > 0.0) { a1 += dopogr[i][0] * mu; b1 += dopogr[i][1] * mu; c1 += dopogr[i][2] * mu; d1 += dopogr[i][3] * mu; e1 += dopogr[i][4] * mu; f1 += dopogr[i][5] * mu; } } ResOtvet = VeryFastDown(a1, b1, c1, d1, e1, f1, ref x, ref y); if (((x - xpred) * (x - xpred) + (y - ypred) * (y - ypred)) <= eps * eps * 20) { break; } xpred = x; ypred = y; }while (ReturnAlfa(x, y) > 0.05); Anslabel.Text = "( " + x + " ;"; Ansylabel.Text = "" + y + " )"; Funlabel.Text = "F = " + ResOtvet; pererisovka(ResOtvet, x, y); }
static void Main() { int Height = Screen.PrimaryScreen.WorkingArea.Height; int Width = Screen.PrimaryScreen.WorkingArea.Width; Form MainForm = new Form(); MainForm.AutoSize = true; MainForm.MinimumSize = new Size(Width,Height); MainForm.Activate(); MainForm.BackColor = System.Drawing.Color.White; MainForm.Top = Screen.PrimaryScreen.WorkingArea.Top; MainForm.Left = Screen.PrimaryScreen.WorkingArea.Left; MainForm.Show(); PictureBox pb = new PictureBox(); MainForm.Controls.Add(pb); pb.Size = new Size(Width, Height); pb.Show(); pb.BackColor = System.Drawing.Color.White; int i; Random random = new Random(); int randomNumber; randomNumber = random.Next(0, 255); Point ptStart = new Point(random.Next(0, Width), random.Next(0, Height)); System.Drawing.Graphics Drawer = pb.CreateGraphics(); for (i=0; i<50000; i++) { Pen pn = new Pen( System.Drawing.Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)), random.Next(0,70) ); Point ptEnd = new Point(random.Next(0, Width), random.Next(0, Height)); Drawer.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; Drawer.DrawBezier(pn, ptStart, new Point(random.Next(0, Width), random.Next(0, Height)), new Point(random.Next(0, Width), random.Next(0, Height)), ptEnd); //Point[] pts = {ptStart, new Point(random.Next(0, Width), random.Next(0, Height)), // new Point(random.Next(0, Width), random.Next(0, Height)), // ptEnd}; //Drawer.DrawPolygon(pn,pts); ptStart = ptEnd; //pn.Dispose(); } }
private void documentPanel_Load(object sender, EventArgs e) { int col0Width = (int)docFileTablePanel.ColumnStyles[0].Width; int col1Width = (int)docFileTablePanel.ColumnStyles[1].Width; int textWidth = docFileTablePanel.Width - (col0Width + col1Width) - 20; docFileTablePanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.None; loadProgressBar.Visible = true; loadProgressBar.Minimum = 0; loadProgressBar.Maximum = ebook.Documents.Length; docFileTablePanel.SuspendLayout(); documentPanel_SizeChanged(sender, e); RemoveRows(); foreach (DocumentFile doc in ebook.Documents) { int row = AddTableRow(); docFileTablePanel.VerticalScroll.Enabled = (row > (docFileTablePanel.Height / (int)ROWSIZE)); PictureBox pic = new PictureBox(); pic.Size = new Size(30, 30); pic.Padding = new Padding(2); pic.Image = Properties.Resources.ebook_icon; using (Graphics g = pic.CreateGraphics()) { g.DrawImage(Properties.Resources.ebook_icon, 0, 0); } pic.Anchor = AnchorStyles.Left; pic.Click += DocFileTableRowSelect; docFileTablePanel.Controls.Add(pic, 0, row); pic.BringToFront(); Label l = new Label(); l.Text = doc.ItemID; l.Anchor = AnchorStyles.Left; l.Padding = new Padding(0, 4, 0, 0); l.TextAlign = ContentAlignment.MiddleLeft; l.Click += DocFileTableRowSelect; docFileTablePanel.Controls.Add(l, 1, row); // TextBox text = new TextBox(); Label text = new Label(); text.AutoSize = false; text.Padding = new Padding(0, 4, 0, 0); text.Width = textWidth; text.Text = doc.Filename; text.Anchor = AnchorStyles.Left; docFileTablePanel.Controls.Add(text, 2, row); loadProgressBar.Value = row; } docFileTablePanel.VerticalScroll.Maximum = docFileTablePanel.RowCount * (int)ROWSIZE; docFileTablePanel.ResumeLayout(); docFileTablePanel.PerformLayout(); loadProgressBar.Visible = false; }
private bool checkLineProximity(int indexno, int identifier, Graphics daGe) //checks whether if the mouse pointer is on an object (i.e. shape) { Graphics g = daGe; Pen lePen = new Pen(Color.Yellow, 1); g = pictureBox1.CreateGraphics(); g.TranslateTransform(this.pictureBox1.Left + 8, this.pictureBox1.Size.Height + 8); //transforms point-of-origin to the lower left corner of the canvas. g.SmoothingMode = SmoothingMode.HighQuality; switch (identifier) //depending on the "identifier" value, the relevant object will be highlighted { case 2: //Line { Line line = (Line)drawingList[indexno]; if (mainScale == 0) { mainScale = 1; } if (line.Highlight(lePen, g, aPoint, mainScale)) { this.Cursor = Cursors.Hand; line.highlighted = true; return(true); } break; } case 3: //rectangle { rectangle rect = (rectangle)drawingList[indexno]; if (rect.Highlight(lePen, g, aPoint)) { this.Cursor = Cursors.Hand; rect.highlighted = true; return(true); } break; } case 4: //circle { circle tempCircle = (circle)drawingList[indexno]; if (mainScale == 0) { mainScale = 1; } if (tempCircle.Highlight(lePen, g, aPoint, mainScale)) { this.Cursor = Cursors.Hand; tempCircle.highlighted = true; return(true); } break; } case 5: //polyline { polyline tempPoly = (polyline)drawingList[indexno]; if (mainScale == 0) { mainScale = 1; } if (tempPoly.Highlight(lePen, g, aPoint, mainScale)) { this.Cursor = Cursors.Hand; tempPoly.highlighted = true; return(true); } break; } case 6: //arc { arc tempArc = (arc)drawingList[indexno]; if (mainScale == 0) { mainScale = 1; } if (tempArc.Highlight(lePen, g, aPoint, mainScale)) { this.Cursor = Cursors.Hand; tempArc.highlighted = true; return(true); } break; } } return(false); }
private void DisplayColor(PictureBox box, FormeType formeType = FormeType.Rectangle) { Graphics g = box.CreateGraphics(); int factorX = (int)box.Width / kohonen.X; int factorY = (int)box.Height / kohonen.Y; double[][] cibles = ObtenirCibles(); // recalcule les couleurs foreach (KohonenNeurone neurone in kohonen.Grille) { if (neurone.Couleur == Color.Transparent) { kohonen.CalculerCouleurDepuisPoids(neurone, cibles); } Brush brush = new SolidBrush(neurone.Couleur); Pen pen = new Pen(Color.Black, 2); if (formeType == FormeType.Rectangle) { Rectangle rectangle = new Rectangle(factorX * neurone.X, factorY * neurone.Y, factorX, factorY); g.FillRectangle(brush, rectangle); g.DrawRectangle(pen, rectangle); } else { // inspiré de : // http://www.codeproject.com/Articles/14948/Hexagonal-grid-for-games-and-other-projects-Part // mais les données sont a et b dans notre cas } } }
private void DisplayImage(bool clearFirst) { if (this.WindowState == FormWindowState.Minimized) { return; } //Enhanced=enhanced; Graphics g = PictureBox1.CreateGraphics(); if (clearFirst) { g.FillRectangle(Brushes.White, 0, 0, PictureBox1.ClientRectangle.Width , PictureBox1.ClientRectangle.Height); } if (ImageCurrent == null) { g.Dispose(); return; } if (RecZoom.Width == 0) //need to create new RecZoom { RecZoom = GetSourceRect(); } //RecCrop=new Rectangle();//so it won't show anymore //if(enhanced){ switch (displayedDoc.DegreesRotated) { case 0: // break; case 90: g.TranslateTransform(PictureBox1.ClientRectangle.Width, 0); g.RotateTransform(90); //prepended to matrix transform break; case 180: g.TranslateTransform((float)PictureBox1.ClientRectangle.Width , (float)PictureBox1.ClientRectangle.Height); g.RotateTransform(180); break; case 270: g.TranslateTransform(0, PictureBox1.ClientRectangle.Height); g.RotateTransform(270); break; } //} if (displayedDoc.DegreesRotated == 0 || displayedDoc.DegreesRotated == 180) { g.DrawImage(ImageCurrent , new Rectangle(0, 0, PictureBox1.ClientRectangle.Width, PictureBox1.ClientRectangle.Height) , RecZoom, GraphicsUnit.Pixel); } else //90 or 270 { g.DrawImage(ImageCurrent , new Rectangle(0, 0, PictureBox1.ClientRectangle.Height, PictureBox1.ClientRectangle.Width) , RecZoom, GraphicsUnit.Pixel); } g.Dispose(); }
public static void loadBMP(string Filename, PictureBox Pict) { string path = Filename; // Verify that the path name exits if (!File.Exists(Filename)) { MessageBox.Show("Unable to locate bitmap. Check file path", "LLRP Test", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)(Image.FromFile(Filename)); int X, Y; BITMAPINFO bi24BitInfo = new BITMAPINFO(); //Getting data from PictureBox directly bi24BitInfo.bmiHeader.biBitCount = 24; bi24BitInfo.bmiHeader.biCompression = 0; // BI_RGB bi24BitInfo.bmiHeader.biPlanes = 1; bi24BitInfo.bmiHeader.biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); bi24BitInfo.bmiHeader.biWidth = bmp.Width; bi24BitInfo.bmiHeader.biHeight = bmp.Height; // Flattened it. Multidimension won't work here. byte[] textureImg = new byte[bmp.Width * bmp.Height * 3]; // Pin the array in memory, the garbage collector won't play with it. GCHandle gch = GCHandle.Alloc(textureImg, GCHandleType.Pinned); // Send it off. int result = GetDIBits(Pict.CreateGraphics().GetHdc(), bmp.GetHbitmap(), 0, bmp.Height, gch.AddrOfPinnedObject(), ref bi24BitInfo, 0); gch.Free(); //Swap BGR->RGB for (Y = 0; Y < bmp.Height; Y++) { for (X = 0; X < bmp.Width; X++) { int index = (Y * (bmp.Width * 3)) + (X * 3); byte temp = textureImg[index]; textureImg[index] = textureImg[index + 2]; textureImg[index + 2] = temp; } } // Er... // Now what. We didn't change anything. // We have to get the pixels back into an image now. //Dim bmp2 As New System.Drawing.Bitmap(bmp.Width, bmp.Height, bmp.PixelFormat) ' otherwise it would be 32bppARGB //Dim ms As New IO.MemoryStream //' Save to the stream. //bmp2.Save(ms, ImageFormat.Bmp) //' Overwrite with the new pixels //Dim bw As New IO.BinaryWriter(ms) //' Seek to the start of the pixeldata //bw.BaseStream.Seek(&H36, IO.SeekOrigin.Begin) //' write the bytes //bw.Write(textureImg) //bw.Flush() //bmp2.Dispose() //bmp2 = New System.Drawing.Bitmap(ms) //bw.Close() ' also disposes of ms and bw //Pict.Image = bmp2 Gl.glPixelStorei(Gl.GL_UNPACK_ALIGNMENT, 1); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, 3, bmp.Width, bmp.Height, 0, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, textureImg); textureImg = null; }