コード例 #1
0
ファイル: PolygonControl.xaml.cs プロジェクト: lzroc/Vixen
        /// <summary>
        /// Creates a polygon line segment.
        /// </summary>
        /// <param name="polygon">Polygon to create the line segment for</param>
        /// <param name="previousPoint">Previous polygon point</param>
        /// <param name="nextPoint">Next polygon point</param>
        private void CreatePolygonLineSegment(PolygonViewModel polygon, PolygonPointViewModel previousPoint, PolygonPointViewModel nextPoint)
        {
            PolygonLineSegment segment = new PolygonLineSegment();

            segment.Line.Visibility      = Visibility.Visible;
            segment.Line.Opacity         = 0.0;
            segment.Line.StrokeThickness = 4;
            segment.Line.Stroke          = Brushes.DodgerBlue;
            segment.Line.X1    = previousPoint.X;
            segment.Line.Y1    = previousPoint.Y;
            segment.Line.X2    = nextPoint.X;
            segment.Line.Y2    = nextPoint.Y;
            segment.StartPoint = previousPoint;
            segment.EndPoint   = nextPoint;

            canvas.Children.Add(segment.Line);
            polygon.LineSegments.Add(segment);
        }
コード例 #2
0
ファイル: PolygonControl.xaml.cs プロジェクト: lzroc/Vixen
        /// <summary>
        /// Returns true if the mouse is over a polygon line.
        /// </summary>
        /// <param name="mousePosition">Mouse position</param>
        /// <param name="polygonLineSegment">Polygon line segment the mouse is over</param>
        /// <param name="polygonParent">Polygon the line segment belongs to</param>
        /// <returns></returns>
        private bool IsMouseOverLine(Point mousePosition,
                                     // ReSharper disable once RedundantAssignment
                                     ref PolygonLineSegment polygonLineSegment,
                                     // ReSharper disable once RedundantAssignment
                                     ref PolygonViewModel polygonParent)
        {
            // Default to NOT being over a polygon line
            bool mouseOverLine = false;

            polygonLineSegment = null;
            polygonParent      = null;

            // No need to do this processing if the editor is not in
            // add polygon point mode
            if (VM.AddPoint)
            {
                // Update all the polygon lines to make sure they are accurate
                UpdatePolygonLines();

                // Loop over all the polygons
                foreach (PolygonViewModel polygon in VM.Polygons)
                {
                    // Loop over all the line segments
                    foreach (PolygonLineSegment segment in polygon.LineSegments)
                    {
                        // If the mouse is over a line then...
                        if (segment.Line.IsMouseOver)
                        {
                            // Return the line segment
                            polygonLineSegment = segment;

                            // Return the polygon which contains the line segment
                            polygonParent = polygon;

                            // Indicate that the mouse is over a polygon line segment
                            mouseOverLine = true;
                        }
                    }
                }
            }

            // Return whether the mouse is over a polygon line segment
            return(mouseOverLine);
        }