private void OpenKIFFile(string kifFilePath) { KIFFilePath = kifFilePath; mruManager.AddRecentFile(KIFFilePath); GeneralGameManager = new GeneralGameManager(KIFFilePath, 10, 10, Properties.Settings.Default.WcfSvcHostExecutable, Properties.Settings.Default.TempFilePath) { StartNextMoveEvent = startNextTurnEvent, PrevMoveEvent = prevTurnEvent }; GeneralGame.UseOldWayOfGeneratingAndApplyingMoves = useOriginalMoveGenerationAndApplicationToolStripMenuItem.Checked; playerToolStripMenuItem.DropDownItems.Clear(); int playerOutputWindowX = 0; int playerOutputWindowY = htmlOutputForm.Location.Y + htmlOutputForm.Height; int playerOutputFormWidth = (this.ClientRectangle.Width - 5) / (GeneralGameManager.TheGeneralGame.FindRoles().Count() == 0 ? 1 : GeneralGameManager.TheGeneralGame.FindRoles().Count()); int playerOutputFormHeight = this.ClientRectangle.Height - 25 - this.statusStrip1.Height - managerOutputForm.Height - htmlOutputForm.Height - (2 * SystemInformation.HorizontalScrollBarHeight); int playerFormCount = 0; foreach (string role in GeneralGameManager.TheGeneralGame.FindRoles()) { var playerOutputForm = new Form() { MdiParent = this, Text = role, StartPosition = FormStartPosition.Manual, Location = new Point(playerOutputWindowX, playerOutputWindowY), Width = playerOutputFormWidth, Height = playerOutputFormHeight, Tag = PlayerWindowConfigStringPrefix + playerFormCount }; var playerOutputTextBox = new TextBox() { Dock = DockStyle.Fill, Multiline = true, ScrollBars = ScrollBars.Both }; playerOutputForm.Controls.Add(playerOutputTextBox); DebugAndTraceHelper.AddListener(new TextboxTraceListener(playerOutputTextBox), role); playerOutputWindowX += playerOutputForm.Bounds.Width; WindowGeometryPersistence.SetFormsGeometry(Properties.Settings.Default.WindowGeometry, playerOutputForm); playerOutputForm.Show(); outputForms.Add(playerOutputForm); var mi = new ToolStripMenuItem(role); playerToolStripMenuItem.DropDownItems.Add(mi); var submi = new ToolStripMenuItem("Query Player Prolog Engine"); mi.DropDownItems.Add(submi); submi.Click += (o, k) => { var dialog = new PrologQuery(GeneralGameManager.Players.Where(n => n.Role == role).First().GetPrologEngine()); dialog.Show(this); }; playerFormCount++; } startGameToolStripMenuItem.Enabled = true; saveCollapsedParseTreesToolStripMenuItem.Enabled = true; saveParseTreesToolStripMenuItem.Enabled = true; saveHornClausesToolStripMenuItem.Enabled = true; queryGamePrologEngineToolStripMenuItem.Enabled = true; dumpPrologEngineUserClausesToolStripMenuItem.Enabled = true; }
protected override void OnLoad(EventArgs e) { DebugAndTraceHelper.CustomLocation = Properties.Settings.Default.TempFilePath; mruManager = new MRUManager(selectRecentGameFileToolStripMenuItem, Application.ProductName, recentFileGotClicked, null); freeRunningToolStripMenuItem.Enabled = false; tsb_NextTurn.Enabled = false; tsb_PrevTurn.Enabled = false; startGameToolStripMenuItem.Enabled = false; saveCollapsedParseTreesToolStripMenuItem.Enabled = false; saveParseTreesToolStripMenuItem.Enabled = false; saveHornClausesToolStripMenuItem.Enabled = false; queryGamePrologEngineToolStripMenuItem.Enabled = false; dumpPrologEngineUserClausesToolStripMenuItem.Enabled = false; var dc = new DecoupledConsole(); DebugAndTraceHelper.AddListener(new DecoupledConsoleTraceListener(dc)); DebugAndTraceHelper.AddListener(new ToolStripStatusLabelListener(this.toolStripStatusLabel1), DebugAndTraceHelper.StatusStripChannelId); managerOutputForm = new Form() { MdiParent = this, Text = DebugAndTraceHelper.ManagerChannelId, StartPosition = FormStartPosition.Manual, Location = new Point(0, 0), Width = this.ClientRectangle.Width - 5, Tag = GameManagerWindowConfigStringPrefix }; var managerOutputTextBox = new TextBox() { Dock = DockStyle.Fill, Multiline = true, ScrollBars = ScrollBars.Both }; managerOutputForm.Controls.Add(managerOutputTextBox); DebugAndTraceHelper.AddListener(new TextboxTraceListener(managerOutputTextBox), DebugAndTraceHelper.ManagerChannelId); try { WindowGeometryPersistence.SetFormsGeometry(Properties.Settings.Default.WindowGeometry, managerOutputForm); } catch (Exception) { ; } managerOutputForm.Show(); outputForms.Add(managerOutputForm); htmlOutputForm = new Form() { MdiParent = this, StartPosition = FormStartPosition.Manual, Location = new Point(0, managerOutputForm.Height), Width = this.ClientRectangle.Width - 5, Tag = GameStateWindowConfigString }; var webBrowser = new System.Windows.Forms.WebBrowser() { Dock = DockStyle.Fill, ScrollBarsEnabled = true }; htmlOutputForm.Controls.Add(webBrowser); DebugAndTraceHelper.WriteTraceLine("WebBrowser version: " + webBrowser.Version, DebugAndTraceHelper.ManagerChannelId); htmlOutputFormListener = new IEWebBrowserListener(webBrowser); DebugAndTraceHelper.AddListener(htmlOutputFormListener, DebugAndTraceHelper.StateChannelId); WindowGeometryPersistence.SetFormsGeometry(Properties.Settings.Default.WindowGeometry, htmlOutputForm); htmlOutputForm.Show(); outputForms.Add(htmlOutputForm); GeneralGame.UseOldWayOfGeneratingAndApplyingMoves = useOriginalMoveGenerationAndApplicationToolStripMenuItem.Checked; if (!System.Diagnostics.Debugger.IsAttached && false) { Thread t; t = new Thread(StartSWIPrologService1); t.IsBackground = true; t.Start(); Thread t2; t2 = new Thread(StartSWIPrologService2); t2.IsBackground = true; t2.Start(); Thread t3; t3 = new Thread(StartSWIPrologService3); t3.IsBackground = true; t3.Start(); } #if PrologEngineTest PrologEngine.PrologEngine foo = new PrologEngine.PrologEngine(); foo.Assert("cell(1,1,b)"); foo.Assert("cell(2,2,x)"); foreach (List <SWIPrologServiceLibrary.SolutionVariable> solutionVariables in foo.GetSolutionVariables("cell(X,Y,Z)")) { ; } PrologEngine.PrologEngine foo2 = new PrologEngine.PrologEngine(); foo2.Assert("cell(2,2,o)"); foo2.Assert("cell(3,3,x)"); foreach (List <SWIPrologServiceLibrary.SolutionVariable> solutionVariables in foo2.GetSolutionVariables("cell(X,Y,Z)")) { ; } PrologEngine.PrologEngine foo3 = new PrologEngine.PrologEngine(); foo3.Assert("cell(1,2,b)"); foo3.Assert("cell(2,3,o)"); foreach (List <SWIPrologServiceLibrary.SolutionVariable> solutionVariables in foo3.GetSolutionVariables("cell(X,Y,Z)")) { ; } foreach (List <SWIPrologServiceLibrary.SolutionVariable> solutionVariables in foo2.GetSolutionVariables("cell(X,Y,Z)")) { ; } foreach (List <SWIPrologServiceLibrary.SolutionVariable> solutionVariables in foo.GetSolutionVariables("cell(X,Y,Z)")) { ; } #endif }