/// <summary> /// Shows the saved Kub(s) in the combobox on the Settings page. /// </summary> public void FillComboBox() { if (kubInfo != null) { if (kubInfo.Values.ContainsKey("allKubsStorage")) { kubs.Clear(); string[] kubIds = ((string)kubInfo.Values["allKubsStorage"]).Split(','); if (kubIds != null) { foreach (string id in kubIds) { Kub kub = new Kub(id, this.client); kubs.Add(id, kub); comboBox.Items.Add(kub); if (kubInfo.Values.ContainsKey("selectedKub") && id == (string)kubInfo.Values["selectedkub"]) { this.selectedKub = kub; this.comboBox.SelectedIndex = this.comboBox.Items.IndexOf(kub); } } } } } }
/// <summary> /// The received message of the Kub will be checked on the content. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string[] parts = e.Topic.Split('/'); if (parts.Length != 3 || parts[0] != "kub") { return; } string kid = parts[1]; if (e.Message.Length < 5) { return; } byte protocolVersion = e.Message[0]; byte[] payloadData = new byte[4] { e.Message[4], e.Message[3], e.Message[2], e.Message[1] }; uint payloadLength = BitConverter.ToUInt32(payloadData, 0); if (e.Message.Length < payloadLength + 5) { return; } byte[] payload = e.Message.Skip(5).ToArray(); Kub kub = kubs[kid]; kub.PacketReceived(payload, parts[2]); }
/// <summary> /// Checks if there is a saved Kub, if so then this one will be selected by default. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.comboBox.SelectedItem == null) { return; } this.selectedKub = (Kub)this.comboBox.SelectedItem; if (kubInfo != null && this.selectedKub != null) { kubInfo.Values["selectedKub"] = this.selectedKub.id; } }
private void button2_Click(object sender, EventArgs e) { try { double x = Convert.ToDouble(textBox3.Text); Kub func = new Kub(Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox5.Text), Convert.ToInt32(textBox6.Text)); label5.Text = "значение функции Kub для x = " + Convert.ToString(x) + " равно " + Convert.ToString(func.Count(x)); } catch { label5.Text = "Ошибка ввода"; } }
public override string ToString() { string str = types[0]; for (int i = 1; i < types.Length; i++) { str += "-" + types[i]; } str += " : Ktheta(" + Ktheta; str += "), Theta0(" + Theta0; str += "), Kub(" + (double.IsNaN(Kub)?"-":Kub.ToString()); str += "), S0(" + (double.IsNaN(S0)?"-":S0.ToString()); str += ")"; return(str); }
/// <summary> /// Adds a new Kub through the result of the QR scanner. /// </summary> /// <param name="QRresult"></param> public void AddNewKub(string QRresult) { if (kubs.ContainsKey(QRresult)) { return; } data = JObject.Parse(QRresult); kubId = (data.kubid); Kub newKub = new Kub(kubId, client); kubs.Add(kubId, newKub); kubInfo.Values["allKubsStorage"] = string.Join(",", kubs.Keys.Select(k => k).ToArray()); FillComboBox(); }
public ServerController(Kub kub) { _kub = kub; }