我需要在C#中使用Visual Studio制作图形,但是当我设置这样的点时:
module DSD_Project(flag0, flag1, hit0, hit1,room_counter,someone_inRoom,someone_Spying,hit0_LED, hit1_LED,echo0_LED, echo1_LED, anti_theft_output,reset_Antitheft_output,echo0, echo1, CLOCK_50,anti_theft, reset_Antitheft);
output reg hit0_LED = 1'b0;
output reg hit1_LED = 1'b0;
output reg echo0_LED = 1'b0;
output reg echo1_LED = 1'b0;
output reg flag0 = 1'b0;
output reg flag1 = 1'b0;
output reg hit0 = 1'b0;
output reg hit1 = 1'b0;
output reg room_counter = 1'b0;
output reg someone_inRoom = 1'b0;
output reg someone_Spying = 1'b0;
output reg anti_theft_output = 1'b0;
output reg reset_Antitheft_output = 1'b0;
input echo0; // input_signal from the sensor 1
input echo1;// input_signal from the sensor 2
input CLOCK_50;
input anti_theft ; //= 1'b0; // switch button
input reset_Antitheft; // = 1'b0; // push button
sensor s1(hit0, echo0) ; // , CLOCK_50);
sensor s2(hit1, echo1) ; // , CLOCK_50);
always@(posedge CLOCK_50)
begin
hit0_LED <= hit0;
hit1_LED <= hit1;
echo0_LED <= echo0;
echo1_LED <= echo1;
end
//anti_theft: seting and reseting the output
//always@(anti_theft) //or reset_Antitheft)
//begin
//anti_theft_output <= anti_theft ;
//reset_Antitheft_output <= reset_Antitheft ;
//end
always@(posedge hit0 or posedge hit1)
begin
if (hit0 == 1 && hit1== 0)
begin
flag0<= 1;
//flag1<= 0;
if(flag1==0)
begin
hit0=0;
room_counter <= room_counter +1 ;
someone_inRoom <=1 ;
if(anti_theft == 1)
someone_Spying <= 1;
end
else
flag1<=0;
end
else
begin
if ((hit0 == 0) && (hit1 == 1))
begin
//flag0<=0;
flag1<=1;
if(flag0 == 0)
begin
hit1=0;
room_counter <= room_counter -1 ;
if(room_counter==0)
begin
someone_inRoom <=0 ;
end
end
else
flag0<=0;
end
end
end
always@(reset_Antitheft)
begin
if( (anti_theft==1) && (someone_Spying == 1) )
begin
anti_theft_output <= 0 ;
someone_Spying <= 0 ;
end
end
endmodule
module sensor(hit, input_signal); //, CLOCK_50);
input input_signal;
output reg hit = 1'b0;
//reg [25:0] clock_counter;
always@(input_signal) // posedge CLOCK_50 ||
begin
//if (clock_counter == 8_000_000)
begin
if (input_signal==1)
begin
hit <= 1;
end
else
begin
hit <= 0;
end
end
//else
// clock_counter <= clock_counter+1;
end
endmodule
我的矩形显然从面板上飞过,因为在C#中高度向下增加,有没有办法解决这个问题?我不能将起点设置得更高并让它向下移动,因为我写的程序需要接收数据。
P.S。我知道有一种更简单的方法可以在C#中绘制图形,但这适用于学校作业,我只允许使用DrawRectangle或FillRectangle功能。
答案 0 :(得分:1)
您可以移动Graphics
对象并像这样镜像:
g.TranslateTransform(0, Height);
g.ScaleTransform(1, -1);
现在你可以向上画了:
e.Graphics.DrawRectangle(pen, 10, 300, 30, 400);
请注意,此处Height
是Form.Height
。如果您绘制其他任何内容(包括Bitmap
),则需要使用其高度!
如果你不想从最底层开始,只需使用较小的数字......!