コード例 #1
0
ファイル: MainForm.cs プロジェクト: TuMoXa/ttf
        private void tvList_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DrawingContext context = new DrawingContext(graphics);

            using (Pen pen = new Pen(Color.Blue, lineWidth))
            {
                context.Pen = pen;

                if (e.Node.Nodes.Count > 0)
                {//存在子项
                    pen.Color = Color.Green;

                    Cursor.Current = Cursors.WaitCursor;
                    foreach (TreeNode node in e.Node.Nodes)
                    {
                        IDrawing drawing = node.Tag as IDrawing;
                        if (drawing != null)
                        {
                            drawing.Draw(context);
                        }
                        Thread.Sleep(250);
                    }
                    Cursor.Current = Cursors.Default;
                }
                else
                {
                    IDrawing drawing = e.Node.Tag as IDrawing;
                    if (drawing != null)
                    {
                        drawing.Draw(context);
                    }
                }
            }
        }
コード例 #2
0
        private CanvasRenderTarget GetDrawings()
        {
            CanvasDevice       device = CanvasDevice.GetSharedDevice();
            CanvasRenderTarget target = new CanvasRenderTarget(device, (float)_canvasControl.ActualWidth, (float)_canvasControl.ActualHeight, 96);

            using (CanvasDrawingSession graphics = target.CreateDrawingSession())
            {
                graphics.Clear(Colors.Transparent);

                if (_bitmap != null)
                {
                    graphics.DrawImage(_bitmap, GetBitmapRect());
                }

                if (_strokes != null && _strokes.Any())
                {
                    var list = _strokes.ToList();
                    list.Reverse();
                    list.ForEach((d) => { d.Draw(graphics); });
                }

                if (_currentStroke != null)
                {
                    _currentStroke.Draw(graphics);
                }
            }
            return(target);
        }
コード例 #3
0
        // Listing 15.15 Creating composed drawing

        public static IDrawing Compose(this IDrawing img1, IDrawing img2)
        {
            // Create composed drawing
            return(new Drawing(g => {
                img1.Draw(g);
                img2.Draw(g);
            }
                               ));
        }
コード例 #4
0
        // Listing 15.14 Translating drawings

        // Extension method
        public static IDrawing Translate(this IDrawing img, float x, float y)
        {
            // Return translated 'Drawing' object
            return(new Drawing(g => {
                g.TranslateTransform(x, y);
                img.Draw(g);
                g.TranslateTransform(-x, -y);
            }
                               ));
        }
コード例 #5
0
ファイル: DrawingHelpers.cs プロジェクト: limocute/yak2d
        public void DrawTexturedQuad(IDrawStage drawStage,
                                     CoordinateSpace space,
                                     ITexture texture,
                                     Colour colour,
                                     Vector2 position,
                                     float width,
                                     float height,
                                     float depth,
                                     int layer = 0,
                                     float rotation_clockwise_radians  = 0.0f,
                                     float texcoord_min_x              = 0.0f,
                                     float texcoord_min_y              = 0.0f,
                                     float texcoord_max_x              = 1.0f,
                                     float texcoord_max_y              = 1.0f,
                                     TextureCoordinateMode textureMode = TextureCoordinateMode.Wrap)
        {
            var halfSize = 0.5f * new Vector2(width, height);

            _drawing.Draw(drawStage,
                          space,
                          FillType.Textured,
                          new Vertex2D[]
            {
                new Vertex2D {
                    Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_min_x, texcoord_min_y), TexCoord1 = new Vector2(0.0f, 0.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                },
                new Vertex2D {
                    Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_max_x, texcoord_min_y), TexCoord1 = new Vector2(1.0f, 0.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                },
                new Vertex2D {
                    Position = Common.RotateVectorClockwise(new Vector2(-halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_min_x, texcoord_max_y), TexCoord1 = new Vector2(0.0f, 1.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                },
                new Vertex2D {
                    Position = Common.RotateVectorClockwise(new Vector2(halfSize.X, -halfSize.Y), rotation_clockwise_radians) + position, TexCoord0 = new Vector2(texcoord_max_x, texcoord_max_y), TexCoord1 = new Vector2(1.0f, 1.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                },
            },
                          new int[]
            {
                0, 1, 2, 2, 1, 3
            },
                          colour,
                          texture,
                          null,
                          textureMode,
                          TextureCoordinateMode.None,
                          depth,
                          layer);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: bobbarnes1981/ChaosGame2d
        private static void ApplicationTickEventHandler(object sender, TickEventArgs args)
        {
            m_elapsed          += args.SecondsElapsed;
            Video.WindowCaption = string.Format("ChaosGame2d [FPS: {0} | Elapsed: {1} | Points: {2}]", args.Fps, m_elapsed, m_drawing.NumberOfPoints);

            if (m_elapsed > m_step)
            {
                m_drawing.Update();
                m_drawing.Draw();

                m_video.Update();

                m_elapsed -= m_step;
            }
        }
コード例 #7
0
ファイル: DrawBuilder.cs プロジェクト: limocute/yak2d
        //Usage (Vertex2Ds are created and vertices are finally positioned. Previously all relative to single position point to enable transforms)

        public void SubmitDraw(IDrawStage drawStage, CoordinateSpace space, float depth, int layer)
        {
            _drawing.Draw(drawStage,
                          space,
                          _fill,
                          CreateVerticesInFinalPosition(),
                          _indices,
                          _colour,
                          _texture0.Texture,
                          _texture1.Texture,
                          _texture0.TextureMode,
                          _texture1.TextureMode,
                          depth,
                          layer);
        }
コード例 #8
0
        private void DrawTimer()
        {
            if (!needDrawing)
            {
                return;
            }
            timer.Enabled = false;

            drawing.Draw(bitmap);
            Graphics g = Graphics.FromImage(bitmap);

            Posteffect(g);
            g.Dispose();
            pictureBox.Image = bitmap;
            needDrawing      = false;
            timer.Enabled    = true;
        }
コード例 #9
0
        static void Main(string[] args)
        {
            try
            {
                int      width  = -1;
                int      height = -1;
                char     c      = ' ';
                char[][] matrix = null;

                while (true)
                {
                    Console.Write(Constants.EnterCommandMessage);
                    string[] command = Console.ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                    List <Point> list = new List <Point>();
                    if (!ProcessCommand(command, list, ref matrix, ref width, ref height, ref c))
                    {
                        IDrawingFactory df      = new DrawingFactory.DrawingFactory();
                        IDrawing        drawing = null;
                        drawing = df.CreateObject(command[0].ToUpper());
                        drawing.Draw(matrix, list, c);
                        Utilities.Utilities.Paint(matrix);
                    }

                    Console.WriteLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(Constants.ExceptionMessageToUser);
                File.AppendAllText("ErrorMessages.txt", Environment.NewLine + DateTime.Now +
                                   Environment.NewLine + ex.Message + Environment.NewLine
                                   + ex.StackTrace + Environment.NewLine);
                Console.WriteLine(Constants.ExitMessageWhileException);
            }
            finally
            {
                Console.Read();
            }
        }