/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2017/3/11
 * 时间: 14:09
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;


using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using zyxDll;
using System.Collections.Generic;
using System.Reflection;
using System.Collections;

namespace nativeCom
{
	
	/// <summary>
	/// Description of Form1.
	/// </summary>
	public partial class Formzyx : Form
	{
		
		[DllImport("HjhaServer_dll.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
		public static extern int testfun(ref  tr_test t	);
		
		static Formzyx _fmzyx=null;
		public static Formzyx fmzyx{get{if(_fmzyx==null){_fmzyx=new Formzyx();}return _fmzyx;}}
		
		
		
		public Formzyx()
		{
			
			InitializeComponent();
			
		}
		
		static int logCount = 0;
		
		public static void log(string str,bool isError=false){
			if (isError){ error(str); return;}
			if (logCount>1000){
				fmzyx.textBox3.Clear();
				logCount = 0;
			}
			fmzyx.textBox3.AppendText(str + "\r\n");
			logCount ++;
			
		}
		static int logCount_error = 0;
		public static void error(string str){
			if (logCount_error>1000){
				fmzyx.textBox4.Clear();
				logCount_error = 0;
			}
			fmzyx.textBox4.AppendText(str + "\r\n");
			logCount_error ++;
			
		}
		
		
		
		unsafe void Button1Click(object sender, EventArgs e)
		{
			Form fm=baseinfo.instance.dll.fmsub;
			if (fm==null)return;
			if (!fm.Visible)
				fm.Show();else fm.Hide();
			
		}
		unsafe void Button2Click(object sender, EventArgs e)
		{
			return;
			tr_test t=new tr_test();t.b=651;
			ABlock b=new ABlock();
			
			
			tr_rltpchar sdfsdf=new tr_rltpchar();
			
			string rlt=null;
			
			int kjk=baseinfo.instance.exe.gamefun("-1",
			                                      //"9*3000*"+
			                                      "kljjklj89"
			                                      //+"*"+Marshal.SizeOf(t).ToString()
			                                      , ref sdfsdf,ref b,ref b);
			sdfsdf.str=null;
			return;
//			string ss=null;
//			ABlock b=new ABlock();
//			dcEvent_zyx.Instance.gamefuns("0","",ref ss,ref b,ref b);
//			string s=nativeCom.cls_nativeCom.Instance.	getUnmanagedString(ref b);
//
//			log(s);
//			b.pt=null;
//			log(ss);
//
			
			
			testfun(ref t);
			log(t.b.ToString());
		}
		
		
		
		void Form1FormClosing(object sender, FormClosingEventArgs e)
		{
			if (baseinfo.instance.exe.gamestate>2)return;
			
			e.Cancel=true;
		}
		
		
		void FormzyxFormClosed(object sender, FormClosedEventArgs e)
		{
			Form fm=baseinfo.instance.dll.fmsub;
			if (fm==null)return;
			if(baseinfo.instance.exe.gamestate>2)
				fm.Close();
		}
		
		
		
		
	}


}
namespace zyxDll
{
	public  class FormSub0 : Form{
		public virtual void init(){}
	}
}