Ejemplo n.º 1
0
        public void init()//硬件初始化
        {
            source        = new Source();
            source.CPU    = false;
            source.GPU    = false;
            cpuinfo       = new CPUinfo();
            cpuinfo.Tem   = false;
            cpuinfo.Load  = false;
            cpuinfo.Clock = false;
            updateVisitor = new UpdateVisitor();
            computer      = new Computer();
            computer.Open();
            computer.CPUEnabled = true;
            computer.GPUEnabled = true;
            computer.HDDEnabled = true;
            computer.RAMEnabled = true;
            computer.Accept(updateVisitor);
            source.num = computer.Hardware.Length;
            for (int i = 0; i < computer.Hardware.Length; i++)
            {
                if (computer.Hardware[i].HardwareType == HardwareType.CPU)
                {
                    source.CPU      = true;
                    source.CPUindex = i;
                }
                if (computer.Hardware[i].HardwareType == HardwareType.GpuAti)
                {
                    source.GPU      = true;
                    source.GPUindex = i;
                }
                if (computer.Hardware[i].HardwareType == HardwareType.GpuNvidia)
                {
                    source.GPU      = true;
                    source.GPUindex = i;
                }
            }
            //CPUINFO初始化
            int num = 0;

            //Load初始化
            for (int i = 0; i < computer.Hardware[source.CPUindex].Sensors.Length; i++)
            {
                if (computer.Hardware[source.CPUindex].Sensors[i].SensorType == SensorType.Load)
                {
                    cpuinfo.Load            = true;
                    cpuinfo.LoadSensorindex = i;
                    break;
                }
            }
            for (int i = 0; i < computer.Hardware[source.CPUindex].Sensors.Length; i++)
            {
                if (computer.Hardware[source.CPUindex].Sensors[i].SensorType == SensorType.Load)
                {
                    num++;
                }
            }
            cpuinfo.LoadSensorNum = num;
            num = 0;
            computer.Close();
        }
        public PerformancePatcherForm()
        {
            InitializeComponent();

            if (CPUinfo.GetCpuManufacturer() == "AuthenticAMD")
            {
                statusMessage.ForeColor = Color.Red;
                statusMessage.Text      = "We've detected an AMD CPU.";
            }
            else if (CPUinfo.GetCpuManufacturer() == "GenuineIntel")
            {
                statusMessage.ForeColor = Color.Blue;
                statusMessage.Text      = "We've detected an Intel CPU.";
            }
            else
            {
                statusMessage.ForeColor = Color.DarkRed;
                statusMessage.Text      = "Unknown CPU! What are you running this on? :o";
            }
            CPUManufacturer = CPUinfo.GetCpuManufacturer();
        }
Ejemplo n.º 3
0
        public TrayIcon()
        {
            if (!IsAdmin())
            {
                RunAsRestart();
                Environment.Exit(0);
            }
            InitializeComponent();
            Visibility = Visibility.Hidden;
            cpuinfo    = new CPUinfo();
            if (!cpuinfo.LoadSucceeded)
            {
                taskbarIcon.ShowBalloonTip("Failed, Click To Exit", cpuinfo.ErrorMessage, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Error);
                taskbarIcon.ResetBalloonCloseTimer();
                taskbarIcon.TrayBalloonTipClicked += (s, e) =>
                {
                    cpuinfo.Dispose();
                    Close();
                    Environment.Exit(0);
                };
            }
            #region EPP binding

            NotificationMenu.IsChecked          = NotificationSetting.Setting;
            cpuinfo.underVoltor.AppliedSettings = cpuinfo.underVoltor.GetSettingsFromFile();
            AutoStartMenu.IsChecked             = Startup;
            if (cpuinfo.SST_support)
            {
                PowerPlanMenu.IsEnabled       = true;
                cpuinfo.EPP.EnableChanged    += () => PowerPlanMenu.IsEnabled = cpuinfo.EPP.IsEnabled;
                cpuinfo.PSM.PowerModeChanged += (status) => SetPowerPlan(status);
                cpuinfo.PSM.PowerResume      += () => cpuinfo.underVoltor.AppliedSettings = cpuinfo.underVoltor.GetSettingsFromFile();
                cpuinfo.PSM.EnableChanged    += (status) =>
                {
                    if (AutoSwitchMenu.IsChecked != cpuinfo.PSM.IsEnabled)
                    {
                        AutoSwitchMenu.IsChecked = status;
                    }
                };
                AutoSwitchMenu.Click += (s, e) =>
                {
                    if (AutoSwitchMenu.IsChecked != cpuinfo.PSM.IsEnabled)
                    {
                        cpuinfo.PSM.FileSetting = AutoSwitchMenu.IsChecked;
                    }
                };

                cpuinfo.EPP.NewSettingsApplied += () =>
                {
                    if (cpuinfo.EPP.SettingIndex == 0)
                    {
                        HPMenu.IsChecked = true;
                        PSMenu.IsChecked = false;
                        if (NotificationMenu.IsChecked)
                        {
                            taskbarIcon.ShowBalloonTip("Note", "High Performance Mode", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
                        }
                        taskbarIcon.IconSource = (BitmapImage)Resources["HighPerformanceIcon"];
                    }
                    else
                    {
                        HPMenu.IsChecked = false;
                        PSMenu.IsChecked = true;
                        if (NotificationMenu.IsChecked)
                        {
                            taskbarIcon.ShowBalloonTip("Note", "Power Saving Mode", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
                        }
                        taskbarIcon.IconSource = (BitmapImage)Resources["PowerSavingIcon"];
                    }
                };
                HPMenu.Click            += (s, e) => SetPowerPlan(System.Windows.Forms.PowerLineStatus.Online);
                PSMenu.Click            += (s, e) => SetPowerPlan(System.Windows.Forms.PowerLineStatus.Offline);
                taskbarIcon.ToolTipText  = $"{cpuinfo.wmi.Name}\nIntel® Speed Shift Technology Available";
                AutoSwitchMenu.IsChecked = cpuinfo.PSM.IsEnabled;
                if (AutoStartMenu.IsChecked)
                {
                    SetPowerPlan(cpuinfo.PSM.GetPowerLineStatus());
                }
            }
            else
            {
                taskbarIcon.ToolTipText = $"{cpuinfo.wmi.Name}\n(Intel® Speed Shift Technology NOT supported)";
                PowerPlanMenu.IsEnabled = false;
                taskbarIcon.ShowBalloonTip("Warning", "Intel SST is not supported\nMost Functions wont work", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Warning);
            }
            #endregion
        }
Ejemplo n.º 4
0
        public MainWindow(CPUinfo cP)
        {
            InitializeComponent();
            cpuinfo = cP;
            #region Initialize members
            if (!cpuinfo.SST_support)
            {
                SST_TextBlock.Text  = "Unavailable";
                SST_Group.IsEnabled = false;
                EPP_Group.IsEnabled = false;
            }
            else
            {
                Toggle1.IsChecked = cpuinfo.EPP.IsEnabled;

                ePP = new EPP2Sliders(cpuinfo.EPP, SettingsComboBox, FrequencyRange, EPPSlider, Toggle1, ApplySettingsButton);
                AutoSwitchToggle.IsChecked = cpuinfo.PSM.IsEnabled;
                cpuinfo.PSM.EnableChanged += (status) =>
                {
                    if (status != AutoSwitchToggle.IsChecked)
                    {
                        AutoSwitchToggle.IsChecked = status;
                    }
                };
                AutoSwitchToggle.Click += (s, e) =>
                {
                    if (AutoSwitchToggle.IsChecked != cpuinfo.PSM.IsEnabled)
                    {
                        cpuinfo.PSM.FileSetting = AutoSwitchToggle.IsChecked.Value;
                    }
                };
            }
            frequencyRatioSensors = new List <Sensor>(cpuinfo.CoreCount);
            foreach (LogicalProcessor lp in cpuinfo.logicalProcessors)
            {
                frequencyRatioSensors.Add(new Sensor(lp.GetCurrentFrequency));
            }

            #endregion

            UITimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(800)
            };
            if (cpuinfo.Manufacturer == "GenuineIntel")
            {
                CoreVoltageSensor        = new Sensor(cpuinfo.PPM.GetCurrentVoltage);
                PackageTemperatureSensor = new Sensor(cpuinfo.PPM.GetCurrentTemprature);
                PackagePowerSensor       = new Sensor(cpuinfo.PPM.GetPackagePower);

                Sensor2LineGraph s2l1 = new Sensor2LineGraph(CoreVoltageSensor, CoreVoltagePlotter, "G4", -0.1, 1.9, new TransitionText(VoltaCurrent), VoltaMax, VoltaMin);
                Sensor2LineGraph s2l2 = new Sensor2LineGraph(PackagePowerSensor, PackagePowerPlotter, "G3", -1, cpuinfo.PPM.TDP + 1, new TransitionText(PowerCurrent), PowerMax, PowerMin);
                Sensor2LineGraph s2l3 = new Sensor2LineGraph(PackageTemperatureSensor, PackageTemperaturePlotter, "G2", -2, 101, new TransitionText(TempCurrent), TempMax, TempMin);
                UITimer.Tick += new EventHandler((sender, e) =>
                {
                    s2l1.RefreshUI();
                    s2l2.RefreshUI();
                    s2l3.RefreshUI();
                });
            }
            UV2S = new UnderVoltor2Sliders(cpuinfo.underVoltor, Slider0, Slider1, Slider2, Slider3, Slider4, Slider5, ApplyButton, SaveButton, ResetButton);

            int tmp = 0;
            List <Sensor2LineGraph> S2LGs = new List <Sensor2LineGraph>(cpuinfo.CoreCount);
            foreach (Sensor s in frequencyRatioSensors)
            {
                var lg = new LineGraph();
                lines.Children.Add(lg);
                lg.Stroke      = new SolidColorBrush(Color.FromArgb(255, 0, 128, (byte)(255 * Math.Pow(2, -tmp))));
                lg.Description = "0 Ghz";
                Sensor2LineGraph s2lg;
                if (tmp == 0)
                {
                    s2lg = new Sensor2LineGraph(s, lg, "F2", -0.2, cpuinfo.MaxClockSpeed / 1000.0 + 2, new TransitionText(CurrentFrequencyTransition), MaxFrequencyTextBox, MinFrequencyTextBox);
                }
                else
                {
                    s2lg = new Sensor2LineGraph(s, lg, "F2", -0.2, cpuinfo.MaxClockSpeed / 1000.0 + 2);
                }
                UITimer.Tick += new EventHandler((sender, e) => s2lg.RefreshUI());
                S2LGs.Add(s2lg);
                tmp++;
            }
            #region Basic Info
            CPUNameTextBox.Text       = cpuinfo.wmi.Name;
            CoresTextBox.Text         = cpuinfo.CoreCount.ToString();
            ThreadsTextBox.Text       = cpuinfo.ThreadCount.ToString();
            ManufacturerTextBox.Text  = cpuinfo.SimplifiedManufacturer;
            SocketTextBox.Text        = cpuinfo.wmi.SocketDesignation;
            FamilyTextBox.Text        = cpuinfo.wmi.Family;
            ModelTextBox.Text         = cpuinfo.wmi.Model;
            SteppingTextBox.Text      = cpuinfo.wmi.Stepping;
            L1TextBox.Text            = cpuinfo.wmi.L1Cache;
            L2TextBox.Text            = cpuinfo.wmi.L2Cache;
            L3TextBox.Text            = cpuinfo.wmi.L3Cache;
            MaxClockSpeedTextBox.Text = (cpuinfo.MaxClockSpeed / 1000F).ToString();
            CPUIcon.Source            = new ImageSourceConverter().ConvertFromString(
                "pack://application:,,,/MetroCPU;component/" + cpuinfo.wmi.CPUIcon) as ImageSource;
            FrequencyRangeBox.Text = $"Frequency Range (x{cpuinfo.wmi.ExtClock.ToString()} MHz)";
            #endregion
            UITimer.Start();
        }