本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例4: WindowsFormsSwapChainPresenter
public WindowsFormsSwapChainPresenter(Form window)
{
_width = window.ClientSize.Width;
_height = window.ClientSize.Height;
_bitmap = new Bitmap(_width, _height, PixelFormat.Format24bppRgb);
_graphics = window.CreateGraphics();
}
示例5: GridSettings
/// ------------------------------------------------------------------------------------
public GridSettings()
{
ColumnHeaderHeight = -1;
Columns = new GridColumnSettings[] { };
using (Form frm = new Form())
using (Graphics g = frm.CreateGraphics())
m_currDpi = DPI = g.DpiX;
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}));
}
示例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");
}
示例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");
}
示例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;
}
示例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;
}
示例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);
}
}