public Size MeasureText(VirtualCanvas parent, string label) { FontFamily fontFamily = (FontFamily)parent.GetValue(TextBlock.FontFamilyProperty); FontStyle fontStyle = (FontStyle)parent.GetValue(TextBlock.FontStyleProperty); FontWeight fontWeight = (FontWeight)parent.GetValue(TextBlock.FontWeightProperty); FontStretch fontStretch = (FontStretch)parent.GetValue(TextBlock.FontStretchProperty); double fontSize = (double)parent.GetValue(TextBlock.FontSizeProperty); Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); FormattedText ft = new FormattedText(label, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeface, fontSize, Brushes.Black); return(new Size(ft.Width, ft.Height)); }
public CanvasContextMenu(VirtualCanvas canvas) { _canvas = canvas; }