예제 #1
0
 protected void OnFanControlStatusChanged(FanControlInfo info)
 {
     if (this.FanControlStatusChanged != null)
     {
         FanControlStatusChanged(this, new FanControlStatusChangedEventArgs(info));
     }
 }
예제 #2
0
        void timer_Tick(object sender, EventArgs e)
        {
            FanControlInfo info = GetFanControlInfo();

            fanControlInfo = info;
            OnFanControlStatusChanged(info);
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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));
            }
        }
예제 #5
0
        private void Refresh(bool ignoreCache)
        {
            FanControlInfo info = ignoreCache
                ? client.GetFanControlInfo()
                : client.FanControlInfo;

            UpdateProperties(info);
        }
예제 #6
0
        private void Refresh(bool ignoreCache)
        {
            FanControlInfo info = ignoreCache
                ? client.GetFanControlInfo()
                : client.FanControlInfo;

            UpdateNotifyIcon(info.Temperature);
            UpdateProperties(info);
        }
예제 #7
0
        public FanControlClient(int updateInterval = 3000)
        {
            fanControlInfo      = new FanControlInfo();
            timer               = new DispatcherTimer();
            timer.Tick         += timer_Tick;
            this.UpdateInterval = updateInterval;

            timer.Start();
        }
예제 #8
0
파일: Program.cs 프로젝트: 602p/nbfc
        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;
            }
        }
예제 #9
0
파일: Program.cs 프로젝트: 602p/nbfc
        private static FanControlInfo GetFanControlInfo()
        {
            FanControlInfo info = null;

            CallServiceMethod(client =>
            {
                info = client.GetFanControlInfo();
            });

            return(info);
        }
예제 #10
0
        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());
        }
예제 #11
0
        private static FanControlInfo GetFanControlInfo()
        {
            FanControlInfo info = null;

            Action <FanControlServiceClient> action = client =>
            {
                info = client.GetFanControlInfo();
            };

            CallServiceMethod(action);

            return(info);
        }
예제 #12
0
        public FanControlInfo GetFanControlInfo()
        {
            FanControlInfo info = null;

            CallServiceMethod(client => info = client.GetFanControlInfo());

            if (info == null)
            {
                info = new FanControlInfo();
            }

            return(info);
        }
예제 #13
0
        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));
                }
            }
        }
예제 #14
0
파일: Program.cs 프로젝트: qzcw/nbfc
        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());
        }
 public FanControlStatusChangedEventArgs(FanControlInfo info)
 {
     Status = info;
 }