public override void Echo(TimeScaler Scaler)
        {
            using (DrawingContext dc = this.RenderOpen())
            {
                if (Line.Header != null)
                {
                    var ft = new FormattedText(Line.Header,
                        System.Globalization.CultureInfo.CurrentCulture,
                        System.Windows.FlowDirection.LeftToRight,
                        LabelTypeFace, 10, Foreground);

                    var x = Scaler.GetHorizontalOffset(Scaler.LeftDate) + 1;
                    var w = ft.Width + 4;
                    var y = Scaler.GetVerticalOffset(this.Line) + 1;
                    var h = ft.Height + 2;

                    Rect r = new Rect(x, y, w, h);
                    r = RoundRect(r);

                    var gl = new GuidelineSet();
                    AddRectToGuidlineSet(gl, r);
                    dc.PushGuidelineSet(gl);

                    dc.DrawRoundedRectangle(Background, null, r, 2, 2);

                    dc.DrawText(ft, new Point(x + 2, y + 1));

                    dc.Pop();   // GuidelineSet
                }
            }
        }
Example #2
0
 /// <summary>
 /// Добавляет в GuidelineSet значения привязок для границ прямоугольника
 /// </summary>
 /// <param name="gl">GuidelineSet для добавления</param>
 /// <param name="r">Ограничиваемый прямоугольник</param>
 /// <param name="PenThickness">Толщина границы прямоугольника</param>
 protected void AddRectToGuidlineSet(GuidelineSet gl, Rect r, Double PenThickness = 0)
 {
     gl.GuidelinesX.Add(GetGuideline(r.Left, PenThickness));
     gl.GuidelinesX.Add(GetGuideline(r.Right, PenThickness));
     gl.GuidelinesY.Add(GetGuideline(r.Top, PenThickness));
     gl.GuidelinesY.Add(GetGuideline(r.Bottom, PenThickness));
 }
Example #3
0
 /// <summary>
 ///     PushGuidelineSet -
 ///     Push a set of guidelines which will apply to all drawing operations until the
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     _drawingContext.PushGuidelineSet(
         guidelines
         );
 }
Example #4
0
 private static GuidelineSet CreateGuidelineSet(Pen pen, Rect rect)
 {
     var halfPenWidth = pen.Thickness / 2;
     var guidelines = new GuidelineSet(new[] {rect.Left - halfPenWidth, rect.Right - halfPenWidth},
                                       new [] {rect.Top - halfPenWidth, rect.Bottom - halfPenWidth});
     return guidelines;
 }
        private static void IsDynamicPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GuidelineSet target = ((GuidelineSet)d);


            target.PropertyChanged(IsDynamicProperty);
        }
        protected override void OnRender(DrawingContext drawingContext)
        {
            var fe = AdornedElement as FrameworkElement;
            if (fe == null)
            {
                return;
            }

            var rect = new Rect(1, 1, Math.Max(0, fe.ActualWidth - 2), Math.Max(0, fe.ActualHeight - 2));
            var color = Colors.Red;
            var brush = new SolidColorBrush(color);
            var pen = new Pen(brush, 1);
            pen.Freeze();

            var dashPen = new Pen(brush, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
            dashPen.Freeze();

            var guidelineSet = new GuidelineSet();
            guidelineSet.GuidelinesX.Add(0.5);
            guidelineSet.GuidelinesY.Add(0.5);

            //var outlinePen = new Pen(new SolidColorBrush(Color.FromArgb(0x70, 0xFF, 0xFF, 0xFF)), 5);
            //outlinePen.Freeze();

            drawingContext.PushGuidelineSet(guidelineSet);

            //drawingContext.DrawRectangle(null, outlinePen, rect);
            drawingContext.DrawRectangle(null, pen, rect);

            //var parent = VisualTreeHelper.GetParent(fe) as FrameworkElement;
            //if (parent != null)
            //{
            //    var thisLeft = new Point(0, fe.ActualHeight / 2);
            //    var thisRight = new Point(fe.ActualWidth, fe.ActualHeight / 2);
            //    var thisTop = new Point(fe.ActualWidth / 2, 0);
            //    var thisBottom = new Point(fe.ActualWidth / 2, fe.ActualHeight);
            //    var ancestorLeft = new Point(parent.TranslatePoint(thisLeft, fe).X, thisLeft.Y);
            //    var ancestorRight = ancestorLeft + new Vector(parent.ActualWidth, 0);
            //    var ancestorTop = new Point(thisTop.X, parent.TranslatePoint(new Point(), fe).Y);
            //    var ancestorBottom = new Point(thisBottom.X, parent.TranslatePoint(new Point(), fe).Y + parent.ActualHeight);

            //    var leftPen = fe.HorizontalAlignment == HorizontalAlignment.Left || fe.HorizontalAlignment == HorizontalAlignment.Stretch ? pen : dashPen;
            //    var rightPen = fe.HorizontalAlignment == HorizontalAlignment.Right || fe.HorizontalAlignment == HorizontalAlignment.Stretch ? pen : dashPen;
            //    var topPen = fe.VerticalAlignment == VerticalAlignment.Top || fe.VerticalAlignment == VerticalAlignment.Stretch ? pen : dashPen;
            //    var bottomPen = fe.VerticalAlignment == VerticalAlignment.Bottom || fe.VerticalAlignment == VerticalAlignment.Stretch ? pen : dashPen;

            //    drawingContext.DrawLine(leftPen, thisLeft, ancestorLeft);
            //    drawingContext.DrawLine(rightPen, thisRight, ancestorRight);
            //    drawingContext.DrawLine(topPen, thisTop, ancestorTop);
            //    drawingContext.DrawLine(bottomPen, thisBottom, ancestorBottom);
            //}

            var formattedHeight = new FormattedText(string.Format("{0:0}", fe.ActualHeight), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            var formattedWidth = new FormattedText(string.Format("{0:0}", fe.ActualWidth), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            drawingContext.DrawText(formattedHeight, new Point(rect.Width + 5, (rect.Height / 2) - (formattedHeight.Height / 2)));
            drawingContext.DrawText(formattedWidth, new Point(rect.Width / 2 - formattedWidth.Width / 2, rect.Height + 5));

            drawingContext.Pop();
        }
 /// <summary>
 ///     PushGuidelineSet -
 ///     Push a set of guidelines which should be applied
 ///     to all drawing operations until the
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     if (!IsPushNoOp())
     {
         // This Push doesn't affect the hit test, so just push the current point
         PushPointStack(_point);
     }
 }
        /// <summary>
        ///     PushGuidelineSet -
        ///     Push a set of guidelines which should be applied
        ///     to all drawing operations until the
        ///     corresponding Pop.
        /// </summary>
        /// <param name="guidelines"> The GuidelineSet to push. </param>
        public override void PushGuidelineSet(
            GuidelineSet guidelines)
        {
            // Push the guidelines type
            PushTypeStack(PushType.Guidelines);

            // Nothing else to do. Guidelines are not used,
            // so we only need to register Push() type in order to treat
            // Pop() properly.
        }
Example #9
0
        private static GuidelineSet CreateGuidelineSet(Pen pen, Rect rect)
        {
            var halfPenWidth = pen.Thickness / 2;
            var guidelines = new GuidelineSet();
            guidelines.GuidelinesX.Add(rect.Left + halfPenWidth);
            guidelines.GuidelinesX.Add(rect.Right + halfPenWidth);
            guidelines.GuidelinesY.Add(rect.Top + halfPenWidth);
            guidelines.GuidelinesY.Add(rect.Bottom + halfPenWidth);

            return guidelines;
        }
Example #10
0
        public static void DrawGuideLineLine(this DrawingContext dc, Pen pen, Point point0, Point point1)
        {
            var halfPenWidth = pen.Thickness / 2;
            var guidelines = new GuidelineSet();
            guidelines.GuidelinesX.Add(point0.X + halfPenWidth);
            guidelines.GuidelinesX.Add(point1.X + halfPenWidth);
            guidelines.GuidelinesY.Add(point0.Y + halfPenWidth);
            guidelines.GuidelinesY.Add(point1.Y + halfPenWidth);

            dc.PushGuidelineSet(guidelines);
            dc.DrawLine(pen, point0, point1);
            dc.Pop();
        }
Example #11
0
 public void DrawPoint(double x, double y)
 {
     rectPoint.X = x; rectPoint.Y = y;
     using (DrawingContext dc = this.RenderOpen())
     {
         GuidelineSet guidelines = new GuidelineSet();
         guidelines.GuidelinesX.Add(rectPoint.Left + halfPenWidth);
         guidelines.GuidelinesX.Add(rectPoint.Right + halfPenWidth);
         guidelines.GuidelinesY.Add(rectPoint.Top + halfPenWidth);
         guidelines.GuidelinesY.Add(rectPoint.Bottom + halfPenWidth);
         dc.PushGuidelineSet(guidelines);
         dc.DrawRectangle(scbBkg, null, rectPoint);
         dc.Pop();                
     }
 }
Example #12
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            Pen pen = new Pen(Brushes.Gray, 1);
            Pen penDash = new Pen(Brushes.Silver, 1) { DashStyle = DashStyles.Dash };
            Rect rect = new Rect(20, 20, 50, 60);

            double halfPenWidth = pen.Thickness / 2;

            TimeSpan StartTime = TimeSpan.FromHours(6);
            TimeSpan EndTime = TimeSpan.FromHours(24);

            GuidelineSet guidelines = new GuidelineSet();
            guidelines.GuidelinesX.Add(rect.Left + halfPenWidth);
            guidelines.GuidelinesX.Add(rect.Right + halfPenWidth);
            guidelines.GuidelinesY.Add(rect.Top + halfPenWidth);
            guidelines.GuidelinesY.Add(rect.Bottom + halfPenWidth);

            drawingContext.PushGuidelineSet(guidelines);

            TimeSpan tmpTime = StartTime;
            int drawHours = (int)EndTime.Subtract(StartTime).TotalHours;
            double segmentHeight = this.ActualHeight / drawHours;
            for (int i = 0; i < drawHours; i++)
            {
                int y = (int)(segmentHeight * i);
                drawingContext.DrawLine(pen, new Point(0, y), new Point(this.ActualWidth, y));
                int y2 = (int)(y + segmentHeight / 2);
                drawingContext.DrawLine(penDash, new Point(0, y2), new Point(this.ActualWidth, y2));
                drawingContext.DrawText(new FormattedText(
                    tmpTime.ToString(@"h\:mm"),
                    System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.RightToLeft,
                    new Typeface("Segoe UI"),
                    12,
                    Brushes.Black,
                    null,
                    TextFormattingMode.Display),new Point(this.ActualWidth, y));
                tmpTime = tmpTime.Add(TimeSpan.FromHours(1));
            }

            TimeSpan timeNow = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).Subtract(StartTime);

            double h = segmentHeight * (timeNow.TotalHours);
            drawingContext.DrawLine(new Pen(Brushes.Red, 1), new Point(0, h), new Point(this.ActualWidth, h));

            drawingContext.Pop();
        }
Example #13
0
        public GuidelineSetBlock(
            DrawingContext target,
            IEnumerable<double> xGuides = null,
            IEnumerable<double> yGuides = null)
        {
            Debug.Assert(target != null);

            _target = target;

            var guidelines = new GuidelineSet();
            {
                xGuides?.ForEach(g => guidelines.GuidelinesX.Add(g));
                yGuides?.ForEach(g => guidelines.GuidelinesY.Add(g));
            }

            target.PushGuidelineSet(guidelines);
        }
        public void UpdateVisual()
        {
            using (DrawingContext dc = base.RenderOpen())
            {
                GuidelineSet guidelines = new GuidelineSet();
                guidelines.GuidelinesX.Add(this.Offset.X);
                guidelines.GuidelinesY.Add(this.Offset.Y);
                dc.PushGuidelineSet(guidelines);

                Render.DrawingRenderer renderer = new Render.DrawingRenderer(dc);
                renderer.Begin();

                CircuitElement.Render(renderer, false);

                renderer.End();
            }
        }
Example #15
0
        public void DrawBlood(double x, double y)
        {
            rectBlood.X = x; rectBlood.Y = y;
            using (DrawingContext dc = this.RenderOpen())
            {
                halfPenWidth = (pen.Thickness * 1) / 2;
                GuidelineSet guidelines = new GuidelineSet();
                guidelines.GuidelinesX.Add(rectBlood.Left + halfPenWidth);
                guidelines.GuidelinesX.Add(rectBlood.Right + halfPenWidth);
                guidelines.GuidelinesY.Add(rectBlood.Top + halfPenWidth);
                guidelines.GuidelinesY.Add(rectBlood.Bottom + halfPenWidth);
                dc.PushGuidelineSet(guidelines);
                dc.DrawRectangle(scbBkg, null, rectBlood);
                dc.Pop();

            }
        }
Example #16
0
 public void DrawPointAndShadow(double x, double y)
 {
     rectPoint.X = x; rectPoint.Y = y;
     using (DrawingContext dc = this.RenderOpen())
     {
         GuidelineSet guidelines = new GuidelineSet();
         guidelines.GuidelinesX.Add(rectPoint.Left + halfPenWidth);
         guidelines.GuidelinesX.Add(rectPoint.Right + halfPenWidth);
         guidelines.GuidelinesY.Add(rectPoint.Top + halfPenWidth);
         guidelines.GuidelinesY.Add(rectPoint.Bottom + halfPenWidth);
         dc.PushGuidelineSet(guidelines);
         dc.DrawRectangle(scbBkg, null, rectPoint);
         dc.Pop();
         if (shadow!=null)
         dc.DrawImage(shadow, new Rect(x - 18, y - 4, shadow.PixelWidth, shadow.PixelHeight));
     }
 }
Example #17
0
        private static void GuidelineSetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children)
            // will promote the property value from a default value to a local value. This is technically a sub-property
            // change because the collection was changed and not a new collection set (GeometryGroup.Children.
            // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled
            // the default value to the compositor. If the property changes from a default value, the new local value
            // needs to be marshalled to the compositor. We detect this scenario with the second condition
            // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be
            // Default and the NewValueSource will be Local.
            if (e.IsASubPropertyChange &&
                (e.OldValueSource == e.NewValueSource))
            {
                return;
            }


            DrawingGroup target = ((DrawingGroup)d);


            GuidelineSet oldV = (GuidelineSet)e.OldValue;
            GuidelineSet newV = (GuidelineSet)e.NewValue;

            System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher;

            if (dispatcher != null)
            {
                DUCE.IResource targetResource = (DUCE.IResource)target;
                using (CompositionEngineLock.Acquire())
                {
                    int channelCount = targetResource.GetChannelCount();

                    for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
                    {
                        DUCE.Channel channel = targetResource.GetChannel(channelIndex);
                        Debug.Assert(!channel.IsOutOfBandChannel);
                        Debug.Assert(!targetResource.GetHandle(channel).IsNull);
                        target.ReleaseResource(oldV, channel);
                        target.AddRefResource(newV, channel);
                    }
                }
            }

            target.PropertyChanged(GuidelineSetProperty);
        }
Example #18
0
        internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel)
        {
            if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_DRAWINGGROUP))
            {
                Geometry vClipGeometry = ClipGeometry;
                if (vClipGeometry != null)
                {
                    ((DUCE.IResource)vClipGeometry).AddRefOnChannel(channel);
                }
                Brush vOpacityMask = OpacityMask;
                if (vOpacityMask != null)
                {
                    ((DUCE.IResource)vOpacityMask).AddRefOnChannel(channel);
                }
                Transform vTransform = Transform;
                if (vTransform != null)
                {
                    ((DUCE.IResource)vTransform).AddRefOnChannel(channel);
                }
                GuidelineSet vGuidelineSet = GuidelineSet;
                if (vGuidelineSet != null)
                {
                    ((DUCE.IResource)vGuidelineSet).AddRefOnChannel(channel);
                }

                DrawingCollection vChildren = Children;

                if (vChildren != null)
                {
                    int count = vChildren.Count;
                    for (int i = 0; i < count; i++)
                    {
                        ((DUCE.IResource)vChildren.Internal_GetItem(i)).AddRefOnChannel(channel);
                    }
                }
                AddRefOnChannelAnimations(channel);


                UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */);
            }

            return(_duceResource.GetHandle(channel));
        }
Example #19
0
        public void DrawLine(Pen p, Point startPoint, Point endPoint)
        {
#if !GRID_GUIDELINE
            double halfPenWidth = p.Thickness / 2;

            // Create a guidelines set
            System.Windows.Media.GuidelineSet guidelines = new System.Windows.Media.GuidelineSet();

            guidelines.GuidelinesX.Add(startPoint.X + halfPenWidth);
            guidelines.GuidelinesY.Add(startPoint.Y + halfPenWidth);

            g.PushGuidelineSet(guidelines);
#endif // GRID_GUIDELINE

            g.DrawLine(p, (System.Windows.Point)startPoint, (System.Windows.Point)endPoint);

#if !GRID_GUIDELINE
            g.Pop();
#endif // GRID_GUIDELINE
        }
 protected override void OnRender(DrawingContext drawingContext)
 {
     base.OnRender(drawingContext);
     Pen pen = new Pen(LineBrush, 1);
     GuidelineSet gs = new GuidelineSet();
     gs.GuidelinesX.Clear();
     gs.GuidelinesY.Clear();
     gs.GuidelinesY.Add(_lastPoint.Y - 0.5);
     gs.GuidelinesY.Add(_lastPoint.Y + 0.5);
     drawingContext.PushGuidelineSet(gs.Clone());
     drawingContext.DrawLine(pen, new Point(0, _lastPoint.Y), new Point(ActualWidth, _lastPoint.Y));
     drawingContext.PushGuidelineSet(gs.Clone());
     gs.GuidelinesX.Clear();
     gs.GuidelinesY.Clear();
     gs.GuidelinesX.Add(_lastPoint.X - 0.5);
     gs.GuidelinesX.Add(_lastPoint.X + 0.5);
     drawingContext.PushGuidelineSet(gs.Clone());
     drawingContext.DrawLine(pen, new Point(_lastPoint.X, 0), new Point(_lastPoint.X, ActualHeight));
     drawingContext.PushGuidelineSet(gs.Clone());
 }
Example #21
0
        //for linescontrol

        public static void DrawColumnLines(this FrameworkElement element, DrawingContext drawingContext, 
            double RowWidth, double xOffset,double offset,Pen pen)
        {
            double halfPenHeight = pen.Thickness / 2;
            Point start = new Point(0, 0);
            Point end = new Point(0, element.RenderSize.Height);
            
            GuidelineSet guidelines = new GuidelineSet();
            //draw column
            var count = Convert.ToInt32(element.RenderSize.Width / RowWidth);
            for (int i = 1; i <= count; i++)
            {
                start.X = xOffset - offset;
                end.X = xOffset - offset;
                guidelines.GuidelinesX = new DoubleCollection(new[] { xOffset - halfPenHeight, xOffset + halfPenHeight });
                drawingContext.PushGuidelineSet(guidelines);
                drawingContext.DrawLine(pen, start, end);
                drawingContext.Pop();
                xOffset += RowWidth;
            }
        }
Example #22
0
        internal override void ReleaseOnChannelCore(DUCE.Channel channel)
        {
            Debug.Assert(_duceResource.IsOnChannel(channel));

            if (_duceResource.ReleaseOnChannel(channel))
            {
                Geometry vClipGeometry = ClipGeometry;
                if (vClipGeometry != null)
                {
                    ((DUCE.IResource)vClipGeometry).ReleaseOnChannel(channel);
                }
                Brush vOpacityMask = OpacityMask;
                if (vOpacityMask != null)
                {
                    ((DUCE.IResource)vOpacityMask).ReleaseOnChannel(channel);
                }
                Transform vTransform = Transform;
                if (vTransform != null)
                {
                    ((DUCE.IResource)vTransform).ReleaseOnChannel(channel);
                }
                GuidelineSet vGuidelineSet = GuidelineSet;
                if (vGuidelineSet != null)
                {
                    ((DUCE.IResource)vGuidelineSet).ReleaseOnChannel(channel);
                }

                DrawingCollection vChildren = Children;

                if (vChildren != null)
                {
                    int count = vChildren.Count;
                    for (int i = 0; i < count; i++)
                    {
                        ((DUCE.IResource)vChildren.Internal_GetItem(i)).ReleaseOnChannel(channel);
                    }
                }
                ReleaseOnChannelAnimations(channel);
            }
        }
Example #23
0
        public override void Echo(TimeScaler Scaler)
        {
            //this.Opacity = 0.5;
            using (DrawingContext dc = this.RenderOpen())
            {
                var x = Scaler.GetHorizontalOffset(StartDate);
                var w = Scaler.GetWidth(EndDate - StartDate);
                var y = Scaler.GetVerticalOffset(this.Line);
                var h = Scaler.GetHeight(this.Line);

                Rect r = new Rect(x, y + h * (1 - Value), w, h * Value);
                r = RoundRect(r);

                var gl = new GuidelineSet();
                AddRectToGuidlineSet(gl, r, 0);
                dc.PushGuidelineSet(gl);

                dc.DrawRectangle(Background, null, r);

                dc.Pop();   // GuidelineSet
            }
        }
Example #24
0
       public static void DrawPoint(DrawingContext dc, Point? point,string fromColor, string toColor, double duration, bool isAutoReverse)
       {
           SolidColorBrush scbW = new SolidColorBrush(Colors.Black);
           ColorAnimation myAnimation = new ColorAnimation((Color)ColorConverter.ConvertFromString(fromColor),
                                                           (Color)ColorConverter.ConvertFromString(toColor),
                                                           new Duration(TimeSpan.FromSeconds(duration)));
           myAnimation.AutoReverse = isAutoReverse;
           myAnimation.RepeatBehavior = RepeatBehavior.Forever;
           scbW.BeginAnimation(SolidColorBrush.ColorProperty, myAnimation);
           Pen wpen = new Pen(scbW, 1);
           Rect rectW = new Rect(point.Value.X, point.Value.Y, 0.1, 0.1);
           double halfPenWidth = wpen.Thickness / 2;
           GuidelineSet guidelines = new GuidelineSet();
           guidelines.GuidelinesX.Add(rectW.Left + halfPenWidth);
           guidelines.GuidelinesX.Add(rectW.Right + halfPenWidth);
           guidelines.GuidelinesY.Add(rectW.Top + halfPenWidth);
           guidelines.GuidelinesY.Add(rectW.Bottom + halfPenWidth);
           dc.PushGuidelineSet(guidelines);

           dc.DrawRectangle(null, wpen, rectW);
           dc.Pop();
       }
        /// <summary>
        /// OnRender method.
        /// </summary>
        /// <param name="drawingContext">Drawing context.</param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (TimeAxis.ZoomMode == ZoomMode.FrameLevel)
            {
                GuidelineSet gs = new GuidelineSet();
                Pen pen = new Pen(Brushes.LightGray, 1);
                double halfPen = pen.Thickness / 2;
                
                // draw time line for each frame
                for (int i = 0; i <= ActualWidth / ViewHelper.TimespanToPixel(TimeAxis.SampleInterval, TimeAxis.ZoomScale); ++i)
                {
                    double x = ViewHelper.TimespanToPixel(TimeAxis.SampleInterval * (double)i, TimeAxis.ZoomScale);
                    gs.GuidelinesX.Clear();
                    gs.GuidelinesX.Add(x - halfPen);
                    gs.GuidelinesX.Add(x + halfPen);
                    drawingContext.PushGuidelineSet(gs.Clone());
                    drawingContext.DrawLine(pen, new Point(x, 0), new Point(x, Height));
                    drawingContext.Pop();
                }
            }
        }
Example #26
0
        public override void Echo(TimeScaler Scaler)
        {
            using (DrawingContext dc = this.RenderOpen())
            {
                var x = Scaler.GetHorizontalOffset(StartDate);
                var w = Scaler.GetWidth(EndDate - StartDate);
                var y = Scaler.GetVerticalOffset(this.Line);
                var h = Scaler.GetHeight(this.Line);
                Pen pb = new Pen(StrokeBrush ?? Background, 1);

                Rect r = new Rect(x, y, w, h);
                r = RoundRect(r);

                var gl = new GuidelineSet();
                AddRectToGuidlineSet(gl, r, pb.Thickness);
                dc.PushGuidelineSet(gl);

                dc.DrawRectangle(Background, pb, r);

                if (LabelText != null)
                {
                    var ZeroX = Scaler.GetHorizontalOffset(Scaler.LeftDate);
                    var TextX = Math.Max(x, ZeroX) + 2;

                    var ft = new FormattedText(this.LabelText,
                        System.Globalization.CultureInfo.CurrentCulture,
                        System.Windows.FlowDirection.LeftToRight,
                        LabelTypeFace, 8, Foreground);

                    if (TextX + ft.Width + 10 <= x + w)
                        dc.DrawText(ft, new Point(TextX, y + 3));
                }

                dc.Pop();   // GuidelineSet
            }
        }
Example #27
0
        public GuidelineSetBlock(
            DrawingContext target,
            Rect rect,
            double rectPenWidth = 0,
            IEnumerable<double> xGuides = null,
            IEnumerable<double> yGuides = null)
        {
            Debug.Assert(target != null);

            _target = target;

            var guidelines = new GuidelineSet();
            {
                guidelines.GuidelinesX.Add(rect.Left + rectPenWidth*0.5);
                guidelines.GuidelinesX.Add(rect.Right + rectPenWidth*0.5);
                guidelines.GuidelinesY.Add(rect.Top + rectPenWidth*0.5);
                guidelines.GuidelinesY.Add(rect.Bottom + rectPenWidth*0.5);

                xGuides?.ForEach(g => guidelines.GuidelinesX.Add(g));
                yGuides?.ForEach(g => guidelines.GuidelinesY.Add(g));
            }

            target.PushGuidelineSet(guidelines);
        }
Example #28
0
 public abstract void PushGuidelineSet(GuidelineSet set);
Example #29
0
 /// <summary>
 ///     PushGuidelineSet -
 ///     Push a set of guidelines which should be applied
 ///     to all drawing operations until the
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     // GuidelineSet does not affect hit testing, but requires a place-holder on the stack
     PushModifierStack(null);
 }
Example #30
0
        protected override void OnRender(DrawingContext dc)
        {
            if (!guidelinesFixed)
            {
                System.Windows.Media.Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
                halfDpiX = m.M11 * 0.5;
                halfDpiY = m.M22 * 0.5;
                guidelinesFixed = true;
            }

            // Create a guidelines set
            GuidelineSet guidelines = new GuidelineSet();
            guidelines.GuidelinesX.Add(halfDpiX);
            guidelines.GuidelinesY.Add(halfDpiY);
            dc.PushGuidelineSet(guidelines);

            dc.DrawRectangle(backgroundBrush, null, new Rect(0, 0, ActualWidth, ActualHeight));

            double range;
            double pos = 0;
            double orderOfMag;
            double stepSize = 0.1;

            switch (Orientation)
            {
                case RulerOrientation.Vertical:
                    //// Thin horizontal lines
                    //range = MaxY - MinY;
                    //orderOfMag = Math.Pow(10, Math.Truncate(Math.Log10(range)));
                    //stepSize = 0.1 * orderOfMag;
                    pos = (Math.Truncate(MinY / stepSize) - 0) * stepSize;
                    //DrawGridHorizonalLines(dc, pos, stepSize, gridLinePen);
                    break;
                case RulerOrientation.Horizontal:
                    // Thin vertical lines.
                    //range = MaxX - MinX;
                    //orderOfMag = Math.Pow(10, Math.Truncate(Math.Log10(range)));
                    //stepSize = 0.1 * orderOfMag;
                    pos = Math.Truncate(MinX / stepSize) * stepSize;
                    //DrawGridVerticalLines(dc, pos, stepSize, gridLinePen);

                    // Draw the seek needle
                    var needlePos = new System.Windows.Point(NeedlePosition, 0);
                    needlePos = CurveCoordsToScreen(ref needlePos);
                    dc.PushTransform(new TranslateTransform(needlePos.X, needlePos.Y));
                    dc.DrawDrawing(SeekNeedle);
                    dc.Pop();
                    break;
            }

            dc.Pop();

            switch (Orientation)
            {
                case RulerOrientation.Vertical:
                    DrawHorizontalLinesText(dc, pos, stepSize);
                    break;
                case RulerOrientation.Horizontal:
                    DrawVerticalLinesText(dc, pos, stepSize);
                    break;
            }
            base.OnRender(dc);
        }
 /// <summary>
 ///     PushGuidelineSet - 
 ///     Push a set of guidelines which will apply to all drawing operations until the 
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     _drawingContext.PushGuidelineSet(
         guidelines
         );
 }
 /// <summary>
 ///     PushGuidelineSet - 
 ///     Push a set of guidelines which should be applied
 ///     to all drawing operations until the 
 ///     corresponding Pop. 
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param> 
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     // GuidelineSet does not affect hit testing, but requires a place-holder on the stack 
     PushModifierStack(null);
 } 
Example #33
0
        protected override void OnRender(DrawingContext ctx)
        {
            base.OnRender(ctx);
            if (ctx != null)
            {
                // only solid brush is supported now
                var brush = (IsContentActive ? ActiveBorderBrush : InactiveBorderBrush) as SolidColorBrush;
                if (brush != null)
                {
                    Rect rClient = new Rect(0, 0, this.ActualWidth, this.ActualHeight);

                    var thick = BorderThickness;
                    var clientW = rClient.Width - thick.Right - thick.Left;// -1;
                    var clientH = rClient.Height - thick.Top - thick.Bottom;// -1;

                    if (clientW > 1 && clientH > 1)
                    {
                        rClient.X += thick.Left;
                        rClient.Y += thick.Top;
                        rClient.Width = clientW;
                        rClient.Height = clientH;

                        var rTop = new Rect(rClient.Left, 0, rClient.Width, thick.Top);
                        var rTopLeft = new Rect(0, 0, thick.Left, thick.Top);
                        var rTopRight = new Rect(rClient.Right, 0, thick.Right, thick.Top);

                        var rBottom = new Rect(rClient.Left, rClient.Bottom, rClient.Width, thick.Bottom);
                        var rBottomLeft = new Rect(0, rClient.Bottom, thick.Left, thick.Bottom);
                        var rBottomRight = new Rect(rClient.Right, rClient.Bottom, thick.Right, thick.Bottom);

                        var rLeft = new Rect(0, rClient.Top, thick.Left, rClient.Height);
                        var rRight = new Rect(rClient.Right, rClient.Top, thick.Right, rClient.Height);

                        var brushes = GetShadowBrushes(brush.Color);//, (thick.Top + thick.Bottom + thick.Right + thick.Left) / 4);
                        ctx.DrawRectangle(brushes[(int)BorderSide.TopLeft], null, rTopLeft);
                        ctx.DrawRectangle(brushes[(int)BorderSide.TopRight], null, rTopRight);
                        ctx.DrawRectangle(brushes[(int)BorderSide.Top], null, rTop);
                        ctx.DrawRectangle(brushes[(int)BorderSide.BottomLeft], null, rBottomLeft);
                        ctx.DrawRectangle(brushes[(int)BorderSide.BottomRight], null, rBottomRight);
                        ctx.DrawRectangle(brushes[(int)BorderSide.Bottom], null, rBottom);
                        ctx.DrawRectangle(brushes[(int)BorderSide.Left], null, rLeft);
                        ctx.DrawRectangle(brushes[(int)BorderSide.Right], null, rRight);

                        Pen borderPen = new Pen(brush, 1);

                        // from http://wpftutorial.net/DrawOnPhysicalDevicePixels.html
                        double halfPenWidth = borderPen.Thickness / 2;

                        // Create a guidelines set
                        GuidelineSet guidelines = new GuidelineSet();
                        guidelines.GuidelinesX.Add(rClient.Left + halfPenWidth);
                        guidelines.GuidelinesX.Add(rClient.Right + halfPenWidth);
                        guidelines.GuidelinesY.Add(rClient.Top + halfPenWidth);
                        guidelines.GuidelinesY.Add(rClient.Bottom + halfPenWidth);

                        ctx.PushGuidelineSet(guidelines);

                        rClient.X -= 1;
                        rClient.Y -= 1;
                        rClient.Width += 1;
                        rClient.Height += 1;
                        ctx.DrawRectangle(null, borderPen, rClient);
                        //ctx.DrawRectangle(null, new Pen(Brushes.Red, 1), rect);
                    }
                }
            }
        }
Example #34
0
 /// <summary>
 ///     PushGuidelineSet -
 ///     Push a set of guidelines which will apply to all drawing operations until the
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public abstract void PushGuidelineSet(
     GuidelineSet guidelines);
 /// <summary>
 ///     PushGuidelineSet - 
 ///     Push a set of guidelines which should be applied
 ///     to all drawing operations until the 
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     if (!IsPushNoOp())
     {
         // This Push doesn't affect the hit test, so just push the current point
         PushPointStack(_point);
     }
 }
Example #36
0
    protected override void OnRender( DrawingContext drawingContext )
    {
      if( this.ConnectionLinePen != null )
      {
        bool left = false;
        bool top = false;
        bool middle = false;

        switch( this.ConnectionLineAlignment )
        {
          case ConnectionLineAlignment.LeftToBottom:
            left = true;
            break;

          case ConnectionLineAlignment.RightToTop:
            top = true;
            break;

          case ConnectionLineAlignment.LeftToTop:
            left = true;
            top = true;
            break;

          case ConnectionLineAlignment.CenterToCenter:
            middle = true;
            break;

          case ConnectionLineAlignment.RightToBottom:
          default:
            break;
        }

        //cycling with count -1 because we don't want to draw a ligne after last item
        for( int i = 0; i < this.InternalChildren.Count - 1; i++ )
        {
          UIElement startItem = this.InternalChildren[ i ];
          UIElement endItem = this.InternalChildren[ i + 1 ];

          Vector startOffset = VisualTreeHelper.GetOffset( startItem );
          Vector endOffset = VisualTreeHelper.GetOffset( endItem );

          Size startSize = startItem.RenderSize;
          Size endSize = endItem.RenderSize;

          double startPointX = 0.0d;
          double startPointY = 0.0d;
          double endPointX = 0.0d;
          double endPointY = 0.0d;

          List<PathSegment> myPathSegments = null;

          GuidelineSet guidelineSet = new GuidelineSet();
          drawingContext.PushGuidelineSet( guidelineSet );

          if( middle == true )
          {
            startPointX = startOffset.X + startSize.Width + this.ConnectionLineOffset;

            startPointY = startOffset.Y + ( startSize.Height / 2 );

            endPointY = endOffset.Y + ( endSize.Height / 2 );

            endPointX = endOffset.X - this.ConnectionLineOffset;

            double deltaX = ( endPointX - startPointX );

            guidelineSet.GuidelinesX.Add( startPointX );
            guidelineSet.GuidelinesX.Add( startPointX + ( deltaX / 2 ) + 0.5d );
            guidelineSet.GuidelinesX.Add( startPointX + deltaX );
            guidelineSet.GuidelinesY.Add( startPointY );
            guidelineSet.GuidelinesY.Add( endPointY );

            myPathSegments = new List<PathSegment>( 4 ); //we know there are going be only 4 segments
            myPathSegments.Add( new LineSegment( new Point( startPointX, startPointY ), true ) );
            myPathSegments.Add( new LineSegment( new Point( startPointX + ( deltaX / 2 ), startPointY ), true ) );
            myPathSegments.Add( new LineSegment( new Point( startPointX + ( deltaX / 2 ), endPointY ), true ) );
            myPathSegments.Add( new LineSegment( new Point( startPointX + deltaX, endPointY ), true ) );

          }
          else
          {
            if( left == true )
            {
              startPointX = startOffset.X + this.ConnectionLineOffset;
            }
            else
            {
              startPointX = startOffset.X + startSize.Width - this.ConnectionLineOffset;
            }

            startPointY = startOffset.Y + startSize.Height;

            if( top == true )
            {
              endPointY = endOffset.Y + this.ConnectionLineOffset;
            }
            else
            {
              endPointY = endOffset.Y + endSize.Height - this.ConnectionLineOffset;
            }

            endPointX = endOffset.X;

            guidelineSet.GuidelinesX.Add( startPointX );
            guidelineSet.GuidelinesX.Add( endPointX );
            guidelineSet.GuidelinesY.Add( startPointY );
            guidelineSet.GuidelinesY.Add( endPointY );

            myPathSegments = new List<PathSegment>( 2 ); //we know there are going be only 2 segments
            myPathSegments.Add( new LineSegment( new Point( startPointX, endPointY ), true ) );
            myPathSegments.Add( new LineSegment( new Point( endPointX, endPointY ), true ) );
          }

          PathFigure myPathFigure = new PathFigure( new Point( startPointX, startPointY ), myPathSegments, false );

          PathGeometry myPathGeometry = new PathGeometry();
          myPathGeometry.Figures.Add( myPathFigure );

          drawingContext.DrawGeometry( null, this.ConnectionLinePen, myPathGeometry );

          // pop the context to remove the GuidelineSet
          drawingContext.Pop();
        }
      }

      base.OnRender( drawingContext );
    }
Example #37
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                DrawingCollection vChildren     = Children;
                Geometry          vClipGeometry = ClipGeometry;
                Brush             vOpacityMask  = OpacityMask;
                Transform         vTransform    = Transform;
                GuidelineSet      vGuidelineSet = GuidelineSet;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hClipGeometry = vClipGeometry != null ? ((DUCE.IResource)vClipGeometry).GetHandle(channel) : DUCE.ResourceHandle.Null;
                DUCE.ResourceHandle hOpacityMask  = vOpacityMask != null ? ((DUCE.IResource)vOpacityMask).GetHandle(channel) : DUCE.ResourceHandle.Null;
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }
                DUCE.ResourceHandle hGuidelineSet = vGuidelineSet != null ? ((DUCE.IResource)vGuidelineSet).GetHandle(channel) : DUCE.ResourceHandle.Null;

                // Obtain handles for animated properties
                DUCE.ResourceHandle hOpacityAnimations = GetAnimationResourceHandle(OpacityProperty, channel);

                // Store the count of this resource's contained collections in local variables.
                int ChildrenCount = (vChildren == null) ? 0 : vChildren.Count;

                // Pack & send command packet
                DUCE.MILCMD_DRAWINGGROUP data;
                unsafe
                {
                    data.Type          = MILCMD.MilCmdDrawingGroup;
                    data.Handle        = _duceResource.GetHandle(channel);
                    data.ChildrenSize  = (uint)(sizeof(DUCE.ResourceHandle) * ChildrenCount);
                    data.hClipGeometry = hClipGeometry;
                    if (hOpacityAnimations.IsNull)
                    {
                        data.Opacity = Opacity;
                    }
                    data.hOpacityAnimations = hOpacityAnimations;
                    data.hOpacityMask       = hOpacityMask;
                    data.hTransform         = hTransform;
                    data.hGuidelineSet      = hGuidelineSet;
                    data.EdgeMode           = (EdgeMode)GetValue(RenderOptions.EdgeModeProperty);
                    data.bitmapScalingMode  = (BitmapScalingMode)GetValue(RenderOptions.BitmapScalingModeProperty);
                    data.ClearTypeHint      = (ClearTypeHint)GetValue(RenderOptions.ClearTypeHintProperty);

                    channel.BeginCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_DRAWINGGROUP),
                        (int)(data.ChildrenSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for (int i = 0; i < ChildrenCount; i++)
                    {
                        DUCE.ResourceHandle resource = ((DUCE.IResource)vChildren.Internal_GetItem(i)).GetHandle(channel);;
                        channel.AppendCommandData(
                            (byte *)&resource,
                            sizeof(DUCE.ResourceHandle)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
Example #38
0
        private static void DrawPathGeometryInternal(DrawingContext dc, double half, Brush brush, Pen pen, bool isStroked, bool isFilled, PathGeometry pg)
        {
            if (!isStroked && !isFilled)
                return;

            var gs = new GuidelineSet(
                new double[]
                    {
                        pg.Bounds.TopLeft.X + half,
                        pg.Bounds.BottomRight.X + half
                    },
                new double[]
                    {
                        pg.Bounds.TopLeft.Y + half,
                        pg.Bounds.BottomRight.Y + half
                    });
            dc.PushGuidelineSet(gs);
            dc.DrawGeometry(isFilled ? brush : null, isStroked ? pen : null, pg);
            dc.Pop();
        }
Example #39
0
        private static void DrawEllipseInternal(DrawingContext dc, double half, Brush brush, Pen pen, bool isStroked, bool isFilled, ref Point center, double rx, double ry)
        {
            if (!isStroked && !isFilled)
                return;

            var gs = new GuidelineSet(
                new double[]
                    {
                        center.X - rx + half,
                        center.X + rx + half
                    },
                new double[]
                    {
                        center.Y - ry + half,
                        center.Y + ry + half
                    });
            dc.PushGuidelineSet(gs);
            dc.DrawEllipse(isFilled ? brush : null, isStroked ? pen : null, center, rx, ry);
            dc.Pop();
        }
Example #40
0
        private static void DrawRectangleInternal(DrawingContext dc, double half, Brush brush, Pen pen, bool isStroked, bool isFilled, ref Rect rect)
        {
            if (!isStroked && !isFilled)
                return;

            var gs = new GuidelineSet(
                new double[]
                    {
                        rect.TopLeft.X + half,
                        rect.BottomRight.X + half
                    },
                new double[]
                    {
                        rect.TopLeft.Y + half,
                        rect.BottomRight.Y + half
                    });
            dc.PushGuidelineSet(gs);
            dc.DrawRectangle(isFilled ? brush : null, isStroked ? pen : null, rect);
            dc.Pop();
        }
Example #41
0
        private static void DrawLineInternal(DrawingContext dc, double half, Pen pen, bool isStroked, ref Point p0, ref Point p1)
        {
            if (!isStroked)
                return;

            var gs = new GuidelineSet(
                new double[] { p0.X + half, p1.X + half },
                new double[] { p0.Y + half, p1.Y + half });
            dc.PushGuidelineSet(gs);
            dc.DrawLine(isStroked ? pen : null, p0, p1);
            dc.Pop();
        }
Example #42
0
        /// <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();
            } 
        }
Example #43
0
 /// <summary>
 ///     PushGuidelineSet -
 ///     Push a set of guidelines which will apply to all drawing operations until the
 ///     corresponding Pop.
 /// </summary>
 /// <param name="guidelines"> The GuidelineSet to push. </param>
 public override void PushGuidelineSet(
     GuidelineSet guidelines)
 {
     Debug.Assert(false);
 }