/// <summary> /// CSVからデータを読み込み /// </summary> /// <param name="s"></param> /// <returns></returns> public List <CurvePointControl.BezierPoint> Load(string s) { List <CurvePointControl.BezierPoint> list = new List <CurvePointControl.BezierPoint>(); StreamReader file = new StreamReader(s); //末尾まで繰り返す while (!file.EndOfStream) { // CSVファイルの一行を読み込む string line = file.ReadLine(); // 読み込んだ一行をカンマ毎に分けて配列に格納する string[] values = line.Split(','); CurvePointControl.BezierPoint b = ToBezierPoint(values); list.Add(b); } file.Close(); //例外処理 var sx = CMath.ChageDecimalPosX(list[0].startPoint.X); var ex = CMath.ChageDecimalPosX(list[list.Count - 1].endPoint.X); if (sx != 0) { MessageBox.Show("グラフデータがおかしいです"); } if (ex != 1) { MessageBox.Show("グラフデータがおかしいです"); } return(list); }
/// <summary> /// 制御点2X /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChangeControlPoint2X(object sender, EventArgs e) { int num = CMath.ChageNomalPosX(numericUpDown3.Value); int num2 = m_CurvePointControl.SetControl2PointX(num); numericUpDown3.Value = CMath.ChageDecimalPosX(num2); if (!m_CurvePointControl.isMoveSelectPoint()) { pictureBox1.Refresh(); //再描画 } }
/// <summary> /// 点を動かした際同期を取る /// </summary> public void numericUpDownSync() { bp = m_CurvePointControl.GetBezierPoint(); numericUpDown1.Value = CMath.ChageDecimalPosX(bp.startPoint.X); numericUpDown2.Value = CMath.ChageDecimalPosX(bp.controlPoint1.X); numericUpDown3.Value = CMath.ChageDecimalPosX(bp.controlPoint2.X); numericUpDown4.Value = CMath.ChageDecimalPosY(bp.startPoint.Y); numericUpDown5.Value = CMath.ChageDecimalPosY(bp.controlPoint1.Y); numericUpDown6.Value = CMath.ChageDecimalPosY(bp.controlPoint2.Y); numericUpDown7.Value = CMath.ChageDecimalPosY(m_CurvePointControl.GetEndPointY()); numericUpDown8.Value = CMath.ChageDecimalPosY(m_CurvePointControl.GetFirstStartPointY()); }
/// <summary> /// //座標を0~1の間に変換し文字列化させる /// </summary> /// <param name="bs"></param> /// <returns></returns> public string[] ToSting(CurvePointControl.BezierPoint bs) { //座標を0~1の間に変換し文字列化させる string[] name = new string[4]; name[0] = CMath.ChageDecimalPosX(bs.startPoint.X).ToString() + "," + CMath.ChageDecimalPosY(bs.startPoint.Y).ToString(); name[1] = CMath.ChageDecimalPosX(bs.controlPoint1.X).ToString() + "," + CMath.ChageDecimalPosY(bs.controlPoint1.Y).ToString(); name[2] = CMath.ChageDecimalPosX(bs.controlPoint2.X).ToString() + "," + CMath.ChageDecimalPosY(bs.controlPoint2.Y).ToString(); name[3] = CMath.ChageDecimalPosX(bs.endPoint.X).ToString() + "," + CMath.ChageDecimalPosY(bs.endPoint.Y).ToString(); return(name); }
public void SetList(List <CurvePointControl.BezierPoint> list) { m_list = list; m_Csvlist.Clear(); foreach (CurvePointControl.BezierPoint item in m_list) { CSVPoint cp = new CSVPoint(); cp.startPoint = new decimal[2]; cp.controlPoint1 = new decimal[2]; cp.controlPoint2 = new decimal[2]; cp.endPoint = new decimal[2]; cp.startPoint[0] = CMath.ChageDecimalPosX(item.startPoint.X); cp.startPoint[1] = CMath.ChageDecimalPosY(item.startPoint.Y); cp.controlPoint1[0] = CMath.ChageDecimalPosX(item.controlPoint1.X); cp.controlPoint1[1] = CMath.ChageDecimalPosY(item.controlPoint1.Y); cp.controlPoint2[0] = CMath.ChageDecimalPosX(item.controlPoint2.X); cp.controlPoint2[1] = CMath.ChageDecimalPosY(item.controlPoint2.Y); cp.endPoint[0] = CMath.ChageDecimalPosX(item.endPoint.X); cp.endPoint[1] = CMath.ChageDecimalPosY(item.endPoint.Y); m_Csvlist.Add(cp); } }