Ejemplo n.º 1
0
        /// <summary>
        /// Add a Vector to the VectorLines list.
        /// Each vector has a tooltip and MouseEnter/MouseLeave events
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void AddVector(double x, double y)
        {
            DWVector        vector = VectorMath.GetNewVectorLocation(IHat, JHat, x, y);
            SolidColorBrush color  = PickRandomColor();

            DWLine vectorLine = new DWLine
                                (
                x, y, LineType.VECTOR,
                new Line
            {
                Stroke = color,
                X1     = CanvasXOrigin,
                Y1     = CanvasYOrigin,
                X2     = CanvasXOrigin + (vector.X * UnitLength),
                Y2     = CanvasYOrigin - (vector.Y * UnitLength)
            }, color
                                );

            vectorLine.Line.ToolTip = $"X: {vectorLine.X}\nY: {vectorLine.Y}";

            vectorLine.Line.MouseEnter += MouseEnterVectorHighlight;
            vectorLine.Line.MouseLeave += MouseLeaveVectorHighlight;

            VectorLines.Add(vectorLine);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the static gridlines to VectorLines list.
        /// They are created active as default, but the optional param can set this to false
        /// </summary>
        /// <param name="isactive"></param>
        public void AddStaticGridLines(bool isactive = true)
        {
            SolidColorBrush color = Brushes.Gray;

            for (int i = 0; i <= MaxSize * 2; i++)
            {
                DWLine xline = new DWLine
                               (
                    i, 1, LineType.GRIDORIG,
                    new Line
                {
                    Stroke          = color,
                    StrokeThickness = 0.3,
                    X1 = UnitLength * i,
                    Y1 = 0,
                    X2 = UnitLength * i,
                    Y2 = CanvasHeight
                },
                    color,
                    isactive
                               );

                DWLine yline = new DWLine
                               (
                    1, i, LineType.GRIDORIG,
                    new Line
                {
                    Stroke          = color,
                    StrokeThickness = 0.3,
                    X1 = 0,
                    Y1 = UnitLength * i,
                    X2 = CanvasWidth,
                    Y2 = UnitLength * i
                },
                    color,
                    isactive
                               );

                StaticGridLines.Add(xline);
                StaticGridLines.Add(yline);
            }
        }
Ejemplo n.º 3
0
 public DWGridLine(DWVector vec1, DWVector vec2, DWLine dwline)
 {
     Vector1 = vec1;
     Vector2 = vec2;
     DWLine  = dwline;
 }