コード例 #1
0
        public static void Start()
        {
            if (!IsActive)
            {
                IsActive = true;

                companionCube = Resources.CompanionCube;

                if (cubesForm != null) cubesForm.Close();
                cubesForm = new CompanionCubesForm();
                cubesForm.MouseClick += CubesForm_MouseClick;
                cubesForm.Show();

                area = new Rectangle(0, 0, cubesForm.Width, cubesForm.Height);

                Cubes = new List<CompanionCube>(CubeCount);

                for (int i = 0; i < CubeCount; i++)
                {
                    CompanionCube cube = new CompanionCube(MathHelpers.Random(50, 100), MathHelpers.Random(250, 500));
                    cube.Location = new Point(MathHelpers.Random(area.X, area.X + area.Width - cube.Size.Width),
                        MathHelpers.Random(area.Y - cube.Size.Height - 500, area.Y - cube.Size.Height));
                    Cubes.Add(cube);
                }

                previousElapsed = TimeSpan.Zero;
                startTime = Stopwatch.StartNew();

                timer = new Timer();
                timer.Interval = 20;
                timer.Tick += Timer_Tick;
                timer.Start();
            }
        }
コード例 #2
0
        public static void Stop()
        {
            if (IsActive)
            {
                if (timer != null)
                {
                    timer.Dispose();
                    timer = null;
                }

                if (cubesForm != null)
                {
                    cubesForm.Close();
                    cubesForm = null;
                }

                if (companionCube != null)
                {
                    companionCube.Dispose();
                    companionCube = null;
                }

                if (Cubes != null)
                {
                    Cubes.Clear();
                    Cubes = null;
                }

                IsActive = false;
            }
        }
コード例 #3
0
        public static void Start()
        {
            if (!IsActive)
            {
                IsActive = true;

                companionCube = Resources.CompanionCube;

                if (cubesForm != null)
                {
                    cubesForm.Close();
                }
                cubesForm             = new CompanionCubesForm();
                cubesForm.MouseClick += CubesForm_MouseClick;
                cubesForm.Show();

                area = new Rectangle(0, 0, cubesForm.Width, cubesForm.Height);

                Cubes = new List <CompanionCube>(CubeCount);

                for (int i = 0; i < CubeCount; i++)
                {
                    CompanionCube cube = new CompanionCube(MathHelpers.Random(50, 100), MathHelpers.Random(250, 500));
                    cube.Location = new Point(MathHelpers.Random(area.X, area.X + area.Width - cube.Size.Width),
                                              MathHelpers.Random(area.Y - cube.Size.Height - 500, area.Y - cube.Size.Height));
                    Cubes.Add(cube);
                }

                previousElapsed = TimeSpan.Zero;
                startTime       = Stopwatch.StartNew();

                timer          = new Timer();
                timer.Interval = 20;
                timer.Tick    += Timer_Tick;
                timer.Start();
            }
        }
コード例 #4
0
        public static void Stop()
        {
            if (IsActive)
            {
                if (timer != null)
                {
                    timer.Dispose();
                    timer = null;
                }

                if (cubesForm != null)
                {
                    cubesForm.Close();
                    cubesForm = null;
                }

                if (companionCube != null)
                {
                    companionCube.Dispose();
                    companionCube = null;
                }

                if (Cubes != null)
                {
                    Cubes.Clear();
                    Cubes = null;
                }

                IsActive = false;
            }
        }