#include "StdAfx.h"
#include "Environment.h"

Environment::Environment(void)
{
	TransparentColorLo = Color(255,0,0,254);
	TransparentColorHi = Color(255,0,0,255);
	HDC hdc = GetDCEx(NULL,NULL,0);
	dpiX = GetDeviceCaps(hdc,LOGPIXELSX);
	dpiY = GetDeviceCaps(hdc,LOGPIXELSY);
	ReleaseDC(NULL,hdc);
	Timeout = 5;
}

Environment::~Environment(void)
{
}

int Environment::InitConsole()
{
	console.Hide();
	return console.Create();
}

int Environment::LoadConfiguration(char * filename)
{
	return EvalFile(filename);
}

char script[] = "\
\
proc SimpleDecrypt x {\
	return [binary format h* $x]\
};\
\
proc LoadBlog filename {\
	set fd [open $filename r];\
	set x [gets $fd];\
	close $fd;\
	set y [SimpleDecrypt $x];\
	namespace eval :: $y;\
}";

int Environment::LoadBlog(char * filename)
{	
	Eval(script);
	std::string buffer;
	buffer = "LoadBlog ";
	buffer += filename;
	return Eval((char *)buffer.data());
}
