用图形拉伸winform

时间:2016-08-29 19:41:18

标签: c# winforms graphics

我正在使用c#的winforms编写游戏, 在创建一个场景(包含图形,对象等......)时,我转移了表单,以便c&#t; tor看起来像这样:

private ngAfterViewInit(){
  this.animateTransLeaf();
}

private animateTransLeaf(){
  let i = -1;

  while (++i < this.transLeafTmp.length) {
    setTimeout(() => {
      this.transLeafTmp[i].isAnimated = true;
    }, 50 * i);
  }
}

现在我试图添加一个选项以全屏显示游戏, 但是当我试图最大化窗口时,它只会将图形打印到原始宽度x高度, 我怎么能加强那些?

1 个答案:

答案 0 :(得分:0)

您只需要听取表单的SizeChanged事件。每当尺寸发生变化时,您可以设置场景的“宽度”和“高度”属性以匹配新尺寸。

因此,在代码中的某处,您应该具有以下内容:

// I assume that this code is in the code-behind of the form, so "this" is the form 
this.SizeChanged += new EventHandler(FormSizeChanged);

private void FormSizeChanged(object sender, EventArgs e)
{
    yourScene.Width = this.Width;
    yourScene.Height = this.Height;
}
相关问题