Ejemplo n.º 1
0
        public Mat3DView()
        {
            Host = new Window() { Background = new LinearGradientBrush(Color.FromRgb(30,30,60),Color.FromRgb(10,10,10),90) };
            ViewArea = new Border();
            Host.WindowStyle = WindowStyle.None;
            Host.WindowState = WindowState.Maximized;
            Host.Content = ViewArea;
            Host.SizeChanged += Host_SizeChanged;
            Host.Closing += Host_Closing;

            Host.Show();

            CreateDeviceAndSwapChain(out _GraphicsDevice, out _SwapChain);

            InitRenderTarget();
            InitDepthStencil();
            GraphicsDevice.ImmediateContext.OutputMerger.SetTargets(DepthStencil, RenderTarget);

            AnimationClock = new MatTimer(1000.0 / 60.0);
            AnimationClock.MatTickEvent += Clock_MatTickEvent;
            AnimationClock.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the TimerCallback method for the checkTimer, used to remove
        /// remove expired items from the cache.
        /// </summary>
        /// <param name="info">unused</param>
        private void CheckExpirations(
            object info)
        {
            #if (CACHE_TRACE)
            MatTimer	timer = new MatTimer();
            timer.Start();
            LogManager.GetCurrentClassLogger().Debug(
            debugMessage => debugMessage(string.Format("CheckExpirations start: count = {0}.", hash.Count));
            #endif
            //  get the current time
            DateTime now = DateTime.Now;
            //  get an array of the keys in the hash to loop thru
            string[] keys = new string[this.hash.Count];
            this.hash.Keys.CopyTo(keys, 0);

            //  loop thru the hash checking the expiration times of each item
            //  and removing any that have expired
            for (int k = 0; k < keys.Length; k++) {
                try {
                    if (((CacheItem)this.hash[keys[k]]).ExpiresAt <= now) {
            #if (CACHE_TRACE)

            LogManager.GetCurrentClassLogger().Debug(
            debugMessage => debugMessage("Item Removed: {0} : {1}", keys[k], ((CacheItem)hash[keys[k]]).Object.ToString()));
            #endif
                        this.Remove(keys[k]);
                    }
                } catch (Exception e) {
                    LogManager.GetCurrentClassLogger().Error(
                        errorMessage => errorMessage(string.Format("Cache.CheckExpirations: k = {0}, Length = {1}, key = {2}",
                                                                   k,
                                                                   keys.Length,
                                                                   keys[k]),
                                                     e));
                }
            }
            #if (CACHE_TRACE)
            timer.Stop();
            LogManager.GetCurrentClassLogger().Debug(
            debugMessage => debugMessage("CheckExpirations done: count = {0}.  Execute time: {1}", hash.Count, timer.Time));
            #endif
        }