public void OnPowerMessage(bool enabled, PowerState state) { if (this.ListView != null) { MicrocontrollerListView listView = (MicrocontrollerListView)this.ListView; string stateString = "unknown"; switch (state) { case PowerState.On: stateString = "on"; break; case PowerState.Off: stateString = "off"; break; case PowerState.FuseBlown: stateString = "fuse blown"; break; case PowerState.OpenLoad: stateString = "open load"; break; case PowerState.Resetting1: stateString = "resetting 1"; break; case PowerState.Resetting2: stateString = "resetting 2"; break; } string text = string.Format("{0}/{1}/{2}", powerPort, stateString, enabled ? "enabled" : "disabled"); this.SubItems[listView.columnPowerStatus.DisplayIndex].Text = text; if (state == PowerState.FuseBlown) { this.BackColor = Color.LightCoral; } else if (state == PowerState.Off) { this.BackColor = Color.LightGreen; } else if (state == PowerState.Resetting1 || state == PowerState.Resetting2) { this.BackColor = Color.Thistle; } else if (state == PowerState.OpenLoad) { this.BackColor = Color.Wheat; } else { this.BackColor = this.ListView.BackColor; } } }
private void UpdateSyncPulse() { if (this.ListView != null) { MicrocontrollerListView listView = (MicrocontrollerListView)this.ListView; bool bad = !(synced.GetValueOrDefault(true) && pulsed.GetValueOrDefault(true)); string syncText; if (synced.HasValue) { syncText = synced.Value ? "sync" : "no sync"; } else { syncText = "?"; } string pulseText; if (pulsed.HasValue) { pulseText = pulsed.Value ? "pulse" : "no pulse"; } else { pulseText = "?"; } this.SubItems[listView.columnSyncPulse.DisplayIndex].Text = syncText + "/" + pulseText; if (bad) { this.SubItems[listView.columnSyncPulse.DisplayIndex].ForeColor = Color.Red; } else { this.SubItems[listView.columnSyncPulse.DisplayIndex].ForeColor = Color.Black; } } }
public void OnPingReceived(string message) { if (this.ListView != null) { MicrocontrollerListView listView = (MicrocontrollerListView)this.ListView; this.SubItems[listView.columnPingTime.DisplayIndex].Text = message; } }
public MicrocontrollerListViewItem(MicroConfig config, MicrocontrollerListView listView) : base(config.name) { if (IPAddress.TryParse(config.address, out address)) { this.Group = listView.Groups["groupMicros"]; this.ImageKey = "micro"; if (LicenseManager.UsageMode == LicenseUsageMode.Runtime) { ping = new Ping(); ping.PingCompleted += new PingCompletedEventHandler(ping_PingCompleted); } } else { this.Group = listView.Groups["groupPower"]; this.ImageKey = "power"; } this.powerPort = config.powerPort; this.supportsTiming = config.supportsTiming; // add the subitems for (int i = 0; i < listView.Columns.Count - 1; i++) { this.SubItems.Add(""); } if (address != null) { this.SubItems[listView.columnAddress.DisplayIndex].Text = address.ToString(); } if (supportsTiming) { this.SubItems[listView.columnSyncPulse.DisplayIndex].Text = "?/?"; } else { this.SubItems[listView.columnSyncPulse.DisplayIndex].Text = " - "; } if (powerPort != -1) { this.SubItems[listView.columnPowerStatus.DisplayIndex].Text = powerPort.ToString() + "/?"; } else { this.SubItems[listView.columnPowerStatus.DisplayIndex].Text = " - "; } }
public MicrocontrollerListViewItem(MicroConfig config, MicrocontrollerListView listView) : base(config.name) { if (IPAddress.TryParse(config.address, out address)) { this.Group = listView.Groups["groupMicros"]; this.ImageKey = "micro"; if (LicenseManager.UsageMode == LicenseUsageMode.Runtime) { ping = new Ping(); ping.PingCompleted += new PingCompletedEventHandler(ping_PingCompleted); } } else { this.Group = listView.Groups["groupPower"]; this.ImageKey = "power"; } this.powerPort = config.powerPort; this.supportsTiming = config.supportsTiming; // add the subitems for (int i = 0; i < listView.Columns.Count-1; i++) { this.SubItems.Add(""); } if (address != null) { this.SubItems[listView.columnAddress.DisplayIndex].Text = address.ToString(); } if (supportsTiming) { this.SubItems[listView.columnSyncPulse.DisplayIndex].Text = "?/?"; } else { this.SubItems[listView.columnSyncPulse.DisplayIndex].Text = " - "; } if (powerPort != -1) { this.SubItems[listView.columnPowerStatus.DisplayIndex].Text = powerPort.ToString() + "/?"; } else { this.SubItems[listView.columnPowerStatus.DisplayIndex].Text = " - "; } }