Inheritance: Shape, ILine
        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
        {
            var rect = line.GetBoundingRect(rootElement).ToSharpDX();
            //var fill = line.Fill.ToSharpDX(renderTarget, rect);
            var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);

            if (stroke == null ||
                line.StrokeThickness <= 0)
            {
                return;
            }

            //var layer = new Layer(renderTarget);
            //var layerParameters = new LayerParameters();
            //layerParameters.ContentBounds = rect;
            //renderTarget.PushLayer(ref layerParameters, layer);

            renderTarget.DrawLine(
                new DrawingPointF(
                    rect.Left + (float)line.X1,
                    rect.Top + (float)line.Y1),
                new DrawingPointF(
                    rect.Left + (float)line.X2,
                    rect.Top + (float)line.Y2),
                    stroke,
                    (float)line.StrokeThickness,
                    line.GetStrokeStyle(compositionEngine.D2DFactory));

            //renderTarget.PopLayer();
        }
Beispiel #2
0
 /// <summary>
 /// Measures the axis.
 /// </summary>
 /// <param name="availableSize">The available size.</param>
 public void MeasureAxis(Windows.Foundation.Size availableSize)
 {
     if (!double.IsInfinity(availableSize.Width) && !double.IsInfinity(availableSize.Height))
     {
         if (this.axisLine == null)
         {
             this.axisLine = this.CreateAxisLine(availableSize);
         }
         if (this.axisLine != null)
         {
             this.axisLine.X1 = this.LeftSpace;
             this.axisLine.X2 = availableSize.Width - this.RightSpace;
             double axisY = this.GetAxisY(availableSize);
             this.axisLine.Y1 = Math.Floor(axisY) + 0.5;
             double actualMinValue = this.GetActualMinValue();
             double actualMaxValue = this.GetActualMaxValue();
             if ((actualMaxValue == actualMinValue) && (actualMaxValue >= 0.0))
             {
                 this.axisLine.Y1 = Math.Floor(axisY) - 0.5;
             }
             this.axisLine.Y2 = this.axisLine.Y1;
             double zoomFactor = this.ZoomFactor;
             if (zoomFactor < 1.0)
             {
                 zoomFactor = 1.0;
             }
             this.axisLine.StrokeThickness = zoomFactor;
         }
     }
 }
        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
        {
            var rect = line.GetBoundingRect(rootElement).ToSharpDX();
            var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);

            if (stroke == null ||
                line.StrokeThickness <= 0)
            {
                return;
            }

            var layer = line.CreateAndPushLayerIfNecessary(renderTarget, rootElement);

            renderTarget.DrawLine(
                new Vector2(
                    rect.Left + (float)line.X1,
                    rect.Top + (float)line.Y1),
                new Vector2(
                    rect.Left + (float)line.X2,
                    rect.Top + (float)line.Y2),
                    stroke,
                    (float)line.StrokeThickness,
                    line.GetStrokeStyle(compositionEngine.D2DFactory));

            if (layer != null)
            {
                renderTarget.PopLayer();
                layer.Dispose();
            }
        }
Beispiel #4
0
 internal void TransFormLine(Windows.UI.Xaml.Shapes.Line line, Windows.Foundation.Size availableSize)
 {
     if (this.SparklineInfo.Setting.RightToLeft && (line != null))
     {
         line.X1 = availableSize.Width - line.X1;
         line.X2 = availableSize.Width - line.X2;
     }
 }
Beispiel #5
0
 // 連線的點
 private Windows.UI.Xaml.Shapes.Line LinkPointToLine(double x1, double y1, double x2, double y2)
 {
     Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
     line.X1 = x1;
     line.Y1 = y1;
     line.X2 = x2;
     line.Y2 = y2;
     return(line);
 }
Beispiel #6
0
 //Implement drawing a line
 public void DrawLine(double x1, double y1, double x2, double y2)
 {
     Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
     line.X1     = x1;
     line.Y1     = y1;
     line.X2     = x2;
     line.Y2     = y2;
     line.Stroke = new SolidColorBrush(Colors.DodgerBlue);
     _canvas.Children.Add(line);
 }
 // 畫線
 public void DrawLine(double x1, double y1, double x2, double y2, bool selected)
 {
     Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
     line.X1     = x1;
     line.Y1     = y1;
     line.X2     = x2;
     line.Y2     = y2;
     line.Stroke = new SolidColorBrush(selected ? Colors.Red : Colors.Black);
     _canvas.Children.Add(line);
 }
 // override IGraphics 的 DrawLine,畫 line
 public void DrawLine(Point startPoint, Point endPoint)
 {
     Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
     line.X1     = startPoint.Left;
     line.Y1     = startPoint.Top;
     line.X2     = endPoint.Left;
     line.Y2     = endPoint.Top;
     line.Stroke = new SolidColorBrush(Colors.Black);
     _canvas.Children.Add(line);
 }
Beispiel #9
0
 internal static FrameworkElement LineControlFactory(Model.Line line)
 {
     Windows.UI.Xaml.Shapes.Line lineControl = new Windows.UI.Xaml.Shapes.Line();
     lineControl.Stroke = new SolidColorBrush(Colors.Black);
     lineControl.X1     = line.Start.X;
     lineControl.Y1     = line.Start.Y;
     lineControl.X2     = line.End2.X;
     lineControl.Y2     = line.End2.Y;
     return(lineControl);
 }
Beispiel #10
0
        //
        private void DrawAndFillLine(Boundary lineBoundary)
        {
            var line = new Windows.UI.Xaml.Shapes.Line();

            line.Stroke = new SolidColorBrush(Colors.Red);
            line.X1     = lineBoundary.firstPoint.X;
            line.X2     = lineBoundary.secondPoint.X;
            line.Y1     = lineBoundary.firstPoint.Y;
            line.Y2     = lineBoundary.secondPoint.Y;
            _canvas.Children.Add(line);
        }
Beispiel #11
0
 // 畫線框
 public void DrawLineFrame(double x1, double y1, double x2, double y2)
 {
     Windows.UI.Xaml.Shapes.Line line = LinkPointToLine(x1, y1, x2, y2);
     line.Stroke          = new SolidColorBrush(Colors.Red);
     line.StrokeThickness = (int)3m;
     line.StrokeDashArray = new DoubleCollection();
     line.StrokeDashArray.Add(1);
     line.StrokeDashArray.Add((int)2m);
     DrawAnglePoint(x1, y1);
     DrawAnglePoint(x2, y2);
     _canvas.Children.Add(line);
 }
Beispiel #12
0
 // Draw Arrow
 public void DrawArrow(double x1, double y1, double x2, double y2)
 {
     Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
     line.X1               = x1;
     line.Y1               = y1;
     line.X2               = x2;
     line.Y2               = y2;
     line.Fill             = new SolidColorBrush(Colors.DeepSkyBlue);
     line.Stroke           = new SolidColorBrush(Colors.Black);
     line.StrokeEndLineCap = PenLineCap.Triangle;
     _canvas.Children.Add(line);
 }
Beispiel #13
0
 /// <summary>
 /// Resets this instance.
 /// </summary>
 public void Reset()
 {
     this.cachedMaxValue     = double.MinValue;
     this.cahcedMinValue     = double.MaxValue;
     this.cachedValues       = null;
     this.cachedDatetimes    = null;
     this.cachedIndexMapping = null;
     this.cachedMaxDatetime  = DateTime.MinValue;
     this.cachedMinDatetime  = DateTime.MaxValue;
     this.axisLine           = null;
     this._zoomfactor        = 1.0;
 }
Beispiel #14
0
 private void polerysowania_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     czyRysuje = false;
     if (rdbProsta.IsChecked == true)
     {
         listaUndo.Push(tmpKreska);
     }
     else if (rdbDowolna.IsChecked == true)
     {
         listaUndo.Push(tmpKreska);
     }
     tmpKreska = null;
 }
Beispiel #15
0
 internal List <Windows.UI.Xaml.Shapes.Line> GetLines(Windows.Foundation.Size size)
 {
     this.MeasureLines(size);
     if (this.lines != null)
     {
         Windows.UI.Xaml.Shapes.Line axisLine = base.GetAxisLine(size);
         if (axisLine != null)
         {
             this.lines.Insert(0, axisLine);
         }
     }
     return(this.lines);
 }
Beispiel #16
0
        internal override void Paint(Graphics gs, Windows.Foundation.Size avilableSize)
        {
            List <Windows.UI.Xaml.Shapes.Line> lines = this.GetLines(avilableSize);

            if (lines != null)
            {
                using (List <Windows.UI.Xaml.Shapes.Line> .Enumerator enumerator = lines.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Windows.UI.Xaml.Shapes.Line item = enumerator.Current;
                        base.TransFormLine(item, avilableSize);
                        double num1   = item.X1;
                        double num3   = item.Y1;
                        double width  = Math.Abs((double)(item.X2 - item.X1));
                        double height = Math.Abs((double)(item.Y2 - item.Y1));
                        if ((width >= 0.0) && (height >= 0.0))
                        {
                            gs.SaveState();
                            gs.MoveTo(new Windows.Foundation.Point(item.X1, item.Y1));
                            gs.LineTo(new Windows.Foundation.Point(item.X2, item.Y2));
                            gs.ApplyFillEffect(item.Stroke, new Windows.Foundation.Rect(item.X1, item.Y1, width, height), true, false);
                            gs.SetLineWidth(item.StrokeThickness);
                            gs.Stroke();
                            gs.RestoreState();
                        }
                    }
                }
            }
            List <DrawRectInfo> drawRects = base.GetDrawRects(avilableSize);

            if (drawRects != null)
            {
                foreach (DrawRectInfo info in drawRects)
                {
                    if (((info.brush != null) && (info.rect.Height > 0.0)) && (info.rect.Height > 0.0))
                    {
                        gs.SaveState();
                        Windows.Foundation.Rect rect = base.TransFormRect(info.rect, avilableSize);
                        gs.Translate(rect.Left + (rect.Width / 2.0), rect.Top + (rect.Height / 2.0));
                        gs.Rotate(-45.0);
                        rect = new Windows.Foundation.Rect(-rect.Width / 2.0, -rect.Height / 2.0, rect.Width, rect.Height);
                        gs.FillRectangle(rect, info.brush);
                        gs.RestoreState();
                    }
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// Creates the axis line.
 /// </summary>
 /// <param name="avalibleSize">The available size.</param>
 /// <returns></returns>
 public Windows.UI.Xaml.Shapes.Line CreateAxisLine(Windows.Foundation.Size avalibleSize)
 {
     if (this.SparklineInfo.Setting.DisplayXAxis && this.HasAxis)
     {
         Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
         line.X1              = this.LeftSpace;
         line.X2              = avalibleSize.Width - this.RightSpace;
         line.Y1              = this.GetAxisY(avalibleSize);
         line.Y2              = line.Y1;
         line.Stroke          = new SolidColorBrush(this.SparklineInfo.Setting.AxisColor);
         line.StrokeThickness = 1.0;
         Canvas.SetZIndex(line, this.AxisZIndex);
         return(line);
     }
     return(null);
 }
Beispiel #18
0
        // Draw Dash line
        public void DrawDashLine(double x1, double y1, double x2, double y2)
        {
            const int DASH = 10;

            Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
            line.X1              = x1;
            line.Y1              = y1;
            line.X2              = x2;
            line.Y2              = y2;
            line.Stroke          = new SolidColorBrush(Colors.Red);
            line.StrokeDashArray = new DoubleCollection()
            {
                DASH
            };
            _canvas.Children.Add(line);
        }
Beispiel #19
0
        void MeasureLines(Windows.Foundation.Size availableSize)
        {
            LineSparklineViewInfo sparklineViewInfo = base.SparklineViewInfo as LineSparklineViewInfo;

            if (sparklineViewInfo != null)
            {
                sparklineViewInfo.MeasurelinePos(availableSize);
            }
            if ((sparklineViewInfo.LinePos != null) && (sparklineViewInfo.LinePos.Count > 0))
            {
                if (this.lines == null)
                {
                    this.lines = new List <Windows.UI.Xaml.Shapes.Line>();
                }
                for (int i = 0; i < sparklineViewInfo.LinePos.Count; i++)
                {
                    Windows.UI.Xaml.Shapes.Line line;
                    Windows.Foundation.Point    p1;
                    Windows.Foundation.Point    p2;
                    Tuple <Windows.Foundation.Point, Windows.Foundation.Point> tuple = sparklineViewInfo.LinePos[i];
                    if (tuple != null)
                    {
                        line = null;
                        if (i >= this.lines.Count)
                        {
                            line = new Windows.UI.Xaml.Shapes.Line();
                            line.StrokeStartLineCap = PenLineCap.Round;
                            line.StrokeEndLineCap   = PenLineCap.Round;
                            line.Stroke             = new SolidColorBrush(this.SparklineInfo.Setting.SeriesColor);
                            double lineWeight = this.GetLineWeight();
                            line.StrokeThickness = lineWeight;
                            this.lines.Add(line);
                        }
                        else
                        {
                            line = this.lines[i];
                        }
                        p1      = tuple.Item1;
                        p2      = tuple.Item2;
                        line.X1 = p1.X;
                        line.X2 = p2.X;
                        line.Y1 = p1.Y;
                        line.Y2 = p2.Y;
                    }
                }
            }
        }
Beispiel #20
0
        private void rysujLinie(Line linia, Point po)
        {
            if (czyRysuje == true)
            {
                if (rysowanie == 2)
                {
                    linia.X1                 = punktPoczatkowy.X;
                    linia.Y1                 = punktPoczatkowy.Y;
                    linia.X2                 = po.X;
                    linia.Y2                 = po.Y;
                    linia.Stroke             = pedzel;
                    linia.StrokeThickness    = SliderThickness.Value;
                    linia.StrokeEndLineCap   = PenLineCap.Round;
                    linia.StrokeStartLineCap = PenLineCap.Round;
                    if (usunPoprzednie != null)
                    {
                        poleRysowania.Children.Remove(usunPoprzednie);
                    }
                    usunPoprzednie = linia;
                    poleRysowania.Children.Add(linia);
                    usunPoprzednie = linia;
                    listaUndo.Push(linia);
                    j++;
                }
                else if (rysowanie == 1)
                {
                    Point pktAkt = po;

                    Windows.UI.Xaml.Shapes.Line kreska = new Windows.UI.Xaml.Shapes.Line {
                        Stroke             = pedzel,
                        X2                 = pktAkt.X,
                        Y2                 = pktAkt.Y,
                        X1                 = punktPoczatkowy.X,
                        Y1                 = punktPoczatkowy.Y,
                        StrokeThickness    = SliderThickness.Value,
                        StrokeEndLineCap   = PenLineCap.Round,
                        StrokeStartLineCap = PenLineCap.Round
                    };

                    punktPoczatkowy = pktAkt;
                    poleRysowania.Children.Add(kreska);
                    listaUndo.Push(kreska);
                    j++;
                }
            }
        }
Beispiel #21
0
        internal virtual void Paint(Graphics gs, Windows.Foundation.Size avilableSize)
        {
            List <DrawRectInfo> drawRects = this.GetDrawRects(avilableSize);

            if (drawRects != null)
            {
                foreach (DrawRectInfo info in drawRects)
                {
                    if (info.brush != null)
                    {
                        Windows.Foundation.Rect rect  = info.rect;
                        Windows.Foundation.Rect rect2 = this.TransFormRect(new Windows.Foundation.Rect(rect.X + (rect.Width / 4.0), rect.Y, rect.Width / 2.0, rect.Height), avilableSize);
                        gs.SaveState();
                        gs.FillRectangle(rect2, info.brush);
                        gs.RestoreState();
                    }
                }
            }
            Windows.UI.Xaml.Shapes.Line axisLine = this.GetAxisLine(avilableSize);
            if (axisLine != null)
            {
                double num1   = axisLine.X1;
                double num3   = axisLine.Y1;
                double width  = Math.Abs((double)(axisLine.X2 - axisLine.X1));
                double height = Math.Abs((double)(axisLine.Y2 - axisLine.Y1));
                if ((width >= 0.0) && (height >= 0.0))
                {
                    gs.SaveState();
                    gs.MoveTo(new Windows.Foundation.Point(axisLine.X1, axisLine.Y1));
                    gs.LineTo(new Windows.Foundation.Point(axisLine.X2, axisLine.Y2));
                    gs.ApplyFillEffect(axisLine.Stroke, new Windows.Foundation.Rect(axisLine.X1, axisLine.Y1, width, height), true, false);
                    gs.SetLineWidth(axisLine.StrokeThickness);
                    gs.Stroke();
                    gs.RestoreState();
                }
            }
        }
Beispiel #22
0
        private void RysujLinie(PointerRoutedEventArgs e)
        {
            if (czyRysuje)
            {
                Point pktAkt = e.GetCurrentPoint(polerysowania).Position;

                Line kreska = new Line()
                {
                    Stroke          = pisak,
                    StrokeThickness = sldGrubość.Value,
                    X2 = pktAkt.X,
                    Y2 = pktAkt.Y,
                    //teraz poczatek lini
                    X1 = pktStartowy.X,
                    Y1 = pktStartowy.Y,
                    StrokeEndLineCap   = PenLineCap.Round,
                    StrokeStartLineCap = PenLineCap.Round
                };

                polerysowania.Children.Add(kreska);

                if (rdbProsta.IsChecked == true)
                {
                    if (tmpKreska != null)
                    {
                        polerysowania.Children.Remove(tmpKreska);
                    }
                    tmpKreska = kreska;
                }
                else if (rdbDowolna.IsChecked == true)
                {
                    pktStartowy = pktAkt;
                    tmpKreska   = kreska;
                }
            }
        }
Beispiel #23
0
 private void DoDraw(Windows.Foundation.Point[] points)
 {
     for (int i = 1; i < points.Length; i++)
     {
         Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line();
         line.Stroke = new SolidColorBrush(Colors.Red);
         line.StrokeThickness = 5;
         line.X1 = points[i - 1].X * DrawCanvas.ActualWidth;
         line.Y1 = points[i - 1].Y * DrawCanvas.ActualHeight;
         line.X2 = points[i].X * DrawCanvas.ActualWidth;
         line.Y2 = points[i].Y * DrawCanvas.ActualHeight;
         DrawCanvas.Children.Add(line);   
     }   
 }
Beispiel #24
0
 // 畫線
 public void DrawLine(double x1, double y1, double x2, double y2)
 {
     Windows.UI.Xaml.Shapes.Line line = LinkPointToLine(x1, y1, x2, y2);
     line.Stroke = new SolidColorBrush(Colors.Black);
     _canvas.Children.Add(line);
 }
        /// <summary>
        /// Returns a grid containing line with exact length and in the rotation specified for LiDAR Map.
        /// </summary>
        /// <param name="Angle">Angle to be map</param>
        /// <param name="Distance">Distance to be map on specified angle</param>
        /// <returns>Returns the grid that contain line and an ellipse that will exactly of length 'Distance' on specified 'Angle'.</returns>
        public static Grid GetMapper(double Angle, int Distance)
        {
            /* Create a new composite transform for Rotation and set angle */
            _CompositeTransform = new CompositeTransform();
            _CompositeTransform.Rotation = Angle;

            /* Crete new grid object and apply transformation */
            _Grid = new Grid();
            _Grid.RenderTransform = _CompositeTransform;

            /* <RowDefination Height="Auto"/> */
            _RowDefination = new RowDefinition();
            _RowDefination.Height = GridLength.Auto;
            _Grid.RowDefinitions.Add(_RowDefination);

            /* <RowDefination Height="*"/> */
            _RowDefination = new RowDefinition();
            _Grid.RowDefinitions.Add(_RowDefination);

            _Grid.HorizontalAlignment = HorizontalAlignment.Center;
            _Grid.VerticalAlignment = VerticalAlignment.Bottom;

            _Grid.RenderTransformOrigin = new Windows.Foundation.Point(0, 1);

            /* Ellipse is the point that will be mapped on the specified distance from the origin */
            _Ellipse = new Ellipse();
            _Ellipse.Height = 3;
            _Ellipse.Width = 3;
            _Ellipse.RenderTransformOrigin = new Windows.Foundation.Point(0, 0);
            _Ellipse.Margin = new Thickness(-3, 0, -3, 0);

            /* Apply different color for different region like < 50cm will be red and so on */
            if(Distance < 50)
            {
                _Ellipse.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
            }
            else if(Distance < 100)
            {
                _Ellipse.Fill = new SolidColorBrush(Color.FromArgb(255, 200, 100, 0));
            }
            else
            {
                _Ellipse.Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
            }

            /* Add ellipse in Grid.Row=0 & Grid.Column=0 */
            _Grid.Children.Add(_Ellipse);

            /* Create new object of line*/
            _Line = new Line();

            /* Add line in Grid.Row=1 & Grid.Column=0 */
            Grid.SetRow(_Line, 1);

            /* Specify line starting and ending point */
            _Line.X1 = 0;
            _Line.X2 = 0;
            _Line.Y1 = Distance + 3;
            _Line.Y2 = 0;

            /* Line thickness. Set to ZERO if not needed */
            _Line.StrokeThickness = 0;
            _Line.Stroke = _Ellipse.Fill;

            /* Add line to grid created above */
            _Grid.Children.Add(_Line);

            /* Return the complete grid back so that it will be plotted */
            return _Grid;
        }
        /// <summary>
        /// Called when a sprite is deleted to clean up resources
        /// </summary>
        public void Cleanup()
        {
            this.ManipulationStarted -= (sprite_ManipulationStarted);
            this.ManipulationDelta -= (sprite_ManipulationDelta);
            this.ManipulationCompleted -= (sprite_ManipulationCompleted);

            if (_lineShowSpring != null)
            {
                _physicsCanvas.Children.Remove(_lineShowSpring);
                _lineShowSpring = null;
            }

            CleanupCollisionHandler();
        }