我正在尝试在Visual Studio中创建一个C# Windows窗体,这样我就可以在窗体上绘图(就像微软画图的基本版本一样)。我正在研究C# 2012书籍中的一个示例。我已经逐字编写了代码,但是当我构建和运行程序时,我实际上无法在窗体上绘制任何内容。代码编译成功,没有任何错误。谁能看到代码可以改进的地方,这样我就可以成功地在窗体上绘制了?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Sys
我需要从一个csv文件中做一个线条的图形,并用GDI绘制它。我得到了一个Windows窗体,但现在我想改变比例并移动。
我从一些更简单的东西开始,比如用鼠标移动一个矩形,但开始绘制矩形总是从原点开始。有人能帮上忙吗?
我的代码是:
public partial class Form1 : Form {
int origenX;
int origenY;
bool transformar = false;
public Form1() {
InitializeComponent();
}
private void Form1
显然,我最近开始用C#编程,并尝试做一个简单的WinForms应用程序,该应用程序采用鼠标坐标,并根据坐标缩放矩形。
我面临的问题是,我不知道如何调用使用更多参数的方法(在本例中是x、y和PaintEventArgs)。或者,我知道如何处理PaintEvent。
下面是整个代码,因为它很短而且相当简单:
using System;
using System.Drawing;
using System.Windows.Forms;
public partial class Form1 : Form
{
public void Form1_MouseMove(object sender,
下面的代码是用来从上到下绘制全屏窗体的线条的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Gr
我需要帮助在WinForm上画一条线。
我目前拥有的代码主要是从MSDN中删除的:
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BouncingBall
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object se
我对学习C# GDI+感兴趣,并搜索了许多教程。我正在尝试创建一个简单的windows窗体,其中包含两个textbox控件和一个按钮。我只想在一个文本框中放置一个长度维度,在另一个文本框中放置一个高度维度,然后单击按钮,让应用程序使用这两个输入的维度在窗口上绘制矩形。到目前为止,我所能做的就是找到矩形参数硬编码到Form_Load和Form_Paint中的教程。如何从文本框中获取用户输入并传递给它们,以使应用程序刷新并在按钮单击上绘制矩形?如果需要更多的信息,请告诉我。提前感谢您的知识!
public partial class Form1 : Form
{
Bitmap drwBit
如果之前有人问过这个问题,很抱歉。
我在C# windows窗体中开发了一个简单的连接4游戏,因为我以前从未做过任何涉及图形的工作。要做到这一点,我需要程序绘制圆圈时,按钮被按下,但我不知道如何调用函数这样做。
public void printToken(PaintEventArgs pe, int x)
{
Graphics g = pe.Graphics;
Pen blue = new Pen(Color.Blue);
Pen red = new Pen(Color.Red);
Rectangle rect = n
private void pnlViewer_Paint(object sender, PaintEventArgs e)
{
e.Graphics.TranslateTransform(pnlViewer.AutoScrollPosition.X, pnlViewer.AutoScrollPosition.Y);
e.Graphics.FillRectangle(Brushes.Black, Screen.PrimaryScreen.Bounds);
//**draw Y Axis**
int y;
for (int i = 0; i <= 5
我想在圈子里画圈,我试过了,但有困难。
这是我的密码
Private Sub DrawCircle()
Dim g As Graphics
g = Panel1.CreateGraphics
Dim yellowPen As New Pen(Color.Yellow, 20)
Dim bluePen As New Pen(Color.Blue, 30)
Dim greenPen As New Pen(Color.Green, 20)
Dim skybluePen As New Pen(Color.AliceBlue, 20)
Dim voiletPen As New Pen(Color.Vio