Ejemplo n.º 1
0
        public void SetPixel(int x, int y, Color color)
        {
            BitmapData bitmapData = bitmap.Lock();

            bitmapData.SetPixel(x, y, color);
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, null);
        }
Ejemplo n.º 2
0
        public void Fill(Polygon polygon)
        {
            BitmapData bitmapData = bitmap.Lock();

            polygon.Fill(bitmapData);
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, polygon);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders a figure on a canvas.
        /// </summary>
        public void Render(Figure figure)
        {
            BitmapData bitmapData = bitmap.Lock();

            figure.Render(bitmapData, renderMode);
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, figure);
        }
Ejemplo n.º 4
0
 protected override void OnAfterRender(bool firstRender)
 {
     if (requireRender)
     {
         StateHasChanged();
         requireRender = false;
         return;
     }
     RenderCompleted?.Invoke();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Renders set of figures on a canvas.
        /// </summary>
        public void Render(IList <Figure> figures)
        {
            BitmapData bitmapData = bitmap.Lock();

            foreach (var figure in figures)
            {
                figure.Render(bitmapData, renderMode);
            }
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, null);
        }
Ejemplo n.º 6
0
        protected override void OnAfterRender(bool firstRender)
        {
            if (firstRun)
            {
                // 第一次执行,执行if语句true的部分
                firstRun      = false;
                hideContainer = false;
                StateHasChanged();
                return;
            }

            RenderCompleted?.Invoke();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sets each pixel on a canvas to white color.
        /// </summary>
        public void Clear()
        {
            BitmapData bitmapData = bitmap.Lock();

            for (int y = 0; y < bitmap.Height; y++)
            {
                for (int x = 0; x < bitmap.Width; x++)
                {
                    bitmapData.SetPixel(x, y, Colors.White);
                }
            }
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, null);
        }
Ejemplo n.º 8
0
        protected override void OnAfterRender(bool firstRender)
        {
            if (firstRun)
            {
                // 第一次执行,执行if语句true的部分
                firstRun      = false;
                hideContainer = false;
                MakeFirstRDataSource();
                StateHasChanged();
                return;
            }
            if (RConditions.Any() && refreshRDataSource)
            {
                refreshRDataSource = false;
                MakeAllRDataSource();
                StateHasChanged();
                return;
            }

            RenderCompleted?.Invoke();
        }
Ejemplo n.º 9
0
        public void EnableSuperSampling(IList <Figure> figures)
        {
            BitmapData bitmapData = bitmap.Lock();

            var _bitmap = new Bitmap(bitmap.Width * 2, bitmap.Height * 2);

            using (Graphics graph = Graphics.FromImage(_bitmap))
            {
                Rectangle ImageSize = new Rectangle(0, 0, bitmap.Width * 2, bitmap.Height * 2);
                graph.FillRectangle(Brushes.White, ImageSize);
            }
            var _bitmapData = _bitmap.Lock();

            foreach (var figure in figures)
            {
                var ssFigure = figure.SuperSampled();
                ssFigure.Render(_bitmapData);
            }

            for (int i = 0; i < _bitmapData.Width; i += 2)
            {
                for (int j = 0; j < _bitmapData.Height; j += 2)
                {
                    var bottomLeft  = _bitmapData.GetPixel(i, j);
                    var bottomRight = _bitmapData.GetPixel(i + 1, j);
                    var topLeft     = _bitmapData.GetPixel(i, j + 1);
                    var topRight    = _bitmapData.GetPixel(i + 1, j + 1);

                    var avg = (bottomLeft.R + bottomRight.R + topLeft.R + topRight.R) / 4;

                    bitmapData.SetPixel(i / 2, j / 2, (byte)avg);
                }
            }

            _bitmap.Unlock(_bitmapData);
            bitmap.Unlock(bitmapData);

            RenderCompleted?.Invoke(this, null);
        }
Ejemplo n.º 10
0
        protected override void OnAfterRender(bool firstRender)
        {
            if (RConditions.Any() && makeRDataSource)
            {
                MakeAllRDataSource();

                makeRDataSource = false;

                StateHasChanged();
                return;
            }
            if (requireRender)
            {
                if (isContainerHidden)
                {
                    isContainerHidden = false;
                }
                requireRender = false;
                StateHasChanged();
                return;
            }

            RenderCompleted?.Invoke();
        }
Ejemplo n.º 11
0
 protected virtual void OnRenderCompleted()
 {
     RenderCompleted?.Invoke(this, EventArgs.Empty);
 }