//------------------------------------------------------------------------------
// TOPPERS/ASP Sample1 Debuging Environment
// Copyright (C) 2010-2011 Cores Co., Ltd. Japan
//------------------------------------------------------------------------------
// $Id: Test0001.cs 87 2011-04-05 10:30:40Z nagasima $
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SimBase;
using ConsoleView;

namespace Sample1Sim
{
	public partial class Sample1View : Form
	{
		SimEnvironment m_SimEnvironment;

		public Sample1View(SimEnvironment simEnvironment)
		{
			TopLevel = false;
			m_SimEnvironment = simEnvironment;
			((Sample1)m_SimEnvironment.Sample1).ConsoleOut += new UnitOutputEventHandler(Sample1_UnitOutput);
			InitializeComponent();
		}

		private void Sample1View_Load(object sender, EventArgs e)
		{
		}

		private void Sample1_UnitOutput(IUnitSim sender, int kind, byte[] data)
		{
			BeginInvoke(new MethodInvoker(delegate()
			{
				consoleView1.Parse(data, 0, data.Length);
			}));
		}

		private void consoleView1_DataReceive(object sender, byte[] data)
		{
			m_SimEnvironment.Sample1.Input(0, data);
		}
	}
}