private void btn_updatefw_Click(object sender, RoutedEventArgs e) { SubNode n; if (curr_sel == -1) { return; } int lastcurr = curr_sel; App p = Application.Current as App; Button btn; for (Byte i = 1; i < 18; i++) { n = null; if (i < 17) { btn = IdToButton(i.ToString()); n = p.agent[i]; } else { btn = IdToButton("36"); n = p.agent.missingnode; } if (n is SubNode) { n.status = NodeStatus.ST_IDLE; n["board_id"] = null; Thread.Sleep(100); if (n["board_id"] != null) { if ((curr_sel == n.node_id) || (all_sel == true)) { curr_sel = n.node_id; btn.Template = this.FindResource("roundButtonsel2") as ControlTemplate; btn.ApplyTemplate(); btn.Visibility = Visibility.Visible; fwprgs_bar.Visibility = Visibility.Visible; fwprgs_bar.Minimum = 0; fwprgs_bar.Maximum = (int)(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ioex_cs.Resources.MAIN.BIN").Length / 128); bootloader bl = new bootloader(n); string ret = bl.download(fwprogress); btn_updatefw.Content = StringResource.str("updatefw"); fwprgs_bar.Visibility = Visibility.Hidden; if (ret != "") { MessageBox.Show(StringResource.str("updatefwfail") + n.node_id.ToString() + "\r\n" + ret); } curr_sel = lastcurr; continue; } } } } btn_refreshreg_Click(null, null); UpdateDisplay(true); }
private void btn_updatefw_Click(object sender, RoutedEventArgs e) { SubNode n; if (curr_sel == -1) return; int lastcurr = curr_sel; App p = Application.Current as App; Button btn; for (Byte i = 1; i < 18; i++) { n = null; if (i < 17) { btn = IdToButton(i.ToString()); n = p.agent[i]; } else { btn = IdToButton("36"); n = p.agent.missingnode; } if (n is SubNode) { n.status = NodeStatus.ST_IDLE; n["board_id"] = null; Thread.Sleep(100); if (n["board_id"] != null) { if ((curr_sel == n.node_id) || (all_sel == true)) { curr_sel = n.node_id; btn.Template = this.FindResource("roundButtonsel2") as ControlTemplate; btn.ApplyTemplate(); btn.Visibility = Visibility.Visible; fwprgs_bar.Visibility = Visibility.Visible; fwprgs_bar.Minimum = 0; fwprgs_bar.Maximum = (int)(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ioex_cs.Resources.MAIN.BIN").Length/128); bootloader bl = new bootloader(n); string ret = bl.download(fwprogress); btn_updatefw.Content = StringResource.str("updatefw"); fwprgs_bar.Visibility = Visibility.Hidden; if (ret != "") MessageBox.Show(StringResource.str("updatefwfail") +n.node_id.ToString() + "\r\n" + ret); curr_sel = lastcurr; continue; } } } } btn_refreshreg_Click(null, null); UpdateDisplay(true); }