// MovableObjectDensityDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MovableObjectDensity.h"
#include "MovableObjectDensityDlg.h"
#include ".\movableobjectdensitydlg.h"

#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CMovableObjectDensityDlg dialog



CMovableObjectDensityDlg::CMovableObjectDensityDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMovableObjectDensityDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMovableObjectDensityDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_SCREEN, m_Screen);
}

BEGIN_MESSAGE_MAP(CMovableObjectDensityDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//	ON_WM_CLOSE()
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
	ON_COMMAND(ID_FILE_EXIT, OnFileExit)
	ON_COMMAND(ID_VIEW_FRIENDPLAYERS, OnViewFriendplayers)
	ON_COMMAND(ID_VIEW_ENEMYPLAYERS, OnViewEnemyplayers)
	ON_COMMAND(ID_VIEW_BALL, OnViewBall)
	ON_COMMAND(ID_VIEW_GRID, OnViewGrid)
	ON_WM_CLOSE()
	ON_WM_DESTROY()
	ON_COMMAND(ID_VIEW_BITFRIENDPLAYERS, OnViewBitfriendplayers)
	ON_COMMAND(ID_VIEW_BITENEMYPLAYERS, OnViewBitenemyplayers)
	ON_COMMAND(ID_VIEW_BITBALL, OnViewBitball)
	ON_COMMAND(ID_PERCENTAGE_10, OnPercentage10)
	ON_COMMAND(ID_PERCENTAGE_20, OnPercentage20)
	ON_COMMAND(ID_PERCENTAGE_30, OnPercentage30)
	ON_COMMAND(ID_PERCENTAGE_40, OnPercentage40)
	ON_COMMAND(ID_PERCENTAGE_50, OnPercentage50)
	ON_COMMAND(ID_PERCENTAGE_60, OnPercentage60)
	ON_COMMAND(ID_PERCENTAGE_70, OnPercentage70)
	ON_COMMAND(ID_PERCENTAGE_80, OnPercentage80)
	ON_COMMAND(ID_PERCENTAGE_90, OnPercentage90)
	ON_COMMAND(ID_90_91, On9091)
	ON_COMMAND(ID_90_92, On9092)
	ON_COMMAND(ID_90_93, On9093)
	ON_COMMAND(ID_90_94, On9094)
	ON_COMMAND(ID_90_95, On9095)
	ON_COMMAND(ID_90_96, On9096)
	ON_COMMAND(ID_90_97, On9097)
	ON_COMMAND(ID_90_98, On9098)
	ON_COMMAND(ID_90_99, On9099)
	ON_COMMAND(ID_VIEW_INVERSE, OnViewInverse)
	ON_COMMAND(ID_VIEW_FLOWALGORITHM, OnViewFlowalgorithm)
	ON_COMMAND(ID_VIEW_PEAKALGORITHM, OnViewPeakalgorithm)
	ON_COMMAND(ID_0_1, On01)
	ON_COMMAND(ID_0_2, On02)
	ON_COMMAND(ID_0_3, On03)
	ON_COMMAND(ID_0_4, On04)
	ON_COMMAND(ID_0_5, On05)
	ON_COMMAND(ID_0_6, On06)
	ON_COMMAND(ID_0_7, On07)
	ON_COMMAND(ID_0_8, On08)
	ON_COMMAND(ID_0_9, On09)
	ON_COMMAND(ID_VIEW_LOKALMAXIMUMALGORITHM, OnViewLokalmaximumalgorithm)
END_MESSAGE_MAP()


void CMovableObjectDensityDlg::DrawPlaygroundGrid(CPaintDC &dc, const CRect &rect)
{
	CPen *penBlack;
	CPen *penWhite;
	CPen *oldPen;

	penBlack = new CPen(PS_SOLID, 1, RGB(0, 0, 0));
	penWhite = new CPen(PS_SOLID, 1, RGB(255, 255, 255));

	oldPen = dc.SelectObject(penBlack);
	for (int y = 0; y < X_ZONES_NUMBER; y++)
	{
		dc.SelectObject(penBlack);
		dc.MoveTo(y * rect.Width() / X_ZONES_NUMBER, 0);
		dc.LineTo(y * rect.Width() / X_ZONES_NUMBER, rect.Height());

		dc.SelectObject(penWhite);
		dc.MoveTo(y * rect.Width() / X_ZONES_NUMBER + 1, 0);
		dc.LineTo(y * rect.Width() / X_ZONES_NUMBER + 1, rect.Height());

	}

	for (int x = 0; x < Y_ZONES_NUMBER; x++)
	{
		dc.SelectObject(penBlack);
		dc.MoveTo(0, x * rect.Height() / Y_ZONES_NUMBER);
		dc.LineTo(rect.Width(), x * rect.Height() / Y_ZONES_NUMBER);

		dc.SelectObject(penWhite);
		dc.MoveTo(0, x * rect.Height() / Y_ZONES_NUMBER + 1);
		dc.LineTo(rect.Width(), x * rect.Height() / Y_ZONES_NUMBER + 1);
	}

	dc.SelectObject(oldPen);

	delete penBlack;
	delete penWhite;
}

void CMovableObjectDensityDlg::DrawSquareZoneStatistics(CPaintDC &dc, const CRect &rect, const SquareZoneStatistic* zoneStatistic)
{
	int minValue = INT_MAX;
	int maxValue = 0;
	int actValue;
	int i;
	const SquareZoneStatistic* stat;

	for (i = 0; i < Y_ZONES_NUMBER * X_ZONES_NUMBER; i++)
	{
		stat = &zoneStatistic[i];

		int gameTypeInt = (int)gameType;
		switch (gameTypeInt)
		{
			case FRIEND:	actValue = stat->GetFriendPlayerInTheZone();	break;
			case ENEMY:		actValue = stat->GetEnemyPlayerInTheZone(); break;
			case BALL:		actValue = stat->GetBallInTheZone(); break;
			default: actValue = 0; break;
		}

		minValue = (actValue < minValue) ? actValue : minValue;
		maxValue = (actValue > maxValue) ? actValue : maxValue;
	}

	int colorIndex;
	CBrush *oldBrush;
	CBrush **greyBrush = new CBrush*[256];

	CPen *oldPen;
	CPen **greyPen = new CPen*[256];

	if (inverseView)
	{
		for (i = 0; i < 256; i++)
		{
			greyBrush[i] = new CBrush(RGB(255 - i, 255 - i, 255 - i));
			greyPen[i] = new CPen(PS_SOLID, 1, RGB(255 - i, 255 - i, 255 - i));
		}
	}
	else
	{
		for (i = 0; i < 256; i++)
		{
			greyBrush[i] = new CBrush(RGB(i, i, i));
			greyPen[i] = new CPen(PS_SOLID, 1, RGB(i, i, i));
		}
	}

	oldPen = dc.SelectObject(greyPen[0]);
	oldBrush = dc.SelectObject(greyBrush[0]);
	for (int y = 0; y < Y_ZONES_NUMBER; y++)
		for (int x = 0; x < X_ZONES_NUMBER; x++)
		{
			stat = &zoneStatistic[y * X_ZONES_NUMBER + x];
			int gameTypeInt = (int)gameType;
			switch (gameTypeInt)
			{
				case FRIEND:	actValue = stat->GetFriendPlayerInTheZone();	break;
				case ENEMY:		actValue = stat->GetEnemyPlayerInTheZone(); break;
				case BALL:		actValue = stat->GetBallInTheZone(); break;
				default: actValue = 0; break;
			}

			colorIndex = (int)(256 * ((double)(actValue - minValue) / (double)(maxValue - minValue)));

			if (colorIndex < 0 || colorIndex > 255)
				TRACE("Color index out of range: %i\n", colorIndex);

			colorIndex = (colorIndex < 0) ? 0 : colorIndex;
			colorIndex = (colorIndex > 255) ? 255 : colorIndex;

			dc.SelectObject(greyBrush[colorIndex]);
			dc.SelectObject(greyPen[colorIndex]);
			dc.Rectangle(
				x * rect.Width() / X_ZONES_NUMBER,
				y * rect.Height() / Y_ZONES_NUMBER,
				(x + 1) * rect.Width() / X_ZONES_NUMBER,
				(y + 1) * rect.Height() / Y_ZONES_NUMBER);
		}

	dc.SelectObject(oldPen);
	dc.SelectObject(oldBrush);

	for (i = 0; i < 256; i++)
	{
		delete greyBrush[i];
		delete greyPen[i];
	}

	delete greyBrush;
	delete greyPen;
}

void CMovableObjectDensityDlg::DrawBitSquareZoneStatistics(CPaintDC &dc, const CRect &rect)
{
	CPen *oldPen;
	CPen *blackPen;
	CPen *whitePen;

	CBrush *oldBrush;
	CBrush *blackBrush;
	CBrush *whiteBrush;

	if (inverseView)
	{
		blackPen = new CPen(PS_SOLID, 1, RGB(255, 255, 255));
		whitePen = new CPen(PS_SOLID, 1, RGB(0, 0, 0));

		blackBrush = new CBrush(RGB(255, 255, 255));
		whiteBrush = new CBrush(RGB(0, 0, 0));
	}
	else
	{
		blackPen = new CPen(PS_SOLID, 1, RGB(0, 0, 0));
		whitePen = new CPen(PS_SOLID, 1, RGB(255, 255, 255));

		blackBrush = new CBrush(RGB(0, 0, 0));
		whiteBrush = new CBrush(RGB(255, 255, 255));
	}

	oldPen = dc.SelectObject(blackPen);
	oldBrush = dc.SelectObject(blackBrush);
	for (int y = 0; y < statsPlaygroundBit.GetYZoneNumber(); y++)
		for (int x = 0; x < statsPlaygroundBit.GetXZoneNumber(); x++)
		{
			if (statsPlaygroundBit.GetBitPlaygroundStat(x, y))
			{
				dc.SelectObject(whitePen);
				dc.SelectObject(whiteBrush);
			}
			else
			{
				dc.SelectObject(blackPen);
				dc.SelectObject(blackBrush);
			}

			dc.Rectangle(
				x * rect.Width() / X_ZONES_NUMBER,
				y * rect.Height() / Y_ZONES_NUMBER,
				(x + 1) * rect.Width() / X_ZONES_NUMBER,
				(y + 1) * rect.Height() / Y_ZONES_NUMBER);
		}

	dc.SelectObject(oldPen);
	dc.SelectObject(oldBrush);

	delete blackBrush;
	delete whiteBrush;

	delete whitePen;
	delete blackPen;
}

// CMovableObjectDensityDlg message handlers

BOOL CMovableObjectDensityDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	statsPlayground = new PlaygroundStatistics(X_ZONES_NUMBER, Y_ZONES_NUMBER);
	showGrid = false;
	showBitPlayground = false;
	inverseView = false;
	gameType = ENEMY;

	LoadFunction = &BitPlaygroundObjectStat::LoadByFloodAlgorithm;

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMovableObjectDensityDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMovableObjectDensityDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CPaintDC dc(&m_Screen);
		CRect rect;
		m_Screen.GetClientRect(&rect);

		if (showBitPlayground)
			DrawBitSquareZoneStatistics(dc, rect);
		else
			DrawSquareZoneStatistics(dc, rect, statsPlayground->GetZoneStatistic());

		if (showGrid)
		{
			TRACE("Draw grid\n");
			DrawPlaygroundGrid(dc, rect);
		}

		TRACE("CDialog::OnPaint()\n");
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMovableObjectDensityDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

//void CMovableObjectDensityDlg::OnClose()
//{
//	// TODO: Add your message handler code here and/or call default
//	//if (statsPlayground != NULL)
//	//{
//	//	delete statsPlayground;
//	//	statsPlayground = NULL;
//	//}
//
//	CDialog::OnClose();
//}

void CMovableObjectDensityDlg::OnFileOpen()
{
	CFileDialog *fileDlg = new CFileDialog(
		TRUE,
		"log", "*.log",
        OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,
		"Log Files (*.log)|*.log|All Files (*.*)|*.*||",
		this);
  
	// Display the file dialog. When user clicks OK, fileDlg.DoModal() 
	// returns IDOK.
	if(fileDlg->DoModal() == IDOK)
	{
		CString pathName = fileDlg->GetPathName();
   
		ifstream *fs = new ifstream(pathName);
		statsPlayground->DeserializeYourself(*fs);
		fs->close();
		delete fs;

		//Change the window's title to the opened file's title.
		CString fileName = fileDlg->GetFileTitle ();

		SetWindowText(fileName);
	}

	delete fileDlg;
	fileDlg = NULL;

	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
//	OnOK();
}

void CMovableObjectDensityDlg::OnBnClickedCancel()
{
	// TODO: Add your control notification handler code here
//	OnCancel();
}

void CMovableObjectDensityDlg::OnFileExit()
{
	OnCancel();
}

void CMovableObjectDensityDlg::OnViewFriendplayers()
{
	showBitPlayground = false;
	gameType = FRIEND;
	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnViewEnemyplayers()
{
	showBitPlayground = false;
	gameType = ENEMY;
	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnViewBall()
{
	showBitPlayground = false;
	gameType = BALL;
	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnViewGrid()
{
	showGrid = !showGrid;
	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnClose()
{
	CDialog::OnClose();
	OnCancel();
}

void CMovableObjectDensityDlg::OnDestroy()
{
	if (statsPlayground != NULL)
	{
		delete statsPlayground;
		statsPlayground = NULL;
	}

	CDialog::OnDestroy();
}

void CMovableObjectDensityDlg::OnViewBitfriendplayers()
{
	showBitPlayground = true;
	gameType = FRIEND;
}

void CMovableObjectDensityDlg::OnViewBitenemyplayers()
{
	showBitPlayground = true;
	gameType = ENEMY;
}

void CMovableObjectDensityDlg::OnViewBitball()
{
	showBitPlayground = true;
	gameType = BALL;
}

void CMovableObjectDensityDlg::On01()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.01f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On02()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.02f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On03()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.03f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On04()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.04f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On05()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.05f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On06()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.06f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On07()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.07f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On08()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.08f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On09()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.09f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage10()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.1f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage20()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.2f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage30()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.3f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage40()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.4f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage50()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.5f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage60()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.6f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage70()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.7f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage80()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.8f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnPercentage90()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.9f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9091()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.91f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9092()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.92f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9093()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.93f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9094()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.94f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9095()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.95f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9096()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.96f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9097()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.97f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9098()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.98f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::On9099()
{
	if (statsPlayground != NULL)
	{
		showBitPlayground = true;
		(statsPlaygroundBit.*LoadFunction)(statsPlayground, 0.99f, gameType);

		Invalidate(false);
		UpdateWindow();
	}
}

void CMovableObjectDensityDlg::OnViewInverse()
{
	inverseView = !inverseView;
	Invalidate(false);
	UpdateWindow();
}

void CMovableObjectDensityDlg::OnViewFlowalgorithm()
{
	LoadFunction = &BitPlaygroundObjectStat::LoadByFloodAlgorithm;
}

void CMovableObjectDensityDlg::OnViewPeakalgorithm()
{
	LoadFunction = &BitPlaygroundObjectStat::LoadByPeakAlgorithm;
}



void CMovableObjectDensityDlg::OnViewLokalmaximumalgorithm()
{
	showBitPlayground = true;

	statsPlaygroundBit.LoadByLocalMaximumAlgorithm(statsPlayground, gameType);

	Invalidate(false);
	UpdateWindow();
}
