Beispiel #1
0
        public void DrawLine(double x0, double y0, double x1, double y1, DicomColor color, LineType lineType)
        {
            x0 *= Canvas.ActualWidth;
            x1 *= Canvas.ActualWidth;
            y1 *= Canvas.ActualHeight;
            y0 *= Canvas.ActualHeight;
            Line line = new Line();

            line.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            if (lineType != LineType.Normal)
            {
                line.StrokeDashArray = new DoubleCollection();
                if (lineType == LineType.Dotted)
                {
                    line.StrokeDashArray.Add(1);
                    line.StrokeDashArray.Add(1);
                }
                else if (lineType == LineType.Dashed)
                {
                    line.StrokeDashArray.Add(2);
                    line.StrokeDashArray.Add(2);
                }
            }
            line.StrokeThickness = 1;
            line.X1 = x0;
            line.X2 = x1;
            line.Y1 = y0;
            line.Y2 = y1;
            Canvas?.Children.Add(line);
        }
        public void DrawLines(double[] vertices, DicomColor color)
        {
            var actualColor = WriteableBitmapExtensions.ConvertColor(DicomColorConverter.FromDicomColor(color));

            using (var context = _bitmap.GetBitmapContext())
            {
                for (int i = 0; i < vertices.Length; i += 4)
                {
                    WriteableBitmapExtensions.DrawLine(context, context.Width, context.Height, transxi(vertices[i]), transyi(vertices[i + 1]), transxi(vertices[i + 2]), transyi(vertices[i + 3]), actualColor);
                }
            }
        }
        private Color getCachedColor(DicomColor dicomColor)
        {
            Color color;

            if (!cachedColors.ContainsKey(dicomColor))
            {
                color = DicomColorConverter.FromDicomColor(dicomColor);
                cachedColors.Add(dicomColor, color);
            }
            else
            {
                color = cachedColors[dicomColor];
            }
            return(color);
        }
Beispiel #4
0
        public void DrawRect(double x0, double y0, double x1, double y1, DicomColor color)
        {
            x0 *= Canvas.ActualWidth;
            x1 *= Canvas.ActualWidth;
            y1 *= Canvas.ActualHeight;
            y0 *= Canvas.ActualHeight;

            Rectangle rectangle = new Rectangle();

            rectangle.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            rectangle.Width  = Math.Abs(x1 - x0);
            rectangle.Height = Math.Abs(y1 - y0);
            Canvas.SetLeft(rectangle, Math.Min(x0, x1));
            Canvas.SetTop(rectangle, Math.Min(y0, y1));
            Canvas?.Children.Add(rectangle);
        }
Beispiel #5
0
        public void DrawEllipse(double x0, double y0, double radiusX, double radiusY, DicomColor color)
        {
            x0      *= Canvas.ActualWidth;
            y0      *= Canvas.ActualHeight;
            radiusX *= Canvas.ActualWidth;
            radiusY *= Canvas.ActualHeight;

            Ellipse ellipse = new Ellipse();

            ellipse.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            ellipse.Width  = Math.Abs(radiusX);
            ellipse.Height = Math.Abs(radiusY);
            Canvas.SetLeft(ellipse, x0 - radiusX / 2);
            Canvas.SetTop(ellipse, y0 - radiusY / 2);
            Canvas?.Children.Add(ellipse);
        }
Beispiel #6
0
        public void DrawString(string text, double x, double y, double size, DicomColor color)
        {
            TextBlock tb  = new TextBlock();
            var       dse = new DropShadowEffect();

            dse.BlurRadius  = 1;
            dse.ShadowDepth = 4;
            dse.Direction   = 0;
            tb.FontSize     = size;
            tb.Foreground   = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            tb.Text         = text;
            Canvas.SetLeft(tb, x * Canvas.ActualWidth);
            Canvas.SetTop(tb, y * Canvas.ActualHeight);

            FormattedText fm = new FormattedText(tb.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(tb.FontFamily, tb.FontStyle, tb.FontWeight, tb.FontStretch), tb.FontSize, tb.Foreground);

            FillRect(x, y, x + fm.Width / Canvas.ActualWidth, y + fm.Height / Canvas.ActualHeight, DicomColor.FromArgb(128, 0, 0, 0), DicomColor.FromArgb(0, 0, 0, 0));

            Canvas?.Children.Add(tb);
        }
 public void DrawString(string text, double x, double y, double size, DicomColor color)
 {
     _bitmap.DrawString(transxi(x), transyi(y), DicomColorConverter.FromDicomColor(color), new PortableFontDesc("Aria", (int)((double)size / 1.5)), text);
 }
        public void FillRect(double x0, double y0, double x1, double y1, DicomColor fill, DicomColor stroke)
        {
            int y0i = transyi(y0);
            int y1i = transyi(y1);

            _bitmap.FillRectangle(transxi(x0), transyi(y0), transxi(x1), transyi(y1), DicomColorConverter.FromDicomColor(fill));
            DrawRect(x0, y0, x1, y1, stroke);
        }
        public void DrawRect(double x0, double y0, double x1, double y1, DicomColor color)
        {
            int y0i = transyi(y0);
            int y1i = transyi(y1);

            _bitmap.DrawRectangle(transxi(x0), transyi(y0), transxi(x1), transyi(y1), DicomColorConverter.FromDicomColor(color));
        }
 public void DrawEllipse(double x0, double y0, double radiusX, double radiusY, DicomColor color)
 {
     _bitmap.DrawEllipseCentered(transxi(x0), transyi(y0), transxi(radiusX / 2), transyi(radiusY / 2), DicomColorConverter.FromDicomColor(color));
 }