Пример #1
0
        public DrawingImage GenerateImage(int x, int y, int width, int height, double CanvasWidth, double CanvasHeight)
        {
            var          IC = CreateICFromPick(this);
            var          di = IC.Grid.GenerateImage(x, y, width, height, CanvasWidth, CanvasHeight);
            DrawingGroup dg = di.Drawing as DrawingGroup;

            if (dg == null)
            {
                return(di);
            }
            int h = 20;

            for (int i = 0; i < Matrices.Count; i++)
            {
                RectangleGeometry rg =
                    new RectangleGeometry(new Rect(new Point(0, 10 + CanvasHeight + h * i),
                                                   new Point(10, 10 + CanvasHeight + h * (i + 1))));
                var gd = new GeometryDrawing
                {
                    Brush    = SPDAssets.GetBrush(i),
                    Geometry = rg,
                    Pen      = new Pen(Brushes.Black, 0.5)
                };
                var text = new FormattedText(Matrices[i].ToString(),
                                             CultureInfo.CurrentCulture,
                                             FlowDirection.LeftToRight,
                                             new Typeface(SPDAssets.GetFont()),
                                             10,
                                             Brushes.Black);
                var gd2 = new GeometryDrawing
                {
                    Pen      = new Pen(Brushes.Black, 1),
                    Brush    = Brushes.Black,
                    Geometry = text.BuildGeometry(new Point(11, 10 + (h / 2) + CanvasHeight + h * i))
                };
                dg.Children.Add(gd);
                dg.Children.Add(gd2);
            }
            return(new DrawingImage(dg));
        }
Пример #2
0
        public DrawingImage GenerateImage(int x, int y, int width, int height, double CanvasWidth, double CanvasHeight, int replace = -1)
        {
            var cellWidth  = CanvasWidth / width;
            var cellHeight = CanvasHeight / height;


            var dg = new DrawingGroup();

            for (var i = x; i < x + width; i++)
            {
                for (var j = y; j < y + height; j++)
                {
                    var rg = new RectangleGeometry(new Rect(new Point((i - x) * cellWidth, (j - y) * cellHeight), new Point((i - x + 1) * cellWidth, (j + 1 - y) * cellHeight)));
                    var gd = new GeometryDrawing
                    {
                        Brush    = CellGrid[i, j].Value == replace?new SolidColorBrush(Color.FromRgb(0, 0, 0)):SPDAssets.GetBrush(this.CellGrid[i, j].Value),
                        Geometry = rg
                    };
                    dg.Children.Add(gd);
                }
            }
            return(new DrawingImage(dg));
        }
Пример #3
0
 private Brush GetBrush(int p)
 {
     return(SPDAssets.GetBrush(p));
 }