VERSION 5.00
Begin VB.Form frmConfig 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Configure"
   ClientHeight    =   4935
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3750
   Icon            =   "frmConfig.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4935
   ScaleWidth      =   3750
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame fra2 
      Caption         =   "CPU throttling"
      Height          =   1095
      Left            =   120
      TabIndex        =   13
      Top             =   1680
      Width           =   3495
      Begin VB.ComboBox cboProcModeAC 
         Height          =   315
         Left            =   1920
         Style           =   2  'Dropdown List
         TabIndex        =   16
         Top             =   600
         Width           =   1455
      End
      Begin VB.ComboBox cboProcModeDC 
         Height          =   315
         Left            =   1920
         Style           =   2  'Dropdown List
         TabIndex        =   15
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label lbl2 
         Caption         =   "On AC line :"
         Height          =   255
         Left            =   120
         TabIndex        =   17
         Top             =   600
         Width           =   2175
      End
      Begin VB.Label lbl1 
         Caption         =   "On battery :"
         Height          =   375
         Left            =   120
         TabIndex        =   14
         Top             =   240
         Width           =   2175
      End
   End
   Begin VB.CommandButton butCancel 
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   375
      Left            =   2040
      TabIndex        =   10
      Top             =   4440
      Width           =   1455
   End
   Begin VB.CommandButton butSave 
      Caption         =   "Save"
      Height          =   375
      Left            =   240
      TabIndex        =   9
      Top             =   4440
      Width           =   1455
   End
   Begin VB.Frame fra1 
      Caption         =   "Advanced settings"
      Height          =   1455
      Left            =   120
      TabIndex        =   7
      Top             =   120
      Width           =   3495
      Begin VB.CommandButton butUnpatch 
         Caption         =   "Unpatch ACPIEC"
         Height          =   255
         Left            =   1800
         TabIndex        =   19
         Top             =   1080
         Width           =   1575
      End
      Begin VB.CommandButton butPatch 
         Caption         =   "Patch ACPIEC"
         Height          =   255
         Left            =   120
         TabIndex        =   18
         Top             =   1080
         Width           =   1575
      End
      Begin VB.CheckBox chkShowTime 
         Caption         =   "Show remaining battery time in tray"
         Height          =   195
         Left            =   120
         TabIndex        =   12
         Top             =   720
         Width           =   3255
      End
      Begin VB.CheckBox chkNoHDClicks 
         Caption         =   "Prevent HD clicks"
         Height          =   195
         Left            =   120
         TabIndex        =   11
         Top             =   480
         Width           =   1935
      End
      Begin VB.CheckBox chkAutostart 
         Caption         =   "Autostart with Windows"
         Height          =   195
         Left            =   120
         TabIndex        =   8
         Top             =   240
         Width           =   2295
      End
   End
   Begin VB.Frame fra3 
      Caption         =   "Custom fan control"
      Height          =   1455
      Left            =   120
      TabIndex        =   0
      Top             =   2880
      Width           =   3495
      Begin VB.CheckBox chkAutofan 
         Caption         =   "Start fan in auto mode at"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   960
         Width           =   2055
      End
      Begin VB.ComboBox cboAutofan 
         Height          =   315
         Left            =   2400
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   960
         Width           =   975
      End
      Begin VB.ComboBox cboSlowfan 
         Height          =   315
         Left            =   2400
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   600
         Width           =   975
      End
      Begin VB.ComboBox cboStopfan 
         Height          =   315
         ItemData        =   "frmConfig.frx":058A
         Left            =   2400
         List            =   "frmConfig.frx":058C
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   240
         Width           =   975
      End
      Begin VB.CheckBox chkSlowfan 
         Caption         =   "Start fan in slow mode at"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   600
         Width           =   2055
      End
      Begin VB.CheckBox chkStopfan 
         Caption         =   "Stop fan under"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   2055
      End
   End
End
Attribute VB_Name = "frmConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' ----------------------------------------------------------------------------
'  Copyright (C) 2009 Noda (Yohan Lasorsa) - http://nodadev.wordpress.com
' ----------------------------------------------------------------------------
'  This software Is provided 'as-is', without any express or implied
'  warranty. In no event will the author be held liable for any damages
'  arising from the use of this software.
'
'  Permission is granted to anyone to use this software for any purpose,
'  including commercial applications, and to alter it and redistribute it
'  freely, subject to the following restrictions:
'
'  1. The origin of this software must not be misrepresented; you must not
'     claim that you wrote the original software. If you use this software
'     in a product, an acknowledgment in the product documentation would be
'     appreciated but is not required.
'  2. Altered source versions must be plainly marked as such, and must not be
'     misrepresented as being the original software.
'  3. This notice may not be removed or altered from any source distribution.
' ----------------------------------------------------------------------------

Option Explicit

Private Const TEMP_MIN_CHOICE As Integer = 35
Private Const TEMP_MAX_CHOICE As Integer = 75

Private Sub Form_Load()
    Dim i As Integer
    Dim patched As Boolean

    Me.Caption = "Configure " & App.Title
    
    ' init components
    patched = CheckACPIECPatched And Not settings.vistaOS
    butPatch.Enabled = Not patched And Not settings.vistaOS And Not settings.useAltDriver
    butUnpatch.Enabled = patched
    cboProcModeAC.AddItem "800 Mhz"
    cboProcModeDC.AddItem "800 Mhz"
    cboProcModeAC.AddItem "Dynamic"
    cboProcModeDC.AddItem "Dynamic"
    
    For i = TEMP_MIN_CHOICE To TEMP_MAX_CHOICE
        cboStopfan.AddItem i & "°C"
        cboSlowfan.AddItem i & "°C"
        cboAutofan.AddItem i & "°C"
    Next i
    
    ' set values
    chkAutostart.value = IIf(settings.autostart, 1, 0)
    chkNoHDClicks.value = IIf(settings.noHDClicks, 1, 0)
    chkShowTime.value = IIf(settings.showTime, 1, 0)
    chkStopfan.value = IIf((settings.fanStop > 0), 1, 0)
    chkSlowfan.value = IIf((settings.fanSlow > 0), 1, 0)
    chkAutofan.value = IIf((settings.fanAuto > 0), 1, 0)
    cboProcModeAC.ListIndex = settings.procModeAC
    cboProcModeDC.ListIndex = settings.procModeDC
    cboStopfan.ListIndex = IIf((settings.fanStop > 0), settings.fanStop - TEMP_MIN_CHOICE, 0)
    cboSlowfan.ListIndex = IIf((settings.fanSlow > 0), settings.fanSlow - TEMP_MIN_CHOICE, 0)
    cboAutofan.ListIndex = IIf((settings.fanAuto > 0), settings.fanAuto - TEMP_MIN_CHOICE, 0)
    cboStopfan.Enabled = (chkStopfan.value = 1)
    cboSlowfan.Enabled = (chkSlowfan.value = 1)
    cboAutofan.Enabled = (chkAutofan.value = 1)
    
End Sub

Private Sub butPatch_Click()
    Dim patched As Boolean
    PatchACPIEC
    patched = CheckACPIECPatched
    butPatch.Enabled = Not patched
    butUnpatch.Enabled = patched
End Sub

Private Sub butUnpatch_Click()
    Dim patched As Boolean
    UnpatchACPIEC
    patched = CheckACPIECPatched
    butPatch.Enabled = Not patched
    butUnpatch.Enabled = patched
End Sub

Private Sub butSave_Click()
    ' update settings
    With settings
        .autostart = chkAutostart.value
        .noHDClicks = chkNoHDClicks.value
        .showTime = chkShowTime.value
        .procModeAC = cboProcModeAC.ListIndex
        .procModeDC = cboProcModeDC.ListIndex
        .fanStop = IIf((chkStopfan.value = 1), cboStopfan.ListIndex + TEMP_MIN_CHOICE, 0)
        .fanSlow = IIf((chkSlowfan.value = 1), cboSlowfan.ListIndex + TEMP_MIN_CHOICE, 0)
        .fanAuto = IIf((chkAutofan.value = 1), cboAutofan.ListIndex + TEMP_MIN_CHOICE, 0)
    End With
    
    ' set autostart or remove it
    If (HasStartupShortcut(App.EXEName)) Then
        If (Not settings.autostart) Then
            DeleteStartupShortcut App.EXEName
        End If
    Else
        If (settings.autostart) Then
            AddStartupShortcut App.EXEName, CurrentPath
        End If
    End If
    
    Unload Me
    WriteSettings
    fanStatus = Unknown
    SetCPUModes settings.procModeAC, settings.procModeDC
    frmMain.TimerMon_Timer
End Sub

Private Sub butCancel_Click()
    Unload Me
End Sub

Private Sub chkAutofan_Click()
    cboAutofan.Enabled = (chkAutofan.value = 1)
End Sub

Private Sub chkSlowfan_Click()
    cboSlowfan.Enabled = (chkSlowfan.value = 1)
'    chkAutofan.Enabled = (cboStopfan.Enabled Or cboSlowfan.Enabled)
'    cboAutofan.Enabled = (cboStopfan.Enabled Or cboSlowfan.Enabled) And (chkAutofan.value = 1)
End Sub

Private Sub chkStopfan_Click()
    cboStopfan.Enabled = (chkStopfan.value = 1)
'    chkAutofan.Enabled = (cboStopfan.Enabled Or cboSlowfan.Enabled)
'    cboAutofan.Enabled = (cboStopfan.Enabled Or cboSlowfan.Enabled) And (chkAutofan.value = 1)
End Sub
