public RealTemp4RTSS() { InitializeComponent(); realTemp = RealTemp.GetInstance(); PopulateMetrics(); lblRealTempStatus.Text = "Initialising..."; lblOSDStatus.Text = "Initialising..."; lsvAvailableMetrics.EnableDoubleBuffer(); try { rtssController = new RTSSController(); lblOSDStatus.Text = "OK"; } catch { // RTSS is currently unavailable or uncommunicative; don't stop as if it becomes responsive later // we can re-establish communication then... lblOSDStatus.Text = "Unavailable"; } LoadSettings(); realTempRefresh.Enabled = true; }
private void realTempRefresh_Tick(object sender, EventArgs e) { StringBuilder rtssString = new StringBuilder(); foreach (ListViewItem lvi in lsvAvailableMetrics.Items) { if (realTemp.IsRealTempAvailable()) { lblRealTempStatus.Text = "Polling..."; if (lvi.Tag != null) { if (Visible) { int coreCount = realTemp.GetCoreCount(); if (coreCount > 0) { switch ((RealTemp.RealTempControlID)lvi.Tag) { case RealTemp.RealTempControlID.CoreZeroTemp: lvi.SubItems[1].Text = realTemp.GetCoreTemperature(0).ToString(); break; case RealTemp.RealTempControlID.CoreOneTemp: if (coreCount > 1) lvi.SubItems[1].Text = realTemp.GetCoreTemperature(1).ToString(); else lvi.SubItems[1].Text = "N/A"; break; case RealTemp.RealTempControlID.CoreTwoTemp: if (coreCount > 2) lvi.SubItems[1].Text = realTemp.GetCoreTemperature(2).ToString(); else lvi.SubItems[1].Text = "N/A"; break; case RealTemp.RealTempControlID.CoreThreeTemp: if (coreCount > 3) lvi.SubItems[1].Text = realTemp.GetCoreTemperature(3).ToString(); else lvi.SubItems[1].Text = "N/A"; break; case RealTemp.RealTempControlID.TemperatureUnit: lvi.SubItems[1].Text = realTemp.GetHighestCoreTemperature().ToString(); break; case RealTemp.RealTempControlID.Load: lvi.SubItems[1].Text = realTemp.GetLoad() + "%"; break; case RealTemp.RealTempControlID.Frequency: if (lvi.Name.EndsWith("mhz")) lvi.SubItems[1].Text = realTemp.GetFrequency(RealTemp.FrequencyUnit.MHz).ToString(); else if (lvi.Name.EndsWith("ghz")) lvi.SubItems[1].Text = realTemp.GetFrequency(RealTemp.FrequencyUnit.GHz).ToString(); else lvi.SubItems[1].Text = realTemp.GetFrequency().ToString(); break; } } else { lvi.SubItems[1].Text = "N/A"; } } if (lvi.Checked) { if (rtssString.Length > 0) rtssString.Append(", "); rtssString.Append("{" + lvi.Name + "}"); if ((RealTemp.RealTempControlID)lvi.Tag == RealTemp.RealTempControlID.Load) rtssString.Append(" %"); } } else { switch (lvi.Name) { case "time": if (Visible) lvi.SubItems[1].Text = DateTime.Now.ToShortTimeString(); if (lvi.Checked) { if (rtssString.Length > 0) rtssString.Append("\r\n"); rtssString.Append("TIME \t: " + DateTime.Now.ToShortTimeString()); } break; } } } else { lvi.SubItems[1].Text = "N/A"; lblRealTempStatus.Text = "Unavailable"; } } if (rtssController == null) { try { rtssController = new RTSSController(); lblOSDStatus.Text = "OK"; } catch { // RTSS is still unavailable or uncommunacative; ignore - we'll try next time. lblOSDStatus.Text = "Unavailable"; } } if (rtssController != null) { try { rtssCommunicationErrors = 0; if (rtssString.Length > 0) { osdSlot = rtssController.SetOSDValue(osdSlot, "CPU \t: " + realTemp.GetFormattedString(rtssString.ToString())); lblOSDStatus.Text = "OK"; } else if (osdSlot != -1) { rtssController.ClearOSDValue(osdSlot); osdSlot = -1; lblOSDStatus.Text = "OK"; } else { lblOSDStatus.Text = rtssController.GetStatus().GetDescription(); } } catch { lblOSDStatus.Text = "Unavailable"; // Something went wrong when communicating with RTSS... rtssCommunicationErrors++; // This may actually cause more trouble as if it manages to reconnect to the existing // RTSS instance its shared memory will still be intact and hence our AppId will be // in-use... so we won't be allowed to do anything. I'm not sure whether it's // RivaTuner (Afterburner, etc.) that maintain it or RTSS itself... lets hope the later! if (rtssCommunicationErrors >= MAX_RTSS_COMMUNICATION_ERRORS) rtssController = null; } } if (Properties.Settings.Default.NotifyNewVersions && Properties.Settings.Default.LastVersionCheck.Date.AddDays(14) <= DateTime.Today) { Properties.Settings.Default.LastVersionCheck = DateTime.Now; Properties.Settings.Default.Save(); Version latestVersion; if (IsNewVersionAvailable(out latestVersion)) { notifyIcon.ShowBalloonTip(5000, "Update Available", "Version " + latestVersion.ToString() + " is available to download", ToolTipIcon.Info); notifyIcon.BalloonTipClicked += btnUpdateCheck_Click; notifyIcon.BalloonTipClosed += notifyIcon_UpdateCheck_BalloonTipClosed; } } }