/// <summary> /// Update the starting position /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPositionScreen_Click(object sender, EventArgs e) { MacomberMap_Form NetworkMap = Program.MM; MacomberMapClient.Data_Elements.Geographic.MM_Boundary Bound = MM_Repository.Counties["STATE"]; //NetworkMap.ctlNetworkMap.SetDisplayCoordinates(Bound.Min, Bound.Max); NetworkMap.ctlNetworkMap.SetDisplayCoordinates(new PointF(-109.544678f, 35.5947838f), new PointF(-90.60425f, 25.37381f)); }
/// <summary> /// Every interval, grab a screen shot /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tmrCaptureScreenshot_Tick(object sender, EventArgs e) { if (!chkCapturePaused.Checked && Data_Integration.SimulatorStatus != MacomberMapCommunications.Messages.EMS.MM_Simulation_Time.enumSimulationStatus.Running) { return; } MacomberMap_Form NetworkMap = Program.MM; using (Bitmap OutBmp = new Bitmap(NetworkMap.DisplayRectangle.Width, NetworkMap.DisplayRectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) { //Note, due to the DirectX layer, now a printscreen core library must be used using (Graphics g = Graphics.FromImage(OutBmp)) using (Font DrawFont = new Font("Arial", 16, FontStyle.Bold)) using (StringFormat sF = new StringFormat() { Alignment = StringAlignment.Center }) { IntPtr hDC = g.GetHdc(); try { PrintWindow(NetworkMap.Handle, hDC, (uint)0); } catch { NetworkMap.DrawToBitmap(OutBmp, NetworkMap.DisplayRectangle); } finally { g.ReleaseHdc(hDC); } g.DrawString(DateTime.Now.ToString(), DrawFont, Brushes.White, OutBmp.Width / 2, 20, sF); } OutBmp.Save("img" + ImageCount.ToString("00000") + ".png", ImageFormat.Png); lblFramesCaptured.Text = "Frames captured: " + (++CapturedFrames).ToString("#,##0"); using (XmlTextWriter xW = new XmlTextWriter("snp" + ImageCount.ToString("00000") + ".xml", new UTF8Encoding(false))) { xW.WriteStartDocument(); xW.WriteStartElement("Savecase"); xW.WriteAttributeString("Realtime", XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Unspecified)); xW.WriteAttributeString("SavecaseTime", XmlConvert.ToString(Data_Integration.CurrentTime, XmlDateTimeSerializationMode.Unspecified)); xW.WriteAttributeString("SimulatorState", Data_Integration.SimulatorStatus.ToString()); xW.WriteAttributeString("Commands", Data_Integration.EMSCommands.Count.ToString()); foreach (Data_Integration.OverallIndicatorEnum Indicator in Enum.GetValues(typeof(Data_Integration.OverallIndicatorEnum))) { xW.WriteAttributeString(Indicator.ToString(), Data_Integration.OverallIndicators[(int)Indicator].ToString()); } xW.WriteEndElement(); xW.WriteEndDocument(); } ImageCount++; } }
/// <summary> /// Start the network map in its own thread /// </summary> /// <param name="state"></param> private static void StartNetworkMap(object state) { object[] State = (object[])state; MM = new MacomberMap_Form(State[0] as MM_Coordinates, State[1] as MM_Startup_Form); ApplicationContext MMContext = new ApplicationContext(MM); MMContext.ThreadExit += new EventHandler(MMContext_ThreadExit); Application.Run(MMContext); }
/// <summary> /// Initialize the pipe handler to prepare for input /// </summary> /// <param name="Map">The map to interface with</param> public static void Initialize(MacomberMap_Form Map) { MM_Pipe.Map = Map; PIPE_NAME = "\\\\.\\pipe\\MacomberMap-" + Environment.UserDomainName + "-" + Environment.UserName; ThreadPool.QueueUserWorkItem(new WaitCallback(PipeHandler)); }