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


C# Form.CreateGraphics方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Client");

            string server;
            int port;
            ParseArgs(args, out server, out port);

            var points = Remoting(server, port);

            var frm = new Form();

            var closed = Observable.FromEventPattern(frm, "FormClosed");

            frm.Load += (o, e) =>
            {
                var g = frm.CreateGraphics();

                points.TakeUntil(closed).ObserveOn(frm).Subscribe(pt =>
                {
                    g.DrawEllipse(Pens.Red, pt.X, pt.Y, 1, 1);
                });
            };

            Application.Run(frm);
        }
开发者ID:Balharmander123,项目名称:Rx.NET,代码行数:26,代码来源:Program.cs

示例2: BufferAroundLine

        public void BufferAroundLine()
        {
            var form = new Form {BackColor = Color.White, Size = new Size(500, 200)};

            form.Paint += delegate
                              {

                                  Graphics g = form.CreateGraphics();

                                  List<ICoordinate> vertices = new List<ICoordinate>();

                                  vertices.Add(new Coordinate(0, 4));
                                  vertices.Add(new Coordinate(40, 15));
                                  vertices.Add(new Coordinate(50, 50));
                                  vertices.Add(new Coordinate(100, 62));
                                  vertices.Add(new Coordinate(240, 45));
                                  vertices.Add(new Coordinate(350, 5));

                                  IGeometry geometry = new LineString(vertices.ToArray());

                                  g.DrawLines(new Pen(Color.Blue, 1), GetPoints(geometry));

                                  BufferOp bufferOp = new BufferOp(geometry);
                                  bufferOp.EndCapStyle = BufferStyle.CapButt;
                                  bufferOp.QuadrantSegments = 0;

                                  IGeometry bufGeo = bufferOp.GetResultGeometry(5);

                                  bufGeo = bufGeo.Union(geometry);
                                  g.FillPolygon(new SolidBrush(Color.Pink), GetPoints(bufGeo));
                              };

            WindowsFormsTestHelper.ShowModal(form);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:BufferTest.cs

示例3: Show

        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider provider)
        {
            using (Form form1 = new Form())
            {
                form1.Paint += new PaintEventHandler(form1_Paint);

                form1.Text = "Font Visualizer";

                font = (Font)provider.GetObject();

                form1.StartPosition = FormStartPosition.WindowsDefaultLocation;
                form1.SizeGripStyle = SizeGripStyle.Auto;
                form1.ShowInTaskbar = false;
                form1.ShowIcon = false;

                Graphics formGraphics = form1.CreateGraphics();

                var size = formGraphics.MeasureString(font.Name, font);

                form1.Width = (int)size.Width + 100;
                form1.Height = (int)size.Height + 100;

                windowService.ShowDialog(form1);
            }
        }
开发者ID:piotrosz,项目名称:DebugVisualizersCollection,代码行数:25,代码来源:FontVisualizer.cs

示例4: WindowsFormsSwapChainPresenter

		public WindowsFormsSwapChainPresenter(Form window)
		{
			_width = window.ClientSize.Width;
			_height = window.ClientSize.Height;
			_bitmap = new Bitmap(_width, _height, PixelFormat.Format24bppRgb);
			_graphics = window.CreateGraphics();
		}
开发者ID:modulexcite,项目名称:rasterizr,代码行数:7,代码来源:WindowsFormsSwapChainPresenter.cs

示例5: GridSettings

		/// ------------------------------------------------------------------------------------
		public GridSettings()
		{
			ColumnHeaderHeight = -1;
			Columns = new GridColumnSettings[] { };
			using (Form frm = new Form())
			using (Graphics g = frm.CreateGraphics())
				m_currDpi = DPI = g.DpiX;
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:9,代码来源:GridSettings.cs

示例6: FormSettings

		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FormSettings()
		{
			Bounds = new Rectangle(0, 0, 0, -1);
			State = FormWindowState.Normal;
			using (Form frm = new Form())
			using (Graphics g = frm.CreateGraphics())
				m_currDpi = DPI = g.DpiX;
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:13,代码来源:FormSettings.cs

示例7: DrawBoard

 public void DrawBoard(Form form)
 {
     Graphics g = form.CreateGraphics();
     Pen _pen = new Pen(Color.Black, _linewidth);
     g.DrawLine(_pen, new Point(_outerMargin + _square + _linewidth / 2, _outerMargin), new Point(_outerMargin + _square + _linewidth / 2, _outerMargin + 3 * _square + 2 * _linewidth));
     g.DrawLine(_pen, new Point(_outerMargin + 2 * _square + _linewidth + _linewidth / 2, _outerMargin), new Point(_outerMargin + 2 * _square + _linewidth + _linewidth / 2, _outerMargin + 3 * _square + 2 * _linewidth));
     g.DrawLine(_pen, new Point(_outerMargin, _outerMargin + _square + _linewidth / 2), new Point(_outerMargin + 3 * _square + 2 * _linewidth, _outerMargin + _square + _linewidth / 2));
     g.DrawLine(_pen, new Point(_outerMargin, _outerMargin + 2 * _square + _linewidth + _linewidth / 2), new Point(_outerMargin + 3 * _square + 2 * _linewidth, _outerMargin + 2 * _square + _linewidth + _linewidth / 2));
 }
开发者ID:dreggjarnar,项目名称:Sidannaverkefni,代码行数:9,代码来源:DrawTicTacToe.cs

示例8: GameManager

        public GameManager(Form f)
        {
            form = f;
            g = f.CreateGraphics();

            u = new Universe(form.Width, form.Height);
            asteroids = new List<Sprite>();

            form.Paint += new PaintEventHandler(form_Paint);
        }
开发者ID:Turlough,项目名称:Asteroids,代码行数:10,代码来源:GameManager.cs

示例9: CaptureScreen

        //Prepare for print and save image
        private void CaptureScreen(Form parent)
        {
            Graphics myGraphics = parent.CreateGraphics();
            formSize = parent.Size;
            bitmap = new Bitmap(formSize.Width, formSize.Height, myGraphics);
            myGraphics.Dispose();

            Graphics graphics = Graphics.FromImage(bitmap);
            graphics.CopyFromScreen(parent.Location.X, parent.Location.Y, 0, 0, formSize);
        }
开发者ID:ghitme,项目名称:timesheet-serverless,代码行数:11,代码来源:PrinterForm.cs

示例10: DrawingSystem

 public DrawingSystem(Form form, EntityManager manager)
     : base(manager)
 {
     _form = form;
     _form.Invoke(new Action(() =>
     {
         _context = BufferedGraphicsManager.Current;
         _buffer = _context.Allocate(_form.CreateGraphics(), _form.DisplayRectangle);
     }));
 }
开发者ID:jjvdangelo,项目名称:ESTest,代码行数:10,代码来源:DrawingSystem.cs

示例11: LoadContent

 private void LoadContent() {
     form = new Form {
         Size = new Size(Width, Height),
         StartPosition = FormStartPosition.CenterScreen
     };
     formGraphics = form.CreateGraphics();
     camera = new Camera { Position = new Vector(0, 0, 10), Target = Vector.Zero };
     buffer = new GraphicsBuffer(Width, Height, camera);
     meshes = Mesh.FromBabylonModel("Contents/monkey.babylon");
 }
开发者ID:CanFengHome,项目名称:ToysFactory,代码行数:10,代码来源:AppDelegate.cs

示例12: capture

 public static void capture(Form form)
 {
     Graphics g1 = form.CreateGraphics();
     Image MyImage = new Bitmap(form.ClientRectangle.Width, form.ClientRectangle.Height, g1);
     Graphics g2 = Graphics.FromImage(MyImage);
     IntPtr dc1 = g1.GetHdc();
     IntPtr dc2 = g2.GetHdc();
     BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height, dc1, 0, 0, 13369376);
     g1.ReleaseHdc(dc1);
     g2.ReleaseHdc(dc2);
     MyImage.Save(@"c:\Captured.jpg", ImageFormat.Jpeg);
     MessageBox.Show("Finished Saving Image");
 }
开发者ID:skaulana,项目名称:eflash,代码行数:13,代码来源:FormCapture.cs

示例13: StylusMouseMux

 public StylusMouseMux( Form form )
 {
     using ( var fx = form.CreateGraphics() ) {
         FormDpiX = fx.DpiX;
         FormDpiY = fx.DpiY;
     }
     form.MouseDown += OnMouseDown;
     form.MouseMove += OnMouseMove;
     form.MouseUp   += OnMouseUp;
     RTS = new RealTimeStylus(form,true);
     RTS.AsyncPluginCollection.Add(this);
     Form = form;
 }
开发者ID:MaulingMonkey,项目名称:SketchBook,代码行数:13,代码来源:StylusMouseMux.cs

示例14: GetFormImage

 /// <summary>
 /// 根据Form,取得原始彩色图像
 /// </summary>
 /// <param name="frm"></param>
 /// <returns></returns>
 public static Bitmap GetFormImage(Form frm)
 {
     Graphics g = frm.CreateGraphics();
     Size s = frm.Size;
     Bitmap formImage = new Bitmap(s.Width, s.Height, g);
     Graphics mg = Graphics.FromImage(formImage);
     IntPtr dc1 = g.GetHdc();
     IntPtr dc2 = mg.GetHdc();//13369376
     BitBlt(dc2, 0, 0, frm.ClientRectangle.Width, frm.ClientRectangle.Height, dc1, 0, 0, 23369376);
     g.ReleaseHdc(dc1);
     mg.ReleaseHdc(dc2);
     return formImage;
 }
开发者ID:gudaling,项目名称:hotel,代码行数:18,代码来源:GrayScale.cs

示例15: TestCreateChildren

 public void TestCreateChildren()
 {
     var bounds = new Rectangle(1920, 0, 1024, 768);
     var screen = new GridScreen(bounds, new HandyMap());
     using (var form = new Form())
     {
         form.Size = new Size(1024, 768);
         screen.CreateChildren(form.CreateGraphics());
         var dic = screen.Root.DicChildren;
         Assert.AreEqual(dic.Count, 9);
         Assert.AreEqual(new Rectangle(0, 0, 341, 256), dic["w"].Bounds);
         Assert.AreEqual(new Rectangle(682, 256, 341, 256), dic["f"].Bounds);
         Assert.AreEqual(new Rectangle(0, 512, 341, 256), dic["x"].Bounds);
     }
 }
开发者ID:payaneco,项目名称:GridMouseControler,代码行数:15,代码来源:GridScreenTest.cs


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