当前位置: 首页>>代码示例>>C#>>正文


C# Timer.start方法代码示例

本文整理汇总了C#中Timer.start方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.start方法的具体用法?C# Timer.start怎么用?C# Timer.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


在下文中一共展示了Timer.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public unsafe void Run()
        {
            var timer = new Timer();
            timer.start();

            // for fps info update
            int lastTick = timer.read_ms();
            int color = 0;
            int dir = 1;

            // create double buffered display
            var canvas = new Canvas();

            string infoString = "";

            while (true)
            {
                // fill screen with pixels
                for (UInt16 x = 0; x < 480; x++)
                {
                    for (UInt16 y = 0; y < 272; y++)
                    {
                        canvas.SetPixel(x, y, (UInt32)(0xFF000000 | (color << 16)));
                    }
                }

                // show info every couple of seconds
                if (timer.read_ms() - lastTick > 2000)
                {
                    // string.format broken?
                    //infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}",
                    //    display.Fps,
                    //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory,
                    //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory);

                    infoString = "FPS: " + canvas.Fps.ToString() + " MEMAVAIL: " + Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory.ToString();

                    lastTick = timer.read_ms();
                }

                //canvas.DrawString(infoString, 0, 0);

                // fade in/out the pixel fill
                color += dir;

                if (color == 255)
                {
                    dir = -1;
                }
                else if (color == 0)
                {
                    dir = +1;
                }

                // show the back buffer
                canvas.Flip();
            }
        }
开发者ID:roceh,项目名称:stm32f7disco_llilum_lcdtest,代码行数:58,代码来源:PixelTest.cs

示例2: Run

        public void Run()
        {
            var timer = new Timer();
            timer.start();

            // for fps info update
            int lastTick = timer.read_ms();

            // create double buffered display
            var canvas = new Canvas();
            var touch = new Touch();

            string infoString = "";

            while (true)
            {
                int touches = touch.GetTouchInfo();

                canvas.Clear(0xFFFFFFFF);

                for (int i = 0; i < touches; i++)
                {
                    canvas.DrawCircle((UInt16)Math.Max(50, Math.Min(480 - 50 - 1, touch.X[i])), (UInt16)Math.Max(50, Math.Min(272 - 50 - 1, touch.Y[i])), 50, 0xFFFF0000);
                }

                // show info every couple of seconds
                if (timer.read_ms() - lastTick > 2000)
                {
                    infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}",
                        canvas.Fps,
                        Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory,
                        Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory);

                    lastTick = timer.read_ms();
                }

                //canvas.DrawString(infoString, 0, 0);

                // show the back buffer
                canvas.Flip();
            }
        }
开发者ID:roceh,项目名称:stm32f7disco_llilum_lcdtest,代码行数:42,代码来源:TouchTest.cs

示例3: Run

        public unsafe void Run()
        {
            var timer = new Timer();
            timer.start();

            // for fps info update
            int lastTick = timer.read_ms();

            string infoString = "";

            SDCardManager.Mount();

            _background = new Bitmap("BACK.DAT", 480, 272);
            _sprite = new Bitmap("SPRITE.DAT", 64, 64);
            _font = Font.LoadFromFile("DEJAVU.FNT");

            // create double buffered display
            var canvas = new Canvas();

            var sprites = new List<Sprite>();

            var r = new Random();

            for (int i = 0; i < 20; i++)
            {
                sprites.Add(new Sprite
                {
                    X = r.Next(480 - 64),
                    Y = r.Next(272 - 64),
                    Width = (int)_sprite.Width,
                    Height = (int)_sprite.Height,
                    Dx = r.Next(2) == 0 ? 2 : -2,
                    Dy = r.Next(2) == 0 ? 2 : -2
                });
            }

            while (true)
            {
                canvas.Clear(_background);

                foreach (var sprite in sprites)
                {
                    canvas.DrawBitmap(_sprite, 0, 0, sprite.X, sprite.Y, 64, 64);
                    sprite.Step(Canvas.ScreenWidth, Canvas.ScreenHeight);
                }

                // show info every couple of seconds
                if (timer.read_ms() - lastTick > 2000)
                {
                    // string.format broken?
                    //infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}",
                    //    display.Fps,
                    //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory,
                    //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory);

                    infoString = "FPS: " + canvas.Fps.ToString() + " MEMAVAIL: " + Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory.ToString();

                    lastTick = timer.read_ms();
                }

                canvas.DrawString(infoString, 0, 0, _font);

                // show the back buffer
                canvas.Flip();
            }
        }
开发者ID:roceh,项目名称:stm32f7disco_llilum_lcdtest,代码行数:66,代码来源:BitmapTest.cs

示例4: Run

        public void Run(Control root)
        {
            SDCardManager.Mount();

            // load in the system font
            _systemFont = Font.LoadFromFile("DEJAVU.FNT");

            var timer = new Timer();
            timer.start();

            // for fps info update
            float lastDebugTime = 0;
            float lastUpdateTime = 0;

            string infoString = "";

            while (true)
            {
                FrameTime = timer.read();

                // fixed time step - both for update and draw
                if (FrameTime - lastUpdateTime >= DeltaTime)
                {
                    int touches = Touch.GetTouchInfo();

                    for (int i = 0; i < touches; i++)
                    {
                        // near a touch we have seen recently ?
                        var previous = _activeTouches.Find(x => Math.Abs(x.Position.X - Touch.X[i]) < TouchTrackTolerance &&
                                                                Math.Abs(x.Position.Y - Touch.Y[i]) < TouchTrackTolerance);

                        if (previous == null)
                        {
                            _nextTouchId++;

                            // remember this touch
                            _activeTouches.Add(new TouchInfo { Position = new Point((int)Touch.X[i], (int)Touch.Y[i]), LastSeenTime = FrameTime, Id = _nextTouchId });

                            // new touch so send message to root control
                            root.SendMessage(UIMessage.TouchStart, new TouchEventArgs(_nextTouchId, new Point((int)Touch.X[i], (int)Touch.Y[i])));
                        }
                        else
                        {
                            bool hasMoved = (Math.Abs(previous.Position.X - Touch.X[i]) > 0 || Math.Abs(previous.Position.Y - Touch.Y[i]) > 0);

                            // touch seen again - update for tracking
                            previous.Position = new Point((int)Touch.X[i], (int)Touch.Y[i]);
                            previous.LastSeenTime = FrameTime;

                            // moved at all ?
                            if (hasMoved)
                            {
                                root.SendMessage(UIMessage.TouchMove, new TouchEventArgs(previous.Id, previous.Position));
                            }
                        }
                    }

                    // get rid of old touches
                    for (int i = _activeTouches.Count - 1; i >= 0; i--)
                    {
                        if (FrameTime - _activeTouches[i].LastSeenTime > 0.1f)
                        {
                            root.SendMessage(UIMessage.TouchEnd, new TouchEventArgs(_activeTouches[i].Id, _activeTouches[i].Position));

                            _activeTouches.RemoveAt(i);
                        }
                    }

                    lastUpdateTime = FrameTime;

                    Display.Clear(0xFFFFFFFF);

                    root.Update(DeltaTime);
                    root.Draw();

                    if (ShowDebug)
                    {
                        // show debug info every couple of seconds
                        if (timer.read_ms() - lastDebugTime > 2.0f)
                        {
                            // string.format broken?
                            //infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}",
                            //    Display.Fps,
                            //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory,
                            //    Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory);

                            infoString = "FPS: " + Display.Fps.ToString() + " MEMAVAIL: " + Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory.ToString();

                            lastDebugTime = timer.read();
                        }

                        //Display.DrawString(infoString, 0, 0);
                    }

                    // show the back buffer
                    Display.Flip();
                }
            }
        }
开发者ID:roceh,项目名称:stm32f7disco_llilum_lcdtest,代码行数:99,代码来源:Application.cs

示例5: Canvas

        /// <summary>
        /// Initialise the class
        /// </summary>
        public Canvas()
        {
            _buffers = new UInt32[] { FrameBufferBase, FrameBufferBase + (ScreenWidth * ScreenHeight * 4) };

            _activeBuffer = 0;
            _backBuffer = 1;

            DisplayInterop.LCD_Init((UInt32*)_buffers[_activeBuffer], (UInt32*)_buffers[_backBuffer]);

            // initial clip
            _screenClip = new Rect(0, 0, ScreenWidth, ScreenHeight);
            _clip = _screenClip;

            _timer = new Timer();
            _timer.start();
        }
开发者ID:roceh,项目名称:stm32f7disco_llilum_lcdtest,代码行数:19,代码来源:Canvas.cs

示例6: Start

 // Use this for initialization
 void Start()
 {
     time = new Timer(60.0F, Inactive);
     time.start();
     checkChallengeCompleted();
 }
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:7,代码来源:MainController.cs


注:本文中的Timer.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。