private void toolStripMenuItem1_Click(object sender, EventArgs e) { string newtopic = this.toolStripTextBoxtopicpath.Text; if (!topics.Any(a => a.path == newtopic)) { byte qos; if (byte.TryParse(this.toolStripTextBox_qos.Text, out qos) && qos >= 0 && qos <= 2) { MqqtTopic t = new MqqtTopic() { path = newtopic, qos = qos, subscribed = false }; topics.Add(t); //mqtt.subscribe(t.path, t.qos); } else MessageBox.Show("the topic QOS must be from 0 to 2 included"); } else MessageBox.Show("this topic is already in the topic list"); }
private void LoadSettings(string settingfilename) { try { XmlSerializer serializer = new XmlSerializer(typeof(SettingsContainer)); string settingspath = Path.Combine(settingsDirectory, settingfilename); SettingsContainer allsettings; using (FileStream fs = new FileStream(settingspath, FileMode.Open)) { allsettings = (SettingsContainer)serializer.Deserialize(fs); } if (allsettings != null) { this.topics.Clear(); this.serversett = allsettings.BrokerSettings; allsettings.Topics.ForEach(t => this.topics.Add(t)); this.currenttopic = allsettings.Topics.FirstOrDefault(a => a.path == allsettings.currenttopicpath); settingsfilepath = settingspath; //MessageBox.Show(string.Format("Settings correctly loaded from file {0}", settingfilename)); } } catch (Exception e) { MessageBox.Show(string.Format("Error while loading settings from file {0} : {1}", settingfilename, e.Message)); } }
private void DataGridView_topics_CurrentCellChanged(object sender, EventArgs e) { if (this.dataGridView_topics.CurrentRow != null) { var ct = (MqqtTopic)this.dataGridView_topics.CurrentRow.DataBoundItem; if (ct != null && (this.currenttopic == null || ct.path != this.currenttopic.path)) { currenttopic = ct; this.label_curernttopic.Text = currenttopic.path; this.toolStripStatusLabel_curentopic.Text = currenttopic.path; } } }