protected void OnFanControlStatusChanged(FanControlInfo info) { if (this.FanControlStatusChanged != null) { FanControlStatusChanged(this, new FanControlStatusChangedEventArgs(info)); } }
void timer_Tick(object sender, EventArgs e) { FanControlInfo info = GetFanControlInfo(); fanControlInfo = info; OnFanControlStatusChanged(info); }
private void UpdateMainViewModel() { try { FanControlInfo info = client.GetFanControlInfo(); if (info != null) { viewModel.Temperature = info.Temperature; viewModel.IsServiceAvailable = info.Enabled; viewModel.SelectedConfig = info.SelectedConfig; viewModel.TemperatureSourceName = info.TemperatureSourceDisplayName; if (info.FanStatus != null) { UpdateFanControllerViewModels(info.FanStatus); } } } catch { ResetMainViewModel(); InitializeClient(); } }
private void UpdateProperties(FanControlInfo info) { FanStatus status = null; if ((info.FanStatus == null) || (info.FanStatus.Length <= fanIndex)) { status = new FanStatus(); } else { status = info.FanStatus[fanIndex]; } Set(ref currentFanSpeed, status.CurrentFanSpeed, nameof(CurrentFanSpeed)); Set(ref targetFanSpeed, status.TargetFanSpeed, nameof(TargetFanSpeed)); Set(ref fanDisplayName, status.FanDisplayName, nameof(FanDisplayName)); Set(ref fanSpeedSteps, status.FanSpeedSteps, nameof(FanSpeedSteps)); Set(ref isAutoFanControlEnabled, status.AutoControlEnabled, nameof(IsAutoFanControlEnabled)); Set(ref isCriticalModeEnabled, status.CriticalModeEnabled, nameof(IsCriticalModeEnabled)); if (status.AutoControlEnabled) { // set the current speed level to (highest possible value) + 1 to indicate autmatic control Set(ref currentFanSpeedLevel, status.FanSpeedSteps + 1, nameof(CurrentFanSpeedLevel)); } else { int level = (int)Math.Round((status.TargetFanSpeed / 100.0) * status.FanSpeedSteps); Set(ref currentFanSpeedLevel, level, nameof(CurrentFanSpeedLevel)); } }
private void Refresh(bool ignoreCache) { FanControlInfo info = ignoreCache ? client.GetFanControlInfo() : client.FanControlInfo; UpdateProperties(info); }
private void Refresh(bool ignoreCache) { FanControlInfo info = ignoreCache ? client.GetFanControlInfo() : client.FanControlInfo; UpdateNotifyIcon(info.Temperature); UpdateProperties(info); }
public FanControlClient(int updateInterval = 3000) { fanControlInfo = new FanControlInfo(); timer = new DispatcherTimer(); timer.Tick += timer_Tick; this.UpdateInterval = updateInterval; timer.Start(); }
private static void PrintStatus(StatusVerb verb) { // If we are polling, we return to here: start: FanControlInfo info = GetFanControlInfo(); if (info == null) { return; } bool printAll = verb.All || (!verb.Service && (verb.Fan == null)); if (printAll || verb.Service) { PrintServiceStatus(info); } if (printAll || verb.Fan != null) { if (info.FanStatus == null) { Console.Error.WriteLine("Could not get fan info because the service is disabled"); } else if (verb.Fan != null && verb.Fan.Count > 0) { foreach (int idx in verb.Fan) { if (idx < info.FanStatus.Length) { PrintFanStatus(info.FanStatus[idx]); } else { Console.Error.WriteLine(string.Format("A fan with index {0} does not exist", idx)); } } } else { foreach (FanStatus status in info.FanStatus) { PrintFanStatus(status); } } } if (verb.Poll.HasValue) { Thread.Sleep((int)(verb.Poll.Value * 1000)); goto start; } }
private static FanControlInfo GetFanControlInfo() { FanControlInfo info = null; CallServiceMethod(client => { info = client.GetFanControlInfo(); }); return(info); }
private static void PrintServiceStatus(FanControlInfo info) { var sb = new StringBuilder(); sb.AppendFormat("Service enabled\t\t: {0}", info.Enabled); sb.AppendLine(); sb.AppendFormat("Selected config name\t: {0}", info.SelectedConfig); sb.AppendLine(); sb.AppendFormat("Temperature\t\t: {0}", info.Temperature); sb.AppendLine(); Console.WriteLine(sb.ToString()); }
private static FanControlInfo GetFanControlInfo() { FanControlInfo info = null; Action <FanControlServiceClient> action = client => { info = client.GetFanControlInfo(); }; CallServiceMethod(action); return(info); }
public FanControlInfo GetFanControlInfo() { FanControlInfo info = null; CallServiceMethod(client => info = client.GetFanControlInfo()); if (info == null) { info = new FanControlInfo(); } return(info); }
private void UpdateProperties(FanControlInfo info) { Set(ref isServiceDisabled, !info.Enabled, nameof(IsServiceDisabled)); Set(ref isServiceReadOnly, (info.Enabled && info.ReadOnly), nameof(IsServiceReadOnly)); Set(ref isServiceEnabled, (info.Enabled && !info.ReadOnly), nameof(IsServiceEnabled)); Set(ref temperature, info.Temperature, nameof(Temperature)); Set(ref selectedConfig, info.SelectedConfig, nameof(SelectedConfig)); Set(ref temperatureSourceName, info.TemperatureSourceDisplayName, nameof(TemperatureSourceName)); if (info.FanStatus == null) { this.fanControllers.Clear(); } else if (this.fanControllers.Count != info.FanStatus.Length) { this.fanControllers.Clear(); for (int i = 0; i < info.FanStatus.Length; i++) { fanControllers.Add(new FanControllerViewModel(client, i)); } } }
public FanControlStatusChangedEventArgs(FanControlInfo info) { Status = info; }