コード例 #1
0
 public bool WaitForClickPoints(double x, double y)
 {
     if (_clickedPointsPositionList.Count < _clickPoints)
     {
         var isNotTheSamePoint = _clickedPointsPositionList.Count == 0;
         var prevIdx           = _clickedPointsPositionList.Count - 1;
         var prevPoint         = prevIdx > -1 ? _clickedPointsPositionList[prevIdx] : null;
         if (prevPoint != null)
         {
             isNotTheSamePoint = Math.Abs(prevPoint.ColBegin - x) > 0 || Math.Abs(prevPoint.RowBegin - y) > 0;
         }
         if (isNotTheSamePoint)
         {
             _clickedPointsPositionList.Add(new PositionModel()
             {
                 ColBegin = x, RowBegin = y
             });
         }
     }
     _initPointsDone = _clickedPointsPositionList.Count == _clickPoints;
     if (_initPointsDone)
     {
         //3 點求圓
         var rows = _clickedPointsPositionList.Select(p => p.RowBegin).ToArray();
         var cols = _clickedPointsPositionList.Select(p => p.ColBegin).ToArray();
         GeoOperatorSet.CalculateCircleCenter(rows, cols, out midR, out midC, out radius);
         row1 = midR;
         col1 = midC + radius;
     }
     return(_initPointsDone);
 }
コード例 #2
0
        public bool WaitForClickPoints(double x, double y)
        {
            if (_clickedPointsPositionList.Count < _clickPoints)
            {
                _clickedPointsPositionList.Add(new PositionModel()
                {
                    ColBegin = x, RowBegin = y
                });
            }
            _initPointsDone = _clickedPointsPositionList.Count == _clickPoints;
            if (_initPointsDone)
            {
                //3 點求圓
                var rows = _clickedPointsPositionList.Select(p => p.RowBegin).ToArray();
                var cols = _clickedPointsPositionList.Select(p => p.ColBegin).ToArray();
                GeoOperatorSet.CalculateCircleCenter(rows, cols, out midR, out midC, out radius);

                //檢查 and notify
                _success = (midR > 0 && midC > 0 && radius > 0);
                if (_success)
                {
                    _FirstPoint = new GeoPoint()
                    {
                        Row = rows[0], Col = cols[0]
                    };
                    _SecondPoint = new GeoPoint()
                    {
                        Row = rows[1], Col = cols[1]
                    };
                    _EndPoint = new GeoPoint()
                    {
                        Row = rows[2], Col = cols[2]
                    };

                    //
                    sizeR = midR;
                    sizeC = midC - radius;

                    //toDo, 計算startPhi, extentPhi
                    // 角度為正,表示在圓心的上方,反之在下方
                    // 角度越大,表示越接近左上角,視為起始點
                    // 角度越小,視為終點
                    var agOne   = HMisc.AngleLx(midR, midC, _FirstPoint.Row, _FirstPoint.Col);
                    var agTwo   = HMisc.AngleLx(midR, midC, _SecondPoint.Row, _SecondPoint.Col);
                    var agThree = HMisc.AngleLx(midR, midC, _EndPoint.Row, _EndPoint.Col);
                    Dictionary <string, double> agDict = new Dictionary <string, double>()
                    {
                    };
                    agDict.Add("1", agOne);
                    agDict.Add("2", agTwo);
                    agDict.Add("3", agThree);

                    //逆排序,再取奇數, 即為 StartPhi, EndPhi
                    var angles = agDict.OrderByDescending(p => p.Value)
                                 .Where((p, idx) => idx % 2 == 0)
                                 .Select(p => p.Value).ToArray();
                    _startPhi = angles[0];
                    var endPhi = angles[1];

                    //計算延伸長度

                    /*
                     * 起始點在第一,二象限,則
                     */
                    _extentPhi = (_startPhi < 0) ? Math.Abs(_startPhi) - Math.Abs(endPhi)
                                                                                                : endPhi - _startPhi;
                    _pointOrder = "negative";                    //clockwise 畫弧

                    determineArcHandles();
                    updateArrowHandle();
                }
            }
            return(_initPointsDone);
        }