Exemplo n.º 1
0
        public void Draw(DrawState state)
        {
            state.PushWorldTranslateMultiply(ref this.position);

            if (geometry.CullTest(state))
            {
                //draw the geometry
                shader.Bind(state);
                geometry.Draw(state);

                //now, if set, draw the wireframe too
                if (wireframeShader != null)
                {
                    wireframeShader.Bind(state);

                    //show the wireframe, disabling depth testing
                    state.PushRenderState();
                    state.RenderState.DepthColourCull.DepthTestEnabled = false;
                    //also set additive blending
                    state.RenderState.AlphaBlend = AlphaBlendState.Additive;
                    //set wireframe
                    state.RenderState.DepthColourCull.FillMode = FillMode.WireFrame;

                    //draw
                    geometry.Draw(state);

                    state.PopRenderState();
                }
            }

            state.PopWorldMatrix();
        }
Exemplo n.º 2
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (Form.MouseButtons == MouseButtons.Left)
            {
                if (figure == null)
                {
                    //Создание фигуры
                    Type type = GetFigure(Figures.SelectedIndex);
                    figure = Activator.CreateInstance(type) as IDraw;

                    //Инициализация значений
                    Point point = new Point();
                    point.X = Form1.MousePosition.X - pictureBox1.Location.X - 1;
                    point.Y = Form1.MousePosition.Y - pictureBox1.Location.Y - 22;
                    figure.Initialization(point, GetThickness(comboBox2.SelectedIndex), GetColor(comboBox3.SelectedIndex), GetColor(comboBox4.SelectedIndex));
                }
                else
                {
                    //Обновление
                    FieldRefresh();

                    //Отрисовка
                    Point point = new Point();
                    point.X = Form1.MousePosition.X - pictureBox1.Location.X - 1;
                    point.Y = Form1.MousePosition.Y - pictureBox1.Location.Y - 22;
                    if (figure.IsSimpleFigure())
                    {
                        figure.SetPoint(point);
                    }
                    else
                    {
                        figure.AddPoint(point);
                    }
                    figure.Draw(Graph);
                    pictureBox1.Refresh();
                }
            }
            else if (Form.MouseButtons == MouseButtons.Right)
            {
                if (figure != null)
                {
                    if (!figure.IsSimpleFigure())
                    {
                        //Сохранение фигуры
                        if ((figure.GetWidth() > 0) && (figure.GetHeight() > 0))
                        {
                            figure.Save();
                            AddFigure();
                        }
                        figure = null;

                        //Обновление
                        FieldRefresh();
                        pictureBox1.Refresh();
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void Canvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (a != null)
     {
         a.Draw(e);
     }
 }
Exemplo n.º 4
0
        public static int Main(string[] args)
        {
            SuperImage si = new SuperImage();

            // Get IDraw.
            IDraw itfDraw = (IDraw)si;

            itfDraw.Draw();

            // Now get IDraw3.
            if (itfDraw is IDraw3)
            {
                IDraw3 itfDraw3 = (IDraw3)itfDraw;
                itfDraw3.DrawToMetaFile();
                itfDraw3.DrawToPrinter();
            }

            JBCar j = new JBCar();

            if (j is IJamesBondCar)
            {
                ((IJamesBondCar)j).Drive();
                ((IJamesBondCar)j).TurboBoost();
                ((IJamesBondCar)j).Dive();
            }

            return(0);
        }
Exemplo n.º 5
0
        public void Draw(DrawState state)
        {
            SetupShadowShader(state);

            //set render mode to shadow map
            state.PushDrawFlag(new ModelInstance.ShaderProviderFlag(this.shaderProvider));
            state.PushDrawFlag(TutorialRenderMode.DrawShadow);

            //Push the shadow map camera as a post-culler.
            //This way, anything not within the frustum of the shadow map
            //camera will not be drawn with the shadow shader
            state.PushPostCuller(this.shadowMapTarget.Camera);

            //set an additive blending mode
            state.PushRenderState();
            state.RenderState.AlphaBlend = AlphaBlendState.Additive;
            state.RenderState.DepthColourCull.DepthWriteEnabled = false;

            //draw the shadowed scene
            scene.Draw(state);

            state.PopRenderState();
            state.PopPostCuller();

            state.PopDrawFlag <TutorialRenderMode>();
            state.PopDrawFlag <ModelInstance.ShaderProviderFlag>();
        }
Exemplo n.º 6
0
        public void Draw(DrawState state)
        {
            //bind the background filling shader
            state.GetShader <Shaders.BackgroundFill>().Bind(state);

            geometry.Draw(state);
        }
Exemplo n.º 7
0
        // método chamado toda vez que o painel é pintado
        private void OnCanvasPaint(object sender, PaintEventArgs e)
        {
            foreach (var draw in _drawList)
            {
                draw.Draw(e.Graphics);
            }

            // ?. é acesso condicional, ele vai chamar Draw se _currObject não for nulo
            _currObject?.Draw(e.Graphics);
        }
Exemplo n.º 8
0
        private void DrawSphere(DrawState state)
        {
            //draw the geometry with a solid colour shader
            if (geometry.CullTest(state))
            {
                Xen.Ex.Shaders.FillSolidColour shader = state.GetShader <Xen.Ex.Shaders.FillSolidColour>();

                shader.FillColour = lightColour.ToVector4();
                shader.Bind(state);

                geometry.Draw(state);
            }
        }
Exemplo n.º 9
0
        private void drawingCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var mouseLocation = e.GetPosition(drawingCanvas);
            var myCircle      = new Circle(100);

            IDraw drawCircle = myCircle;

            drawCircle.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
            drawCircle.Draw(drawingCanvas);

            IColor colorCircle = myCircle;

            colorCircle.SetColor(Colors.HotPink);
        }
Exemplo n.º 10
0
        public void Draw(DrawState state)
        {
            //set the draw flags up, which will control rendering
            //this will make the models render depth
            state.PushDrawFlag(new ModelInstance.ShaderProviderFlag(this.shaderProvider));
            state.PushDrawFlag(TutorialRenderMode.DepthOutput);

            //draw the scene
            scene.Draw(state);

            //reset the flags
            state.PopDrawFlag <ModelInstance.ShaderProviderFlag>();
            state.PopDrawFlag <TutorialRenderMode>();
        }
Exemplo n.º 11
0
        public T Draw()
        {
            int count = _list.Count();
            var idx   = _draw.Draw(count);

            if (idx >= 0 && idx < count)
            {
                return(_list.ElementAt(idx));
            }
            else
            {
                throw new IndexOutOfRangeException();
            }
        }
Exemplo n.º 12
0
        private void drawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var mouseLocation = e.GetPosition(drawingCanvas);
            var mySquare      = new Square(100);

            IDraw drawSquare = mySquare;

            drawSquare.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
            drawSquare.Draw(drawingCanvas);

            IColor colorSquare = mySquare;

            colorSquare.SetColor(Colors.BlueViolet);
        }
Exemplo n.º 13
0
        protected override void DrawContent(Graphics graphics)
        {
            IDraw draw = null;
            int   x = this.Rectangle.X;
            int   y = this.Rectangle.Y;
            bool  newPage = true;
            int   tmpx = 0, tmpy = 0;

            while (this.CurrentRowIndex < this.list.Count)
            {
                if (this.header != null && newPage)
                {
                    //只画一次或者每次都要画
                    if (this.CurrentRowIndex == 0 || this.everyPageHeader)
                    {
                        newPage          = false;
                        tmpx             = header.Rectangle.X;
                        tmpy             = header.Rectangle.Y;
                        header.Rectangle = new System.Drawing.Rectangle(x + header.Rectangle.X, y + header.Rectangle.Y, header.Rectangle.Width, header.Rectangle.Height);
                        header.Draw(graphics);
                        header.Rectangle = new Rectangle(tmpx, tmpy, header.Rectangle.Width, header.Rectangle.Height);
                        y += header.Rectangle.Y + header.Rectangle.Height;
                        continue;
                    }
                }

                draw = this.list[CurrentRowIndex];
                tmpx = draw.Rectangle.X;
                tmpy = draw.Rectangle.Y;
                //算出行的y距离
                y = y + tmpy;

                //判断再画一行是否超出页的可绘制位置的高度
                if (draw.Rectangle.Height + y > this.Rectangle.Height + this.Rectangle.Y)
                {
                    if (this.everyPageHeader)
                    {
                        newPage = true;
                    }
                    break;
                }
                draw.Rectangle = new System.Drawing.Rectangle(x + tmpx, y, draw.Rectangle.Width, draw.Rectangle.Height);
                draw.Draw(graphics);
                draw.Rectangle = new System.Drawing.Rectangle(tmpx, tmpy, draw.Rectangle.Width, draw.Rectangle.Height);
                y += draw.Rectangle.Height;
                CurrentRowIndex++;
            }
        }
Exemplo n.º 14
0
 private void drawingCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     Point mouseLocation = e.GetPosition(this.drawingCanvas);
     Circle myCircle = new Circle(100);
     if (myCircle is IDraw)
     {
         IDraw drawCircle = myCircle;
         drawCircle.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
         drawCircle.Draw(drawingCanvas);
     }
     if (myCircle is IColor)
     {
         IColor colorSquare = myCircle;
         colorSquare.SetColor(Colors.HotPink);
     }
 }
Exemplo n.º 15
0
 private void drawingCanvas_Tapped(object sender, TappedRoutedEventArgs e)
 {
     Point mouseLocation = e.GetPosition(this.drawingCanvas);
     Square mySquare = new Square(100);
     if (mySquare is IDraw)
     {
         IDraw drawSquare = mySquare;
         drawSquare.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
         drawSquare.Draw(drawingCanvas);
     }
     if (mySquare is IColor)
     {
         IColor colorSquare = mySquare;
         colorSquare.SetColor(Colors.BlueViolet);
     }
 }
Exemplo n.º 16
0
        private void drawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point  mouseLocation = e.GetPosition(this.drawingCanvas);
            Square mySquare      = new Square(100);

            if (mySquare is IDraw)
            {
                IDraw drawSquare = mySquare;
                drawSquare.setLocation((int)mouseLocation.X, (int)mouseLocation.Y);
                drawSquare.Draw(drawingCanvas);
            }
            if (mySquare is IColor)
            {
                IColor colorSquare = mySquare;
                colorSquare.setColor(Colors.Cyan);
            }
        }
Exemplo n.º 17
0
        private void drawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point  mouselocation = e.GetPosition(this.drawingCanvas);
            Square square        = new Square(100);

            if (square is IDraw)
            {
                IDraw drawinginterface = square;
                drawinginterface.setLocation((int)mouselocation.X, (int)mouselocation.Y);
                drawinginterface.Draw(drawingCanvas);
            }
            if (square is IColor)
            {
                IColor col = square;
                col.changeColor(Colors.DarkBlue);
            }
        }
Exemplo n.º 18
0
        private void drawingCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point  mouseLocation = e.GetPosition(this.drawingCanvas);
            Circle myCircle      = new Circle(50);

            if (myCircle is IDraw)
            {
                IDraw drawCircle = myCircle;
                drawCircle.setLocation((int)mouseLocation.X, (int)mouseLocation.Y);
                drawCircle.Draw(drawingCanvas);
            }
            if (myCircle is IColor)
            {
                IColor colorCircle = myCircle;
                colorCircle.setColor(Colors.HotPink);
            }
        }
Exemplo n.º 19
0
        public void Draw(DrawState state)
        {
            //generate the rotation matrix for the object.
            Matrix basis = new Matrix(1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1);             //xna_dude model is on his side

            state.PushWorldMatrixMultiply(ref basis);

            Matrix.CreateRotationZ(RotationAngle, out basis);             // generate the rotation.
            state.PushWorldMatrixMultiply(ref basis);

            if (item.CullTest(state))
            {
                item.Draw(state);
            }

            state.PopWorldMatrix();
            state.PopWorldMatrix();
        }
Exemplo n.º 20
0
        private void drawingCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point    mouselocation = e.GetPosition(this.drawingCanvas);
            MyCircle circle        = new MyCircle(120);

            if (circle is IDraw)

            {
                IDraw drawinginterface = circle;
                drawinginterface.setLocation((int)mouselocation.X, (int)mouselocation.Y);
                drawinginterface.Draw(drawingCanvas);
            }

            if (circle is IColor)
            {
                IColor col = circle;
                col.changeColor(Colors.HotPink);
            }
        }
Exemplo n.º 21
0
        private void drawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point  mouseLocation = e.GetPosition(this.drawingCanvas);
            Square mySquare      = new Square(100);

            if (mySquare is IDraw)
            {
                IDraw drawSquare = mySquare;
                drawSquare.X = (int)mouseLocation.X;
                drawSquare.Y = (int)mouseLocation.Y;
                drawSquare.Draw(drawingCanvas);
            }

            if (mySquare is IColor)
            {
                IColor colorSquare = mySquare;
                colorSquare.color = Colors.BlueViolet;
            }
        }
Exemplo n.º 22
0
        private void drawingCanvas_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Point  mouseLocation = e.GetPosition(this.drawingCanvas);
            Square mySquare      = new Square(100);

            if (mySquare is IDraw)
            {
                IDraw drawSquare = mySquare;
                // drawSquare.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
                drawSquare.X = (int)mouseLocation.X;
                drawSquare.Y = (int)mouseLocation.Y;
                drawSquare.Draw(drawingCanvas);
            }

            if (mySquare is IColor)
            {
                IColor colorSquare = mySquare;
                colorSquare.Color = Colors.DarkOliveGreen;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 根据子对象进行绘画
        /// </summary>
        protected override void DrawContent(Graphics graphics)
        {
            IDraw draw = null;
            int   x    = this.Rectangle.X;
            int   y    = this.Rectangle.Y;
            int   tmpx = 0;
            int   tmpy = 0;

            for (int i = 0; i < this.list.Count; i++)
            {
                draw = this.list[i];
                //复位表格的相对位置,以便在所有页面都要绘画对象不会变化
                tmpx           = draw.Rectangle.X;
                tmpy           = draw.Rectangle.Y;
                draw.Rectangle = new System.Drawing.Rectangle(x + tmpx, y + tmpy, draw.Rectangle.Width, draw.Rectangle.Height);
                draw.Draw(graphics);
                draw.Rectangle = new Rectangle(tmpx, tmpy, draw.Rectangle.Width, draw.Rectangle.Height);
                //x = x + draw.Rectangle.Width;
            }
        }
Exemplo n.º 24
0
        private void drawingCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            Point  mouseLocation = e.GetPosition(this.drawingCanvas);
            Circle myCircle      = new Circle(100);

            if (myCircle is IDraw)
            {
                IDraw drawCircle = myCircle;
                //drawCircle.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);'
                drawCircle.X = (int)mouseLocation.X;
                drawCircle.Y = (int)mouseLocation.Y;
                drawCircle.Draw(drawingCanvas);
            }

            if (myCircle is IColor)
            {
                IColor colorCircle = myCircle;
                colorCircle.Color = Colors.Firebrick;
            }
        }
Exemplo n.º 25
0
            //draw without culling
            public void Draw(DrawState state, IDraw[] children, BinaryNode[] nodes, bool treeIsOptimized)
            {
                if (left == 0)
                {
                    uint child = firstChild;
                    child <<= ChildCountShift;

                    for (ushort i = 0; i < childCount; i++)
                    {
                        children[child++].Draw(state);
                    }
                }
                else
                {
                    if (treeIsOptimized)
                    {
                        uint firstChild = this.firstChild;
                        firstChild <<= ChildCountShift;
                        uint lastChild = this.childCount;
                        lastChild <<= ChildCountShift;                         // actually lastChild + 1

                        for (uint i = firstChild; i < lastChild; i++)
                        {
                            IDraw item = children[i];
                            if (item != null)
                            {
                                item.Draw(state);
                            }
                        }
                    }
                    else
                    {
                        nodes[left].Draw(state, children, nodes, treeIsOptimized);
                        nodes[right].Draw(state, children, nodes, treeIsOptimized);
                    }
                }
            }
Exemplo n.º 26
0
        public virtual void Run(string[] args)
        {
            _args = (string[])args.Clone();
            try
            {
                if (Validator.IsValid(_args, out int height, out int width))
                {
                    _board = new ChessBoard(height, width);

                    _userInterface = new ConsoleUI();
                    _userInterface.Draw(_board);
                }
            }
            catch (ArgumentException ex)
            {
                _view.ShowErrorMessage(ex.Message);
                Run();
            }
            catch (Exception ex)
            {
                _view.ShowErrorMessage(ex.Message);
                Run();
            }
        }
Exemplo n.º 27
0
 public static void Draw(IDraw Obj)
 {
     Obj.Draw();
 }
Exemplo n.º 28
0
 public virtual string Draw()
 {
     return(_draw.Draw());
 }
Exemplo n.º 29
0
 public void DrawShape(IDraw shape)
 {
     shape.Draw();
 }
Exemplo n.º 30
0
 public void Draw()
 {
     _draw.Draw();
 }
Exemplo n.º 31
0
 /// �����ӡ�ӿ�
 private void OutObject(IDraw outer)
 {
     //			this.mGraphics.ResetTransform();
     if (outer != null)
     {
         outer.Graphics = this.mGraphics;
         outer.PrintDocument = this.mPrintDocument;
         outer.Sewing = this.Sewing;
         outer.RectangleF = new RectangleF(X,Y,Width,outer.Height);
         outer.Draw();
         this.Y  += outer.RectangleF.Height;
     }
 }