Exemple #1
0
        /// <summary>
        /// Function to clear the timing data and reset any timers.
        /// </summary>
        /// <remarks>You do not need to call this method unless you've got your own mechanism for handling an idle time loop.
        /// <para>Values set by the user (e.g. <see cref="P:GorgonLibrary.Diagnostics.GorgonTiming.UseHighResolutionTimer">UseHighResolutionTimer</see>, <see cref="P:GorgonLibrary.Diagnostics.GorgonTiming.AverageFPS">MaxAverageCount</see>, etc...) will not be reset.
        /// The exception to this is if a high resolution timer is required but is not supported by the hardware.</para>
        /// </remarks>
        public static void Reset()
        {
            if ((_timer == null) || (UseHighResolutionTimer != _timer.IsHighResolution))
            {
                _timer = new GorgonTimer(UseHighResolutionTimer);
            }

            _useHighResTimer   = _timer.IsHighResolution;
            HighestFPS         = float.MinValue;
            LowestFPS          = float.MaxValue;
            AverageFPS         = 0.0f;
            HighestDelta       = float.MinValue;
            LowestDelta        = float.MaxValue;
            AverageScaledDelta = 0.0f;
            AverageDelta       = 0.0f;
            Delta                    = 0.0f;
            ScaledDelta              = 0.0f;
            FPS                      = 0.0f;
            FrameCount               = 0;
            _averageCounter          = 0;
            _frameCounter            = 0;
            _lastTime                = 0.0;
            _lastTimerValue          = 0.0;
            _averageFPSTotal         = 0.0f;
            _averageScaledDeltaTotal = 0.0f;
            _timer.Reset();
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RawPointingDevice"/> class.
 /// </summary>
 /// <param name="owner">The control that owns this device.</param>
 /// <param name="deviceName">Device name.</param>
 /// <param name="handle">The handle to the device.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when the owner parameter is NULL (or Nothing in VB.NET).</exception>
 internal RawPointingDevice(GorgonRawInputFactory owner, string deviceName, IntPtr handle)
     : base(owner, deviceName)
 {
     Gorgon.Log.Print("Raw input pointing device interface created for handle 0x{0}.", LoggingLevel.Verbose, handle.FormatHex());
     _deviceHandle  = handle;
     _doubleClicker = new GorgonTimer();
     _doubleClicker.Reset();
     _messageFilter = owner.MessageFilter;
 }
Exemple #3
0
        /// <summary>
        /// Function to begin a double click.
        /// </summary>
        /// <param name="button">Button used for double click.</param>
        private void BeginDoubleClick(PointingDeviceButtons button)
        {
            if (_clickCount >= 1)
            {
                return;
            }

            _doubleClickPosition = Position;
            _doubleClickButton   = button;
            _doubleClicker.Reset();
        }
Exemple #4
0
        /// <summary>
        /// Function to begin the execution of the application context.
        /// </summary>
        public void RunMe()
        {
            string annoyUser = "******";
            int    counter   = 0;

            try
            {
                _timer.Reset();
                _splashScreen.Show();
                _splashScreen.UpdateText("This is the splash screen.");

                // Fade in the splash screen about 10% every 7 milliseconds.
                while (_splashScreen.Opacity < 1)
                {
                    if (!(_timer.Milliseconds > 7))
                    {
                        continue;
                    }

                    _timer.Reset();
                    _splashScreen.Opacity += 0.01;
                }

                // Annoy the user.  They're asking for it.
                while (counter < 5)
                {
                    while (_timer.Seconds > 1)
                    {
                        if (annoyUser.Length < 50)
                        {
                            annoyUser += ".";
                        }
                        else
                        {
                            annoyUser = "******";
                        }

                        _splashScreen.UpdateText(annoyUser);
                        _timer.Reset();
                        counter++;
                    }
                }

                // Fade it out.
                while (_splashScreen.Opacity > 0.02)
                {
                    if (!(_timer.Milliseconds > 5))
                    {
                        continue;
                    }

                    _timer.Reset();
                    _splashScreen.Opacity -= 0.01;
                }

                // Resize the main form to 640 x 480.
                MainForm.KeyDown   += MainForm_KeyDown;
                MainForm.ClientSize = new Size(640, 480);
                MainForm.Show();
            }
            catch (Exception ex)
            {
                // If we get an error, then leave the application.
                GorgonDialogs.ErrorBox(MainForm, ex);

                if (MainForm != null)
                {
                    MainForm.Dispose();
                }
                MainForm = null;
            }
            finally
            {
                // We don't need this any more.
                if (_splashScreen != null)
                {
                    _splashScreen.Dispose();
                }
                _splashScreen = null;
            }
        }