public void Draw(ApplicationContext actx, SWM.DrawingContext dc, double scaleFactor, double x, double y, ImageDescription idesc) { if (drawCallback != null) { DrawingContext c = new DrawingContext(dc, scaleFactor); actx.InvokeUserCode(delegate { drawCallback(c, new Rectangle(x, y, idesc.Size.Width, idesc.Size.Height)); }); } else { if (idesc.Alpha < 1) { dc.PushOpacity(idesc.Alpha); } var f = GetBestFrame(actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false); dc.DrawImage(f, new Rect(x, y, idesc.Size.Width, idesc.Size.Height)); if (idesc.Alpha < 1) { dc.Pop(); } } }
public void Draw(ApplicationContext actx, SWM.DrawingContext dc, double scaleFactor, double x, double y, ImageDescription idesc) { if (drawCallback != null) { DrawingContext c = new DrawingContext(dc, scaleFactor); actx.InvokeUserCode(delegate { drawCallback(c, new Rectangle(x, y, idesc.Size.Width, idesc.Size.Height)); }); } else { if (idesc.Alpha < 1) { dc.PushOpacity(idesc.Alpha); } var f = GetBestFrame(actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false); var bmpImage = f as BitmapSource; if (bmpImage != null && (bmpImage.PixelHeight != idesc.Size.Height || bmpImage.PixelWidth != idesc.Size.Width)) { f = new TransformedBitmap(bmpImage, new ScaleTransform(idesc.Size.Width / bmpImage.PixelWidth, idesc.Size.Height / bmpImage.PixelHeight)); } dc.DrawImage(f, new Rect(x, y, idesc.Size.Width, idesc.Size.Height)); if (idesc.Alpha < 1) { dc.Pop(); } } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (mDraggedElement != null) { Win32.POINT screenPos = new Win32.POINT(); if (Win32.GetCursorPos(ref screenPos)) { Point pos = PointFromScreen(new Point(screenPos.X, screenPos.Y)); Rect rect = new Rect(pos.X, pos.Y, mDraggedElement.ActualWidth, mDraggedElement.ActualHeight); drawingContext.PushOpacity(1.0); drawingContext.DrawRectangle(new VisualBrush(mDraggedElement), new Pen(Brushes.Transparent, 0), rect); // drawingContext.Pop(); } } }
protected void RenderTiles(System.Windows.Media.DrawingContext dc) { double opacityIncrement = 1.0f / Layers.Count; double opacity = opacityIncrement; foreach (Layer layer in Layers) { dc.PushOpacity(opacity); foreach (Sprite sprite in layer.Tiles) { dc.DrawImage(sprite.ImageSource, sprite.Rect); } dc.Pop(); opacity += opacityIncrement; } }
protected override void OnRender(DrawingContext dc) { base.OnRender(dc); if (_borderVisible) { dc.DrawRectangle(null, OuterPen, new Rect(0.5, 0.5, Zoom * Screen.PixelWidth - 1, Zoom * Screen.PixelHeight - 1)); dc.DrawRectangle(null, InnerPen, new Rect(1.5, 1.5, Zoom * Screen.PixelWidth - 3, Zoom * Screen.PixelHeight - 3)); } if (_propertiesVisible) { dc.PushOpacity(0.5); dc.DrawImage(_propertiesBitmap, new Rect(0, 0, Zoom * Screen.PixelWidth, Zoom * Screen.PixelHeight)); dc.Pop(); } }
protected override void OnRender(DrawingContext drawingContext) { // draw everything except the reflection base.OnRender(drawingContext); // set opacity drawingContext.PushOpacityMask(_opacityMask); drawingContext.PushOpacity(0.4); // set reflection parameters based on content size _reflection.Visual = Child; // draw the reflection drawingContext.DrawRectangle(_reflection, null, new Rect(0, ActualHeight + _gap, ActualWidth, ActualHeight)); // cleanup drawingContext.Pop(); drawingContext.Pop(); }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary<int, BookmarkBase> bookmarkDict = new Dictionary<int, BookmarkBase>(); foreach (var bm in BookmarkManager.Bookmarks) { if (DebugData.DecompiledMemberReferences == null || DebugData.DecompiledMemberReferences.Count == 0 || !DebugData.DecompiledMemberReferences.ContainsKey(bm.MemberReference.MetadataToken.ToInt32())) continue; int line = bm.LineNumber; BookmarkBase existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) bookmarkDict[line] = bm; } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; BookmarkBase bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { Rect rect = new Rect(0, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) drawingContext.PushOpacity(0.5); drawingContext.DrawImage(bm.Image, rect); if (dragDropBookmark == bm && dragStarted) drawingContext.Pop(); } } if (dragDropBookmark != null && dragStarted) { Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage(dragDropBookmark.Image, rect); } } }
protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides) { // create a drop shadow // if (this.Shadowed) { Geometry pathGeometry = this.GetGeometry(overrides).Clone(); pathGeometry.Transform = new TranslateTransform(5, 0); try { context.PushOpacity(0.5); context.DrawGeometry(Brushes.DarkGray, null, pathGeometry); } finally { context.Pop(); } } base.DrawCore(context, overrides); }
protected override void OnRender(DrawingContext drawingContext) { // draw everything except the reflection base.OnRender(drawingContext); // set opacity drawingContext.PushOpacityMask(_opacityMask); drawingContext.PushOpacity(0.3); // set reflection parameters based on content size _reflection.Visual = Child; ((ScaleTransform)_reflection.Transform).CenterY = 3 * ActualHeight / 4; ((ScaleTransform)_reflection.Transform).CenterX = ActualWidth / 2; // draw the reflection drawingContext.DrawRectangle( _reflection, null, new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2)); // cleanup drawingContext.Pop(); drawingContext.Pop(); }
public void Draw(ApplicationContext actx, SWM.DrawingContext dc, double scaleFactor, double x, double y, ImageDescription idesc) { if (drawCallback != null) { DrawingContext c = new DrawingContext(dc, scaleFactor); actx.InvokeUserCode(delegate { drawCallback(c, new Rectangle(x, y, idesc.Size.Width, idesc.Size.Height), idesc, actx.Toolkit); }); } else { if (idesc.Alpha < 1) { dc.PushOpacity(idesc.Alpha); } var f = GetBestFrame(actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false); var bmpImage = f as BitmapSource; // When an image is a single bitmap that doesn't have the same intrinsic size as the drawing size, dc.DrawImage makes a very poor job of down/up scaling it. // Thus we handle this manually by using a TransformedBitmap to handle the conversion in a better way when it's needed. var scaledWidth = idesc.Size.Width * scaleFactor; var scaledHeight = idesc.Size.Height * scaleFactor; if (bmpImage != null && (Math.Abs(bmpImage.PixelHeight - scaledHeight) > 0.001 || Math.Abs(bmpImage.PixelWidth - scaledWidth) > 0.001)) { f = new TransformedBitmap(bmpImage, new ScaleTransform(scaledWidth / bmpImage.PixelWidth, scaledHeight / bmpImage.PixelHeight)); } dc.DrawImage(f, new Rect(x, y, idesc.Size.Width, idesc.Size.Height)); if (idesc.Alpha < 1) { dc.Pop(); } } }
/// <summary> /// Render the StrokeCollection under the specified DrawingContext. This draw method uses the /// passing in drawing attribute to override that on the stroke. /// </summary> /// <param name="drawingContext"></param> /// <param name="drawingAttributes"></param> public void Draw(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { if (null == drawingContext) { throw new System.ArgumentNullException("context"); } if (null == drawingAttributes) { throw new System.ArgumentNullException("drawingAttributes"); } // context.VerifyAccess(); //our code never calls this public API so we can assume that opacity //has not been set up if (drawingAttributes.IsHighlighter) { drawingContext.PushOpacity(StrokeRenderer.HighlighterOpacity); try { this.DrawInternal(drawingContext, StrokeRenderer.GetHighlighterAttributes(this, this.DrawingAttributes), false); } finally { drawingContext.Pop(); } } else { this.DrawInternal(drawingContext, drawingAttributes, false); } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); drawingContext.PushOpacityMask(ReflectionMask); drawingContext.PushOpacity(ReflectionOpacity); _mReflection.Visual = Child; ((ScaleTransform)_mReflection.Transform).CenterY = 3 * ActualHeight / 4; ((ScaleTransform)_mReflection.Transform).CenterX = ActualWidth / 2; drawingContext.DrawRectangle(_mReflection, null, new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2)); drawingContext.Pop(); drawingContext.Pop(); }
/// <summary> /// Performs the actual rendering of the caret on the given context. Called by /// CaretSubElement. /// </summary> /// <param name="context">Drawing context</param> /// <remarks>This method is on CaretElement instead of CaretSubElement because CaretElement /// knows all of the necessary data, and conceptually CaretSubElement only exists to provide /// a rendering surface.</remarks> internal void OnRenderCaretSubElement(DrawingContext context) { // [....] up Win32 caret position with Avalon caret position. Win32SetCaretPos(); if (_showCaret) { TextEditorThreadLocalStore threadLocalStore = TextEditor._ThreadLocalStore; Invariant.Assert(!(_italic && this.IsInInterimState), "Assert !(_italic && IsInInterimState)"); // Drawing context's pushed count to pop it up int contextPushedCount = 0; // Apply internally requested opacity. context.PushOpacity(_opacity); contextPushedCount++; // Apply italic transformation if (_italic && !(threadLocalStore.Bidi)) { // Rotate transform 20 degree for italic that is the based on 'H' italic degree. // NOTE: The angle of italic caret is constant. This is Word behavior // established after usability studies with conditional angle dependent // on font properties - they discovered that variations look annoying. // NOTE: We ignore _italic setting in _bidi case. This is Word behavior. // When flow direction is Right to Left, we need to reverse the caret transform. // // Get the flow direction which is the flow direction of AdornedElement. // CaretElement is rendering the caret that based on AdornedElement, so we can // render the right italic caret whatever the text content set the flow direction. FlowDirection flowDirection = (FlowDirection)AdornedElement.GetValue(FlowDirectionProperty); context.PushTransform(new RotateTransform( flowDirection == FlowDirection.RightToLeft ? -20 : 20, 0, _height)); contextPushedCount++; } if (this.IsInInterimState || _systemCaretWidth > DefaultNarrowCaretWidth) { // Make the block caret partially transparent to avoid obstructing text. context.PushOpacity(CaretOpacity); contextPushedCount++; } if (this.IsInInterimState) { // Render the interim block caret as the specified interim block caret width. context.DrawRectangle(_caretBrush, null, new Rect(0, 0, _interimWidth, _height)); } else { // Snap the caret to device pixels. if (!_italic || threadLocalStore.Bidi) { GuidelineSet guidelineSet = new GuidelineSet(new double[] { -(_systemCaretWidth / 2), _systemCaretWidth / 2 }, null); context.PushGuidelineSet(guidelineSet); contextPushedCount++; } // If we don't snap, the caret will render as a 2 pixel wide rect, one pixel in each bordering char bounding box. context.DrawRectangle(_caretBrush, null, new Rect(-(_systemCaretWidth / 2), 0, _systemCaretWidth, _height)); } if (threadLocalStore.Bidi) { // Set the Bidi caret indicator width. TextBox/RichTextBox control must have // the enough margin to display BiDi indicator. double bidiCaretIndicatorWidth = BidiCaretIndicatorWidth; // Get the flow direction which is the flow direction of AdornedElement. // Because CaretElement is rendering the caret that based on AdornedElement. // With getting the flow direction, we can render the BiDi caret indicator correctly // whatever AdornedElement's flow direction is set. FlowDirection flowDirection = (FlowDirection)AdornedElement.GetValue(FlowDirectionProperty); if (flowDirection == FlowDirection.RightToLeft) { // BiDi caret indicator should always direct by the right to left bidiCaretIndicatorWidth = bidiCaretIndicatorWidth * (-1); } // Draw BIDI caret to indicate the coming input is BIDI characters. // Shape is a little flag oriented to the left - as in Word. // Orientation does not depend on anything (which seems to be Word behavior). // PathGeometry pathGeometry; PathFigure pathFigure; pathGeometry = new PathGeometry(); pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(0, 0); pathFigure.Segments.Add(new LineSegment(new Point(-bidiCaretIndicatorWidth, 0), true)); pathFigure.Segments.Add(new LineSegment(new Point(0, _height / BidiIndicatorHeightRatio), true)); pathFigure.IsClosed = true; pathGeometry.Figures.Add(pathFigure); context.DrawGeometry(_caretBrush, null, pathGeometry); } // Pop the drawing context if pushed for italic or opacity setting for (int i = 0; i < contextPushedCount; i++) { context.Pop(); } } else { // Destroy Win32 caret. Win32DestroyCaret(); } }
protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height) { dc.PushOpacity(Opacity/100.0); dc.DrawImage(source.InnerBitmap, new Rect(0, 0, width, height)); dc.Pop(); }
private void DrawInvalidCommand(DrawingContext context) { var origin = CaseVisibleOffset(_displayInvalidCommandOn.X, _displayInvalidCommandOn.Y); var myDoubleAnimation = new DoubleAnimation(); myDoubleAnimation.From = 1.0; myDoubleAnimation.To = 0.0; myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(3)); context.PushOpacity(1.0, myDoubleAnimation.CreateClock()); context.DrawRectangle(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#55FF2B2B")), null, new Rect(origin.Item1, origin.Item2, CaseWidth, CaseHeight)); context.Pop(); }
// Render override -- we render the selection here. protected override void OnRender(DrawingContext drawingContext) { if (_selectionGeometry != null) { FrameworkElement owner = GetOwnerElement(); Brush selectionBrush = (Brush)owner.GetValue(TextBoxBase.SelectionBrushProperty); if (selectionBrush == null) { return; } double selectionOpacity = (double)owner.GetValue(TextBoxBase.SelectionOpacityProperty); drawingContext.PushOpacity(selectionOpacity); Pen selectionOutlinePen = null; drawingContext.DrawGeometry(selectionBrush, selectionOutlinePen, _selectionGeometry); drawingContext.Pop(); } }
private void DrawMapPosition(DrawingContext context) { var myDoubleAnimation = new DoubleAnimation(); myDoubleAnimation.From = 1.0; myDoubleAnimation.To = 0.0; myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(3)); context.PushOpacity(1.0, myDoubleAnimation.CreateClock()); context.DrawRectangle(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF2B2B2B")), null, new Rect(702, 10, 248, 64)); var relativePositions = RelativePositions(); var position = new FormattedText( relativePositions.Item1.ToString() + "% / " + relativePositions.Item2.ToString() + "%", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Charlemagne STD"), 36, Brushes.PaleVioletRed); context.DrawText(position, new Point(712, 20)); }
protected override void OnRender(DrawingContext dc) { //warning : много хаков! if (_diagram == null) return; Rect actualViewport = new Rect(0, 0, ActualWidth, ActualHeight); dc.DrawRectangle(Brushes.White, null, actualViewport); Rect boundaries = _diagram.Boundaries; Rect viewport = _diagram.Viewport; double scale; double scaleX = actualViewport.Width / boundaries.Width; double scaleY = actualViewport.Height / boundaries.Height; scale = scaleX > scaleY ? scaleY : scaleX; //прямоугольник с элементами Rect viewerBoundaries = new Rect(0, 0, boundaries.Width * scale, boundaries.Height * scale); dc.DrawRectangle(Brushes.White, GlobalData.BorderPen, viewerBoundaries); //вьюпорт Vector offset = new Vector(-boundaries.Left, -boundaries.Top); Rect viewerViewport = new Rect(viewport.TopLeft, viewport.BottomRight); viewerViewport.Offset(offset.X , offset.Y); viewerViewport.Scale(scale, scale); //пересекаем RectangleGeometry geometryBoundaries = new RectangleGeometry(viewerBoundaries); RectangleGeometry geometryViewport = new RectangleGeometry(viewerViewport); CombinedGeometry geometryCombined = new CombinedGeometry(GeometryCombineMode.Exclude, geometryBoundaries, geometryViewport); SolidColorBrush brush = new SolidColorBrush(Colors.LightGray); dc.PushOpacity(0.3); dc.DrawGeometry(brush, null, geometryCombined); dc.Pop(); dc.PushTransform(new ScaleTransform(scale, scale)); dc.PushTransform(new TranslateTransform(offset.X, offset.Y)); _diagram.DrawItems(dc); dc.Pop(); dc.Pop(); }
/// <summary> /// OnRender /// </summary> protected override void OnRender(DrawingContext drawingContext) { drawingContext.PushOpacity(0.45d); //recurse through the tree of results DrawFeedback(drawingContext, _inkAnalyzer.RootNode); }
protected override void OnRender(DrawingContext dc) { dc.PushOpacity(0.7); dc.DrawRectangle(Brush, null, Bounds); dc.Pop(); }
private void RenderText(string textMessage, double opacity, DrawingContext drawingContext) { var text = new FormattedText( textMessage, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 36, Brushes.WhiteSmoke); drawingContext.PushOpacity(opacity); drawingContext.DrawText( text, new Point( _lastControlSize.Width / 2 - text.Width / 2, _lastControlSize.Height / 2 - text.Height / 2)); drawingContext.Pop(); }
/// <summary> /// Draws a mouse cursor on the adorened element /// </summary> /// <param name="drawingContext"></param> protected override void OnRender(DrawingContext drawingContext) { GeneralTransform inverse = elementTransform.Inverse; if (inverse == null) return; Brush blackBrush = new SolidColorBrush(Colors.Black); blackBrush.Freeze(); float radius = 5; Pen blackPen = new Pen(blackBrush, .7); blackPen.Freeze(); if (isInPanMode) { //drawing the pan icon symbol if (panCursorImage != null) drawingContext.DrawImage(panCursorImage, new Rect(mousePoint, new Size(16, 16))); } else { // Draw the normal zooming symbol drawingContext.DrawLine(blackPen, new Point(mousePoint.X, mousePoint.Y - radius), new Point(mousePoint.X, mousePoint.Y + radius)); drawingContext.DrawLine(blackPen, new Point(mousePoint.X - radius, mousePoint.Y), new Point(mousePoint.X + radius, mousePoint.Y)); } if (lockPoints.Count >0) { foreach(ColoredPoint pt in lockPoints) if (pt.pointData.Y >= 0 && pt.pointData.Y <= canvasSize.Height) { Brush cursorBrush = new SolidColorBrush(pt.pointColor); Pen cursorPen = new Pen(cursorBrush, 0.7); cursorBrush.Freeze(); cursorPen.Freeze(); drawingContext.DrawEllipse(cursorBrush, cursorPen, pt.pointData, 4, 4); } } if (isDrawingZoomVisual) { Rect rect = new Rect(); rect.X = Math.Min(mouseDownPoint.X, mousePoint.X); rect.Y = Math.Min(mouseDownPoint.Y, mousePoint.Y); rect.Width = Math.Abs(mouseDownPoint.X - mousePoint.X); rect.Height = Math.Abs(mouseDownPoint.Y - mousePoint.Y); Brush zoomingBrush = new SolidColorBrush(Colors.LightBlue); drawingContext.PushOpacity(0.3); drawingContext.DrawRectangle(zoomingBrush, blackPen, rect); drawingContext.Pop(); } }
protected override void OnRender(DrawingContext drawingContext) { Rect adornedElementRect = new Rect(position, size); drawingContext.PushOpacity(opacity); drawingContext.DrawRectangle(SystemColors.HighlightBrush, null, adornedElementRect); }
//------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods /// <summary> /// Render override to render the composition adorner here. /// </summary> protected override void OnRender(DrawingContext drawingContext) { // Get the matrix from AdornedElement to the visual parent to get the transformed // start/end point Visual parent2d = VisualTreeHelper.GetParent(this.AdornedElement) as Visual; if (parent2d == null) { return; } GeneralTransform transform = AdornedElement.TransformToAncestor(parent2d); if (transform == null) { return; } // Please note that we do the highlight adornment for the CONVERTED text only // for Simplified Chinese IMEs. Doing this uniformly across all IMEs wasnt possible // because it was noted that some of them (viz. Japanese) werent being consistent // about this attribute. bool isChinesePinyin = chinesePinyin.Equals(InputLanguageManager.Current.CurrentInputLanguage.IetfLanguageTag); // Render the each of the composition string attribute from the attribute ranges. for (int i = 0; i < _attributeRanges.Count; i++) { DoubleCollection dashArray; // Get the composition attribute range from the attribute range lists AttributeRange attributeRange = (AttributeRange)_attributeRanges[i]; // Skip the rendering composition lines if the composition line doesn't exist. if (attributeRange.CompositionLines.Count == 0) { continue; } // Set the line bold and squiggle bool lineBold = attributeRange.TextServicesDisplayAttribute.IsBoldLine ? true : false; bool squiggle = false; bool hasVirtualSelection = (attributeRange.TextServicesDisplayAttribute.AttrInfo & UnsafeNativeMethods.TF_DA_ATTR_INFO.TF_ATTR_TARGET_CONVERTED) != 0; Brush selectionBrush = null; double selectionOpacity = -1; Pen selectionPen = null; if (isChinesePinyin && hasVirtualSelection) { DependencyObject owner = _textView.TextContainer.Parent; selectionBrush = (Brush)owner.GetValue(TextBoxBase.SelectionBrushProperty); selectionOpacity = (double)owner.GetValue(TextBoxBase.SelectionOpacityProperty); } // Set the line height and cluse gap value that base on the ratio of text height double height = attributeRange.Height; double lineHeight = height * (lineBold ? BoldLineHeightRatio : NormalLineHeightRatio); double clauseGap = height * ClauseGapRatio; // Create Pen for drawing the composition lines with the specified line color Pen pen = new Pen(new SolidColorBrush(Colors.Black), lineHeight); // Set the pen style that based on IME's composition line style switch (attributeRange.TextServicesDisplayAttribute.LineStyle) { case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DOT: // Add the dot length and specify the start/end line cap as the round dashArray = new DoubleCollection(); dashArray.Add(DotLength); dashArray.Add(DotLength); pen.DashStyle = new DashStyle(dashArray, 0); pen.DashCap = System.Windows.Media.PenLineCap.Round; pen.StartLineCap = System.Windows.Media.PenLineCap.Round; pen.EndLineCap = System.Windows.Media.PenLineCap.Round; // Update the line height for the dot line. Dot line will be more thickness than // other line to show it clearly. lineHeight = height * (lineBold ? BoldDotLineHeightRatio : NormalDotLineHeightRatio); break; case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DASH: double dashLength = height * (lineBold ? BoldDashRatio : NormalDashRatio); double dashGapLength = height * (lineBold ? BoldDashGapRatio : NormalDashGapRatio); // Add the dash and dash gap legth dashArray = new DoubleCollection(); dashArray.Add(dashLength); dashArray.Add(dashGapLength); pen.DashStyle = new DashStyle(dashArray, 0); pen.DashCap = System.Windows.Media.PenLineCap.Round; pen.StartLineCap = System.Windows.Media.PenLineCap.Round; pen.EndLineCap = System.Windows.Media.PenLineCap.Round; break; case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID: pen.StartLineCap = System.Windows.Media.PenLineCap.Round; pen.EndLineCap = System.Windows.Media.PenLineCap.Round; break; case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SQUIGGLE: squiggle = true; break; } double halfLineHeight = lineHeight / 2; // Draw the each of the composition line for (int j = 0; j < attributeRange.CompositionLines.Count; j++) { CompositionLine compositionLine = (CompositionLine)attributeRange.CompositionLines[j]; // Get the start/end point for composition adorner. // Currently Text doesn't aware of the spaceroom for the drawing of the composition // adorner(like as normal/bold dot/line/squggle), so we should draw the composition adorners // to the closest area of the bottom text. Point startPoint = new Point(compositionLine.StartPoint.X + clauseGap, compositionLine.StartPoint.Y - halfLineHeight); Point endPoint = new Point(compositionLine.EndPoint.X - clauseGap, compositionLine.EndPoint.Y - halfLineHeight); // Apply composition line color which is actually the foreground of text as well pen.Brush = new SolidColorBrush(compositionLine.LineColor); // Apply matrix to start/end point // transform.TryTransform(startPoint, out startPoint); transform.TryTransform(endPoint, out endPoint); if (isChinesePinyin && hasVirtualSelection) { Rect rect = Rect.Union(compositionLine.StartRect, compositionLine.EndRect); rect = transform.TransformBounds(rect); drawingContext.PushOpacity(selectionOpacity); drawingContext.DrawRectangle(selectionBrush, selectionPen, rect); drawingContext.Pop(); } if (squiggle) { // Draw the squiggle line with using of the PathFigure and DrawGemetry. // We may revisit this logic to render the smooth squiggle line. Point pathPoint = new Point(startPoint.X, startPoint.Y - halfLineHeight); double squiggleGap = halfLineHeight; PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = pathPoint; int indexPoint = 0; while (indexPoint < ((endPoint.X - startPoint.X) / (squiggleGap))) { if (indexPoint % 4 == 0 || indexPoint % 4 == 3) { pathPoint = new Point(pathPoint.X + squiggleGap, pathPoint.Y + halfLineHeight); pathFigure.Segments.Add(new LineSegment(pathPoint, true)); } else if (indexPoint % 4 == 1 || indexPoint % 4 == 2) { pathPoint = new Point(pathPoint.X + squiggleGap, pathPoint.Y - halfLineHeight); pathFigure.Segments.Add(new LineSegment(pathPoint, true)); } indexPoint++; } PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(pathFigure); // Draw the composition line with the squiggle drawingContext.DrawGeometry(null, pen, pathGeometry); } else { drawingContext.DrawLine(pen, startPoint, endPoint); } } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary<int, IBookmark> bookmarkDict = new Dictionary<int, IBookmark>(); foreach (var bm in BookmarkManager.Bookmarks) { if (bm is BreakpointBookmark) { if (DebugInformation.CodeMappings == null || DebugInformation.CodeMappings.Count == 0 || !DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)bm).FunctionToken)) continue; } int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) bookmarkDict[line] = bm; } foreach (var bm in manager.Bookmarks) { int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) bookmarkDict[line] = bm; } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { Rect rect = new Rect(0, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) drawingContext.PushOpacity(0.5); drawingContext.DrawImage(bm.Image, rect); if (dragDropBookmark == bm && dragStarted) drawingContext.Pop(); } } if (dragDropBookmark != null && dragStarted) { Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage(dragDropBookmark.Image, rect); } } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); var bc = new BrushConverter(); var user = XIVInfoViewModel.Instance.CurrentUser; if (user == null) { return; } var origin = new Coordinate { X = (float) (ActualWidth / 2), Y = (float) (ActualHeight / 2) }; var scale = ((float) (ActualHeight / 2.0f) / 125.0f); var angle = Math.Abs(user.Heading * (180 / Math.PI) - 180); if (Settings.Default.RadarCompassMode) { var drawingGroup = new DrawingGroup { Transform = new RotateTransform { Angle = angle, CenterX = origin.X, CenterY = origin.Y } }; drawingGroup.Children.Add(new ImageDrawing(RadarIconHelper.RadarHeading, new Rect(origin.X - 64, origin.Y - 128, 128, 128))); drawingContext.DrawDrawing(drawingGroup); } else { drawingContext.DrawImage(RadarIconHelper.RadarHeading, new Rect(new Point(origin.X - 64, origin.Y - 128), new Size(128, 128))); } var sb = new StringBuilder(); var npcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentNPCs.Select(kvp => kvp.Value) .ToList()); var monsterEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentMonsters.Select(kvp => kvp.Value) .ToList()); var pcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentPCs.Select(kvp => kvp.Value) .ToList()); if (Settings.Default.FilterRadarItems) { var npcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type != Actor.Type.PC && filter.Type != Actor.Type.Monster) .ToList(); if (npcFilters.Any()) { npcEntites = RadarFilterHelper.ResolveFilteredEntities(npcFilters, npcEntites); } var monsterFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.Monster) .ToList(); if (PluginViewModel.Instance.RankedFilters.Any()) { monsterFilters.AddRange(PluginViewModel.Instance.RankedFilters); } if (monsterFilters.Any()) { monsterEntites = RadarFilterHelper.ResolveFilteredEntities(monsterFilters, monsterEntites); } var pcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.PC) .ToList(); if (pcFilters.Any()) { pcEntites = RadarFilterHelper.ResolveFilteredEntities(pcFilters, pcEntites); } } #region Resolve PCs if (Settings.Default.PCShow) { foreach (var actorEntity in pcEntites) { sb.Clear(); var fsModifier = 0; drawingContext.PushOpacity(1); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); if (Settings.Default.PCShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.PCShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.PCShowDistance) { sb.AppendFormat(" {0:N2} {1}", user.GetDistanceTo(actorEntity), ResolveHeightVariance(user, actorEntity)); } var useJob = Settings.Default.PCShowJob; if (Settings.Default.PCShowJob) { #region Get Job Icons switch (actorEntity.Job) { case Actor.Job.ACN: drawingContext.DrawImage(RadarIconHelper.Arcanist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ALC: drawingContext.DrawImage(RadarIconHelper.Alchemist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ARC: drawingContext.DrawImage(RadarIconHelper.Archer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ARM: drawingContext.DrawImage(RadarIconHelper.Armorer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.AST: drawingContext.DrawImage(RadarIconHelper.Astrologian, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BLM: drawingContext.DrawImage(RadarIconHelper.Blackmage, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BRD: drawingContext.DrawImage(RadarIconHelper.Bard, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BSM: drawingContext.DrawImage(RadarIconHelper.Blacksmith, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BTN: drawingContext.DrawImage(RadarIconHelper.Botanist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CNJ: drawingContext.DrawImage(RadarIconHelper.Conjurer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CPT: drawingContext.DrawImage(RadarIconHelper.Carpenter, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CUL: drawingContext.DrawImage(RadarIconHelper.Culinarian, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.DRG: drawingContext.DrawImage(RadarIconHelper.Dragoon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.DRK: drawingContext.DrawImage(RadarIconHelper.DarkKnight, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.FSH: drawingContext.DrawImage(RadarIconHelper.Fisher, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.GLD: drawingContext.DrawImage(RadarIconHelper.Gladiator, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.GSM: drawingContext.DrawImage(RadarIconHelper.Goldsmith, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.LNC: drawingContext.DrawImage(RadarIconHelper.Leatherworker, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.LTW: drawingContext.DrawImage(RadarIconHelper.Leatherworker, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MCH: drawingContext.DrawImage(RadarIconHelper.Machinist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MIN: drawingContext.DrawImage(RadarIconHelper.Miner, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MNK: drawingContext.DrawImage(RadarIconHelper.Monk, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MRD: drawingContext.DrawImage(RadarIconHelper.Marauder, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.NIN: drawingContext.DrawImage(RadarIconHelper.Ninja, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.PGL: drawingContext.DrawImage(RadarIconHelper.Pugilist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.PLD: drawingContext.DrawImage(RadarIconHelper.Paladin, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ROG: drawingContext.DrawImage(RadarIconHelper.Rogue, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.SCH: drawingContext.DrawImage(RadarIconHelper.Scholar, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.Unknown: if (actorEntity.OwnerID > 0 && actorEntity.OwnerID < 3758096384) { drawingContext.DrawImage(RadarIconHelper.Chocobo, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } useJob = false; break; case Actor.Job.WAR: drawingContext.DrawImage(RadarIconHelper.Warrior, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.WHM: drawingContext.DrawImage(RadarIconHelper.Whitemage, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.WVR: drawingContext.DrawImage(RadarIconHelper.Weaver, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; } #endregion } if (!useJob) { var imageSource = actorEntity.HPCurrent > 0 ? RadarIconHelper.Player : RadarIconHelper.Skull; drawingContext.DrawImage(imageSource, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.PCShowName || Settings.Default.PCShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, Int32.Parse(Settings.Default.PCFontSize) + fsModifier, (SolidColorBrush) bc.ConvertFromString(Settings.Default.PCFontColor)); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } } #endregion #region Resolve Monsters if (Settings.Default.MonsterShow) { foreach (var actorEntity in monsterEntites) { sb.Clear(); var fsModifier = 0; var fontColor = Settings.Default.MonsterFontColor; var RankB = LocaleHelper.GetRankedMonsters("B"); var RankA = LocaleHelper.GetRankedMonsters("A"); var RankS = LocaleHelper.GetRankedMonsters("S"); if (Settings.Default.MonsterShowRankColor) { if (RankA.Any(x => x.Equals(actorEntity.Name, StringComparison.InvariantCultureIgnoreCase))) { fontColor = Settings.Default.MonsterFontColorARank; fsModifier += 2; } else if (RankS.Any(x => x.Equals(actorEntity.Name, StringComparison.InvariantCultureIgnoreCase))) { fontColor = Settings.Default.MonsterFontColorSRank; fsModifier += 2; } else if (RankB.Any(x => x.Equals(actorEntity.Name, StringComparison.InvariantCultureIgnoreCase))) { fontColor = Settings.Default.MonsterFontColorBRank; fsModifier += 2; } } drawingContext.PushOpacity(1); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); ImageSource actorIcon = null; switch (actorEntity.IsFate) { case true: actorIcon = RadarIconHelper.Fate; break; case false: if (actorEntity.OwnerID > 0 && actorEntity.OwnerID < 3758096384) { actorIcon = RadarIconHelper.ChocoboPersonal; } else { actorIcon = actorEntity.IsClaimed ? RadarIconHelper.MonsterClaimed : RadarIconHelper.Monster; } break; } if (actorEntity.HPCurrent > 0) { if (actorIcon != null) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.MonsterShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.MonsterShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.MonsterShowDistance) { sb.AppendFormat(" {0:N2} {1}", user.GetDistanceTo(actorEntity), ResolveHeightVariance(user, actorEntity)); } if (Settings.Default.MonsterShowName || Settings.Default.MonsterShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, Int32.Parse(Settings.Default.MonsterFontSize) + fsModifier, (SolidColorBrush) bc.ConvertFromString(fontColor)); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } } #endregion #region Resolve NPCs, Gathering & Other foreach (var actorEntity in npcEntites) { switch (actorEntity.Type) { case Actor.Type.NPC: #region Resolve NPCs if (Settings.Default.NPCShow) { sb.Clear(); var fsModifier = 0; drawingContext.PushOpacity(1); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); if (Settings.Default.NPCShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.NPCShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.NPCShowDistance) { sb.AppendFormat(" {0:N2} {1}", user.GetDistanceTo(actorEntity), ResolveHeightVariance(user, actorEntity)); } var actorIcon = RadarIconHelper.NPC; if (actorEntity.HPCurrent > 0) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.NPCShowName || Settings.Default.NPCShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, Int32.Parse(Settings.Default.NPCFontSize) + fsModifier, (SolidColorBrush) bc.ConvertFromString(Settings.Default.NPCFontColor)); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; case Actor.Type.Gathering: #region Resolve Gathering if (Settings.Default.GatheringShow) { sb.Clear(); var fsModifier = 0; drawingContext.PushOpacity(1); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); if (Settings.Default.GatheringShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.GatheringShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.GatheringShowDistance) { sb.AppendFormat(" {0:N2} {1}", user.GetDistanceTo(actorEntity), ResolveHeightVariance(user, actorEntity)); } var actorIcon = RadarIconHelper.Wood; if (actorEntity.HPCurrent > 0) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.GatheringShowName || Settings.Default.GatheringShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, Int32.Parse(Settings.Default.GatheringFontSize) + fsModifier, (SolidColorBrush) bc.ConvertFromString(Settings.Default.GatheringFontColor)); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; default: #region Resolve Other if (Settings.Default.OtherShow) { sb.Clear(); var fsModifier = 0; drawingContext.PushOpacity(1); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale); } screen = screen.Add(-8, -8, 0); ImageSource actorIcon; switch (actorEntity.Type) { case Actor.Type.Aetheryte: actorIcon = RadarIconHelper.Crystal; break; case Actor.Type.Minion: actorIcon = RadarIconHelper.Sheep; break; default: actorIcon = RadarIconHelper.NPC; break; } if (actorEntity.HPCurrent > 0 || actorEntity.Type == Actor.Type.Aetheryte) { if (actorIcon != null) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.OtherShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.OtherShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.OtherShowDistance) { sb.AppendFormat(" {0:N2} {1}", user.GetDistanceTo(actorEntity), ResolveHeightVariance(user, actorEntity)); } if (Settings.Default.OtherShowName || Settings.Default.OtherShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, Int32.Parse(Settings.Default.OtherFontSize) + fsModifier, (SolidColorBrush) bc.ConvertFromString(Settings.Default.OtherFontColor)); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; } } #endregion }
private void DrawChip(DrawingContext drawingContext, System.Windows.Rect r, Face f) { if (f == null) { drawingContext.DrawImage(ChartView.graychip, r); //drawingContext.PushOpacity(.1); //drawingContext.DrawImage(ChartView.pinkchipBorder, r); //drawingContext.Pop(); return; } if (f.Finalized) { if (f.Gender == "m") drawingContext.DrawImage(ChartView.bluechipBorder, r); else if (f.Gender == "f") drawingContext.DrawImage(ChartView.pinkchipBorder, r); return; } drawingContext.DrawImage(ChartView.graychip, r); if (f.BetafaceReturned) { double percentColor = f.GenderTotalConf / Face.CONF_THRESH; if (f.Gender == "m") { drawingContext.PushOpacity(percentColor); drawingContext.DrawImage(ChartView.bluechip, r); drawingContext.Pop(); } else if (f.Gender == "f") { drawingContext.PushOpacity(percentColor); drawingContext.DrawImage(ChartView.pinkchip, r); drawingContext.Pop(); } } }
protected override void OnRender(DrawingContext drawingContext) { if (_suspendDraw) { RenderText(MlResources.PleaseWait, drawingContext); return; } _curveBitmaps .Where(it => it.Curve.IsVisible) .ForEachElement(it => { var renderOffset = it.Curve.GetRenderOffset(); var offScreenOffset = new Rect(50000, 50000, renderOffset.Width, renderOffset.Height); drawingContext.DrawImage(it.FrozenBitmap1, it.CurrentImageSelection == ImageSelection.Primary ? renderOffset : offScreenOffset); drawingContext.DrawImage(it.FrozenBitmap2, it.CurrentImageSelection == ImageSelection.Secondary ? renderOffset : offScreenOffset); if (_curvePool.SelectedCurve == it.Curve) { drawingContext.PushOpacity(0.4); drawingContext.DrawImage(it.FrozenSelection1, it.CurrentImageSelection == ImageSelection.Primary ? renderOffset : offScreenOffset); drawingContext.DrawImage(it.FrozenSelection2, it.CurrentImageSelection == ImageSelection.Secondary ? renderOffset : offScreenOffset); drawingContext.Pop(); } }); // Inform the Print Preview IEnumerable<AutoResetEvent> currentRefreshViewFinishedEvents; lock (_refreshViewFinishedEvents) { currentRefreshViewFinishedEvents = _refreshViewFinishedEvents.ToArray(); _refreshViewFinishedEvents.Clear(); } currentRefreshViewFinishedEvents.ForEachElement(it => it.Set()); }
protected override void OnRender(DrawingContext dc) { base.OnRender(dc); var height = base.ActualHeight - ReservedSpace; var tickRange = Maximum - Minimum; var tickCount = (int)(tickRange / TickFrequency) + 1; var labels = TickLabels.Split(','); if (labels.Length != tickCount) return; FontFamily fontFamily = new FontFamily("Segoe UI"); var fontPointSize = FontSize; var fontHeight = Math.Ceiling(fontPointSize * fontFamily.LineSpacing); var typeface = new Typeface("Segoe"); var cultureInfo = CultureInfo.GetCultureInfo(Language.IetfLanguageTag); var verticalOffset = ReservedSpace / 2 - fontHeight / 2; var tickSpacing = height * this.TickFrequency / tickRange; dc.PushOpacity(TickLabelsOpacity); for (var i = 0; i < tickCount; ++i) { var formattedText = new FormattedText(labels[i], cultureInfo, FlowDirection.RightToLeft, typeface, fontPointSize, Fill); var y = verticalOffset + height - (i * tickSpacing); dc.DrawText(formattedText, new Point(TickLabelsOffset, y)); } dc.Pop(); }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark var bookmarkDict = new Dictionary<int, IBookmark>(); foreach (IBookmark bm in manager.Bookmarks) { int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) bookmarkDict[line] = bm; } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { double lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset; var rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) drawingContext.PushOpacity(0.5); drawingContext.DrawImage((bm.Image ?? BookmarkBase.DefaultBookmarkImage).ImageSource, rect); if (dragDropBookmark == bm && dragStarted) drawingContext.Pop(); } } if (dragDropBookmark != null && dragStarted) { var rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage((dragDropBookmark.Image ?? BookmarkBase.DefaultBookmarkImage).ImageSource, rect); } } }
protected override void OnRender(DrawingContext drawingContext) { // Draw non-reflection controls base.OnRender(drawingContext); double halfHeight = ActualHeight / 2; // Create fading opacity mask drawingContext.PushOpacityMask(opacityMask); drawingContext.PushOpacity(0.15); // Create the reflection mirror transform. reflection.Visual = Child; ((ScaleTransform)reflection.Transform).CenterY = ActualHeight * 3/4; ((ScaleTransform)reflection.Transform).CenterX = ActualWidth / 2; // Draw the reflection visual with opacity mask applied drawingContext.DrawRectangle( reflection, null, new Rect(0, halfHeight, ActualWidth, halfHeight)); // Remove opacity masks for next drawing drawingContext.Pop(); drawingContext.Pop(); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); var user = XIVInfoViewModel.Instance.CurrentUser; var origin = new Coordinate { X = (float) (ActualWidth / 2), Y = (float) (ActualHeight / 2) }; var scale = ((float) (ActualHeight / 2.0f) / 125.0f); var angle = Math.Abs(user.Heading * (180 / Math.PI) - 180); if (Settings.Default.RadarCompassMode) { var drawingGroup = new DrawingGroup { Transform = new RotateTransform { Angle = angle, CenterX = origin.X, CenterY = origin.Y } }; drawingGroup.Children.Add(new ImageDrawing(RadarIconHelper.RadarHeading, new Rect(origin.X - 64, origin.Y - 128, 128, 128))); drawingContext.DrawDrawing(drawingGroup); } else { drawingContext.DrawImage(RadarIconHelper.RadarHeading, new Rect(new Point(origin.X - 64, origin.Y - 128), new Size(128, 128))); } var sb = new StringBuilder(); var npcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentNPCs.ToList()); var monsterEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentMonsters.ToList()); var pcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentPCs.ToList()); #region Resolve PCs if (Settings.Default.PCShow) { foreach (var actorEntity in pcEntites) { sb.Clear(); var opacityLevel = (actorEntity.Coordinate.Z / XIVInfoViewModel.Instance.CurrentUser.Coordinate.Z); var fsModifier = ResolveFontSize(opacityLevel); opacityLevel = opacityLevel < 0.5 ? 0.5 : opacityLevel > 1 ? 1 : opacityLevel; drawingContext.PushOpacity(opacityLevel); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); if (Settings.Default.PCShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.PCShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.PCShowDistance) { sb.AppendFormat(" {0:N2}", XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(actorEntity)); } var useJob = Settings.Default.PCShowJob; if (Settings.Default.PCShowJob) { #region Get Job Icons switch (actorEntity.Job) { case Actor.Job.ACN: drawingContext.DrawImage(RadarIconHelper.Arcanist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ALC: drawingContext.DrawImage(RadarIconHelper.Alchemist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ARC: drawingContext.DrawImage(RadarIconHelper.Archer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.ARM: drawingContext.DrawImage(RadarIconHelper.Armorer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BLM: drawingContext.DrawImage(RadarIconHelper.Blackmage, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BRD: drawingContext.DrawImage(RadarIconHelper.Bard, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BSM: drawingContext.DrawImage(RadarIconHelper.Blacksmith, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.BTN: drawingContext.DrawImage(RadarIconHelper.Botanist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CNJ: drawingContext.DrawImage(RadarIconHelper.Conjurer, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CPT: drawingContext.DrawImage(RadarIconHelper.Carpenter, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.CUL: drawingContext.DrawImage(RadarIconHelper.Culinarian, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.Chocobo: drawingContext.DrawImage(RadarIconHelper.Chocobo, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.DRG: drawingContext.DrawImage(RadarIconHelper.Dragoon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.FSH: drawingContext.DrawImage(RadarIconHelper.Fisher, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.GLD: drawingContext.DrawImage(RadarIconHelper.Gladiator, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.GSM: drawingContext.DrawImage(RadarIconHelper.Goldsmith, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.LNC: drawingContext.DrawImage(RadarIconHelper.Leatherworker, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.LTW: drawingContext.DrawImage(RadarIconHelper.Leatherworker, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MIN: drawingContext.DrawImage(RadarIconHelper.Miner, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MNK: drawingContext.DrawImage(RadarIconHelper.Monk, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.MRD: drawingContext.DrawImage(RadarIconHelper.Marauder, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.PGL: drawingContext.DrawImage(RadarIconHelper.Pugilist, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.PLD: drawingContext.DrawImage(RadarIconHelper.Paladin, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.Pet: drawingContext.DrawImage(RadarIconHelper.Sheep, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.SCH: drawingContext.DrawImage(RadarIconHelper.Scholar, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.Unknown: useJob = false; break; case Actor.Job.WAR: drawingContext.DrawImage(RadarIconHelper.Warrior, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.WHM: drawingContext.DrawImage(RadarIconHelper.Whitemage, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; case Actor.Job.WVR: drawingContext.DrawImage(RadarIconHelper.Weaver, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); break; } #endregion } if (!useJob) { var imageSource = actorEntity.HPCurrent > 0 ? RadarIconHelper.Player : RadarIconHelper.Skull; drawingContext.DrawImage(imageSource, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.PCShowName || Settings.Default.PCShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, 12 + fsModifier, Brushes.White); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } } #endregion #region Resolve Monsters if (Settings.Default.MonsterShow) { foreach (var actorEntity in monsterEntites) { sb.Clear(); var opacityLevel = (actorEntity.Coordinate.Z / XIVInfoViewModel.Instance.CurrentUser.Coordinate.Z); var fsModifier = ResolveFontSize(opacityLevel); opacityLevel = opacityLevel < 0.5 ? 0.5 : opacityLevel > 1 ? 1 : opacityLevel; drawingContext.PushOpacity(opacityLevel); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); ImageSource actorIcon = null; var brush = Brushes.Red; switch (actorEntity.IsFate) { case true: actorIcon = RadarIconHelper.Fate; break; case false: actorIcon = actorEntity.IsClaimed ? RadarIconHelper.MonsterClaimed : RadarIconHelper.Monster; break; } if (actorEntity.HPCurrent > 0) { if (actorIcon != null) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.MonsterShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.MonsterShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.MonsterShowDistance) { sb.AppendFormat(" {0:N2}", XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(actorEntity)); } if (Settings.Default.MonsterShowName || Settings.Default.MonsterShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, 12 + fsModifier, brush); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } } #endregion #region Resolve NPCs, Gathering & Other foreach (var actorEntity in npcEntites) { switch (actorEntity.Type) { case Actor.Type.NPC: #region Resolve NPCs if (Settings.Default.NPCShow) { sb.Clear(); var opacityLevel = (actorEntity.Coordinate.Z / XIVInfoViewModel.Instance.CurrentUser.Coordinate.Z); var fsModifier = ResolveFontSize(opacityLevel); opacityLevel = opacityLevel < 0.5 ? 0.5 : opacityLevel > 1 ? 1 : opacityLevel; drawingContext.PushOpacity(opacityLevel); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); var brush = Brushes.LimeGreen; if (Settings.Default.NPCShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.NPCShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.NPCShowDistance) { sb.AppendFormat(" {0:N2}", XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(actorEntity)); } var actorIcon = RadarIconHelper.NPC; if (actorEntity.HPCurrent > 0) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.NPCShowName || Settings.Default.NPCShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, 12 + fsModifier, brush); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; case Actor.Type.Gathering: #region Resolve Gathering if (Settings.Default.GatheringShow) { sb.Clear(); var opacityLevel = (actorEntity.Coordinate.Z / XIVInfoViewModel.Instance.CurrentUser.Coordinate.Z); var fsModifier = ResolveFontSize(opacityLevel); opacityLevel = opacityLevel < 0.5 ? 0.5 : opacityLevel > 1 ? 1 : opacityLevel; drawingContext.PushOpacity(opacityLevel); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale) .Add(origin); } screen = screen.Add(-8, -8, 0); var brush = Brushes.Orange; if (Settings.Default.GatheringShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.GatheringShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.GatheringShowDistance) { sb.AppendFormat(" {0:N2}", XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(actorEntity)); } var actorIcon = RadarIconHelper.Wood; if (actorEntity.HPCurrent > 0) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.GatheringShowName || Settings.Default.GatheringShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, 12 + fsModifier, brush); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; default: #region Resolve Other if (Settings.Default.OtherShow) { sb.Clear(); var opacityLevel = (actorEntity.Coordinate.Z / XIVInfoViewModel.Instance.CurrentUser.Coordinate.Z); var fsModifier = ResolveFontSize(opacityLevel); opacityLevel = opacityLevel < 0.5 ? 0.5 : opacityLevel > 1 ? 1 : opacityLevel; drawingContext.PushOpacity(opacityLevel); try { if (!actorEntity.IsValid || user == null) { continue; } if (actorEntity.ID == user.ID) { continue; } Coordinate screen; if (Settings.Default.RadarCompassMode) { var coord = user.Coordinate.Subtract(actorEntity.Coordinate) .Scale(scale); screen = new Coordinate(-coord.X, 0, -coord.Y).Add(origin); } else { screen = user.Coordinate.Subtract(actorEntity.Coordinate) .Rotate2D(user.Heading) .Scale(scale); } screen = screen.Add(-8, -8, 0); ImageSource actorIcon; var brush = Brushes.Yellow; switch (actorEntity.Type) { case Actor.Type.Aetheryte: actorIcon = RadarIconHelper.Crystal; break; case Actor.Type.Minion: actorIcon = RadarIconHelper.Sheep; break; default: actorIcon = RadarIconHelper.NPC; break; } if (actorEntity.HPCurrent > 0 || actorEntity.Type == Actor.Type.Aetheryte) { if (actorIcon != null) { drawingContext.DrawImage(actorIcon, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } } else { drawingContext.DrawImage(RadarIconHelper.Skull, new Rect(new Point(screen.X, screen.Y), new Size(16, 16))); } if (Settings.Default.OtherShowName) { sb.Append(actorEntity.Name); } if (Settings.Default.OtherShowHPPercent) { sb.AppendFormat(" {0:P0}", actorEntity.HPPercent); } if (Settings.Default.OtherShowDistance) { sb.AppendFormat(" {0:N2}", XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(actorEntity)); } if (Settings.Default.OtherShowName || Settings.Default.OtherShowHPPercent) { var label = new FormattedText(sb.ToString(), _cultureInfo, _flowDirection, _typeface, 12 + fsModifier, brush); drawingContext.DrawText(label, new Point(screen.X + 20, screen.Y)); } } catch (Exception ex) { Logging.Log(Logger, ex.Message); } drawingContext.Pop(); } #endregion break; } } #endregion }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); int maxX = this.HorizontalPositionConverter.GetMaxImagePosition(); int maxY = this.VerticalPositionConverter.GetMaxImagePosition(); double maxXView = this.HorizontalPositionConverter.GetMaxViewPosition(); double maxYView = this.VerticalPositionConverter.GetMaxViewPosition(); // FIXME: sorting everytime is slow. int[] xSplitPosArray = ImageViewModel.HorizontalSplitPositionBarViewModel.GetPositionArraySorted(); int[] ySplitPosArray = ImageViewModel.VerticalSplitPositionBarViewModel.GetPositionArraySorted(); // render lines Pen pen = new Pen(); pen.Brush = Brushes.Red; pen.Thickness = 1; foreach (int x in xSplitPosArray) { double xView = this.HorizontalPositionConverter.ConvertImagePositionToViewPosition(x); drawingContext.DrawLine(pen, new Point(xView, 0), new Point(xView, maxYView)); } foreach (int y in ySplitPosArray) { double yView = this.HorizontalPositionConverter.ConvertImagePositionToViewPosition(y); drawingContext.DrawLine(pen, new Point(0, yView), new Point(maxXView, yView)); } int i = 1; foreach (PointInt point in ImageViewModel.MarkedPointList) { int x = point.X; int y = point.Y; Int32Rect? markedRegion = Util.SearchRegionFromArray(x, y, xSplitPosArray, ySplitPosArray, maxX, maxY); if (markedRegion.HasValue) { double xView = this.HorizontalPositionConverter.ConvertImagePositionToViewPosition(x); double yView = this.VerticalPositionConverter.ConvertImagePositionToViewPosition(y); // marked point cursor drawingContext.DrawEllipse(Brushes.Red, null, new Point(xView, yView), 3.0, 3.0); // number FormattedText ft = new FormattedText( String.Format("({0})", i), System.Globalization.CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 16, // font size Brushes.Red); Rect rect = ImagePositionRectToViewPointRect(markedRegion.Value); drawingContext.DrawText(ft, new Point(rect.X + rect.Width / 2 - ft.Width / 2, rect.Y + rect.Height / 2 - ft.Height / 2)); // region color drawingContext.PushOpacity(0.5); drawingContext.DrawRectangle(Brushes.LightSalmon, null, rect); drawingContext.Pop(); i++; } } int curPosX = ImageViewModel.CurrentPositon.X; int curPosY = ImageViewModel.CurrentPositon.Y; // if y < 0 or x < 0, the cursor is on the vertical/horizontal bar if ((curPosY < 0 || curPosX < 0) && !(curPosX < 0 && curPosY < 0)) { if (this.ImageViewModel.ShowCursorLine) { Pen cursorLinePen = new Pen(); cursorLinePen.Brush = Brushes.Green; cursorLinePen.Thickness = 1; if (curPosX < maxX && curPosY < 0) { double xView = this.HorizontalPositionConverter.ConvertImagePositionToViewPosition(curPosX); drawingContext.DrawLine(cursorLinePen, new Point(xView, 0), new Point(xView, maxYView)); } else if (curPosX < 0 && curPosY < maxY) { double yView = this.VerticalPositionConverter.ConvertImagePositionToViewPosition(curPosY); drawingContext.DrawLine(cursorLinePen, new Point(0, yView), new Point(maxXView, yView)); } } } else { Int32Rect? cursorRegion = Util.SearchRegionFromArray( curPosX, curPosY, xSplitPosArray, ySplitPosArray, maxX, maxY); if (cursorRegion.HasValue) { drawingContext.PushOpacity(0.5); drawingContext.DrawRectangle(Brushes.LightGreen, null, ImagePositionRectToViewPointRect(cursorRegion.Value)); drawingContext.Pop(); } } }