示例#1
0
        private void bufferedPanel1_Paint(object sender, PaintEventArgs e)
        {
            _state.ScrollOffsetX = -(bufferedPanel1.AutoScrollPosition.X / _state.ScaleFactor) * _state.ScaleFactor;
            _state.ScrollOffsetY = -(bufferedPanel1.AutoScrollPosition.Y / _state.ScaleFactor) * _state.ScaleFactor;

            int scaleFactor = _state.ScaleFactor;

            if ((_room.Resolution == RoomResolution.LowRes) &&
                (Factory.AGSEditor.CurrentGame.IsHighResolution))
            {
                // low-res room in high-res game, scale up since object
                // co-ordinates will be high-res
                scaleFactor *= 2;
            }

            int backgroundNumber = cmbBackgrounds.SelectedIndex;

            if (backgroundNumber < _room.BackgroundCount)
            {
                e.Graphics.SetClip(new Rectangle(0, 0, _room.Width * _state.ScaleFactor, _room.Height * _state.ScaleFactor));
                IntPtr hdc = e.Graphics.GetHdc();
                Factory.NativeProxy.CreateBuffer(bufferedPanel1.ClientSize.Width, bufferedPanel1.ClientSize.Height);
                // Adjust co-ordinates using original scale factor so that it lines
                // up with objects, etc
                int drawOffsX = -(_state.ScrollOffsetX / _state.ScaleFactor) * _state.ScaleFactor;
                int drawOffsY = -(_state.ScrollOffsetY / _state.ScaleFactor) * _state.ScaleFactor;
                lock (_room)
                {
                    Factory.NativeProxy.DrawRoomBackground(hdc, _room, drawOffsX, drawOffsY, backgroundNumber, scaleFactor, _filter.MaskToDraw, _filter.SelectedArea, sldTransparency.Value);
                }
                _filter.PaintToHDC(hdc, _state);
                Factory.NativeProxy.RenderBufferToHDC(hdc);
                e.Graphics.ReleaseHdc(hdc);
                _filter.Paint(e.Graphics, _state);
            }
        }