using System;
using System.Collections .Generic ;
using System.ComponentModel ;
using System.Data ;
using System.Drawing ;
using System.Linq ;
using System.Text ;
using System.Threading .Tasks ;
using System.Windows .Forms ;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public PictureBox[ , ] hairetu = new PictureBox[ 10 , 20 ] ;
public Form1( )
{
Timer timer = new Timer( ) ;
timer.Tick += new EventHandler( MyClock) ;
timer.Interval = 1000 ;
timer.Enabled = true ; // timer.Start()と同じ
InitializeComponent( ) ;
}
public void MyClock( object sender, EventArgs e)
{
bool chinko = true ;
for ( int a = 0 ; a < 10 ; a++ )
{
for ( int b = 0 ; b < 20 ; b++ )
{
if ( hairetu[ a, b] != null && hairetu[ a, b] .unko == true )
{
chinko = false ;
}
}
}
if ( chinko)
{
Random rnd = new Random( ) ;
int ransuu = rnd.Next ( 0 , 9 ) ;
hairetu[ ransuu, 0 ] = new PictureBox( ) ;
hairetu[ ransuu, 0 ] .Location = new Point( ransuu * 20 , 20 ) ;
hairetu[ ransuu, 0 ] .BackColor = Color.Red ;
hairetu[ ransuu, 0 ] .Size = new Size( 20 , 20 ) ;
this.Controls .Add ( hairetu[ ransuu, 0 ] ) ;
}
}
}
}
IHVzaW5nIFN5c3RlbTsKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7CnVzaW5nIFN5c3RlbS5Db21wb25lbnRNb2RlbDsKdXNpbmcgU3lzdGVtLkRhdGE7CnVzaW5nIFN5c3RlbS5EcmF3aW5nOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQ7CnVzaW5nIFN5c3RlbS5UaHJlYWRpbmcuVGFza3M7CnVzaW5nIFN5c3RlbS5XaW5kb3dzLkZvcm1zOwoKbmFtZXNwYWNlIFdpbmRvd3NGb3Jtc0FwcGxpY2F0aW9uMwp7CiAgICBwdWJsaWMgcGFydGlhbCBjbGFzcyBGb3JtMSA6IEZvcm0KICAgIHsKIAogcHVibGljIFBpY3R1cmVCb3hbLF0gaGFpcmV0dSA9IG5ldyBQaWN0dXJlQm94WzEwLCAyMF07CiAgICAgICAgcHVibGljIEZvcm0xKCkKICAgICAgICB7CiAgICAgICAgICAgIFRpbWVyIHRpbWVyID0gbmV3IFRpbWVyKCk7CiAgICAgICAgICAgIHRpbWVyLlRpY2sgKz0gbmV3IEV2ZW50SGFuZGxlcihNeUNsb2NrKTsKICAgICAgICAgICAgdGltZXIuSW50ZXJ2YWwgPSAxMDAwOwogICAgICAgICAgICB0aW1lci5FbmFibGVkID0gdHJ1ZTsgLy8gdGltZXIuU3RhcnQoKeOBqOWQjOOBmAoKICAgICAgICAgICAgSW5pdGlhbGl6ZUNvbXBvbmVudCgpOwogICAgICAgIH0KIAogcHVibGljIHZvaWQgTXlDbG9jayhvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkKICAgICAgICB7CiAgICAgICAgICAgIGJvb2wgY2hpbmtvID0gdHJ1ZTsKICAgICAgICAgICAgZm9yIChpbnQgYSA9IDA7IGEgPCAxMDsgYSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3IgKGludCBiID0gMDsgYiA8IDIwOyBiKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhaXJldHVbYSwgYl0gIT0gbnVsbCAmJiBoYWlyZXR1W2EsIGJdLnVua28gPT0gdHJ1ZSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNoaW5rbyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKaWYgKGNoaW5rbykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgUmFuZG9tIHJuZCA9IG5ldyBSYW5kb20oKTsKICAgICAgICAgICAgICAgIGludCByYW5zdXUgPSBybmQuTmV4dCgwLCA5KTsKICAgICAgICAgICAgICAgIGhhaXJldHVbcmFuc3V1LCAwXSA9IG5ldyBQaWN0dXJlQm94KCk7CiAgICAgICAgICAgICAgICBoYWlyZXR1W3JhbnN1dSwgMF0uTG9jYXRpb24gPSBuZXcgUG9pbnQocmFuc3V1ICogMjAsIDIwKTsKICAgICAgICAgICAgICAgIGhhaXJldHVbcmFuc3V1LCAwXS5CYWNrQ29sb3IgPSBDb2xvci5SZWQ7CiAgICAgICAgICAgICAgICBoYWlyZXR1W3JhbnN1dSwgMF0uU2l6ZSA9IG5ldyBTaXplKDIwLCAyMCk7CiAgICAgICAgICAgICAgICB0aGlzLkNvbnRyb2xzLkFkZChoYWlyZXR1W3JhbnN1dSwgMF0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9
compilation info
prog.cs(4,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(8,24): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
prog.cs(9,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(16,9): error CS0246: The type or namespace name `PictureBox' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 4 error(s), 0 warnings
stdout