Void ZakladFormula1::dodajNowyZaklad(){
	System::String^ tekst;
	Int16 id;
	StreamWriter^ plik = gcnew StreamWriter("BazaDanych\\druzyny.txt", true, System::Text::Encoding::Default);
	StreamReader^ plikId = gcnew StreamReader("BazaDanych\\zakladID.txt", System::Text::Encoding::Default);

	tekst = plikId->ReadToEnd()->Trim();
	id = (Int16::Parse(tekst));
	id++;

	zakladId = id;
	plikId->Close();

	StreamWriter^ plik2 = gcnew StreamWriter("BazaDanych\\zakladID.txt", false, System::Text::Encoding::Default);
	plik2->Write(id.ToString());
	plik2->Close();

	plik->WriteLine("ID=" + this->zakladId);
	plik->WriteLine(this->obiektZakladu1->getTyp());
	plik->WriteLine(this->obiektZakladu1->getNazwa1());
	plik->WriteLine(this->obiektZakladu1->getKurs1());
	plik->WriteLine(this->obiektZakladu2->getNazwa1());
	plik->WriteLine(this->obiektZakladu2->getKurs1());
	plik->WriteLine(this->obiektZakladu3->getNazwa1());
	plik->WriteLine(this->obiektZakladu3->getKurs1());
	plik->WriteLine("###########");

	plik->Close();
}
Exemplo n.º 2
0
FileEntitySchemeInputStream::FileEntitySchemeInputStream(ptr<Entity> entity)
: entity(entity), currentBlockIndex(0), currentBlockOffset(0), ended(false)
{
	BEGIN_TRY();

	// read descriptor
	ptr<File> descriptorFile = entity->ReadData(nullptr);
	if(!descriptorFile)
		THROW("No descriptor");

	descriptorReader = NEW(StreamReader(NEW(FileInputStream(descriptorFile))));

	// read & check the version
	size_t version = descriptorReader->ReadShortly();
	// for now only version 1 is supported
	if(version != 1)
		THROW("Invalid descriptor version");
	totalSize = descriptorReader->ReadShortlyBig();
	remainingSize = totalSize;

	hashStream = NEW(Crypto::WhirlpoolStream());
	totalHashStream = NEW(Crypto::WhirlpoolStream());

	// read total hash
	totalHashFromDescriptor = descriptorReader->Read(totalHashStream->GetHashSize());

	END_TRY("Can't create input stream for file entity");
}
Exemplo n.º 3
0
BlobFileSystem::BlobFileSystem(ptr<File> file) : file(file)
{
	try
	{
		void* fileData = file->GetData();
		size_t fileSize = file->GetSize();
		size_t size = fileSize;

		//получить терминатор
		if(size < sizeof(Terminator))
			THROW("Can't read terminator");
		Terminator* terminator = (Terminator*)((char*)fileData + fileSize) - 1;
		size -= sizeof(*terminator);

		//проверить сигнатуру
		if(memcmp(terminator->magic, Terminator::magicValue, sizeof(terminator->magic)) != 0)
			THROW("Invalid magic");

		//проверить, что заголовок читается
		if(size < terminator->headerSize)
			THROW("Can't read header");

		//получить читатель заголовка
		ptr<StreamReader> headerReader = NEW(StreamReader(NEW(FileInputStream(
			NEW(PartFile(file, (char*)terminator - terminator->headerSize, terminator->headerSize))))));
		size -= terminator->headerSize;

		//считывать файлы, пока есть
		for(;;)
		{
			//считать имя файла
			String fileName = headerReader->ReadString();
			//если оно пустое, значит, это конец
			if(fileName.empty())
				break;

			//считать смещение до файла и его размер
			size_t fileOffset = headerReader->ReadShortly();
			size_t fileSize = headerReader->ReadShortly();

			//проверить, что файл читается
			if(fileOffset > size || size - fileOffset < fileSize)
				THROW("Can't read file " + fileName);
			
			//добавить файл в карту
			files[fileName] = NEW(PartFile(file, (char*)fileData + fileOffset, fileSize));
		}
	}
	catch(Exception* exception)
	{
		THROW_SECONDARY("Can't load blob file system", exception);
	}
}
Exemplo n.º 4
0
void Manager::constructTableFromFlatFile() {
	StreamReader^ reader = gcnew StreamReader("Zoo.txt");

	while(reader->Peek() >= 0) {
		array<String^, 1>^ line = reader->ReadLine()->Split(',');
		
		Node^ node = gcnew Node(
				Convert::ToInt16(line[FType::ID]),
				line[FType::NAME],
				line[FType::SPECIES],
				line[FType::CAGENUMBER],
				line[FType::AGE],
				line[FType::FOOD]
			);

			adtTable->Insert(node);
	}
}
	plik->WriteLine("ID=" + this->zakladId);
	plik->WriteLine(this->obiektZakladu1->getTyp());
	plik->WriteLine(this->obiektZakladu1->getNazwa1());
	plik->WriteLine(this->obiektZakladu1->getKurs1());
	plik->WriteLine(this->obiektZakladu2->getNazwa1());
	plik->WriteLine(this->obiektZakladu2->getKurs1());
	plik->WriteLine(this->obiektZakladu3->getNazwa1());
	plik->WriteLine(this->obiektZakladu3->getKurs1());
	plik->WriteLine("###########");

	plik->Close();
}

Single ZakladFormula1::sprWyniki(PostawionyZaklad^ postawiony){
	StreamReader^ plikDruzyny = gcnew StreamReader("BazaDanych\\druzyny.txt", System::Text::Encoding::Default);
	StreamReader^ plikWyniki = gcnew StreamReader("BazaDanych\\wyniki.txt", System::Text::Encoding::Default);
	Single kurs1, kurs2, kurs3, zysk;
	String^ wynik;
	String^ czyKoniec;

	while (!plikDruzyny->ReadLine()->Equals(postawiony->getID_zakladu())); //szukam id zakladu
	plikDruzyny->ReadLine();//typ zakladu
	plikDruzyny->ReadLine();//nazwa pierwszego zawodnika
	kurs1 = Single::Parse(plikDruzyny->ReadLine());
	plikDruzyny->ReadLine();//nazwa drugiego zawodnika
	kurs2 = Single::Parse(plikDruzyny->ReadLine());
	plikDruzyny->ReadLine();//nazwa trzeciego zawodnika
	kurs3 = Single::Parse(plikDruzyny->ReadLine());
	plikDruzyny->Close();
Exemplo n.º 6
0
	
	query1=gcnew String("/current?path=//Path/DataItems/DataItem[@category=\"SAMPLE\"]");
	//
	query2=gcnew String("/current?path=//Path");

	doc= gcnew XmlDocument();

}

void MtConnector::EventHandler(Object^ sender, OpenReadCompletedEventArgs^ e){
	try{
	Console::WriteLine ("fired event");

	Stream ^ data=e->Result;
	StreamReader^ reader= gcnew StreamReader(data);
	String^ str;
	while ((str = reader->ReadLine()) != nullptr) 
                {
                   // Console::WriteLine(str);
                }
	//Console::WriteLine (reader->ReadToEnd ());
	}

	catch(Exception ^e){
		Console::WriteLine(e);
	}



}
Exemplo n.º 7
0
			"makhana",
			gcnew array<Point>
			{
				Point(0,22),		// Idle
				Point(23,60),		// Hurt
				Point(61,134),		// Desecrate
				Point(135,188),		// Tentishock
				Point(189,259),		// Oil Spill
				Point(260,303)		// Killed
			}
		);
}

array<int, 3>^ FrameManager::CreateFrameArrayFromFile(String^ fileName, array<Point>^ spriteSheetState)
{
		 StreamReader^ reader = gcnew StreamReader(fileName + ".map");

		 array<int, 3>^ spriteSheetData = gcnew array<int,3>(spriteSheetState->Length, 81, 4);	

		 for(int dim0 = 0; dim0 < spriteSheetData->GetLength(0); dim0++) // Sprite state
		 {
			int end = spriteSheetState[dim0].Y - spriteSheetState[dim0].X;
	 
			for(int dim1 = 0; dim1 < end; dim1++) // N Frames
			{			
				String^ line = reader->ReadLine();

				if(line != nullptr)
				{
					array<String^>^ items = line->Split(',');
Exemplo n.º 8
0
	// ================================================================
	// read_file_function: 
	// Reads motion file and decides which function to call
	// ================================================================
	void Form1::read_file_function(){
		int func_to_call;
		System::String^ data_read;
		System::String^ substring_data;
		int data_read_length;
		array<wchar_t>^ data_letters;
		double val;

		// Check if file has ended
		if ((myStreamReader -> Peek() >= 0)&!FLAG_READER_CLOSED)
		{
			// Read next line
			data_read = myStreamReader -> ReadLine();
			data_read_length = data_read -> Length;
			data_letters = gcnew array<wchar_t>(data_read -> Length){L' '};
			data_letters = data_read -> ToCharArray();

			// Cancel both background workers
			bw -> CancelAsync();
			bw_motion -> CancelAsync();
			
			// Check if next command is for MOTION
			if (data_letters[0] == 'n')
			{
				// Find spaces in the string
				array<int>^ space_positions = gcnew array<int>(18);
				int space_c = 0;
				for (int i = 0; i < data_read_length; i++)
				{
					if (data_read[i] == ' ')
					{
						space_positions[space_c] = i;
						space_c ++;
					}
				}
				// Parse string into doubles
				// Phalanx 0
				System::String^  substring_data = data_read -> Substring(2, space_positions[1] - space_positions[0] - 1);
				read_values[0] = System::Convert::ToDouble(substring_data);
				this -> trFinger1Ph1 -> Value = (int)(read_values[0] * 10.0f);
				this -> lblFinger1Phalanx1 -> Text = ""+ read_values[0];
				
				substring_data = data_read -> Substring(space_positions[1] + 1, space_positions[2] - space_positions[1] - 1);
				read_values[9] = System::Convert::ToDouble(substring_data);
				this -> tr11s -> Value = (int)(read_values[9]);
				this -> lbl11s -> Text = ""+ read_values[9];

				// Phalanx 1
				substring_data = data_read -> Substring(space_positions[2] + 1, space_positions[3] - space_positions[2] - 1);
				read_values[1] = System::Convert::ToDouble(substring_data);
				this -> trFinger1Ph2 -> Value = (int)(read_values[1] * 10.0f);
				this -> lblFinger1Phalanx2 -> Text = ""+ read_values[1];

				substring_data = data_read -> Substring(space_positions[3] + 1, space_positions[4] - space_positions[3] - 1);
				read_values[10] = System::Convert::ToDouble(substring_data);
				this -> tr12s -> Value = (int)(read_values[10]);
				this -> lbl12s -> Text = ""+ read_values[10];

				// Phalanx 2
				substring_data = data_read -> Substring(space_positions[4] + 1, space_positions[5] - space_positions[4] - 1);
				read_values[2] = System::Convert::ToDouble(substring_data);
				this -> trFinger1Ph3 -> Value = (int)(read_values[2] * 10.0f);
				this -> lblFinger1Phalanx3 -> Text = ""+ read_values[2];

				substring_data = data_read -> Substring(space_positions[5] + 1, space_positions[6] - space_positions[5] - 1);
				read_values[11] = System::Convert::ToDouble(substring_data);
				this -> tr13s -> Value = (int)(read_values[11]);
				this -> lbl13s -> Text = ""+ read_values[11];
				
				// Phalanx 3
				substring_data = data_read -> Substring(space_positions[6] + 1, space_positions[7] - space_positions[6] - 1);
				read_values[3] = System::Convert::ToDouble(substring_data);
				this -> trFinger2Ph1 -> Value = (int)(read_values[3] * 10.0f);
				this -> lblFinger2Phalanx1 -> Text = ""+ read_values[3];

				substring_data = data_read -> Substring(space_positions[7] + 1, space_positions[8] - space_positions[7] - 1);
				read_values[12] = System::Convert::ToDouble(substring_data);
				this -> tr21s -> Value = (int)(read_values[12]);
				this -> lbl21s -> Text = ""+ read_values[12];

				// Phalanx 4
				substring_data = data_read -> Substring(space_positions[8] + 1, space_positions[9] - space_positions[8] - 1);
				read_values[4] = System::Convert::ToDouble(substring_data);
				this -> trFinger2Ph2 -> Value = (int)(read_values[4] * 10.0f);
				this -> lblFinger2Phalanx2 -> Text = ""+ read_values[4];

				substring_data = data_read -> Substring(space_positions[9] + 1, space_positions[10] - space_positions[9] - 1);
				read_values[13] = System::Convert::ToDouble(substring_data);
				this -> tr22s -> Value = (int)(read_values[13]);
				this -> lbl22s -> Text = ""+ read_values[13];

				// Phalanx 5
				substring_data = data_read -> Substring(space_positions[10] + 1, space_positions[11] - space_positions[10] - 1);
				read_values[5] = System::Convert::ToDouble(substring_data);
				this -> trFinger2Ph3 -> Value = (int)(read_values[5] * 10.0f);
				this -> lblFinger2Phalanx3 -> Text = ""+ read_values[5];

				substring_data = data_read -> Substring(space_positions[11] + 1, space_positions[12] - space_positions[11] - 1);
				read_values[14] = System::Convert::ToDouble(substring_data);
				this -> tr23s -> Value = (int)(read_values[14]);
				this -> lbl23s -> Text = ""+ read_values[14];

				// Phalanx 6
				substring_data = data_read -> Substring(space_positions[12] + 1, space_positions[13] - space_positions[12] - 1);
				read_values[6] = System::Convert::ToDouble(substring_data);
				this -> trFinger3Ph1 -> Value = (int)(read_values[6] * 10.0f);
				this -> lblFinger3Phalanx1 -> Text = ""+ read_values[6];

				substring_data = data_read -> Substring(space_positions[13] + 1, space_positions[14] - space_positions[13] - 1);
				read_values[15] = System::Convert::ToDouble(substring_data);
				this -> tr31s -> Value = (int)(read_values[15]);
				this -> lbl31s -> Text = ""+ read_values[15];

				// Phalanx 7
				substring_data = data_read -> Substring(space_positions[14] + 1, space_positions[15] - space_positions[14] - 1);
				read_values[7] = System::Convert::ToDouble(substring_data);
				this -> trFinger3Ph2 -> Value = (int)(read_values[7] * 10.0f);
				this -> lblFinger3Phalanx2 -> Text = ""+ read_values[7];

				substring_data = data_read -> Substring(space_positions[15] + 1, space_positions[16] - space_positions[15] - 1);
				read_values[16] = System::Convert::ToDouble(substring_data);
				this -> tr32s -> Value = (int)(read_values[16]);
				this -> lbl32s -> Text = ""+ read_values[16];

				// Phalanx 8
				substring_data = data_read -> Substring(space_positions[16] + 1, space_positions[17] - space_positions[16] - 1);
				read_values[8] = System::Convert::ToDouble(substring_data);
				this -> trFinger3Ph3 -> Value = (int)(read_values[8] * 10.0f);
				this -> lblFinger3Phalanx3 -> Text = ""+ read_values[8];

				substring_data = data_read -> Substring(space_positions[17] + 1, data_read_length - space_positions[17] - 1);
				read_values[17] = System::Convert::ToDouble(substring_data);
				this -> tr33s -> Value = (int)(read_values[17]);
				this -> lbl33s -> Text = ""+ read_values[17];
				
				// Call background worker for motion
				func_to_call = 1;
			}
			// Check if next action is for WAITING
			else if (data_letters[0] == 'W')
			{
				// Extract wait period (in ms)
				substring_data = data_read -> Substring(2, data_read_length - 2);
				val = System::Convert::ToDouble(substring_data);

				// Call background worker for pause
				func_to_call = 2;
			}
		}
		else 
		{
			// If stream over, close it
			myStreamReader -> Close();
			myStreamReader = gcnew StreamReader(gcnew String(motion_file_name));
			data_read = myStreamReader -> ReadLine();

			// Set closed flag to true, so it can be reopened without reloading
			FLAG_READER_CLOSED = true;
		}
		if (func_to_call == 1)
		{
			motion_config();
		}
		else if (func_to_call == 2)
		{
			motion_pause(val);
		}
		else
		{
			return;
		}
}