问题描述
我想创建一个圈子.它会出现在表格的正中间.
几秒钟后,它会消失.它将出现在右侧(从中心开始),间隙恰好为5英寸.像左侧5英寸间隙一样
I want to Create one Circle. It would be appear in the exact middle of form.
after few secs it would be disappear. It would appear right side (from the centre) with the exact 5 inches gap. same like left side 5 inches gap
推荐答案
Pen blackPen = new Pen(Color.Black, 3);
int width = 200;
int height = 200;
int x = (Width - width) / 2;
int y = 0;
e.Graphics.DrawEllipse(blackPen, x, y, width, height);
这将画出您的圆形,水平居中.
由于屏幕尺寸各不相同,因此您将不得不用左右圆圈的位置来进行游戏,因此很难解决向左5英寸"的移动.
以上代码不起作用?
我有3张图片(图片1,图片2,图片3),
使用间隔值为5000(即5秒,I
)的计时器控件要完成以下任务:
-最初,用户只能在表单中间看到Image1,即2张图像
设置为不可见.
-加载表单时出现image1
出现在表格的正中间
-5秒钟后,图像1消失,图像2出现在右侧.
-5秒钟后,image2消失而image3出现在左侧
-5秒钟后,image3消失,image1出现
我在设计中将计时器控件的Enable属性设置为"True"
时间.
我将计时器控件的Interval属性值设置为5000 in
设计时间.
我假设我已完成所有编码,但仅显示两个图像而不工作
有人可以帮我编写我想完成的工作吗?"
首先,检查您是否正在处理计时器滴答"事件-突出显示计时器,然后在属性窗格中查看,单击事件"按钮(看起来像是闪电),然后检查滴答"事件.如果没有处理程序,请双击创建一个处理程序.
在事件处理程序方法中,您将需要:
类级别的模式"变量:
That will draw your circle, horizontally centred.
You will have to play with the positions of your left and right circles, as screen sizes vary, so moving "5 inches to the left" is harder to work out.
"Above code is not working ?
I have 3 Images (Image1, Image2, Image3),
Using a timer control with interval value of 5000, i.e 5second, I
want to accomplish the following:
- Initially, only Image1 is visible to the user middle of the form, i.e the 2 images
are set to be invisible.
- When load the form appear and image1
appears exact middle of the form
- After 5 seconds, the image1 disappear and image 2 appears right side.
- After 5 seconds, the image2 disappear and image3 appears left side
- After 5 seconds, the image3 disappear and the image1 appear
I am setting timer control''s Enable property to "True" in Design
time.
I am setting timer control''s Interval property value to 5000 in
Design Time.
I assume that I do all the coding but not working only displaying two images
Can anyone help me code what I want to accomplish?"
First, check that you are handling the Timer Tick event - highlight the timer then look in the properties pane, click the Events button (it looks like a lightning bolt) and check the Tick event. If you have no handler, creat one by double clicking on it.
In the event handler method you will need:
A class level "mode" variable:
private enum ShowImage
{
FirstOnly,
SecondOnly,
ThirdOnly,
}
private ShowImage showWhichImage = ShowImage.FirstOnly;
在处理程序方法中,您可以使用此方法确定接下来要显示的内容:
In the handler method, you use this to determine what to show next:
switch(showWhichImage)
{
case ShowImage.FirstOnly:
Image1.Visible = false;
Image2.Visible = true;
Image3.Visible = false;
showWhichImage = ShowImage.SecondOnly;
break;
case ShowImage.SecondOnly:
Image1.Visible = false;
Image2.Visible = false;
Image3.Visible = true;
showWhichImage = ShowImage.ThirdOnly;
break;
case ShowImage.ThirdOnly:
Image1.Visible = true;
Image2.Visible = false;
Image3.Visible = false;
showWhichImage = ShowImage.FirstOnly;
break;
default:
throw new Exception("Unknown ShowImage encountered: " + showWhichImage.ToString());
}
这篇关于出现消失的圈子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!