//Update the bitmap in the pictureBox object public void UpdateMap() { while (true) { Thread.Sleep(int.Parse(ConfigurationManager.AppSettings["UPDATESPEED"])); bMap = new Bitmap(pictureBox1.Width, pictureBox1.Height); foreach (Student student in classList) { if (editClassSync) { break; } HeatPoints.Add(student.StHeatPoint); } pictureBox1.Image = CreateIntensityMask(bMap, HeatPoints); } }
public Form1(int course) { InitializeComponent(); try { clientSocket = new Socket(SocketType.Stream, ProtocolType.Tcp); udpsock = new Socket(SocketType.Dgram, ProtocolType.Udp); outStream = new byte[10025]; Console.WriteLine("trying to connect"); clientSocket.Connect("10.40.45.58", 61600); Console.WriteLine("waiting for starting char"); String returndata = ""; //Wait for the start char, ';' while (returndata != ";") { inStream = new byte[clientSocket.Available]; clientSocket.Receive(inStream); returndata = Encoding.ASCII.GetString(inStream); Console.WriteLine("'" + returndata + "'"); } Console.WriteLine("got start char"); outStream = Encoding.ASCII.GetBytes("#" + Environment.UserName + "#" + course + ";"); //send my name and corse that I want to stream clientSocket.Send(outStream); Console.WriteLine("waiting for port info"); //wait for port inStream = new byte[0]; returndata = ""; while (!returndata.Contains(";")) { inStream = new byte[clientSocket.Available]; clientSocket.Receive(inStream); returndata += Encoding.ASCII.GetString(inStream); } Console.WriteLine("got data=" + returndata); Console.WriteLine(returndata.IndexOf(":")); Console.WriteLine(returndata.Length); Console.WriteLine("port=" + returndata.Substring(returndata.IndexOf(":") + 1, returndata.Length - returndata.IndexOf(":") - 2)); returndata = returndata.Substring(returndata.IndexOf(":") + 1, returndata.Length - returndata.IndexOf(":") - 2); udpsock.Bind(new IPEndPoint(IPAddress.Any, int.Parse(returndata))); Console.WriteLine("Starting UDP"); ThreadStart childref = new ThreadStart(ListenForPackets); Thread childThread = new Thread(childref); childThread.Start(); Console.WriteLine("Thread should have started"); } catch (Exception e) { please.Text = e.StackTrace; Console.WriteLine(e.StackTrace); } // Set the view to show details. // Create new memory bitmap the same size as the picture box Bitmap bMap = new Bitmap(pictureBox1.Width, pictureBox1.Height); // Initialize random number generator Random rRand = new Random(); // Loop variables int iX; int iY; byte iIntense; // Lets loop 500 times and create a random point each iteration for (int i = 0; i < 500; i++) { // Pick random locations and intensity iX = rRand.Next(0, 200); iY = rRand.Next(0, 200); iIntense = (byte)rRand.Next(0, 120); // Add heat point to heat points list HeatPoints.Add(new HeatPoint(iX, iY, iIntense)); } // Call CreateIntensityMask, give it the memory bitmap, and use it's output to set the picture box image pictureBox1.Image = CreateIntensityMask(bMap, HeatPoints); listView1.View = View.Details; listView1.CheckBoxes = true; // Display grid lines. listView1.GridLines = true; // listView2.View = View.Details; // listView2.CheckBoxes = true; // Display grid lines. // listView2.GridLines = true; // Create three items and three sets of subitems for each item. ListViewItem item1 = new ListViewItem("Austin Lambeth", 0); item1.SubItems.Add("al05661"); item1.SubItems.Add("Current Slides"); item1.SubItems.Add("3"); ListViewItem item2 = new ListViewItem("Dylan Albrecht", 1); item2.SubItems.Add("fagot.net"); item2.SubItems.Add("something he shouldn't have open"); item2.SubItems.Add("6"); ListViewItem item3 = new ListViewItem("Phillip", 1); item3.SubItems.Add("cool guy philip"); item3.SubItems.Add("Current Slides"); item3.SubItems.Add("9"); // Create columns for the items and subitems. // Width of -2 indicates auto-size. listView1.Columns.Add("Student Name", -2, HorizontalAlignment.Left); listView1.Columns.Add("Student Email", -2, HorizontalAlignment.Left); listView1.Columns.Add("Current Focused Window", -2, HorizontalAlignment.Left); ListViewItem chrome = new ListViewItem("Chrome", 0); chrome.SubItems.Add("1"); chrome.SubItems.Add("2"); chrome.SubItems.Add("3"); ListViewItem mozilla = new ListViewItem("mozilla", 0); //listView2.Columns.Add("Open Windows", -2, HorizontalAlignment.Left); //Add the items to the ListView. listView1.Items.AddRange(new ListViewItem[] { item1, item2, item3 }); //listView2.Items.AddRange(new ListViewItem[] { chrome,mozilla }); }