public static BitmapSource StringToBitmapSource(this string str, int fontSize, System.Windows.Media.Color foreground, System.Windows.Media.Color background) { TextBlock tbX = new TextBlock(); tbX.FontFamily = new System.Windows.Media.FontFamily("Consolas"); tbX.Foreground = new System.Windows.Media.SolidColorBrush(foreground); tbX.Background = new System.Windows.Media.SolidColorBrush(background); tbX.TextAlignment = TextAlignment.Center; tbX.FontSize = fontSize; tbX.FontStretch = FontStretches.Normal; tbX.FontWeight = FontWeights.Medium; tbX.Text = str; var size = tbX.MeasureString(); tbX.Width = size.Width; tbX.Height = size.Height; tbX.Measure(new Size(size.Width, size.Height)); tbX.Arrange(new Rect(new Size(size.Width, size.Height))); return tbX.ToBitmapSource(); }
private string GetAdaptedText(string text, string filler, double height, double width) { bool isAnyChanged = false; var textBlock = new System.Windows.Controls.TextBlock { Text = text, TextWrapping = TxtContent.TextWrapping, FontSize = FontSize, FontFamily = FontFamily, FontStretch = FontStretch, FontStyle = FontStyle, FontWeight = FontWeight, }; textBlock.Measure(new Size(width, Double.PositiveInfinity)); textBlock.Arrange(new Rect(textBlock.DesiredSize)); while (text.Length > 1 && (textBlock.ActualHeight > height || textBlock.ActualWidth > width)) { isAnyChanged = true; text = text.Remove(text.Length - 1); textBlock = new System.Windows.Controls.TextBlock { Text = text + filler, TextWrapping = TextWrapping, FontSize = FontSize, FontFamily = FontFamily, FontStretch = FontStretch, FontStyle = FontStyle, FontWeight = FontWeight, }; textBlock.Measure(new Size(width, Double.PositiveInfinity)); textBlock.Arrange(new Rect(textBlock.DesiredSize)); } return(isAnyChanged ? (text + filler) : text); }
private void cmdPrint_Click(object sender, RoutedEventArgs e) { PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { // Create the text. Run run = new Run("This is a test of the printing functionality in the Windows Presentation Foundation."); // Wrap it in a TextBlock. TextBlock visual = new TextBlock(run); visual.Margin = new Thickness(15); // Allow wrapping to fit the page width. visual.TextWrapping = TextWrapping.Wrap; // Scale the TextBlock in both dimensions. double zoom; if (Double.TryParse(txtScale.Text, out zoom)) { visual.LayoutTransform = new ScaleTransform(zoom / 100, zoom / 100); // Get the size of the page. Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight); // Trigger the sizing of the element. visual.Measure(pageSize); visual.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height)); // Print the element. printDialog.PrintVisual(visual, "A Scaled Drawing"); } else { MessageBox.Show("Invalid scale value."); } } }
public void FindRightFontSize(TextBlock txt,Square block) { txt.FontSize = 18; txt.Measure(new Size(0, 0)); txt.Arrange(new Rect(0, 0, 0, 0)); while (txt.ActualHeight > block.Height && txt.FontSize > 13) { txt.FontSize--; txt.Measure(new Size(0, 0)); txt.Arrange(new Rect(0, 0, 0, 0)); } }
private static TextBlock Text(string text, double x, double y) { var tb = new TextBlock { Text = text, Foreground = Brushes.Black, FontSize = 11 }; tb.Arrange(new Rect(0, 0, 200, 200)); tb.SetValue(Canvas.LeftProperty, x - tb.DesiredSize.Width / 2.0); tb.SetValue(Canvas.TopProperty, y - tb.DesiredSize.Height / 2.0); tb.LayoutTransform = new ScaleTransform(1, -1); return tb; }
/// <summary> /// Content arrangement. /// </summary> /// <param name="arrangeSize">Size that element should use to arrange itself and its children.</param> protected sealed override Size ArrangeOverride(Size arrangeSize) { TextBlock.Arrange(new Rect(arrangeSize)); return(arrangeSize); }
/// <summary> /// Initializes a new instance of the <see cref="WhereAmI"/> class. /// Creates a square image and attaches an event handler to the layout changed event that /// adds the the square in the upper right-hand corner of the TextView via the adornment layer /// </summary> /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param> /// <param name="settings">The <see cref="IWhereAmISettings"/> injected by the provider</param> public WhereAmI(IWpfTextView view, IWhereAmISettings settings) { _view = view; _settings = settings; _fileName = new TextBlock(); _folderStructure = new TextBlock(); _projectName = new TextBlock(); ITextDocument textDoc; object obj; if (view.TextBuffer.Properties.TryGetProperty<ITextDocument>(typeof(ITextDocument), out textDoc)) { // Retrieved the ITextDocument from the first level } else if (view.TextBuffer.Properties.TryGetProperty<object>("IdentityMapping", out obj)) { // Try to get the ITextDocument from the second level (e.g. Razor files) if ((obj as ITextBuffer) != null) { (obj as ITextBuffer).Properties.TryGetProperty<ITextDocument>(typeof(ITextDocument), out textDoc); } } // If I found an ITextDocument, access to its FilePath prop to retrieve informations about Proj if (textDoc != null) { string fileName = System.IO.Path.GetFileName(textDoc.FilePath); Project proj = GetContainingProject(fileName); if (proj != null) { string projectName = proj.Name; if (_settings.ViewFilename) { _fileName.Text = fileName; Brush fileNameBrush = new SolidColorBrush(Color.FromArgb(_settings.FilenameColor.A, _settings.FilenameColor.R, _settings.FilenameColor.G, _settings.FilenameColor.B)); _fileName.FontFamily = new FontFamily("Consolas"); _fileName.FontSize = _settings.FilenameSize; _fileName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; _fileName.TextAlignment = System.Windows.TextAlignment.Right; _fileName.Foreground = fileNameBrush; _fileName.Opacity = _settings.Opacity; } if (_settings.ViewFolders) { _folderStructure.Text = GetFolderDiffs(textDoc.FilePath, proj.FullName); Brush foldersBrush = new SolidColorBrush(Color.FromArgb(_settings.FoldersColor.A, _settings.FoldersColor.R, _settings.FoldersColor.G, _settings.FoldersColor.B)); _folderStructure.FontFamily = new FontFamily("Consolas"); _folderStructure.FontSize = _settings.FoldersSize; _folderStructure.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; _folderStructure.TextAlignment = System.Windows.TextAlignment.Right; _folderStructure.Foreground = foldersBrush; _folderStructure.Opacity = _settings.Opacity; } if (_settings.ViewProject) { _projectName.Text = projectName; Brush projectNameBrush = new SolidColorBrush(Color.FromArgb(_settings.ProjectColor.A, _settings.ProjectColor.R, _settings.ProjectColor.G, _settings.ProjectColor.B)); _projectName.FontFamily = new FontFamily("Consolas"); _projectName.FontSize = _settings.ProjectSize; _projectName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; _projectName.TextAlignment = System.Windows.TextAlignment.Right; _projectName.Foreground = projectNameBrush; _projectName.Opacity = _settings.Opacity; } } } // Force to have an ActualWidth System.Windows.Rect finalRect = new System.Windows.Rect(); _fileName.Arrange(finalRect); _folderStructure.Arrange(finalRect); _projectName.Arrange(finalRect); //Grab a reference to the adornment layer that this adornment should be added to _adornmentLayer = view.GetAdornmentLayer("WhereAmIAdornment"); _view.ViewportHeightChanged += delegate { this.onSizeChange(); }; _view.ViewportWidthChanged += delegate { this.onSizeChange(); }; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ContentInfo content = value as ContentInfo; if (string.IsNullOrEmpty(content.content)) { return new FlowDocument(); } var flowDocument = new FlowDocument(); var para = new Paragraph(); TextBlock tb = new TextBlock(); var str = content.content; char surrogate1St = '\0'; StringBuilder unicodeCodes = new StringBuilder(); for (int i = 0; i < str.Length; i++) { int utf16Code = System.Convert.ToInt32(str[i]); string hexOutput = String.Format("{0:x}", utf16Code); if (surrogate1St != 0) { if (utf16Code >= 0xDC00 && utf16Code <= 0xDFFF) { int surrogate2Nd = utf16Code; String unicodeCode = String.Format("{0:x}", (surrogate1St - 0xD800) * (1 << 10) + (1 << 16) + (surrogate2Nd - 0xDC00)); unicodeCodes.Append(unicodeCode); if (EmojiStatic.EmojiList.Select(x => x.Key).Any(x => x == ("u" + unicodeCode))) { var bitmap = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "//emoji//u" + unicodeCode + ".png")); var image = new Image { Width = 20, Height = 20, Stretch = Stretch.Uniform, Source = bitmap }; //图片缩放模式 InlineUIContainer iuc = new InlineUIContainer(image); tb.Inlines.Add(iuc); } } surrogate1St = '\0'; } else if (utf16Code >= 0xD800 && utf16Code <= 0xDBFF) { surrogate1St = str[i]; } else { tb.Inlines.Add(new Run(str[i].ToString())); } } para.Inlines.Add(new InlineUIContainer(tb)); flowDocument.Blocks.Add(para); // auto sized tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); tb.Arrange(new Rect(tb.DesiredSize)); Debug.WriteLine(tb.ActualWidth); // prints 80.323333333333 Debug.WriteLine(tb.ActualHeight);// prints 15.96 flowDocument.PageWidth = tb.ActualWidth; return tb.ActualWidth + 30; }
public void Update() { Children.Clear(); xc = Width / 2.0; yc = Height / 2.0; rad = scale * System.Math.Min(Width / 2.5, Height / 2.5); if (eLegend == Legends.LEGEND || eLegend == Legends.LEGEND_PERCENT) { rad *= 0.7; xc -= 0.8 * (xc - rad); } double angle = 0; double x1 = rad, y1 = 0, x2, y2; Size size = new Size(0, 0); Color col = Colors.White; Brush brush; Ellipse ellipse; Rectangle rectangle; TextBlock textblock; for (int i = 0; i < Count; i++) { double frac = startColor + (endColor - startColor) * i / (double)(Count); switch (eHSL) { case HSL.HUE: col = (Color)ColorConverter.ConvertFromString(LDColours.HSLtoRGB(360 * frac, saturation, lightness)); break; case HSL.SATURATION: col = (Color)ColorConverter.ConvertFromString(LDColours.HSLtoRGB(hue, frac, lightness)); break; case HSL.LIGHTNESS: col = (Color)ColorConverter.ConvertFromString(LDColours.HSLtoRGB(hue, saturation, frac)); break; } brush = new SolidColorBrush(col); if (centralColour != "") { GradientBrush gradientBrush = new GradientBrush("", new Primitive("1=" + centralColour + ";2=" + col.ToString() + ";"), ""); brush = gradientBrush.getBrush(); } angle += 2 * System.Math.PI * Values[i] / Total; x2 = rad + rad * System.Math.Sin(angle); y2 = rad - rad * System.Math.Cos(angle); switch (eStyle) { case Styles.PIE: case Styles.DOUGHNUT: { PathSegmentCollection pathSegments = new PathSegmentCollection(); pathSegments.Add(new LineSegment(new Point(x1, y1), false)); pathSegments.Add(new ArcSegment(new Point(x2, y2), new Size(rad, rad), angle, false, SweepDirection.Clockwise, false)); PathFigureCollection pathFigures = new PathFigureCollection(); pathFigures.Add(new PathFigure(new Point(rad, rad), pathSegments, true)); PathFigureCollection figCollection = new PathFigureCollection(pathFigures); ellipse = new Ellipse { Width = 2 * rad, Height = 2 * rad, Fill = brush }; ellipse.Clip = new PathGeometry(figCollection); ellipse.Tag = new Segment(xc, yc, rad, rad, Name, Labels[i]); ellipse.MouseDown += new MouseButtonEventHandler(_ValueClickedEvent); Children.Add(ellipse); Chart.SetLeft(ellipse, xc - rad); Chart.SetTop(ellipse, yc - rad); } break; case Styles.BUBBLE: { double sin = System.Math.Sin(System.Math.PI * Values[i] / Total); double r = rad * sin / (1.0 + sin); angle -= System.Math.PI * Values[i] / Total; double x = xc + (rad - r) * System.Math.Sin(angle); double y = yc - (rad - r) * System.Math.Cos(angle); angle += System.Math.PI * Values[i] / Total; ellipse = new Ellipse { Width = 2 * r, Height = 2 * r, Fill = brush }; ellipse.Tag = new Segment(x, y, r, r, Name, Labels[i]); ellipse.MouseDown += new MouseButtonEventHandler(_ValueClickedEvent); Children.Add(ellipse); Chart.SetLeft(ellipse, x - r); Chart.SetTop(ellipse, y - r); } break; case Styles.BAR: { double w = rad * (Values[i] - Min) / (Max - Min); double h = rad / (double)Count; double x = xc - rad + w; double y = yc - rad + (2 * i + 1) * h; rectangle = new Rectangle { Width = 2 * w, Height = 2 * h, Fill = brush }; rectangle.Tag = new Segment(x, y, w, h, Name, Labels[i]); rectangle.MouseDown += new MouseButtonEventHandler(_ValueClickedEvent); Children.Add(rectangle); Chart.SetLeft(rectangle, x - w); Chart.SetTop(rectangle, y - h); } break; case Styles.COLUMN: { double w = rad / (double)Count; double h = rad * (Values[i] - Min) / (Max - Min); double x = xc - rad + (2 * i + 1) * w; double y = yc + rad - h; rectangle = new Rectangle { Width = 2 * w, Height = 2 * h, Fill = brush }; rectangle.Tag = new Segment(x, y, w, h, Name, Labels[i]); rectangle.MouseDown += new MouseButtonEventHandler(_ValueClickedEvent); Children.Add(rectangle); Chart.SetLeft(rectangle, x - w); Chart.SetTop(rectangle, y - h); } break; } brush = new SolidColorBrush(col); x1 = x2; y1 = y2; if (eLegend == Legends.OVERLAY || eLegend == Legends.PERCENT || eLegend == Legends.LEGEND_PERCENT) { textblock = new TextBlock { Text = eLegend == Legends.OVERLAY ? Labels[i] : string.Format("{0:F1}%", 100 * Values[i] / Total), Foreground = foreground, FontFamily = fontFamily, FontSize = fontSize, FontWeight = fontWeight, FontStyle = fontStyle }; if (bLegendBackground) textblock.Background = brush; textblock.FontSize *= legendScale; textblock.MouseDown += new MouseButtonEventHandler(_ValueClickedEvent); Children.Add(textblock); textblock.Measure(size); textblock.Arrange(new Rect(size)); angle -= System.Math.PI * Values[i] / Total; double w = textblock.ActualWidth / 2.0; double h = textblock.ActualHeight / 2.0; if (eStyle == Styles.PIE) { x2 = xc + 0.67 * rad * System.Math.Sin(angle); y2 = yc - 0.67 * rad * System.Math.Cos(angle); } else if (eStyle == Styles.DOUGHNUT) { x2 = xc + (1 + LDChart.DoughnutFraction) / 2.0 * rad * System.Math.Sin(angle); y2 = yc - (1 + LDChart.DoughnutFraction) / 2.0 * rad * System.Math.Cos(angle); } else if (eStyle == Styles.BUBBLE) { double sin = System.Math.Sin(System.Math.PI * Values[i] / Total); double r = rad * sin / (1.0 + sin); x2 = xc + (rad - r) * System.Math.Sin(angle); y2 = yc - (rad - r) * System.Math.Cos(angle); } else if (eStyle == Styles.BAR) { //x2 = xc - rad + rad * (Values[i] - Min) / (Max - Min); x2 = xc - rad + w + 5; y2 = yc - rad + (2 * i + 1) * rad / (double)Count; } else if (eStyle == Styles.COLUMN) { x2 = xc - rad + (2 * i + 1) * rad / (double)Count; //y2 = yc + rad - rad * (Values[i] - Min) / (Max - Min); y2 = yc + rad - w - 5; RotateTransform rotateTransform = new RotateTransform(); rotateTransform.CenterX = w; rotateTransform.CenterY = h; rotateTransform.Angle = -90; textblock.RenderTransform = rotateTransform; } angle += System.Math.PI * Values[i] / Total; textblock.Tag = new Segment(x2, y2, w, h, Name, Labels[i]); Chart.SetLeft(textblock, x2 - w); Chart.SetTop(textblock, y2 - h); Canvas.SetZIndex(textblock, 1); } if (eLegend == Legends.LEGEND || eLegend == Legends.LEGEND_PERCENT) { rectangle = new Rectangle { Width = 10 * legendScale, Height = 10 * legendScale, Fill = brush }; Children.Add(rectangle); x2 = 2 * xc; y2 = (Width - 15 * Count * legendScale) / 2 + 15 * i * legendScale; Chart.SetLeft(rectangle, x2); Chart.SetTop(rectangle, y2); Canvas.SetZIndex(rectangle, 1); textblock = new TextBlock { Text = Labels[i], Foreground = foreground, FontFamily = fontFamily, FontSize = fontSize, FontWeight = fontWeight, FontStyle = fontStyle }; if (bLegendBackground) textblock.Background = brush; textblock.FontSize *= legendScale; Children.Add(textblock); textblock.Measure(size); textblock.Arrange(new Rect(size)); Chart.SetLeft(textblock, x2 + 15 * legendScale); Chart.SetTop(textblock, y2 + 5 * legendScale - textblock.ActualHeight / 2.0); Canvas.SetZIndex(textblock, 1); } } if (eStyle == Styles.DOUGHNUT) { ellipse = new Ellipse { Width = 2 * LDChart.DoughnutFraction * rad, Height = 2 * LDChart.DoughnutFraction * rad, Fill = Background }; Children.Add(ellipse); Chart.SetLeft(ellipse, xc - LDChart.DoughnutFraction * rad); Chart.SetTop(ellipse, yc - LDChart.DoughnutFraction * rad); } }
/// <summary> /// 绘制刻度线 /// </summary> /// <param name="Primary_Radius_Inner">主刻度线内圆半径</param> /// <param name="Primary_Radius_Outer">主刻度线外圆半径</param> /// <param name="Start_Angle">主刻度线起始角度</param> /// <param name="End_Angle">主刻度线终止角度</param> /// <param name="Primary_Count">主刻度线数量</param> /// <param name="Width">刻度线宽度</param> /// <param name="Background">刻度线颜色</param> void DrawScale(double Primary_Radius_Inner, double Primary_Radius_Outer, int Primary_Count, double Minor_Radius_Inner, double Minor_Radius_Outer, int Minor_Count, double Start_Angle, double End_Angle, double Width, Brush Background) { canScale.Children.Clear(); canPrimaryScaleLabel.Children.Clear(); if (Primary_Count > 0) { /* 计算每个Primary Scale标签所显示的数值 */ double label_interval = (this.Max - this.Min) / Primary_Count; /* 计算每个Primary Scale之间的角度 */ double angle_interval_primary_scale = (End_Angle - Start_Angle) / Primary_Count; /* 计算每个Minor Scale之间的角度 */ double angle_interval_minor_scale = angle_interval_primary_scale / Minor_Count; /* 开始绘制 */ for (int i = 0; i <= Primary_Count; i++) { /* 当前要绘制的主刻度的角度值 */ double current_angle = Start_Angle + angle_interval_primary_scale * i; /* 绘制主刻度 */ Point inner_primary = ShiftedCoordinate(ConvertPolarToDescartes(new Point(Primary_Radius_Inner, current_angle))); Point outer_primary = ShiftedCoordinate(ConvertPolarToDescartes(new Point(Primary_Radius_Outer, current_angle))); Line line_primary = new Line(); line_primary.Stroke = Background; line_primary.StrokeThickness = Width; line_primary.X1 = inner_primary.X; line_primary.Y1 = inner_primary.Y; line_primary.X2 = outer_primary.X; line_primary.Y2 = outer_primary.Y; line_primary.SnapsToDevicePixels = true; canScale.Children.Add(line_primary); /* 如果primary scale标签可见,则绘制标签 */ if (PrimaryScaleLabelVisibility == Visibility.Visible) { Point poslabel = ShiftedCoordinate(ConvertPolarToDescartes(new Point(PrimaryScaleLabelRadius, Start_Angle + angle_interval_primary_scale * i))); TextBlock label = new TextBlock(); label.Text = (this.Min + label_interval * i).ToString("F0"); label.SnapsToDevicePixels = true; label.Foreground = this.PrimaryScaleBackground; label.FontFamily = this.FontFamily; label.FontSize = this.FontSize; label.FontStyle = this.FontStyle; label.FontWeight = this.FontWeight; /* 旋转文本 */ RotateTransform tr = new RotateTransform(Start_Angle + angle_interval_primary_scale * i + 90); TransformGroup trg = new TransformGroup(); trg.Children.Add(tr); label.RenderTransform = trg; label.RenderTransformOrigin = new Point(0.5, 0.5); /* 分析文本宽度和高度,以确定标签应该显示在哪个坐标 */ label.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); label.Arrange(new Rect(label.DesiredSize)); Canvas.SetLeft(label, poslabel.X - label.ActualWidth / 2); Canvas.SetTop(label, poslabel.Y - label.ActualHeight / 2); canPrimaryScaleLabel.Children.Add(label); } /* 绘制次刻度 * 由于Minor_Count表示的时次刻度将主刻度分割的数量, * 所以当分割数量=1时,不对主刻度做任何分割,所以不予处理 * i < PrimaryScaleCount表示绘制完最后一个主刻度以后不再绘制次刻度 */ if (Minor_Count > 1 && i < PrimaryScaleCount) { for (int n = 1; n < Minor_Count; n++) { Point inner_minor = ShiftedCoordinate(ConvertPolarToDescartes(new Point(Minor_Radius_Inner, current_angle + angle_interval_minor_scale * n))); Point outer_minor = ShiftedCoordinate(ConvertPolarToDescartes(new Point(Minor_Radius_Outer, current_angle + angle_interval_minor_scale * n))); Line line_minor = new Line(); line_minor.Stroke = Background; line_minor.StrokeThickness = Width; line_minor.X1 = inner_minor.X; line_minor.Y1 = inner_minor.Y; line_minor.X2 = outer_minor.X; line_minor.Y2 = outer_minor.Y; line_minor.SnapsToDevicePixels = true; canScale.Children.Add(line_minor); } } } } }
public void LabelItems(Dictionary<object, string> baseObjectToLabel, Dictionary<object, string> baseObjectToLabel2, bool clearLabeling) { if (clearLabeling) { this.ClearLabeling(); } this.dictionary_0 = baseObjectToLabel; this.dictionary_1 = baseObjectToLabel2; Thickness padding = new Thickness(4.0); Dictionary<object, TextBlock> dictionary = new Dictionary<object, TextBlock>(); DropShadowEffect effect = new DropShadowEffect { BlurRadius = 3.0, ShadowDepth = 0.0, Opacity = 1.0, Color = Colors.White }; int num = 24; Size size = new Size(10.0, 10.0); Rect finalRect = new Rect(size); new SolidColorBrush(Color.FromArgb(128, 128, 0, 128)); foreach (object current in baseObjectToLabel.Keys) { TreeItem treeItem = this.treemapHost_0.FindTreeItem(current); if (treeItem != null && (treeItem.Bounds.Width >= 70.0 && treeItem.Bounds.Height >= 30.0)) { TextBlock textBlock = new TextBlock { MaxWidth = treeItem.Bounds.Width, MaxHeight = (double)num, Foreground = Brushes.Black, Text = baseObjectToLabel[current], FontWeight = FontWeights.Bold, FontSize = 16.0, Effect = effect, Padding = padding, TextWrapping = TextWrapping.NoWrap, TextTrimming = TextTrimming.None }; textBlock.Measure(size); textBlock.Arrange(finalRect); dictionary.Add(current, textBlock); Canvas.SetTop(textBlock, treeItem.Bounds.Y); Canvas.SetLeft(textBlock, treeItem.Bounds.X); this.canvas_2.Children.Add(textBlock); } } foreach (object current in baseObjectToLabel2.Keys) { TreeItem treeItem = this.treemapHost_0.FindTreeItem(current); if (treeItem != null && (treeItem.Bounds.Width >= 50.0 && treeItem.Bounds.Height >= 30.0)) { TextBlock textBlock = new TextBlock { MaxWidth = treeItem.Bounds.Width, Height = 20.0, Foreground = Brushes.Black, Text = baseObjectToLabel2[current], FontSize = 13.0, Effect = effect, Padding = padding, TextWrapping = TextWrapping.NoWrap, TextTrimming = TextTrimming.None }; double num2 = treeItem.Bounds.Y; if (dictionary.ContainsKey(treeItem.method_0().BaseObject)) { TextBlock textBlock2 = dictionary[treeItem.method_0().BaseObject]; double num3 = Canvas.GetTop(textBlock2) + textBlock2.ActualHeight; if (this.method_0(textBlock2, treeItem.Bounds)) { num2 = num3 - 5.0; if (num2 + textBlock.Height > treeItem.Bounds.Bottom) { continue; } } } Canvas.SetTop(textBlock, num2); Canvas.SetLeft(textBlock, treeItem.Bounds.X); this.canvas_2.Children.Add(textBlock); } } }