private void PopulateColorTempComboBox(string displaySystemId) { //Call JSON rpc post request with source value JObject result; try { result = SendGetRequest(Common.CreateJsonRequest("getdisplaysystem", "{\"displaySystemId\": " + displaySystemId + "}")); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DisplaySystemOnClient displaySystem = JsonConvert.DeserializeObject <DisplaySystemOnClient>(result["result"].ToString()); var validRange = displaySystem.ColorTemperature.ValidRange; comboBoxColorTemp.Items.Clear(); comboBoxColorTemp.Items.Add(""); foreach (var value in validRange) { comboBoxColorTemp.Items.Add(value); } comboBoxColorTemp.Text = displaySystem.ColorTemperature.CurrentValue; }
/// <summary> /// setDisplaySystemButton_Click() - Do a bulk set of parameters on a Display System based on which parameters have been set. /// /// Author: ameja /// Date: 1/25/2018 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void setDisplaySystemButton_Click(object sender, EventArgs e) { try { DisplaySystemOnClient clientObj = new DisplaySystemOnClient(); clientObj.ID = comboBoxDisplaySystemIds.Text; clientObj.ActiveSource = comboBoxActiveSource.Text; clientObj.Luminance = luminanceTextBox.Text; clientObj.ColorTemperature.CurrentValue = colorTempComboBox.Text; clientObj.Gamma.CurrentValue = gammaNumericUpDown.Value.ToString(); clientObj.Name = displaySystemNameText.Text; Point pos = new Point(); pos.X = Int32.Parse(sourcePositionXText.Text); pos.Y = Int32.Parse(sourcePositionYText.Text); clientObj.SourceMappingPosition = pos; Size outputVideoSize = new System.Drawing.Size(); outputVideoSize.Width = Int32.Parse(sourceSizeWidthText.Text); outputVideoSize.Height = Int32.Parse(sourceSizeHeightText.Text); clientObj.SourceMappingSize = outputVideoSize; clientObj.TestPattern.Red = Int32.Parse(redTextBox.Text); clientObj.TestPattern.Green = Int32.Parse(greenTextBox.Text); clientObj.TestPattern.Blue = Int32.Parse(blueTextBox.Text); clientObj.TestPattern.Direction = directionComboBox.Text; clientObj.TestPattern.Movement = movementCheckBox.Checked; clientObj.TestPattern.SelectedTestPattern = availableTestPatternsComboBox.Text; string displaySystemOnClientString = JsonConvert.SerializeObject(clientObj, Formatting.Indented); if (string.IsNullOrEmpty(displaySystemOnClientString)) { MessageBox.Show("Please enter a value for the display system"); } string displaySystem = displaySystemOnClientString.Replace("\n", ""); string displaySystemId = ""; //Call JSON rpc post request with source value byte[] data = Encoding.ASCII.GetBytes(Common.CreateJsonRequest("setdisplaysystem", "{\"displaySystem\": " + displaySystem + ", \"displaySystemId\":\"" + displaySystemId + "\"}")); try { SendRequest(data); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// getDisplaySystemButton_Click() - Get a Display System based on the ID which is chosen. /// /// Author: ameja /// Date: 1/25/2018 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void getDisplaySystemButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(comboBoxDisplaySystemIds.Text)) { MessageBox.Show("Please enter a display system ID"); return; } string displaySystemId = comboBoxDisplaySystemIds.Text; //Call JSON rpc post request with source value JObject result; try { result = SendGetRequest(Common.CreateJsonRequest("getdisplaysystem", "{\"displaySystemId\": \"" + displaySystemId + "\"}")); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } DisplaySystemOnClient displaySystem = JsonConvert.DeserializeObject <DisplaySystemOnClient>(result["result"].ToString()); luminanceTextBox.Text = displaySystem.Luminance; displaySystemNameText.Text = displaySystem.Name; if (displaySystem.Gamma != null) { if (!displaySystem.Gamma.CurrentValue.Equals("Undefined")) { gammaNumericUpDown.Text = displaySystem.Gamma.CurrentValue.ToString(); gammaUndefinedLabel.Visible = false; } else { gammaUndefinedLabel.Visible = true; } gammaNumericUpDown.Maximum = (decimal)displaySystem.Gamma.Max; gammaNumericUpDown.Minimum = (decimal)displaySystem.Gamma.Min; } if (displaySystem.AvailableSources != null) { comboBoxActiveSource.Items.Clear(); displaySystem.AvailableSources.ForEach(x => comboBoxActiveSource.Items.Add(x)); } comboBoxActiveSource.Text = displaySystem.ActiveSource; var validRange = displaySystem.ColorTemperature.ValidRange; colorTempComboBox.Items.Clear(); colorTempComboBox.Items.Add(""); foreach (var value in validRange) { colorTempComboBox.Items.Add(value); } colorTempComboBox.Text = displaySystem.ColorTemperature.CurrentValue; //Load source position sourcePositionXText.Text = displaySystem.SourceMappingPosition.X.ToString(); sourcePositionYText.Text = displaySystem.SourceMappingPosition.Y.ToString(); sourceSizeWidthText.Text = displaySystem.SourceMappingSize.Width.ToString(); sourceSizeHeightText.Text = displaySystem.SourceMappingSize.Height.ToString(); flowLayoutPanel1.Controls.Clear(); //Init the direction combo box directionComboBox.Items.Clear(); displaySystem.TestPattern.ValidDirections.ForEach(x => directionComboBox.Items.Add(x)); //Init available test patterns combo box availableTestPatternsComboBox.Items.Clear(); displaySystem.TestPattern.AvailableTestPatterns.ForEach(x => availableTestPatternsComboBox.Items.Add(x)); //Set the test pattern settings information redTextBox.Text = displaySystem.TestPattern.Red.ToString(); greenTextBox.Text = displaySystem.TestPattern.Green.ToString(); blueTextBox.Text = displaySystem.TestPattern.Blue.ToString(); movementCheckBox.Checked = displaySystem.TestPattern.Movement; directionComboBox.Text = displaySystem.TestPattern.Direction; availableTestPatternsComboBox.Text = displaySystem.TestPattern.SelectedTestPattern; //Add light sensor info if (displaySystem.SensorHosts.Count() > 0) { lightSensorGridView.DataSource = displaySystem.SensorHosts; } //Add power switch info if (displaySystem.PowerBoxes.Count() > 0) { powerSwitchGridView.DataSource = displaySystem.PowerBoxes; } }