예제 #1
0
        static Engine()
        {
            Configuration = EngineConfiguration.Open();
            MediaFile.MCIErrorsThrowExceptions = Configuration.Settings.MCIErrorsThrowExceptions;
            _startTick           = HighResTimer.GetCurrentTickCount();
            _lastCPSSamplingTick = _startTick;
            Keyboard.DefaultTicksBetweenKeyEvents = (long)(Configuration.Settings.TimeBetweenKeyboardEvents * (double)HighResTimer.TicksPerSecond);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            // deserialize all EngineState files listed in configuration
            if (Configuration.StateFiles != null && Configuration.StateFiles.LoadAtStartup == true)
            {
                foreach (var stateFile in Configuration.StateFiles)
                {
                    if (stateFile.LoadAtStartup == true)
                    {
                        LoadEngineStateFile(stateFile.Path, stateFile.IsBinary);
                    }
                }
            }

            VisibleSurfaces.ForcedRefreshRate = Configuration.Settings.VisibleSurfaceRefreshTimer;
            Application.Idle += Application_Idle;
        }
예제 #2
0
        internal static ResizedFrame GetResizedFrame(Frame frame, Size renderSize)
        {
            var          settings = EngineConfiguration.Open().Settings;
            ResizedFrame resizedFrame;

            if (ResizedFrameCache.TryGetValue(GetId(frame, renderSize), out resizedFrame) == false)
            {
                resizedFrame = new ResizedFrame(frame, renderSize);

                // check cache limit; if over, trim cache
                while (ResizedFrameCache.Count > settings.ResizedFrameCacheLimit)
                {
                    var oldestInCache   = ResizedFrameCache.OrderBy(kvp => kvp.Value.CreationTick).First();
                    var oldResizedFrame = oldestInCache.Value;
                    ResizedFrameCache.Remove(oldestInCache.Key);
                    oldResizedFrame.Dispose();
                }
            }

            return(resizedFrame);
        }