Exemple #1
0
		/// <summary>
		/// Parse the whole Line and searchs the Setting and Value
		/// </summary>
		/// <param name="line"></param>
		/// <param name="Config"></param>
		/// <returns></returns>
		private static bool ExtractSetting( string line, out EathenaConfig Config ) {
			string Setting = string.Empty;
			string Value = string.Empty;
			bool bFoundValue = false;
			Config = new EathenaConfig();

			for( int i = 0; i < line.Length; i++ ) {
				if( line.IsComment( i ) == true )
					break;
				if( line[ i ] == ':' ) {
					bFoundValue = true;
					continue;
				}

				if( bFoundValue == true )
					Value += line[ i ];
				else if( line[ i ] != ' ' ) // settings cant store whitespace
					Setting += line[ i ];
			}

			if( Setting.Trim() == string.Empty )
				return false; // no Config found

			//TODO: check the Trim()... maybe eA includes leading/trailing whitespaces in Settings?
			Config.Value = Value.Trim();
			Config.Name = Setting.Trim();

			return true;
		}
Exemple #2
0
		public static bool ReadFile( string Filename, out EathenaConfigFile Configs ) {
			EathenaConfig Config = new EathenaConfig();
			string line = string.Empty;
			string[] Lines;

			Configs = new EathenaConfigFile();
			Configs.Filename = Filename;

			if( File.Exists( Filename ) == false )
				return false;

			Lines = File.ReadAllLines( Filename );
			for( int i = 0; i < Lines.Length; i++ ) {
				line = Lines[ i ].Trim();
				if( line.IsComment() == true || line.Length < 2 )
					continue;

				if( ExtractSetting( line, out Config ) == false )
					continue;

				Config.Comments = FetchComments( Lines, i - 1 );
				Config.Line = i;
				Configs.Add( Config );
			}

			return true;

		}
Exemple #3
0
        private void ConfGrid_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            EathenaConfig conf = new EathenaConfig();

            conf.Name  = (string)e.Row.Cells[0].Value;
            conf.Value = (string)e.Row.Cells[1].Value;
            mFiles[mSelectedFile].Configs.Add(conf);

            SetStatus("Einstellung `" + conf.Name + "` : '" + conf.Value + "' wurde hinzugefügt");
        }
Exemple #4
0
        /// <summary>
        /// Parse the whole Line and searchs the Setting and Value
        /// </summary>
        /// <param name="line"></param>
        /// <param name="Config"></param>
        /// <returns></returns>
        private static bool ExtractSetting(string line, out EathenaConfig Config)
        {
            string Setting     = string.Empty;
            string Value       = string.Empty;
            bool   bFoundValue = false;

            Config = new EathenaConfig();

            for (int i = 0; i < line.Length; i++)
            {
                if (line.IsComment(i) == true)
                {
                    break;
                }
                if (line[i] == ':')
                {
                    bFoundValue = true;
                    continue;
                }

                if (bFoundValue == true)
                {
                    Value += line[i];
                }
                else if (line[i] != ' ')                    // settings cant store whitespace
                {
                    Setting += line[i];
                }
            }

            if (Setting.Trim() == string.Empty)
            {
                return(false);                // no Config found
            }
            //TODO: check the Trim()... maybe eA includes leading/trailing whitespaces in Settings?
            Config.Value = Value.Trim();
            Config.Name  = Setting.Trim();

            return(true);
        }
Exemple #5
0
        public static bool ReadFile(string Filename, out EathenaConfigFile Configs)
        {
            EathenaConfig Config = new EathenaConfig();
            string        line   = string.Empty;

            string[] Lines;

            Configs          = new EathenaConfigFile();
            Configs.Filename = Filename;

            if (File.Exists(Filename) == false)
            {
                return(false);
            }

            Lines = File.ReadAllLines(Filename);
            for (int i = 0; i < Lines.Length; i++)
            {
                line = Lines[i].Trim();
                if (line.IsComment() == true || line.Length < 2)
                {
                    continue;
                }

                if (ExtractSetting(line, out Config) == false)
                {
                    continue;
                }

                Config.Comments = FetchComments(Lines, i - 1);
                Config.Line     = i;
                Configs.Add(Config);
            }

            return(true);
        }
Exemple #6
0
		private void ConfGrid_UserAddedRow( object sender, DataGridViewRowEventArgs e ) {
			EathenaConfig conf = new EathenaConfig();
			conf.Name = (string)e.Row.Cells[ 0 ].Value;
			conf.Value = (string)e.Row.Cells[ 1 ].Value;
			mFiles[ mSelectedFile ].Configs.Add( conf );

			SetStatus( "Einstellung `" + conf.Name + "` : '" + conf.Value + "' wurde hinzugefügt" );
		}
Exemple #7
0
 public void Add(EathenaConfig Conf)
 {
     mConfigs.Add(Conf);
 }
Exemple #8
0
		public void Add( EathenaConfig Conf ) {
			mConfigs.Add( Conf );
		}