Beispiel #1
0
        /// <summary>
        /// 点の追加(ボタンver)
        /// </summary>
        public void AddPoint()
        {
            var         LastCnt         = m_list.Count() - 1;
            BezierPoint startBezirPoint = new BezierPoint();
            const int   ofsetX          = 30;

            //
            startBezirPoint.startPoint = new Point(Math.Min(m_list[LastCnt].startPoint.X + ofsetX, ScrrenRightPosX - 1), m_list[LastCnt].startPoint.Y);
            startBezirPoint.endPoint   = new Point(m_list[LastCnt].endPoint.X, m_list[LastCnt].endPoint.Y);
            //制御点は追加される開始点の少し右に生成させる
            var cpointX = CMath.Clamp(startBezirPoint.startPoint.X + 10, ScrrenLeftPosX, ScrrenRightPosX - 1);

            startBezirPoint.controlPoint1 = new Point(cpointX, m_list[LastCnt].startPoint.Y + 30);
            startBezirPoint.controlPoint2 = new Point(cpointX, m_list[LastCnt].startPoint.Y - 30);
            m_list.Add(startBezirPoint);//新しい点追加

            //追加前の最後の終了点を追加した最後の開始点とつなげる ここ大事!
            BezierPoint BezirPoint = new BezierPoint();

            BezirPoint          = m_list[LastCnt];
            BezirPoint.endPoint = m_list[LastCnt + 1].startPoint;//繋ぎなおす
            m_list[LastCnt]     = BezirPoint;
            //増やした点を選択状態に
            m_SelectPoint = LastCnt + 1;
        }
Beispiel #2
0
        /// <summary>
        ///    制御点2Xセット
        /// </summary>
        /// <param name="y"></param>
        public int SetControl2PointX(int x)
        {
            if (m_SelectMode == SelectMode.None)
            {
                return(0);
            }

            BezierPoint sp = m_list[m_SelectPoint]; //選択している点

            sp.controlPoint2.X = CMath.Clamp(x, ScrrenLeftPosX, ScrrenRightPosX);

            //一番最初の開始点以外を選択しているなら
            if (!isSelectFirstStartPoint())
            {
                int minpx = m_list[m_SelectPoint - 1].endPoint.X + ControlOfSetX;
                sp.controlPoint2.X = CMath.Clamp(sp.controlPoint2.X, minpx, ScrrenRightPosX);
            }

            //一番最後の終了点以外を選択しているなら
            if (!isSelectLastEndPoint())
            {
                int maxpx = m_list[m_SelectPoint + 1].startPoint.X - ControlOfSetX;
                sp.controlPoint2.X = CMath.Clamp(sp.controlPoint2.X, ScrrenLeftPosX, maxpx);
            }
            m_list[m_SelectPoint] = sp;

            return(sp.controlPoint2.X);
        }
Beispiel #3
0
        /// <summary>
        ///    開始点セット
        /// </summary>
        /// <param name="y"></param>
        public int SetStartPointX(int x)
        {
            BezierPoint sp = m_list[m_SelectPoint]; //最初の点

            if (isSelectFirstStartPoint())
            {
                return(0);
            }
            if (m_SelectMode == SelectMode.None)
            {
                return(0);
            }

            var BeforeSelectPoint = m_SelectPoint - 1;
            //X軸の移動 intervalPointPosを加算減算すること隣の点と同じ座標にならないようにする
            int minpx = m_list[BeforeSelectPoint].startPoint.X + intervalPointPos;
            int maxpx = sp.endPoint.X - intervalPointPos;

            sp.startPoint.X = CMath.Clamp(x, minpx, maxpx);
            //ひとつ前の終了点の移動
            BezierPoint sp2 = m_list[BeforeSelectPoint];

            sp2.endPoint = sp.startPoint;
            m_list[BeforeSelectPoint] = sp2;

            m_list[m_SelectPoint] = sp;
            return(x);
        }
Beispiel #4
0
        /// <summary>
        /// 点の追加(ダブルクリックVer)
        /// </summary>
        /// <param name="p"></param>
        public void AddPoint(Point p)
        {
            var         SelectNum       = SearchSelectStartPoint(p);//何番目の点になるか
            BezierPoint startBezirPoint = new BezierPoint();
            const int   ofsetY          = 30;

            startBezirPoint.startPoint = new Point(Math.Min(p.X, ScrrenRightPosX - 1), CMath.Clamp(p.Y, ScrrenTopPosY, ScrrenBottomPosY));
            startBezirPoint.endPoint   = new Point(m_list[SelectNum].endPoint.X, m_list[SelectNum].endPoint.Y);
            //制御点は追加される開始点の少し右に生成させる
            var cpointX = CMath.Clamp(startBezirPoint.startPoint.X + 10, ScrrenLeftPosX + ControlOfSetX, ScrrenRightPosX - ControlOfSetX);

            startBezirPoint.controlPoint1 = new Point(cpointX, CMath.Clamp(startBezirPoint.startPoint.Y + ofsetY, ScrrenTopPosY, ScrrenBottomPosY));
            startBezirPoint.controlPoint2 = new Point(cpointX, CMath.Clamp(startBezirPoint.startPoint.Y - ofsetY, ScrrenTopPosY, ScrrenBottomPosY));

            m_list.Insert(SelectNum + 1, startBezirPoint);//新しい点追加

            //追加前の最後の終了点を追加した最後の開始点とつなげる ここ大事!
            BezierPoint BezirPoint = new BezierPoint();

            BezirPoint          = m_list[SelectNum];
            BezirPoint.endPoint = m_list[SelectNum + 1].startPoint;//繋ぎなおす
            m_list[SelectNum]   = BezirPoint;

            //ダブルクリックで選択モードが解除されてるので選択モードに
            m_SelectMode = SelectMode.SelectStart;
            //増やした点を選択状態に
            m_SelectPoint = SelectNum + 1;
        }
Beispiel #5
0
        /// <summary>
        /// 最初の開始点セット
        /// </summary>
        /// <param name="y"></param>
        public int SetFirstStartPoint(int y)
        {
            BezierPoint sp = m_list[0]; //最初の点

            sp.startPoint.Y = CMath.Clamp(y, ScrrenTopPosY, ScrrenBottomPosY);
            m_list[0]       = sp;
            return(sp.startPoint.Y);
        }
Beispiel #6
0
        /// <summary>
        /// 最後の終了点の移動
        /// </summary>
        /// <param name="mouse"></param>
        public void MoveEndPoint(MouseEventArgs mouse)
        {
            int         LastCnt = m_list.Count() - 1;
            BezierPoint sp      = m_list[LastCnt]; //選択している点

            sp.endPoint.Y   = CMath.Clamp(mouse.Y, ScrrenTopPosY, ScrrenBottomPosY);;
            m_list[LastCnt] = sp;
        }
Beispiel #7
0
        /// <summary>
        /// 最後の終了点セット
        /// </summary>
        /// <param name="y"></param>
        public int  SetEndPoint(int y)
        {
            var LastCnt = m_list.Count() - 1;

            BezierPoint sp = m_list[LastCnt]; //最後の点

            sp.endPoint.Y   = CMath.Clamp(y, ScrrenTopPosY, ScrrenBottomPosY);
            m_list[LastCnt] = sp;
            return(sp.endPoint.Y);
        }
Beispiel #8
0
        /// <summary>
        ///    制御点2Yセット
        /// </summary>
        /// <param name="y"></param>
        public int SetControl2PointY(int y)
        {
            if (m_SelectMode == SelectMode.None)
            {
                return(0);
            }

            BezierPoint sp = m_list[m_SelectPoint];

            sp.controlPoint2.Y    = CMath.Clamp(y, ScrrenTopPosY, ScrrenBottomPosY);
            m_list[m_SelectPoint] = sp;
            return(sp.controlPoint2.Y);
        }
Beispiel #9
0
        /// <summary>
        /// 制御点1の移動
        /// </summary>
        /// <param name="mouse"></param>
        public void MoveControl1Point(MouseEventArgs mouse)
        {
            BezierPoint sp = m_list[m_SelectPoint]; //選択している点

            sp.controlPoint1.X = CMath.Clamp(mouse.X, ScrrenLeftPosX + intervalPointPos, ScrrenRightPosX - intervalPointPos);
            sp.controlPoint1.Y = CMath.Clamp(mouse.Y, ScrrenTopPosY, ScrrenBottomPosY);
            //X軸の移動
            if (!isSelectFirstStartPoint())
            {
                int minpx = m_list[m_SelectPoint - 1].endPoint.X + ControlOfSetX;
                sp.controlPoint1.X = CMath.Clamp(sp.controlPoint1.X, minpx, ScrrenRightPosX - 1);
            }

            //X軸の移動
            if (!(isSelectLastEndPoint()))
            {
                int maxpx = m_list[m_SelectPoint + 1].startPoint.X - ControlOfSetX;
                sp.controlPoint1.X = CMath.Clamp(sp.controlPoint1.X, ScrrenLeftPosX, maxpx);
            }
            m_list[m_SelectPoint] = sp;
        }
Beispiel #10
0
        /// <summary>
        /// 開始点の移動
        /// </summary>
        /// <param name="mouse"></param>
        public void MoveStartPoint(MouseEventArgs mouse)
        {
            BezierPoint sp = m_list[m_SelectPoint]; //選択している点

            sp.startPoint.Y = CMath.Clamp(mouse.Y, ScrrenTopPosY, ScrrenBottomPosY);
            // 一番最初の開始点だけY軸にしか動かせないように
            if (!isSelectFirstStartPoint())
            {
                var BeforeSelectPoint = m_SelectPoint - 1;
                //X軸の移動 intervalPointPosを加算減算すること隣の点と同じ座標にならないようにする
                int minpx = m_list[BeforeSelectPoint].startPoint.X + intervalPointPos;
                int maxpx = sp.endPoint.X - intervalPointPos;
                sp.startPoint.X = CMath.Clamp(mouse.X, minpx, maxpx);
                //ひとつ前の終了点の移動
                BezierPoint sp2 = m_list[BeforeSelectPoint];
                sp2.endPoint = sp.startPoint;
                m_list[BeforeSelectPoint] = sp2;
            }

            m_list[m_SelectPoint] = sp;
        }
Beispiel #11
0
        /// <summary>
        ///    開始点セット
        /// </summary>
        /// <param name="y"></param>
        public int SetStartPointY(int y)
        {
            if (m_SelectMode == SelectMode.None)
            {
                return(0);
            }

            BezierPoint sp = m_list[m_SelectPoint]; //最初の点のY

            sp.startPoint.Y       = CMath.Clamp(y, ScrrenTopPosY, ScrrenBottomPosY);
            m_list[m_SelectPoint] = sp;

            //最初の開始点を選択してないなら前の終了点も移動させる
            if (!isSelectFirstStartPoint())
            {
                var         BeforeSelectPoint = m_SelectPoint - 1;
                BezierPoint sp2 = m_list[BeforeSelectPoint];
                sp2.endPoint = sp.startPoint;
                m_list[BeforeSelectPoint] = sp2;
            }
            return(sp.startPoint.Y);
        }
Beispiel #12
0
        /// <summary>
        /// すべての制御点の位置を整理させる
        /// </summary>
        public void OrganizeControlPoint()
        {
            int ListMax = m_list.Count();
            int LastNum = m_list.Count() - 1;

            //制御点がいてはいけない場所なら位置を補正する
            for (int i = 0; i < ListMax; i++)
            {
                BezierPoint sp = m_list[i]; //選択している点
                //左端以外なら
                if (i != 0)
                {
                    sp.controlPoint1.X = CMath.Clamp(sp.controlPoint1.X, m_list[i - 1].endPoint.X + ControlOfSetX, ScrrenRightPosX);
                    sp.controlPoint2.X = CMath.Clamp(sp.controlPoint2.X, m_list[i - 1].endPoint.X + ControlOfSetX, ScrrenRightPosX);
                }
                //右端以外なら
                if (i != LastNum)
                {
                    sp.controlPoint1.X = CMath.Clamp(sp.controlPoint1.X, ScrrenLeftPosX, m_list[i + 1].startPoint.X - ControlOfSetX);
                    sp.controlPoint2.X = CMath.Clamp(sp.controlPoint2.X, ScrrenLeftPosX, m_list[i + 1].startPoint.X - ControlOfSetX);
                }
                m_list[i] = sp;
            }
        }