public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Color) { var color = (Color)value; return(DicomColor.FromArgb(color.A, color.R, color.G, color.B)); } return(null); }
public void Render(DicomPanelModel model, IRenderContext context) { var s = model.Camera.ConvertWorldToScreenCoords(Position); var r1 = new Point3d(Position.X - 2 / model.Camera.Scale, Position.Y - 2 / model.Camera.Scale, Position.Z); var r2 = new Point3d(Position.X, Position.Y, Position.Z); r2 += model.Camera.ColDir * 48 / model.Camera.Scale; r2 += model.Camera.RowDir * 16 / model.Camera.Scale; var sr1 = model.Camera.ConvertWorldToScreenCoords(r1); var sr2 = model.Camera.ConvertWorldToScreenCoords(r2); context.DrawString(Text, s.X, s.Y, 12, DicomColor.FromArgb((int)(255 * Opacity), 0, 255, 255)); }
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); }