private void readFile(string filePath,Graphics g)
{
using(StreamReader sr = new StreamReader((@filePath),Encoding.Default))
{
string strValue = "";
while(sr.Peek() >= 0)
{
strValue = sr.ReadLine();
if(strValue == "Embellish")//获取线修饰信息
{
this.getEmbellishInfo(g,strValue,sr);
}
if(strValue == "TextProperties")//获取点修饰信息
{
this.getTextPropertiesInfo(g,strValue,sr);
}
if(strValue == "Projection")//获取投影信息
{
this.getProjectionInfo(strValue,sr);
}
}
}
}
private void getEmbellishInfo(Graphics g, string strValue,StreamReader sr)//得到Embellish的信息
{
string inFontHeight = "";
string inNumber = "";
string inColor = "";
string inExcursion = "";
string inCurveWidth = "";
string inCurveColor = "";
string inLineType = "";
string inMark = ""; strValue = sr.ReadLine();
if((strValue.Length > 10) && (strValue.Trim().Substring(0,10) == "Properties"))
{
string[] temp = this.splitSpace(strValue);
strValue = sr.ReadLine();
}
if((strValue.Length > 5) && (strValue.Trim().Substring(0,5) == "COLOR"))
{
string[] temp = this.splitSpace(strValue);
strValue = sr.ReadLine();
}
if(strValue.Trim() == "NoDraw")
{
this.noDrawValue = strValue;
strValue = sr.ReadLine();
}
if(strValue.Trim() == "")
{
strValue = sr.ReadLine();
}
if(strValue.Trim() == "Projection")
{
this.getProjectionInfo(strValue,sr);
}
}
private void getProjectionInfo(string strValue,StreamReader sr)
{
string ellipsiod = "";
string gauss = "";
string whidth = "";
string number = "";
string gx = "";
string gy = ""; strValue = sr.ReadLine();
string[] temp = this.splitSpace(strValue);
ellipsiod = temp[0];
gauss = temp[1];
string[] temp1 = this.splitComma(temp[2]);
whidth = temp1[0];
number = temp1[1]; strValue = sr.ReadLine();
string Description = strValue;
strValue = sr.ReadLine();
while((strValue.Trim().IndexOf(",") != 0) && (strValue.Trim() != ""))
{
string[] temp2 = this.splitComma(strValue);
gx = gx + temp2[0] + ",";
gy = gy + temp2[1] + ",";
strValue = sr.ReadLine();
}
}在以上代码中,我在readFile中调用getEmbellishInfo方法,并将StreamReader传给getEmbellishInfo,而我在getEmbellishInfo中调用getProjectionInfo方法,将StreamReader传给getProjectionInfo,当我假设在getEmbellishInfo方法中读到第13行时调用了getProjectionInfo,并在getProjectionInfo中读了10行,即总共读了23行,再返回getEmbellishInfo方法时应该从23行往下读,为什么在getEmbellishInfo中StreamReader要从13开始读,但为什么getEmbellishInfo读完后的行数在readFile中是真确的??即在getEmbellishInfo读到几行,返回readFile中时就从几行开始往下读??
哪位大侠帮帮忙?
是不是值传递的问题??
{
using(StreamReader sr = new StreamReader((@filePath),Encoding.Default))
{
string strValue = "";
while(sr.Peek() >= 0)
{
strValue = sr.ReadLine();
if(strValue == "Embellish")//获取线修饰信息
{
this.getEmbellishInfo(g,strValue,ref sr);
}
if(strValue == "TextProperties")//获取点修饰信息
{
this.getTextPropertiesInfo(g,strValue,ref sr);
}
if(strValue == "Projection")//获取投影信息
{
this.getProjectionInfo(strValue,ref sr);
}
}
}
}
private void getEmbellishInfo(Graphics g, string strValue,ref StreamReader sr)//得到Embellish的信息
{
string inFontHeight = "";
string inNumber = "";
string inColor = "";
string inExcursion = "";
string inCurveWidth = "";
string inCurveColor = "";
string inLineType = "";
string inMark = ""; strValue = sr.ReadLine();
if((strValue.Length > 10) && (strValue.Trim().Substring(0,10) == "Properties"))
{
string[] temp = this.splitSpace(strValue);
strValue = sr.ReadLine();
}
if((strValue.Length > 5) && (strValue.Trim().Substring(0,5) == "COLOR"))
{
string[] temp = this.splitSpace(strValue);
strValue = sr.ReadLine();
}
if(strValue.Trim() == "NoDraw")
{
this.noDrawValue = strValue;
strValue = sr.ReadLine();
}
if(strValue.Trim() == "")
{
strValue = sr.ReadLine();
}
if(strValue.Trim() == "Projection")
{
this.getProjectionInfo(strValue,sr);
}
}
private void getProjectionInfo(string strValue,ref StreamReader sr)
{
string ellipsiod = "";
string gauss = "";
string whidth = "";
string number = "";
string gx = "";
string gy = ""; strValue = sr.ReadLine();
string[] temp = this.splitSpace(strValue);
ellipsiod = temp[0];
gauss = temp[1];
string[] temp1 = this.splitComma(temp[2]);
whidth = temp1[0];
number = temp1[1]; strValue = sr.ReadLine();
string Description = strValue;
strValue = sr.ReadLine();
while((strValue.Trim().IndexOf(",") != 0) && (strValue.Trim() != ""))
{
string[] temp2 = this.splitComma(strValue);
gx = gx + temp2[0] + ",";
gy = gy + temp2[1] + ",";
strValue = sr.ReadLine();
}
}
应该是传值的问题