示例#1
0
        private void bufferedPanel1_Paint(object sender, PaintEventArgs e)
        {
            _state.UpdateScroll(bufferedPanel1.AutoScrollPosition);

            int scaleFactor = 1;

            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, _state.RoomSizeToWindow(_room.Width), _state.RoomSizeToWindow(_room.Height)));
                IntPtr hdc = e.Graphics.GetHdc();
                Factory.NativeProxy.CreateBuffer(bufferedPanel1.ClientSize.Width + SystemInformation.VerticalScrollBarWidth,
                                                 bufferedPanel1.ClientSize.Height + SystemInformation.HorizontalScrollBarHeight);
                // Adjust co-ordinates using original scale factor so that it lines
                // up with objects, etc
                int drawOffsX = _state.RoomXToWindow(0);
                int drawOffsY = _state.RoomYToWindow(0);
                IRoomEditorFilter maskFilter = GetCurrentMaskFilter();
                lock (_room)
                {
                    Factory.NativeProxy.DrawRoomBackground(hdc, _room, drawOffsX, drawOffsY, backgroundNumber, _state.Scale * scaleFactor,
                                                           maskFilter == null ? RoomAreaMaskType.None : maskFilter.MaskToDraw,
                                                           (maskFilter == null || !maskFilter.Enabled) ? 0 : maskFilter.SelectedArea, sldTransparency.Value);
                }
                foreach (IRoomEditorFilter layer in _layers)
                {
                    if (!IsVisible(layer))
                    {
                        continue;
                    }
                    layer.PaintToHDC(hdc, _state);
                }
                Factory.NativeProxy.RenderBufferToHDC(hdc);
                e.Graphics.ReleaseHdc(hdc);
                foreach (IRoomEditorFilter layer in _layers)
                {
                    if (!IsVisible(layer))
                    {
                        continue;
                    }
                    layer.Paint(e.Graphics, _state);
                }
            }
            base.OnPaint(e);
        }
示例#2
0
        private void bufferedPanel1_Paint(object sender, PaintEventArgs e)
        {
            _state.UpdateScroll(bufferedPanel1.AutoScrollPosition);

            int scaleFactor = 1;

            int backgroundNumber = cmbBackgrounds.SelectedIndex;

            if (backgroundNumber < _room.BackgroundCount)
            {
                int bufWidth  = _state.RoomSizeToWindow(_room.Width);
                int bufHeight = _state.RoomSizeToWindow(_room.Height);
                e.Graphics.SetClip(new Rectangle(0, 0, bufWidth, bufHeight));
                IntPtr hdc = e.Graphics.GetHdc();
                Factory.NativeProxy.CreateBuffer(bufWidth, bufHeight);
                // Adjust co-ordinates using original scale factor so that it lines
                // up with objects, etc
                int drawOffsX = _state.RoomXToWindow(0);
                int drawOffsY = _state.RoomYToWindow(0);
                IRoomEditorFilter maskFilter = GetCurrentMaskFilter();
                lock (_room)
                {
                    Factory.NativeProxy.DrawRoomBackground(hdc, _room, drawOffsX, drawOffsY, backgroundNumber, _state.Scale * scaleFactor,
                                                           maskFilter == null ? RoomAreaMaskType.None : maskFilter.MaskToDraw,
                                                           maskFilter == null ? 0 : maskFilter.SelectedArea, sldTransparency.Value);
                }
                foreach (IRoomEditorFilter layer in _layers)
                {
                    if (!IsVisible(layer))
                    {
                        continue;
                    }
                    layer.PaintToHDC(hdc, _state);
                }
                Factory.NativeProxy.RenderBufferToHDC(hdc);
                e.Graphics.ReleaseHdc(hdc);
                foreach (IRoomEditorFilter layer in _layers)
                {
                    if (!IsVisible(layer))
                    {
                        continue;
                    }
                    layer.Paint(e.Graphics, _state);
                }
            }
            base.OnPaint(e);
        }