当前位置: 首页>>代码示例>>C#>>正文


C# System.Text.ASCIIEncoding.GetChars方法代码示例

本文整理汇总了C#中System.Text.ASCIIEncoding.GetChars方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.ASCIIEncoding.GetChars方法的具体用法?C# System.Text.ASCIIEncoding.GetChars怎么用?C# System.Text.ASCIIEncoding.GetChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.ASCIIEncoding的用法示例。


在下文中一共展示了System.Text.ASCIIEncoding.GetChars方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadObject

		// read object
		internal static ObjectManager.StaticObject ReadObject(string FileName, System.Text.Encoding Encoding, ObjectManager.ObjectLoadMode LoadMode, bool ForceTextureRepeatX, bool ForceTextureRepeatY) {
			byte[] Data = System.IO.File.ReadAllBytes(FileName);
			if (Data.Length < 16 || Data[0] != 120 | Data[1] != 111 | Data[2] != 102 | Data[3] != 32) {
				// not an x object
				Interface.AddMessage(Interface.MessageType.Error, false, "Invalid X object file encountered in " + FileName);
				return null;
			}
			if (Data[4] != 48 | Data[5] != 51 | Data[6] != 48 | Data[7] != 50 & Data[7] != 51) {
				// unrecognized version
				System.Text.ASCIIEncoding Ascii = new System.Text.ASCIIEncoding();
				string s = new string(Ascii.GetChars(Data, 4, 4));
				Interface.AddMessage(Interface.MessageType.Error, false, "Unsupported X object file version " + s + " encountered in " + FileName);
			}
			// floating-point format
			int FloatingPointSize;
			if (Data[12] == 48 & Data[13] == 48 & Data[14] == 51 & Data[15] == 50) {
				FloatingPointSize = 32;
			} else if (Data[12] == 48 & Data[13] == 48 & Data[14] == 54 & Data[15] == 52) {
				FloatingPointSize = 64;
			} else {
				Interface.AddMessage(Interface.MessageType.Error, false, "Unsupported floating point format encountered in X object file " + FileName);
				return null;
			}
			// supported floating point format
			if (Data[8] == 116 & Data[9] == 120 & Data[10] == 116 & Data[11] == 32) {
				// textual flavor
				return LoadTextualX(FileName, System.IO.File.ReadAllText(FileName), Encoding, LoadMode, ForceTextureRepeatX, ForceTextureRepeatY);
			} else if (Data[8] == 98 & Data[9] == 105 & Data[10] == 110 & Data[11] == 32) {
				// binary flavor
				return LoadBinaryX(FileName, Data, 16, Encoding, FloatingPointSize, LoadMode, ForceTextureRepeatX, ForceTextureRepeatY);
			} else if (Data[8] == 116 & Data[9] == 122 & Data[10] == 105 & Data[11] == 112) {
				// compressed textual flavor
				#if !DEBUG
				try {
					#endif
					byte[] Uncompressed = Decompress(Data);
					string Text = Encoding.GetString(Uncompressed);
					return LoadTextualX(FileName, Text, Encoding, LoadMode, ForceTextureRepeatX, ForceTextureRepeatY);
					#if !DEBUG
				} catch (Exception ex) {
					Interface.AddMessage(Interface.MessageType.Error, false, "An unexpected error occured (" + ex.Message + ") while attempting to decompress the binary X object file encountered in " + FileName);
					return null;
				}
				#endif
			} else if (Data[8] == 98 & Data[9] == 122 & Data[10] == 105 & Data[11] == 112) {
				// compressed binary flavor
				#if !DEBUG
				try {
					#endif
					byte[] Uncompressed = Decompress(Data);
					return LoadBinaryX(FileName, Uncompressed, 0, Encoding, FloatingPointSize, LoadMode, ForceTextureRepeatX, ForceTextureRepeatY);
					#if !DEBUG
				} catch (Exception ex) {
					Interface.AddMessage(Interface.MessageType.Error, false, "An unexpected error occured (" + ex.Message + ") while attempting to decompress the binary X object file encountered in " + FileName);
					return null;
				}
				#endif
			} else {
				// unsupported flavor
				Interface.AddMessage(Interface.MessageType.Error, false, "Unsupported X object file encountered in " + FileName);
				return null;
			}
		}
开发者ID:noidelsucre,项目名称:OpenBVE,代码行数:64,代码来源:XObjectParser.cs

示例2: PreprocessChrRndSub


//.........这里部分代码省略.........
                                                if (value > number) {
                                                    chosenIndex = ia;
                                                    break;
                                                }
                                            }
                                            Expression[] expr;
                                            string[] lines = System.IO.File.ReadAllLines(files[chosenIndex], Encoding);
                                            PreprocessSplitIntoExpressions(files[chosenIndex], IsRW, lines, Encoding, out expr, false, offsets[chosenIndex] + Expressions[i].TrackPositionOffset);
                                            int length = Expressions.Length;
                                            if (expr.Length == 0) {
                                                for (int ia = i; ia < Expressions.Length - 1; ia++) {
                                                    Expressions[ia] = Expressions[ia + 1];
                                                }
                                                Array.Resize<Expression>(ref Expressions, length - 1);
                                            } else {
                                                Array.Resize<Expression>(ref Expressions, length + expr.Length - 1);
                                                for (int ia = Expressions.Length - 1; ia >= i + expr.Length; ia--) {
                                                    Expressions[ia] = Expressions[ia - expr.Length + 1];
                                                }
                                                for (int ia = 0; ia < expr.Length; ia++) {
                                                    Expressions[i + ia] = expr[ia];
                                                }
                                            }
                                            i--;
                                            continueWithNextExpression = true;
                                        }
                                    }
                                    break;
                                case "$chr":
                                    {
                                        int x;
                                        if (Interface.TryParseIntVb6(s, out x)) {
                                            if (x > 0 & x < 128) {
                                                Expressions[i].Text = Expressions[i].Text.Substring(0, j) + new string(Encoding.GetChars(new byte[] { (byte)x })) + Expressions[i].Text.Substring(h + 1);
                                            } else {
                                                continueWithNextExpression = true;
                                                Interface.AddMessage(Interface.MessageType.Error, false, "Index does not correspond to a valid ASCII character in " + t + Epilog);
                                            }
                                        } else {
                                            continueWithNextExpression = true;
                                            Interface.AddMessage(Interface.MessageType.Error, false, "Index is invalid in " + t + Epilog);
                                        }
                                    } break;
                                case "$rnd":
                                    {
                                        int m = s.IndexOf(";", StringComparison.Ordinal);
                                        if (m >= 0) {
                                            string s1 = s.Substring(0, m).TrimEnd();
                                            string s2 = s.Substring(m + 1).TrimStart();
                                            int x; if (Interface.TryParseIntVb6(s1, out x)) {
                                                int y; if (Interface.TryParseIntVb6(s2, out y)) {
                                                    int z = x + (int)Math.Floor(Program.RandomNumberGenerator.NextDouble() * (double)(y - x + 1));
                                                    Expressions[i].Text = Expressions[i].Text.Substring(0, j) + z.ToString(Culture) + Expressions[i].Text.Substring(h + 1);
                                                } else {
                                                    continueWithNextExpression = true;
                                                    Interface.AddMessage(Interface.MessageType.Error, false, "Index2 is invalid in " + t + Epilog);
                                                }
                                            } else {
                                                continueWithNextExpression = true;
                                                Interface.AddMessage(Interface.MessageType.Error, false, "Index1 is invalid in " + t + Epilog);
                                            }
                                        } else {
                                            continueWithNextExpression = true;
                                            Interface.AddMessage(Interface.MessageType.Error, false, "Two arguments are expected in " + t + Epilog);
                                        }
                                    } break;
开发者ID:sladen,项目名称:openbve,代码行数:67,代码来源:CsvRwRouteParser.cs

示例3: ReadBinaryTemplate


//.........这里部分代码省略.........
									return false;
								}
							} break;
						case TOKEN_OBRACE:
							Interface.AddMessage(Interface.MessageType.Error, false, "Unexpected token TOKEN_OBRACE encountered at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
							return false;
						case TOKEN_CBRACE:
							if (Level == 0) return true;
							Level--;
							break;
						default:
							Interface.AddMessage(Interface.MessageType.Error, false, "Unknown token encountered at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
							return false;
					} m--;
				} else if (Template.Members[m] == "[...]") {
					// any template
					if (Cache.IntegersRemaining != 0) {
						Interface.AddMessage(Interface.MessageType.Error, false, "An integer list was not depleted at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
					} else if (Cache.FloatsRemaining != 0) {
						Interface.AddMessage(Interface.MessageType.Error, false, "A float list was not depleted at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
					}
					if (Template.Name.Length == 0 && Reader.BaseStream.Position == Reader.BaseStream.Length) {
						// end of file
						return true;
					}
					short Token = Reader.ReadInt16();
					switch (Token) {
						case TOKEN_NAME:
							int n = Reader.ReadInt32();
							if (n < 1) {
								Interface.AddMessage(Interface.MessageType.Error, false, "count is invalid in TOKEN_NAME at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
								return false;
							}
							string Name = new string(Ascii.GetChars(Reader.ReadBytes(n)));
							Token = Reader.ReadInt16();
							if (Token != TOKEN_OBRACE) {
								Interface.AddMessage(Interface.MessageType.Error, false, "TOKEN_OBRACE expected at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
								return false;
							}
							Structure o;
							if (!ReadBinaryTemplate(FileName, Reader, FloatingPointSize, GetTemplate(Name), false, ref Cache, out o)) {
								return false;
							}
							Array.Resize<object>(ref Structure.Data, Structure.Data.Length + 1);
							Structure.Data[Structure.Data.Length - 1] = o;
							break;
						case TOKEN_CBRACE:
							if (Template.Name.Length == 0) {
								Interface.AddMessage(Interface.MessageType.Error, false, "Unexpected TOKEN_CBRACE encountered at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
								return false;
							}
							m++;
							break;
						default:
							Interface.AddMessage(Interface.MessageType.Error, false, "TOKEN_NAME or TOKEN_CBRACE expected at position 0x" + Reader.BaseStream.Position.ToString("X", Culture) + " in binary X object file " + FileName);
							return false;
					} m--;
				} else if (Template.Members[m].EndsWith("]", StringComparison.Ordinal)) {
					// inlined array expected
					string r = Template.Members[m].Substring(0, Template.Members[m].Length - 1);
					int h = r.IndexOf('[');
					if (h >= 0) {
						string z = r.Substring(h + 1, r.Length - h - 1);
						r = r.Substring(0, h);
						if (!int.TryParse(z, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out h)) {
							Interface.AddMessage(Interface.MessageType.Error, false, "The internal format description for a template array is invalid in template " + Template.Name + " in binary X object file " + FileName);
开发者ID:noidelsucre,项目名称:OpenBVE,代码行数:67,代码来源:XObjectParser.cs

示例4: PreprocessChrRndSub

        // preprocess chrrndsub
        private static void PreprocessChrRndSub(string FileName, ref Expression[] Expressions)
        {
            System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture;
            System.Text.Encoding Encoding = new System.Text.ASCIIEncoding();
            string[] Subs = new string[16];
            for (int i = 0; i < Expressions.Length; i++) {
                string Epilog = " at line " + Expressions[i].Line.ToString(Culture) + ", column " + Expressions[i].Column.ToString(Culture) + " in file " + FileName;
                bool err = false;
                for (int j = Expressions[i].Text.Length - 1; j >= 0; j--) {
                    if (Expressions[i].Text[j] == '$') {
                        int k;
                        for (k = j + 1; k < Expressions[i].Text.Length; k++) {
                            if (Expressions[i].Text[k] == '(') break;
                        }
                        if (k <= Expressions[i].Text.Length) {
                            string t = Expressions[i].Text.Substring(j, k - j).TrimEnd();
                            int l = 1, h;
                            for (h = k + 1; h < Expressions[i].Text.Length; h++) {
                                switch (Expressions[i].Text[h]) {
                                    case '(':
                                        l++;
                                        break;
                                    case ')':
                                        l--;
                                        if (l < 0) {
                                            err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Invalid parenthesis structure in " + t + Epilog);
                                        }
                                        break;
                                }
                                if (l <= 0) break;
                            }
                            if (err) break;
                            if (l != 0) {
                                Interface.AddMessage(Interface.MessageType.Error, false, "Invalid parenthesis structure in " + t + Epilog);
                                err = true; break;
                            }
                            string s = Expressions[i].Text.Substring(k + 1, h - k - 1).Trim();
                            switch (t.ToLowerInvariant()) {
                                case "$chr":
                                    {
                                        int x; if (Interface.TryParseIntVb6(s, out x)) {
                                            if (x > 0 & x < 128) {
                                                Expressions[i].Text = Expressions[i].Text.Substring(0, j) + new string(Encoding.GetChars(new byte[] { (byte)x })) + Expressions[i].Text.Substring(h + 1);
                                            } else {
                                                err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Index does not correspond to a valid ASCII character in " + t + Epilog);
                                            }
                                        } else {
                                            err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Index is invalid in " + t + Epilog);
                                        }
                                    } break;
                                case "$rnd":
                                    {
                                        int m = s.IndexOf(";", StringComparison.Ordinal);
                                        if (m >= 0) {
                                            string s1 = s.Substring(0, m).TrimEnd();
                                            string s2 = s.Substring(m + 1).TrimStart();
                                            int x; if (Interface.TryParseIntVb6(s1, out x)) {
                                                int y; if (Interface.TryParseIntVb6(s2, out y)) {
                                                    int z = x + (int)Math.Floor(Game.Generator.NextDouble() * (double)(y - x + 1));
                                                    Expressions[i].Text = Expressions[i].Text.Substring(0, j) + z.ToString(Culture) + Expressions[i].Text.Substring(h + 1);
                                                } else {
                                                    err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Index2 is invalid in " + t + Epilog);
                                                }
                                            } else {
                                                err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Index1 is invalid in " + t + Epilog);
                                            }
                                        } else {
                                            err = true; Interface.AddMessage(Interface.MessageType.Error, false, "Two arguments are expected in " + t + Epilog);
                                        }
                                    } break;
                                case "$sub":
                                    {
                                        l = 0;
                                        bool f = false;
                                        int m;
                                        for (m = h + 1; m < Expressions[i].Text.Length; m++) {
                                            switch (Expressions[i].Text[m]) {
                                                    case '(': l++; break;
                                                    case ')': l--; break;
                                                    case '=': if (l == 0) {
                                                        f = true;
                                                    }
                                                    break;
                                                default:
                                                    if (!char.IsWhiteSpace(Expressions[i].Text[m])) l = -1;
                                                    break;
                                            }
                                            if (f | l < 0) break;
                                        }
                                        if (f) {
                                            l = 0;
                                            int n;
                                            for (n = m + 1; n < Expressions[i].Text.Length; n++) {
                                                switch (Expressions[i].Text[n]) {
                                                        case '(': l++; break;
                                                        case ')': l--; break;
                                                }
                                                if (l < 0) break;
                                            }
//.........这里部分代码省略.........
开发者ID:sladen,项目名称:openbve-routeviewer,代码行数:101,代码来源:CsvRwRouteParser.cs

示例5: parse

        public bool parse()
        {
            byte[]        token = new byte[4096];
            int           lapg_head = 0, group = 0, lapg_i, lapg_size, chr;
            lapg_symbol[] lapg_m = new lapg_symbol[1024];
            lapg_symbol   lapg_n;
            System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding();
            lapg_place    lapg_current;

            lapg_current.offset = 0;
            lapg_current.line = 1;
            lapg_m[0].state = 0; lapg_n.lexem = lapg_n.state = 0;
            chr = buff[l++];

            do {
            lapg_n.pos = lapg_current;
            for( lapg_size = 0, lapg_i = group; lapg_i >= 0; ) {
                if( lapg_size < 4096-1 ) token[lapg_size++] = (byte)chr;
                lapg_i = lapg_lexem[lapg_i,lapg_char2no[chr]];
                if( lapg_i >= -1 && chr != 0 ) {
                    lapg_current.offset++;
                    if( chr == '\n' ) lapg_current.line++;
                    chr = buff[l++];
                }
            }
            lapg_n.endpos = lapg_current;
            token[lapg_size] = 0;

            if( lapg_i == -1 ) {
                error( System.String.Format( "invalid lexem at line {0}: `{1}`, skipped", lapg_n.pos.line, new System.String(AE.GetChars(token,0,lapg_size)) ) );
                continue;
            }

            token[lapg_size-1] = 0;
            lapg_n.lexem = -lapg_i-2;
            lapg_n.sym = null;

            switch( lapg_n.lexem ) {
                case 1:
                    #line 22 "syntax"
                     lapg_n.sym = new System.String(AE.GetChars(token,0,lapg_size-1)); break;
                case 2:
                    #line 26 "syntax"
                     lapg_n.sym = new System.String(AE.GetChars(token,0,lapg_size-1)); break;
                case 3:
                    #line 30 "syntax"
                     lapg_n.sym = new System.String(AE.GetChars(token,0,lapg_size-1)); break;
                case 4:
                    #line 33 "syntax"
                     lapg_n.sym = new System.String(AE.GetChars(token,0,lapg_size-1)); break;
                case 5:
                    #line 34 "syntax"
                     lapg_n.sym = new System.String(AE.GetChars(token,0,lapg_size-1)); break;
                case 6:
                    #line 38 "syntax"
                     lapg_n.sym = "abstract"; break;
                case 7:
                    #line 39 "syntax"
                     lapg_n.sym = "as"; break;
                case 8:
                    #line 40 "syntax"
                     lapg_n.sym = "base"; break;
                case 9:
                    #line 41 "syntax"
                     lapg_n.sym = "bool"; break;
                case 10:
                    #line 42 "syntax"
                     lapg_n.sym = "break"; break;
                case 11:
                    #line 43 "syntax"
                     lapg_n.sym = "byte"; break;
                case 12:
                    #line 44 "syntax"
                     lapg_n.sym = "case"; break;
                case 13:
                    #line 45 "syntax"
                     lapg_n.sym = "catch"; break;
                case 14:
                    #line 46 "syntax"
                     lapg_n.sym = "char"; break;
                case 15:
                    #line 47 "syntax"
                     lapg_n.sym = "checked"; break;
                case 16:
                    #line 48 "syntax"
                     lapg_n.sym = "class"; break;
                case 17:
                    #line 49 "syntax"
                     lapg_n.sym = "const"; break;
                case 18:
                    #line 50 "syntax"
                     lapg_n.sym = "continue"; break;
                case 19:
                    #line 51 "syntax"
                     lapg_n.sym = "decimal"; break;
                case 20:
                    #line 52 "syntax"
                     lapg_n.sym = "default"; break;
                case 21:
                    #line 53 "syntax"
//.........这里部分代码省略.........
开发者ID:inspirer,项目名称:uml-designer,代码行数:101,代码来源:parse.cs

示例6: PreprocessFile

		//
		// File functions
		//

		public void PreprocessFile(int iIndex, String sFileName, string sRealName, bool bCheckPre, bool bForePreprocessing)
		{
            GPSSource gpsSource = (GPSSource)m_GpsTracker.m_gpsSourceList[iIndex];

			#if !DEBUG
			try
			#endif
			{
				//check if preprocess exists
				if(	(File.Exists(sFileName + ".TrackAtOnce") || IsTrackAtOnce(sFileName)) && 
					(bForePreprocessing==false || bCheckPre))
				{
					string sTAOFileName;
					if (IsTrackAtOnce(sFileName))
						sTAOFileName=sFileName;
					else
						sTAOFileName=sFileName + ".TrackAtOnce";

					gpsSource.GpsPos.m_gpsTrack=null;
					BinaryReader binReader = new BinaryReader(File.Open(sTAOFileName, FileMode.Open));
					// If the file is not empty, 
					// read it
					if(binReader.PeekChar() != -1)
					{
						gpsSource.GpsPos.m_gpsTrack=new GPSTrack();

						string sSign="GPSTracker.TrackAtOnce";
						char [] sSignature = binReader.ReadChars(sSign.Length);
						string sSignCompare = new string(sSignature);
						if (sSignCompare==sSign)
						{
							gpsSource.GpsPos.m_gpsTrack.m_uPointCount=binReader.ReadUInt32();
                            gpsSource.GpsPos.m_gpsTrack.SetSize(gpsSource.GpsPos.m_gpsTrack.m_uPointCount);
						
							byte[] byData = new byte[gpsSource.GpsPos.m_gpsTrack.m_uPointCount*8]; 
							byData=binReader.ReadBytes((int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*8);
							System.Buffer.BlockCopy(byData , 0, gpsSource.GpsPos.m_gpsTrack.m_fLat, 0, (int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*8 );
							
							byData=binReader.ReadBytes((int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*8);
							System.Buffer.BlockCopy(byData , 0, gpsSource.GpsPos.m_gpsTrack.m_fLon, 0, (int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*8 );
							
							byData=binReader.ReadBytes((int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*4);
							System.Buffer.BlockCopy(byData , 0, gpsSource.GpsPos.m_gpsTrack.m_fAlt, 0, (int)gpsSource.GpsPos.m_gpsTrack.m_uPointCount*4 );
							
							
						}
					}
					binReader.Close();
				}
				else
				{
					uint uProgress;
					uint uMaxProgress;
					StreamReader fsGpsFile = null;
					String sGpsLine;
					byte [] byNMEA;
					char [] cNMEA=null;
					char [] cNMEAMsg = new char[512];
					System.Text.ASCIIEncoding asciiEncoder = new System.Text.ASCIIEncoding();
					if(File.Exists(sFileName) && !IsTrackAtOnce(sFileName))
					{
						FileInfo fInfo = new FileInfo(sFileName);

						uProgress=0;
						uMaxProgress=(uint)fInfo.Length;
						m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Processing " + sRealName + ": " + Convert.ToString(uProgress) +" of " + Convert.ToString(uMaxProgress) + " bytes.");

						fsGpsFile = File.OpenText(sFileName);
						gpsSource.GpsPos.m_gpsTrack= new GPSTrack();
                        gpsSource.GpsPos.m_gpsTrack.SetSize(500); //set an initial array size for the track
                        uint uResizeArraySize=500;
						while(true)
						{
						
							sGpsLine=fsGpsFile.ReadLine();
							if (sGpsLine==null)
								break;
							uProgress+=(uint)sGpsLine.Length;
							m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Processing " + sRealName + ": " + Convert.ToString(uProgress) +" of " + Convert.ToString(uMaxProgress) + " bytes.");
						
							byNMEA =  asciiEncoder.GetBytes(sGpsLine);
							cNMEA =  asciiEncoder.GetChars(byNMEA);
							cNMEA.CopyTo(cNMEAMsg,0);
							if (m_GpsTracker.m_NMEA.ParseGPSMessage(cNMEAMsg,cNMEA.Length,false,iIndex)==true)
								gpsSource.GpsPos.m_gpsTrack.AddPoint(gpsSource.GpsPos.m_fLat,gpsSource.GpsPos.m_fLon,gpsSource.GpsPos.m_fAlt);

                            //Keep resizing the track array as necessary
                            if (gpsSource.GpsPos.m_gpsTrack.m_uPointCount >= uResizeArraySize)
                            {
                                uResizeArraySize += 100;
                                gpsSource.GpsPos.m_gpsTrack.Resize(uResizeArraySize);
                            }
						}
						uProgress=(uint)fInfo.Length;
						m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Processing " + sRealName + ": " + Convert.ToString(uProgress) +" of " + Convert.ToString(uMaxProgress) + " bytes.");
						fsGpsFile.Close();
//.........这里部分代码省略.........
开发者ID:jpespartero,项目名称:WorldWind,代码行数:101,代码来源:GPSTrackerPlugin.File.cs

示例7: threadFile

		public void threadFile()
		{
			int iIndex= Int32.Parse(Thread.CurrentThread.Name); 
			GPSSource gpsSource = (GPSSource)m_GpsTracker.m_gpsSourceList[iIndex];
			int iIndexFile;
			int iIndexNext; 
			StreamReader fsGpsFile = null;
			System.Text.ASCIIEncoding asciiEncoder = new System.Text.ASCIIEncoding();
			String sGpsLine=null;
			String sIndex;
			byte [] byNMEA;
			char [] cNMEA=null;
			char [] cNMEAMsg = new char[512];
			DateTime dtCurrent;
			DateTime dtNext = new DateTime(0);
			int iEnd=0;
			bool bRestartTrack=false;

			try
			{
				if(File.Exists(gpsSource.sFileNameSession))
				{
					while(m_GpsTracker.m_fCloseThreads==false)
					{
						bRestartTrack=true;
						fsGpsFile = File.OpenText(gpsSource.sFileNameSession);
						{
							if (m_GpsTracker.m_fPlayback==true)
							{
								m_GpsTracker.LoadSettings(fsGpsFile,false);
								iIndexFile=iIndex+1;
								do
								{
									sIndex=fsGpsFile.ReadLine();
									if (sIndex!=null)
										iEnd=sIndex.IndexOf(",");
									if (sIndex!=null && iEnd>0)
									{
										iIndexFile=Convert.ToInt32(sIndex.Substring(0,iEnd));
										if (iIndexFile==iIndex && sIndex.Length>iEnd+1)
										{
											sGpsLine=sIndex.Substring(iEnd+1);
											break;
										}
									}
									else
										break;
								} while(m_GpsTracker.m_fCloseThreads==false);
							}
							else
							{
								sIndex="dummyindex";
								iIndexFile=iIndex;
								sGpsLine=fsGpsFile.ReadLine();
							}
							if (sGpsLine!=null)
							{
								byNMEA =  asciiEncoder.GetBytes(sGpsLine);
								cNMEA =  asciiEncoder.GetChars(byNMEA);
								cNMEA.CopyTo(cNMEAMsg,0);
								if (m_GpsTracker.m_iPlaybackSpeed>0)
									dtNext=m_GpsTracker.m_NMEA.GetNMEATime(-1,sGpsLine);
							}
							while(sIndex!=null && sGpsLine!=null && m_GpsTracker.m_fCloseThreads==false && iIndexFile==iIndex)
							{
								if (sGpsLine!="" && sIndex!="")
								{
									try
									{
										if (m_GpsTracker.m_MessageMonitor!=null)
											m_GpsTracker.m_MessageMonitor.AddMessageFileRaw(sGpsLine);
									}
									catch (Exception)
									{
										m_GpsTracker.m_MessageMonitor=null;
									}

									if (m_GpsTracker.ShowGPSIcon(cNMEAMsg,cNMEA.Length,false,iIndex,bRestartTrack,true)==true)
									{
										if (bRestartTrack)
											bRestartTrack=false;
										//Get current NMEA msg time
										dtCurrent=dtNext;
										while(m_GpsTracker.m_fCloseThreads==false)
										{
											//Get next line from file
											if (m_GpsTracker.m_fPlayback==true)
											{
												sIndex=fsGpsFile.ReadLine();
												if (sIndex!=null)
												{
													iEnd=sIndex.IndexOf(",");
													if (iEnd>0 && sIndex.Length>iEnd+1)
													{
														sGpsLine=sIndex.Substring(iEnd+1);
														sIndex=sIndex.Substring(0,iEnd);
													}
													else 
														sIndex="";
												}
//.........这里部分代码省略.........
开发者ID:jpespartero,项目名称:WorldWind,代码行数:101,代码来源:GPSTrackerPlugin.File.cs


注:本文中的System.Text.ASCIIEncoding.GetChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。