int numberofframesX = 0;
int numberofframesY = 0;
string framesX = "";
string framesY = "";
string X = "";
string Y = "";
string t = path + "\\" + fileName;
OptionsFile setting_file = new OptionsFile(t);
string XX = setting_file.GetKey("Number Of Frames X");
string YY = setting_file.GetKey("Number Of Frames Y");
numberofframesX = Convert.ToInt32(XX);
numberofframesY = Convert.ToInt32(YY);
for (int i = 1; i < numberofframesX ; i++)
{
X = string.Format("Frame_X_{0} ", i);
framesX = setting_file.GetKey(X);
List<string> floatStrings = new List<string>(framesX.Split(new char[] { ',' }));
List<float> test = new List<float>( floatStrings.Select(tempStr => (float)Convert.ToDouble(tempStr)).ToList());
wo1.woc.Point_X = test;
}
我需要在我问题底部的链接中的两个图像中执行它所显示的内容。 woc index [0]有两个float all的列表我需要在Point_X中将每个数字的数字添加到Point_X中的索引,例如第1帧是Frame_X_1所以右边的数字应该已经添加了ot Point_X indexs然后在woc [1] Frame_X_2等等.....
这是文本文件(setting_file)
Frame_X_1 =323,332,322,332
Frame_Y_1 =206,212,218,203
Frame_X_2 =323,332,318,332
Frame_Y_2 =206,212,269,203
Frame_X_3 =323,332,318,332
Frame_Y_3 =206,212,269,203
Frame_X_4 =323,332,318,332
Frame_Y_4 =206,212,269,203
Frame_X_5 =323,332,318,332
Frame_Y_5 =206,212,269,203
Frame_X_6 =323,332,318,332
Frame_Y_6 =206,212,269,203
Frame_X_7 =323,332,318,332
Frame_Y_7 =206,212,269,203
Frame_X_8 =323,332,318,332
Frame_Y_8 =206,212,269,203
Number Of Frames X=4
Number Of Frames Y=4
这是woc WireObjectCoordinates类的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AnimationEditor
{
class WireObjectCoordinates
{
public List<float> Point_X = new List<float>();
public List<float> Point_Y = new List<float>();
public WireObjectCoordinates()
{
}
public WireObjectCoordinates(WireObjectCoordinates w)
{
Point_X.AddRange(w.Point_X);
Point_Y.AddRange(w.Point_Y);
}
public void Set(WireObjectCoordinates w)
{
for (int i = 0; i < Point_X.Count; i++)
{
Point_X[i] = w.Point_X[i];
Point_Y[i] = w.Point_Y[i];
}
}
}
}
来自setting_file(OptionsFile)类的GetKey函数:
/*----------------------------------------------------------
* Function : GetKey
* Description : gets the value of the key.
* Parameters : key
* Return : value of the key if key exist, null if not exist
* --------------------------------------------------------*/
public string GetKey(string key)
{
// string value_of_each_key;
string key_of_each_line;
string line;
int index;
string key_value;
key_value = null;
sr = new StreamReader(Options_File);
while (null != (line = sr.ReadLine()))
{
index = line.IndexOf("=");
// value_of_each_key = line.Substring(index+1);
if (index >= 1)
{
key_of_each_line = line.Substring(0, index);
if (key_of_each_line == key)
{
key_value = line.Substring(key.Length + 1);
}
}
else
{
}
}
sr.Close();
return key_value;
}
我现在添加了两张关于WOC和Point_X以及Point_Y应如何显示的图片:
http://imageshack.us/photo/my-images/515/imag0649b.jpg/ http://imageshack.us/photo/my-images/23/imag0648me.jpg/
答案 0 :(得分:1)
听起来你想使用List<List<float>>
。或者,如果您的浮动集是固定的,则可以使用List<float[]>