internal void Compose() { GraphController controller = graphController as GraphController; IGraphVisualHost visualHost = controller.GetVisualHost(); if (null == visualHost) { return; // Running in headless mode, draw no further. } VisualNode node = graphController.GetVisualNode(nodeId); DrawingVisual bubbleVisual = visualHost.GetDrawingVisualForBubble(this.bubbleId); DrawingContext drawingContext = bubbleVisual.RenderOpen(); if (content == null) { drawingContext.Close(); return; } anchorPoint.X = node.GetBubbleXPosition(); anchorPoint.Y = node.Height + Configurations.InfoBubbleTopMargin; anchorPoint = new Point((int)anchorPoint.X, (int)anchorPoint.Y); arrowLeft = new Point((int)(anchorPoint.X - Configurations.InfoBubbleArrowWidthHalf), (int)(anchorPoint.Y + Configurations.InfoBubbleArrowHeight)); arrowRight = new Point((int)(anchorPoint.X + Configurations.InfoBubbleArrowWidthHalf), (int)(anchorPoint.Y + Configurations.InfoBubbleArrowHeight)); if (this.previewType.HasFlag(PreviewTypes.Collapsed)) { arrowLeft.Y = anchorPoint.Y; anchorPoint.Y = arrowRight.Y; arrowRight.Y = arrowLeft.Y; } else { arrowLeft.Offset(-1, 2); arrowRight.Offset(1, 2); } if (this.previewType.HasFlag(PreviewTypes.String) || this.previewType.HasFlag(PreviewTypes.Unknown)) { this.ComposeValue(drawingContext); } else if (this.previewType.HasFlag(PreviewTypes.Bitmap)) { this.ComposeGeo(drawingContext); } drawingContext.Close(); TranslateTransform transform = bubbleVisual.Transform as TranslateTransform; transform.X = node.X; transform.Y = node.Y; }
internal void Compose() { if (false == this.Dirty) { return; } if (IsRunningHeadless) { return; } GraphController controller = graphController as GraphController; IGraphVisualHost visualHost = controller.GetVisualHost(); DrawingVisual visual = visualHost.GetDrawingVisualForNode(this.NodeId); //TextOptions.SetTextFormattingMode(visual, TextFormattingMode.Display); //TextOptions.SetTextRenderingMode(visual, TextRenderingMode.Aliased); DrawingContext drawingContext = visual.RenderOpen(); CultureInfo cultureInfo = new CultureInfo("en-us"); //@TODO(Ben) Move this into a single place and reuse it //RenderOptions.SetEdgeMode(visual, EdgeMode.Aliased); if (!dotsFlag.HasFlag(MenuDots.DotsFlag)) { this.CheckDots(); } this.ComposeCore(drawingContext, visual); drawingContext.Close(); if (errorBubble != null) { errorBubble.Compose(); } TranslateTransform nodeTransform = visual.Transform as TranslateTransform; nodeTransform.X = this.nodePosition.X; nodeTransform.Y = this.nodePosition.Y; this.Dirty = false; }
internal void Compose() { if (false == this.Dirty) { return; } GraphController controller = this.edgeController.GetGraphController(); IGraphVisualHost visualHost = controller.GetVisualHost(); if (null == visualHost) { return; } DrawingVisual visual = visualHost.GetDrawingVisualForEdge(this.EdgeId); DrawingContext context = visual.RenderOpen(); DrawCurve(context, this.PreviewSelected); context.Close(); }
internal void Compose() { GraphController controller = graphController as GraphController; IGraphVisualHost visualHost = controller.GetVisualHost(); if (null == visualHost) { return; // Running in headless mode, draw no further. } DrawingVisual bubbleVisual = visualHost.GetDrawingVisualForBubble(this.bubbleId); DrawingContext drawingContext = bubbleVisual.RenderOpen(); string text = this.content as string; if (string.IsNullOrEmpty(text)) { drawingContext.Close(); return; } if (this.ErrType == ErrorType.None) { ErrorManager.HandleError(new InvalidOperationException("'errorType' is not set")); } VisualNode node = graphController.GetVisualNode(this.OwnerId); this.anchorPoint.X = node.Width / 2; this.anchorPoint.Y = -Configurations.InfoBubbleTopMargin; this.anchorPoint = new Point((int)this.anchorPoint.X, (int)this.anchorPoint.Y); this.arrowLeft = new Point((int)this.anchorPoint.X - Configurations.InfoBubbleArrowWidthHalf, (int)this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight); this.arrowRight = new Point((int)this.anchorPoint.X + Configurations.InfoBubbleArrowWidthHalf, (int)this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight); this.arrowLeft.Offset(-1, -2); this.arrowRight.Offset(1, -2); double textLength; int textHorizontalMargin; int textVerticalMargin; FormattedText newText; SolidColorBrush textColor; SolidColorBrush backgroundColor; Pen borderPen; if (this.ErrType == ErrorType.Warning) { textColor = Configurations.ErrorBubbleWarningTextColor; borderPen = Configurations.ErrorBubbleWarningBorderPen; backgroundColor = Configurations.ErrorBubbleWarningBackground; } else { textColor = Configurations.ErrorBubbleErrorTextColor; borderPen = Configurations.ErrorBubbleErrorBorderPen; //if (this.node.Selected == true) backgroundColor = Configurations.ErrorBubbleErrorBackgroundActive; //else // backgroundColor = Configurations.ErrorBubbleErrorBackgroundNonActive; } textHorizontalMargin = Configurations.InfoBubbleMargin; textVerticalMargin = Configurations.InfoBubbleMargin; newText = new FormattedText(text, Configurations.culture, FlowDirection.LeftToRight, Configurations.TypeFace, Configurations.InfoBubbleText, textColor); newText.LineHeight = Configurations.InfoBubbleText; textLength = newText.WidthIncludingTrailingWhitespace; this.rectWidth = (int)(textLength + textHorizontalMargin * 2); this.rectHeight = (int)(textVerticalMargin * 2 + newText.Height); if (this.rectWidth < Configurations.InfoBubbleMinWidth) { this.rectWidth = Configurations.InfoBubbleMinWidth; } this.rectPoint = new Point((int)(this.anchorPoint.X - this.rectWidth / 2) + 0.5, (int)(this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight - this.rectHeight) + 0.5); //Draw Bubble base.DrawBubble(drawingContext, backgroundColor, borderPen, true); //Draw Text drawingContext.DrawText(newText, new Point(this.rectPoint.X + textHorizontalMargin, this.rectPoint.Y + textVerticalMargin)); drawingContext.Close(); TranslateTransform transform = bubbleVisual.Transform as TranslateTransform; transform.X = node.X; transform.Y = node.Y; }