当前位置: 首页>>代码示例>>C#>>正文


C# PictureBox.Invalidate方法代码示例

本文整理汇总了C#中System.Windows.Forms.PictureBox.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.Invalidate方法的具体用法?C# PictureBox.Invalidate怎么用?C# PictureBox.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PictureBox的用法示例。


在下文中一共展示了PictureBox.Invalidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public void Draw(PictureBox pictureBox, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         g.DrawLine(pen,_startPoint, _endPoint);
     }
     pictureBox.Invalidate();
 }
开发者ID:red2015,项目名称:Paint,代码行数:8,代码来源:ShapesDrawerLine.cs

示例2: updateGUI

 private void updateGUI(PictureBox picBox, Bitmap img)
 {
     picBox.Image = img;
     picBox.Invalidate();
     picBox.Update();
     picBox.Refresh();
     Application.DoEvents();
 }
开发者ID:TarekVito,项目名称:RobotPlanning,代码行数:8,代码来源:StepViewer.cs

示例3: Draw

 public void Draw(PictureBox pictureBox, Point temporaryPoint, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         g.DrawLine(pen, _startPoint, temporaryPoint);
     }
     _startPoint = temporaryPoint;
     pictureBox.Invalidate();
 }
开发者ID:red2015,项目名称:Paint,代码行数:9,代码来源:BasicDrawer.cs

示例4: ImageEditor

        public ImageEditor(PictureBox picturebox, fmMain _fm)
        {
            fm = _fm;
            PB = picturebox;
            //g = PB.CreateGraphics();
            g = Graphics.FromImage(PB.Image);
            PB.Invalidate(); // вызов полной перерисовки контрола

            Polygs = new List<Polygon>();
            CurPoints = new List<int>();
            PolygonMaxNumber = 2;
        }
开发者ID:mur-mur-moon,项目名称:Clipper,代码行数:12,代码来源:ImageEditor.cs

示例5: Draw

 public void Draw(PictureBox pictureBox, Point temporaryPoint, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         Pen newPen = new Pen(Color.White, 10);
         g.DrawLine(newPen, _startPoint, temporaryPoint);
         Rectangle rectangle = new Rectangle(temporaryPoint.X,temporaryPoint.Y, 10, 10);
         g.DrawRectangle(newPen, rectangle);
     }
     _startPoint = temporaryPoint;
     pictureBox.Invalidate();
 }
开发者ID:red2015,项目名称:Paint,代码行数:12,代码来源:Rubber.cs

示例6: SetCurrentToolHilight

        private void SetCurrentToolHilight(PictureBox pb, bool fValue)
        {
            // Update toolbox button hilight value.
            m_toolOptionCurrent.Hilight = fValue;

            // Update the option based on the state of the toolbox button.
            Options.Set(m_toolOptionCurrent.OptionName, fValue);

            // Update toolbox display
            pb.Invalidate();
        }
开发者ID:jduranmaster,项目名称:spritely,代码行数:11,代码来源:Optionbox.cs

示例7: Render

        /* ----------------------------------------------------------------- */
        ///
        /// Render (private)
        ///
        /// <summary>
        /// MEMO: ロックは暫定処理.Microsoft によると public にアクセス
        /// 可能なオブジェクトを用いた lock は想定していないらしい.
        /// http://msdn.microsoft.com/ja-jp/library/c5kehkcz%28VS.80%29.aspx
        /// </summary>
        /// 
        /* ----------------------------------------------------------------- */
        private static bool Render(Canvas canvas, bool adjust)
        {
            if (canvas == null) return false;
            var engine = canvas.Tag as CanvasEngine;
            if (engine == null) return false;
            var core = engine.Core;
            if (core == null) return false;

            lock (core) {
                var status = core.RenderPage(IntPtr.Zero, false, false);
                if (status && adjust) CanvasPolicy.Adjust(canvas);
                canvas.Invalidate();
                return status;
            }
        }
开发者ID:cube-soft,项目名称:CubePdfViewer,代码行数:26,代码来源:CanvasPolicy.cs

示例8: DrawPath

 /// <summary>
 /// 显示路径到指定的PictureBox
 /// </summary>
 /// <param name="p">要显示路径的PictureBox</param>
 public void DrawPath(PictureBox p)
 {
     //拷贝迷宫地图到新对象
     Bitmap newBmp = new Bitmap(Bmp);
     //创建绘制对象
     Graphics g = Graphics.FromImage(newBmp);
     //将栈内记录的路线点绘制在迷宫图上
     Stack<Point> points = new Stack<Point>(PathStack);
     while (points.Count > 0)
     {
         Point point = points.Pop();
         g.DrawImage(Resources.unblock, point.X * BlockWidth, point.Y * BlockWidth, BlockWidth, BlockHeight);
     }
     p.Image = newBmp;
     p.Invalidate();
 }
开发者ID:JiaoWoWeiZai,项目名称:MazeForm,代码行数:20,代码来源:Maze.cs

示例9: DrawMatrix

 private void DrawMatrix(BinImage bi, PictureBox p)
 {
     //      pictureBox1.Dispose();
     btp = new Bitmap(bi.Width, bi.Height);
     for (int i = 0; i < bi.Width; ++i)
         for (int j = 0; j < bi.Height; ++j)
             if (bi.matr[i, j] == 1)
                 btp.SetPixel(i, j, Color.White);
             else
                 btp.SetPixel(i, j, Color.Black);
     p.Image = btp;
     p.Invalidate();
     p.Update();
 }
开发者ID:ashepelev,项目名称:image-processing,代码行数:14,代码来源:Form1.cs

示例10: PictureBoxSizeChange

		/* P I C T U R E  B O X  S I Z E  C H A N G E */
		/*----------------------------------------------------------------------------
			%%Function: PictureBoxSizeChange
			%%Qualified: bg.BgGraph.PictureBoxSizeChange
			%%Contact: rlittle

		----------------------------------------------------------------------------*/
		void PictureBoxSizeChange(PictureBox pb, HScrollBar sbh, VScrollBar sbv)
		{
			Graphics gr = this.CreateGraphics();
			RectangleF rcf = new RectangleF(Reporter.DxpFromDxa(gr, 100), 
											Reporter.DypFromDya(gr, 100), 
											pb.Width - Reporter.DxpFromDxa(gr, 200), 
											pb.Height - Reporter.DypFromDya(gr, 200));

			if (pb.Tag != null)
				{
				int iFirst = ((GraphicBox)pb.Tag).GetFirstForScroll();
				GraphicBox gb = null;
	
				if (BvFromPb(pb) == BoxView.Graph)
					pb.Tag = gb = (GraphicBox) new Grapher(rcf, gr);
				else if (BvFromPb(pb) == BoxView.Log)
					pb.Tag = gb = (GraphicBox) new Reporter(rcf, gr);
	
				if (gb != null)
					{
					gb.SetProps(m_gp);
					gb.SetDataPoints(m_oData, sbv, sbh);
					gb.Calc();
					gb.SetFirstFromScroll(iFirst);
					}
	
				pb.Invalidate();
				}
		}
开发者ID:rlittletht,项目名称:bg.incomplete,代码行数:36,代码来源:Graph.cs

示例11: ClearImage

 internal void ClearImage(Bitmap bitmap, Color secondaryColor, PictureBox imageBox)
 {
     Graphics.FromImage(bitmap).Clear(secondaryColor);
       imageBox.Invalidate();
 }
开发者ID:pchmielowski,项目名称:Paint,代码行数:5,代码来源:MenuController.cs

示例12: DrawFractal

        private void DrawFractal(PictureBox pic, Fractal f)
        {
            if (pic.Image == null)
                pic.Image = new Bitmap(pic.Width, pic.Height);

            Random r = new Random();

            pic.Image = fractal.Picture;
            pic.Invalidate();
        }
开发者ID:lightfaith,项目名称:NAVY,代码行数:10,代码来源:Form1.cs

示例13: updateDrawing

 void updateDrawing(PictureBox picture)
 {
     if (colourTheme.Count > 0)
     {
         for (int k = 0; k < colourTheme.Count; k++)
         {
             int r, g, b;
             hexToRGB(colours[colourTheme[k]].hex, out r, out g, out b);
             SolidBrush myBrush = new SolidBrush(Color.FromArgb(255, r, g, b));
             Graphics formGraphics;
             formGraphics = picture.CreateGraphics();
             formGraphics.FillRectangle(myBrush, new Rectangle(0, k * picture.Height / colourTheme.Count, picture.Width, picture.Height / colourTheme.Count));
             myBrush.Dispose();
             formGraphics.Dispose();
         }
     }
     else
     {
         picture.Invalidate();
     }
 }
开发者ID:DatSkip,项目名称:Toribash-Art-Companion,代码行数:21,代码来源:Form1.cs

示例14: AnimateToPictureBox

        public override void AnimateToPictureBox(PictureBox pictureBox)
        {
            if (m_trigger == MouseButtons.None || m_modifier == MouseButtons.None) return;

            bool swapedButtons = Win32.GetSystemMetrics(Win32.SM_SWAPBUTTON) == 0 ? false : true;
            
            Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);            
            Graphics gp = Graphics.FromImage(bmp);
            gp.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;            
            int width = (int)Math.Min(bmp.Width * 0.8, bmp.Height * 0.8);
            if (width > Resources.base_mouse.Width)
                width = Resources.base_mouse.Width;
            int height = width;
            Point pos = new Point((bmp.Width - width) / 2, (bmp.Height - height) / 4);
            Rectangle r = new Rectangle(pos, new Size(width, height));
            Point strPos = new Point(0, pos.Y + (int)Math.Floor(r.Height * 0.95));
            Rectangle rString = new Rectangle(strPos, new Size(bmp.Width, (int)Math.Floor((bmp.Height - height) * 0.75)));
            float fontHeight = (float)r.Height / 18;
            Font strFont = new Font(FontFamily.GenericSansSerif, fontHeight, FontStyle.Bold); //SystemFonts.DefaultFont;
            
            string txtPushHoldBtn = string.Format(Translation.GetText("Animate_RockerG_pushHoldBtn"), Translation.GetMouseBtnText(m_trigger));
            string txtClickExecuteBtn = string.Format(Translation.GetText("Animate_RockerG_clickExecuteBtn"), Translation.GetMouseBtnText(m_modifier));

            //float strWidth = Math.Max(gp.MeasureString(txtPushHoldBtn, strFont).Width, gp.MeasureString(txtClickExecuteBtn, strFont).Width);
            //if (strWidth > r.Width * 2)
            //{
            //    fontHeight = (float)r.Height / 22;
            //    strFont = new Font(strFont.FontFamily, fontHeight, strFont.Style);
            //}

            StringFormat strFormat = new StringFormat();
            strFormat.LineAlignment = StringAlignment.Center;
            strFormat.Alignment = StringAlignment.Center;            
            SolidBrush strTriggerBrush = new SolidBrush(Color.FromArgb(250, 10, 10)); //red 
            SolidBrush strModifierBrush = new SolidBrush(Color.FromArgb(220, 215, 16)); //yellow

            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            pictureBox.Image = bmp;            
            System.Threading.Thread.Sleep(DELAY / 4);
            
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            DrawTrigger(m_trigger, gp, r);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            //text = string.Format("Push and hold the {0} button.", button.ToUpper());
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtPushHoldBtn, strFont, strTriggerBrush, rString, strFormat);            
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);

            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            DrawModifier(m_modifier, gp, r);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            //text = string.Format("Click on the {0} button to invoke the action.", button.ToUpper());
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);            
            gp.DrawString(txtClickExecuteBtn, strFont, strModifierBrush, rString, strFormat);            
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);
            
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            pictureBox.Invalidate();
            gp.Dispose();
        }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:63,代码来源:DoubleButton.cs

示例15: DrawCurve

        /// <summary>
        /// Draws curve in to the panel
        /// </summary>
        /// <param name="panel">Panel</param>
        /// <param name="curve">Curve</param>
        /// <param name="delay">Delay if animation is requested</param>
        public static void DrawCurve(PictureBox pictureBox, List<PointF> curve, int delay)
        {
            Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
            //pictureBox.Image = bmp;            
            Pen pen = new Pen(Brushes.Blue, 6);
            pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
            Graphics gp = Graphics.FromImage(bmp);
            gp.FillRectangle(Brushes.White, 0, 0, pictureBox.Width, pictureBox.Height);
            gp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            pictureBox.Image = bmp;
            if (curve == null || curve.Count == 0)
            {
                gp.Dispose();
                return;
            }

            List<PointF> new_curve = ScaleToCenter(curve, pictureBox.ClientRectangle);
            if (delay != 0)
            {
                List<PointF> exactCurve = CreateExactPath(new_curve, 2, 4);
                new_curve = exactCurve;
            }
            
            //Brush brushStart = new System.Drawing.Drawing2D.LinearGradientBrush(
            //        new_curve[0], new_curve[15], Color.Green, Color.Blue);
            

            for (int i = 0; i < new_curve.Count - 1; i++)
            {
                //int lastIndex = i > 15 ? i - 15 : 0;
                //List<PointF> last10Points = new List<PointF>();
                //last10Points.AddRange(new_curve.GetRange(lastIndex, i - lastIndex + 2));
                ////gp.FillEllipse(Brushes.Blue, new_curve[i].X - 3, new_curve[i].Y - 3, 6, 6);
                //Brush brushEnd = new System.Drawing.Drawing2D.LinearGradientBrush(
                //    last10Points[0], last10Points[last10Points.Count - 1], Color.Blue, Color.Red);

                
                //List<PointF> allPoints =  new_curve.GetRange(0, i + 2);
                //pen.Brush = Brushes.Blue;
                //gp.DrawLines(pen, last10Points.ToArray());
                //pen.Brush = brushEnd;
                //if (last10Points.Count > 2)
                //    last10Points.RemoveAt(0);
                //gp.DrawLines(pen, last10Points.ToArray());

                gp.DrawLine(pen, new_curve[i], new_curve[i + 1]);    
                if (delay != 0)
                {
                    pictureBox.Invalidate();
                    System.Threading.Thread.Sleep(delay);
                }
            }
            gp.FillEllipse(Brushes.Green, new_curve[0].X - 3, new_curve[0].Y - 3, 6, 6);
            gp.FillEllipse(Brushes.Red, new_curve[new_curve.Count - 1].X - 3, new_curve[new_curve.Count - 1].Y - 3, 6, 6);
            gp.Dispose();
            pictureBox.Invalidate();
        }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:65,代码来源:MyCurve.cs


注:本文中的System.Windows.Forms.PictureBox.Invalidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。