示例#1
0
        public static void RefreshDesktopSize()
        {
            var height = 0;
            var width  = 0;

            foreach (var screen in Screen.AllScreens)
            {
                var w = screen.Bounds.X + screen.Bounds.Width;
                var h = screen.Bounds.Y + screen.Bounds.Height;

                if (height < h)
                {
                    height = h;
                }

                if (width < w)
                {
                    width = w;
                }
            }

            DesktopRectangle = new Rectangle(0, 0, width, height);

            if (_fullWidthFrame != null)
            {
                _fullWidthFrame.Destroy();
            }
            else
            {
                _fullWidthFrame = new ReusableFrame(new Bitmap(width, height));
            }
        }
示例#2
0
        public IBitmapFrame Get()
        {
            lock (_pool)
            {
                DestroyFreeFrames();

                if (_pool.Count > 0)
                {
                    return(_pool.Dequeue());
                }

                var frame = new ReusableFrame(new Bitmap(Width, Height));

                frame.Released += () =>
                {
                    lock (_pool)
                    {
                        _pool.Enqueue(frame);

                        DestroyFreeFrames();
                    }
                };

                _frames.Add(frame);

                Console.WriteLine($"New Frame Allocated: {_frames.Count - 1}");

                return(frame);
            }
        }
示例#3
0
        public static void RefreshDesktopSize()
        {
            if (_fullWidthFrame != null)
            {
                _fullWidthFrame.Destroy();
            }
            else
            {
                var rect = DesktopRectangle;

                _fullWidthFrame = new ReusableFrame(new Bitmap(rect.Width, rect.Height));
            }
        }
示例#4
0
        public IBitmapFrame Get()
        {
            lock (_pool)
            {
                if (_pool.Count > 0)
                {
                    return(_pool.Dequeue());
                }

                var frame = new ReusableFrame(new Bitmap(Width, Height));

                frame.Released += () =>
                {
                    lock (_pool)
                    {
                        _pool.Enqueue(frame);
                    }
                };

                _frames.Add(frame);

                return(frame);
            }
        }