private void DisplayGrade() { DisplayData data = new DisplayData(); data.Round = this.Round; data.GoldNumber = this.CurrentGoldNumber; foreach (KeyValuePair <string, int> pr in engine.Grade) { data.SortedGrade.Add(new Tuple <string, int>(pr.Key, pr.Value)); } foreach (KeyValuePair <string, int> pr in engine.RoundGrade) { data.SortedRoundGrade.Add(new Tuple <string, int>(pr.Key, pr.Value)); } foreach (Tuple <string, double> tp in engine.result) { data.result.Add(new Tuple <string, double>(tp.Item1, tp.Item2)); } data.SortedRoundGrade.Sort(new cmp2()); data.SortedGrade.Sort(new cmp2()); string JsonData = Microsoft.JScript.Convert.ToString(data, true); JavaScriptSerializer jss = new JavaScriptSerializer(); JsonData = jss.Serialize(data); Monitor.LogGrade(JsonData); if (DisplayServer == null) { return; } DisplayServer.SendResult(JsonData); }
private void DisplayGrade() { if (DisplayServer == null) { return; } DisplayData data = new DisplayData(); data.Round = this.Round; data.GoldNumber = this.CurrentGoldNumber; foreach (KeyValuePair <string, int> pr in engine.Grade) { data.SortedGrade.Add(new Tuple <string, int>(pr.Key, pr.Value)); } foreach (KeyValuePair <string, int> pr in engine.RoundGrade) { data.SortedRoundGrade.Add(new Tuple <string, int>(pr.Key, pr.Value)); } foreach (Tuple <string, double> tp in engine.result) { data.result.Add(new Tuple <string, double>(tp.Item1, tp.Item2)); } data.SortedRoundGrade.Sort(new cmp2()); data.SortedGrade.Sort(new cmp2()); DisplayServer.SendResult(data); }
private void UpdateServers() { foreach (SCConnectionStringBuilder serverSettting in ServerConfiguration.GetAllServerConfiguration()) { var serverName = serverSettting.GetDisplayName(); var displayServer = new DisplayServer(serverName); displayServer.ServerSetting = serverSettting; cboRecentServers.Items.Add(displayServer); _servers.Add(serverName, serverSettting); } if (cboRecentServers.Items.Count > 0) { cboRecentServers.SelectedIndex = 0; cboRecentServers.Text = cboRecentServers.SelectedText; } }
public Projection_Server(bool debugMode = false) { InitializeComponent(); lblIP.Parent = pbProject; lblIP.Font = new Font(lblIP.Font.FontFamily, 16.0f); // FontStyle.Bold, 32.0f); lblIP.TextAlign = ContentAlignment.MiddleCenter; IPAddress[] ipv4Addresses = Array.FindAll(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork); lblIP.BackColor = Color.White; lblIP.Text = ipv4Addresses.Last().ToString(); warmup = true; transitionTimer = new Timer() { Interval = 25 }; transitionStep = 0; if (debugMode) { StartPosition = FormStartPosition.Manual; Left = 0; Top = 0; Left = 2000; debugMode = false; } intervalWatch = new Stopwatch(); //saveProjectionManagerWatch = new Stopwatch(); //intervalWatch.Start(); //saveProjectionManagerWatch.Start(); //Clear out base image pbProject.Image = null; if (!debugMode) { WindowState = FormWindowState.Maximized; } //pbProject.Dock = DockStyle.None; if (!File.Exists("collection.pm")) { projectionManager = new ProjectionManager(Properties.Resources.scenic1); //Projection defaultProj = new Projection(DateTime.Now, DateTime.MinValue, DateTime.MaxValue) //{ // isDefault = true //}; } else //Serialized data found { try { projectionManager = ProjectionManager.Deserialize("collection.pm"); if (projectionManager == null) { throw new Exception("Failed to deserialize ProjectionManager state :("); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); MessageBox.Show(this, "There was an error loading previously scheduled projections.\nData may be corrupt.", "Projection", MessageBoxButtons.OK, MessageBoxIcon.Error); projectionManager = new ProjectionManager(Properties.Resources.scenic1); } } displayServer = new DisplayServer(); displayServer.projectionManager = projectionManager; displayServer.ReceivedProjection += ReceiveProjection; displayServer.Start(); tmrUpdate.Start(); intervalWatch.Start(); }