public TextureFill()
        {
            
            var _xor6 = BuildXorTexture(6);
            _xor6.SamplerState = SamplerState.LinearWrap;
            _brush1 = new TextureBrush(_xor6);
            _brush2 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateTranslation(-50f / _xor6.XNATexture.Width, -175f / _xor6.XNATexture.Height, 0)
            };
            _brush3 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateScale(.25f, .5f, 1f)
            };
            _brush4 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateRotationZ((float)Math.PI / 4)
            };
            _brush5 = new TextureBrush(_xor6, .5f);

            _brush6 = new TextureBrush(_xor6)
            {
                Color = Microsoft.Xna.Framework.Color.Purple
            };

            var pattern = new CCTexture2D("images/pattern1");

            var state = new SamplerState();
            state.AddressU = TextureAddressMode.Mirror;
            state.AddressV = TextureAddressMode.Wrap;
            pattern.SamplerState = state;

            mirrorBrush = new TextureBrush(pattern)
            {
                Color = Microsoft.Xna.Framework.Color.White
            };

            var pattern2 = new CCTexture2D("images/pattern2");
            pattern2.SamplerState = SamplerState.LinearWrap;
            repeatBrush = new TextureBrush(pattern2);


        }
示例#2
0
        public override void Setup (GraphicsDevice device)
        {
            _xor6 = BuildXorTexture(device, 6);

            _brush1 = new TextureBrush(_xor6);
            _brush2 = new TextureBrush(_xor6) {
                Transform = Matrix.CreateTranslation(-50f / _xor6.Width, -175f / _xor6.Height, 0)
            };
            _brush3 = new TextureBrush(_xor6) {
                Transform = Matrix.CreateScale(.25f, .5f, 1f)
            };
            _brush4 = new TextureBrush(_xor6) {
                Transform = Matrix.CreateRotationZ((float)Math.PI / 4)
            };
            _brush5 = new TextureBrush(_xor6, .5f);
            _brush6 = new TextureBrush(_xor6) {
                Color = Color.Purple
            };
        }
示例#3
0
        private void ResetObjectPreview()
        {
            if (_objectBrush != null) {
                _objectBrush.Dispose();
                _objectBrush = null;
            }

            LoadObjectPreview(_sourceFile);

            if (ValidateSourceFile() != null)
                ClearObjectPreiew();
        }
示例#4
0
        private void DrawObjectAction(DrawBatch drawBatch)
        {
            if (_sourceImage == null)
                return;

            drawBatch.GraphicsDevice.ScissorRectangle = Xna.Rectangle.Empty;

            if (_objectBrush == null)
                _objectBrush = new TextureBrush(_sourceImage.CreateTexture(_drawControl.GraphicsDevice)) { OwnsTexture = true };
            if (_maskPen == null)
                _maskPen = new Pen(new CheckerBrush(_drawControl.GraphicsDevice, Xna.Color.Black, Xna.Color.White, 4, .75f), true);

            int originX = (_drawControl.Width - _sourceImage.Width) / 2;
            int originY = (_drawControl.Height - _sourceImage.Height) / 2;

            _objectBrush.Transform = Xna.Matrix.CreateTranslation(-(float)originX / _sourceImage.Width, -(float)originY / _sourceImage.Height, 0);

            drawBatch.Begin();

            drawBatch.FillRectangle(_objectBrush, new Xna.Rectangle(originX, originY, _sourceImage.Width, _sourceImage.Height));
            drawBatch.DrawRectangle(_maskPen, new Microsoft.Xna.Framework.Rectangle(
                originX - 1 + (_maskLeft ?? 0) + (_originX ?? 0),
                originY - 1 + (_maskTop ?? 0) + (_originY ?? 0),
                1 + (_maskRight - _maskLeft) ?? 0,
                1 + (_maskBottom - _maskTop) ?? 0));

            drawBatch.FillCircle(Brush.White, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 4, 12);
            drawBatch.FillCircle(Brush.Black, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 3, 12);

            drawBatch.End();
        }
示例#5
0
        protected override void OnClosed(EventArgs e)
        {
            if (_objectBrush != null) {
                _objectBrush.Dispose();
                _objectBrush = null;
            }

            if (_maskPen != null) {
                _maskPen.Brush.Dispose();
                _maskPen.Dispose();
                _maskPen = null;
            }

            _drawControl.Dispose();

            base.OnClosed(e);
        }
示例#6
0
        private void ResetObjectPreview()
        {
            if (!_validateController.ValidateForm())
                ClearObjectPreiew();

            if (_objectBrush != null) {
                _objectBrush.Dispose();
                _objectBrush = null;
            }

            if (_sourceFileValid)
                LoadObjectPreview(_sourceFile);
        }