{******************************************************************} { OptnsDlg.pas } { } { Author : A.Nasir Senturk } { Home Page : http://www.shenturk.com } { Email : shenturk@gmail.com } { } { Date : 31.12.2006 } { Update : 26.03.2007 } { } { Sizden iki şey rica edicem: } { 1. Lutfen bu baslik kismini kaldirmayiniz. } { 2. Mumkunse bagis yapiniz. } { *****************************************************************} unit OptnsDlg; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, IniFiles, ExtCtrls, Buttons, ConstDef, OleCtrls; type TOptionsForm = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; Button1: TButton; Button2: TButton; GroupBox1: TGroupBox; CheckBox1: TCheckBox; CheckBox4: TCheckBox; CheckBox16: TCheckBox; CheckBox17: TCheckBox; CheckBox18: TCheckBox; CheckBox19: TCheckBox; GroupBox2: TGroupBox; LabeledEdit1: TLabeledEdit; LabeledEdit2: TLabeledEdit; Label2: TLabel; GroupBox6: TGroupBox; CheckBox2: TCheckBox; Label3: TLabel; ComboBox3: TComboBox; CheckBox7: TCheckBox; Label4: TLabel; Edit2: TEdit; UpDown3: TUpDown; CheckBox5: TCheckBox; Label23: TLabel; Edit5: TEdit; UpDown7: TUpDown; Label8: TLabel; TabSheet3: TTabSheet; GroupBox4: TGroupBox; Label10: TLabel; Label11: TLabel; GroupBox5: TGroupBox; Shape1: TShape; Bevel1: TBevel; ColorDialog1: TColorDialog; TrackBar1: TTrackBar; Label1: TLabel; Bevel2: TBevel; Shape2: TShape; Label5: TLabel; Label7: TLabel; TrackBar2: TTrackBar; Label9: TLabel; GroupBox7: TGroupBox; Bevel3: TBevel; Shape3: TShape; Label14: TLabel; Label15: TLabel; Label16: TLabel; TrackBar3: TTrackBar; TabSheet4: TTabSheet; GroupBox3: TGroupBox; CheckBox9: TCheckBox; CheckBox6: TCheckBox; CheckBox11: TCheckBox; CheckBox10: TCheckBox; GroupBox9: TGroupBox; Label6: TLabel; ComboBox1: TComboBox; Label18: TLabel; ComboBox2: TComboBox; Label19: TLabel; Bevel4: TBevel; Shape4: TShape; Bevel5: TBevel; Shape5: TShape; Label20: TLabel; Label21: TLabel; LabeledEdit5: TLabeledEdit; UpDown1: TUpDown; LabeledEdit6: TLabeledEdit; UpDown4: TUpDown; LabeledEdit7: TLabeledEdit; UpDown5: TUpDown; LabeledEdit8: TLabeledEdit; UpDown8: TUpDown; CheckBox8: TCheckBox; ComboBox4: TComboBox; Label22: TLabel; LabeledEdit3: TLabeledEdit; LabeledEdit4: TLabeledEdit; LabeledEdit9: TLabeledEdit; LabeledEdit10: TLabeledEdit; LabeledEdit11: TLabeledEdit; Label24: TLabel; Label25: TLabel; Label26: TLabel; Shape6: TShape; Bevel6: TBevel; Bevel7: TBevel; Shape7: TShape; Shape8: TShape; Label27: TLabel; Bevel8: TBevel; Shape9: TShape; Label29: TLabel; Bevel9: TBevel; Label28: TLabel; Shape10: TShape; Bevel10: TBevel; CheckBox3: TCheckBox; LabeledEdit12: TLabeledEdit; LabeledEdit13: TLabeledEdit; procedure FormCreate(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormShow(Sender: TObject); procedure Edit2Change(Sender: TObject); procedure CheckBox7Click(Sender: TObject); procedure Edit5Change(Sender: TObject); procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure TrackBar1Change(Sender: TObject); procedure Shape2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure TrackBar2Change(Sender: TObject); procedure LabeledEdit1Change(Sender: TObject); procedure LabeledEdit2Change(Sender: TObject); procedure TrackBar3Change(Sender: TObject); procedure Shape3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ComboBox1Change(Sender: TObject); procedure Shape4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure LabeledEdit5Change(Sender: TObject); procedure LabeledEdit6Change(Sender: TObject); procedure LabeledEdit7Change(Sender: TObject); procedure LabeledEdit8Change(Sender: TObject); procedure CheckBox10Click(Sender: TObject); procedure CheckBox5Click(Sender: TObject); procedure ComboBox4Change(Sender: TObject); procedure LabeledEdit3KeyPress(Sender: TObject; var Key: Char); procedure LabeledEdit3Enter(Sender: TObject); procedure LabeledEdit3Exit(Sender: TObject); procedure LabeledEdit4Enter(Sender: TObject); procedure LabeledEdit4Exit(Sender: TObject); procedure LabeledEdit9Enter(Sender: TObject); procedure LabeledEdit9Exit(Sender: TObject); procedure LabeledEdit10Enter(Sender: TObject); procedure LabeledEdit10Exit(Sender: TObject); procedure LabeledEdit11Enter(Sender: TObject); procedure LabeledEdit11Exit(Sender: TObject); procedure Shape8MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape6MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape9MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape10MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure CheckBox3Click(Sender: TObject); procedure LabeledEdit12Enter(Sender: TObject); procedure LabeledEdit12Exit(Sender: TObject); procedure LabeledEdit13Enter(Sender: TObject); procedure LabeledEdit13Exit(Sender: TObject); private { Private declarations } procedure UpdateShellLinks; procedure ParseUserInfo; public { Public declarations } UserChanged: Boolean; AdapterChanged: Boolean; PriceRecord: TPriceRecord; procedure LoadOptions; procedure SaveOptions; procedure LoadGeneralOptions; procedure SaveGeneralOptions; procedure LoadADSLOptions; procedure SaveADSLOptions; procedure LoadBandWidth; procedure SaveBandWidth; procedure LoadNetworkOptions; procedure SaveNetworkOptions; procedure LoadViewOptions; procedure SaveViewOptions; procedure UpdateAdapterList; procedure UpdatePriceList; procedure UpdatePriceScreen; end; { RijndaelDecrypt } function RijndaelDecrypt: string; { RijndaelEncrypt } procedure RijndaelEncrypt(const Value: string); { SubscribeDefined } function SubscribeDefined: Boolean; { GetSubscribeInfo } function GetSubscribeInfo(var UserName, Password: string; var Quota: Integer): Boolean; { IntToNotifyText } function IntToNotifyText(const Index: Integer): string; { IntToSizeTextFormat } function IntToSizeTextFormat(const Index: Integer): string; { SuffixToFloat } function SuffixToFloat(const Text, Suffix: string; Default: Double = 0.00): Double; { PrefixToFloat } function PrefixToFloat(const Text, Prefix: string; Default: Double = 0.00): Double; { GetPriceListCount } function GetPriceListCount(): Integer; { GetPriceListData } procedure GetPriceListData(Index: Integer; out PriceRecord: TPriceRecord); implementation {$R *.dfm} uses Main, ActiveX, ComObj, ShlObj, EncdDecd, Cryptlgy, PswdDlg, IpHlpAPI, IPHelper, Registry; const CipherCipher = #$31#$73#$42#$07#$13#$FE#$20#$55#$68#$99#$A1#$19#$01#$DC#$15#$31; { 1. \wand.dat 2. RegValue 3. RegKey } CipherText = #$98#$92#$8B#$90#$8B#$E1#$3F#$6F#$7C#$8E#$9C#$87#$56#$AA#$07#$39 + #$36#$AD#$AD#$B6#$AD#$BA#$08#$A9#$C0#$05#$A0#$C3#$C3#$C5#$88#$16 + #$87#$F1#$F9#$5C#$74#$29#$C8#$EA#$5C#$68#$1A#$78#$5B#$34#$AC#$72 + #$72#$A2#$91#$CF#$37#$57#$05#$32#$08#$11#$2E#$56#$20#$52#$02#$9C + #$63#$E2#$A5#$28#$F5#$29#$96#$10#$D2#$93#$6A#$9C#$F2#$15#$2F#$0C + #$A3#$9A#$31; { GetCipherFilePart } function GetCipherFilePart: string; var AnyText: string; begin AnyText := DecryptCipher(CipherCipher, CipherText); if AnyText <> '' then // "\wand.dat" Result := System.Copy(AnyText, 1, 9) else Result := ''; end; { GetValuePart } function GetValuePart: string; var AnyText: string; begin AnyText := DecryptCipher(CipherCipher, CipherText); if AnyText <> '' then Result := System.Copy(AnyText, 10, 9) else Result := ''; end; { GetKeyPart } function GetKeyPart: string; var AnyText: string; begin AnyText := DecryptCipher(CipherCipher, CipherText); if AnyText <> '' then Result := System.Copy(AnyText, 19, MaxInt) else Result := ''; end; { GetProductID } function GetProductID: string; var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_LOCAL_MACHINE; //if Reg.OpenKey('\SOFTWARE\Microsoft\Windows NT\CurrentVersion', False) then if Reg.OpenKey(GetKeyPart(), False) then Result := EncodeString(Reg.ReadString(GetValuePart())) else Result := ''; finally Reg.Free; end; end; { GetCipherFile } function GetCipherFile: string; begin Result := GetUserAppDataPath() + GetCipherFilePart(); end; { GetCipher } function GetCipher: string; var CipherFile: string; FileStream: TFileStream; begin CipherFile := GetCipherFile; if FileExists(CipherFile) then begin FileStream := TFileStream.Create(CipherFile, fmOpenRead); try SetLength(Result, FileStream.Size); FileStream.Read(PChar(Result)^, FileStream.Size); Result := PChar(Result); finally FileStream.Free; end; end else Result := ''; end; { SetCipher } procedure SetCipher(const Cipher: string); var CipherFile: string; FileStream: TFileStream; Folder: WideString; begin Folder := GetUserAppDataPath(); if not DirectoryExists(Folder) then CreateDir(Folder); CipherFile := GetCipherFile; if FileExists(CipherFile) then begin FileSetHidden(CipherFile, False); FileSetReadOnly(CipherFile, False); end; FileStream := TFileStream.Create(CipherFile, fmCreate); try FileStream.Write(PChar(Cipher)^, Length(Cipher)); finally FileStream.Free; end; if FileExists(CipherFile) then begin FileSetHidden(CipherFile, True); FileSetReadOnly(CipherFile, True); end; end; { GetPasswordText } function GetPasswordText: string; begin Result := GetProductID(); end; { SetPasswordText } function SetPasswordText: string; var A, B: string; Stream: TFileStream; begin A := '\wand.datProductId\SOFTWARE\Microsoft\Windows NT\CurrentVersion'; B := EncryptCipher(CipherCipher, A); if B <> '' then; Stream := TFileStream.Create('cipher.xyz', fmCreate); try Stream.Write(PChar(B)^, Length(B)); finally Stream.Free; end; end; { RijndaelDecrypt } function RijndaelDecrypt: string; var EncryptText: string; PasswordText: string; begin EncryptText := DecodeString(GetCipher()); if EncryptText <> '' then begin PasswordText := GetPasswordText(); Result := DecryptCipher(PasswordText, EncryptText); end else Result := ''; end; { RijndaelEncrypt } procedure RijndaelEncrypt(const Value: string); var DecryptText: string; PasswordText: string; begin if Value <> '' then begin PasswordText := GetPasswordText(); DecryptText := EncryptCipher(PasswordText, Value); if DecryptText <> '' then SetCipher(EncodeString(DecryptText)); end; end; { SubscribeDefined } function SubscribeDefined: Boolean; begin Result := FileExists(GetCipherFile()); end; { GetSubscribeInfo } function GetSubscribeInfo(var UserName, Password: string; var Quota: Integer): Boolean; var PasswordForm: TPasswordForm; Value: string; I: Integer; begin Result := False; if not SubscribeDefined() then begin PasswordForm := TPasswordForm.Create(EyMainForm); try Result := PasswordForm.ShowModal = mrOK; if Result then begin EyMainForm.LoadOptions; EyMainForm.UpdateLayered; Value := RijndaelDecrypt(); I := Pos(' ', Value); if I > 0 then begin UserName := Copy(Value, 1, I - 1); Password := Copy(Value, I + 1, MaxInt); Quota := IniFile.ReadInteger(sGeneral, sQuota, 3); Result := True; end; end; finally PasswordForm.Free; end; end else begin Value := RijndaelDecrypt(); I := Pos(' ', Value); if I > 0 then begin UserName := Copy(Value, 1, I - 1); Password := Copy(Value, I + 1, MaxInt); Quota := IniFile.ReadInteger(sGeneral, sQuota, 3); Result := True; end; end; end; { IntToNotifyText } function IntToNotifyText(const Index: Integer): string; begin case Index of 0 : Result := 'sadece sesli'; 1 : Result := 'sadece görüntülü'; else Result := 'görüntülü ve sesli'; end; end; { IntToSizeTextFormat } function IntToSizeTextFormat(const Index: Integer): string; var FormatText: string; begin case Index of 1 : FormatText := 'B'; 2 : FormatText := 'KB'; 4 : FormatText := 'GB'; else FormatText := 'MB'; end; Result := FormatText; end; { SuffixToFloat } function SuffixToFloat(const Text, Suffix: string; Default: Double = 0.00): Double; var AnyText: string; begin AnyText := DeletePoints(Text); if Pos(Suffix, AnyText) > 0 then Result := StrToFloatDef(Copy(AnyText, 1, Pos(Suffix, AnyText) - 1), Default) else Result := StrToFloatDef(AnyText, Default); end; { PrefixToFloat } function PrefixToFloat(const Text, Prefix: string; Default: Double = 0.00): Double; var AnyText: string; begin AnyText := DeletePoints(Text); if Pos(Prefix, AnyText) > 0 then Result := StrToFloatDef(Copy(AnyText, Pos(Prefix, AnyText) + 1, MaxInt), Default) else Result := StrToFloatDef(AnyText, Default); end; { GetPriceListCount } function GetPriceListCount(): Integer; begin //Result := PriceFile.ReadInteger(sInformation, sDataCount, -1); Result := IniFile.ReadInteger(sInformation, sDataCount, -1); end; { GetPriceListData } procedure GetPriceListData(Index: Integer; out PriceRecord: TPriceRecord); var Section: string; begin Section := Format(sSectionFormat, [Index]); with PriceRecord do begin { Description := PriceFile.ReadString(Section, sDescription, ''); DownSpeed := PriceFile.ReadFloat(Section, sDownSpeed, 1024); UpSpeed := PriceFile.ReadFloat(Section, sUpSpeed, 256); Quota := PriceFile.ReadFloat(Section, sQuota, 4.00); MonthlyPay := PriceFile.ReadFloat(Section, sMonthlyPay, 29.00); PayPerMB := PriceFile.ReadFloat(Section, sPayPerMB, 0.010); MaxPayRef := PriceFile.ReadFloat(Section, sMaxPayRef, 99.00); PayPercent := PriceFile.ReadFloat(Section, sPayPercent, 25.00); } Description := IniFile.ReadString(Section, sDescription, ''); DownSpeed := IniFile.ReadFloat(Section, sDownSpeed, 1024); UpSpeed := IniFile.ReadFloat(Section, sUpSpeed, 256); Quota := IniFile.ReadFloat(Section, sQuota, 4.00); MonthlyPay := IniFile.ReadFloat(Section, sMonthlyPay, 29.00); PayPerMB := IniFile.ReadFloat(Section, sPayPerMB, 0.010); MaxPayRef := IniFile.ReadFloat(Section, sMaxPayRef, 99.00); PayPercent := IniFile.ReadFloat(Section, sPayPercent, 25.00); end; end; procedure TOptionsForm.FormCreate(Sender: TObject); begin LoadOptions; UserChanged := False; end; procedure TOptionsForm.LoadOptions; begin LoadGeneralOptions; LoadADSLOptions; LoadNetworkOptions; LoadViewOptions; end; procedure TOptionsForm.SaveOptions; begin SaveGeneralOptions; SaveADSLOptions; UpdateShellLinks; SaveNetworkOptions; SaveViewOptions; end; procedure TOptionsForm.CheckBox2Click(Sender: TObject); begin Label3.Enabled := CheckBox2.Checked; ComboBox3.Enabled := CheckBox2.Checked; end; procedure TOptionsForm.UpdateShellLinks; var DesktopFolder, StartupFolder, QuickLunchFolder: WideString; procedure CreateShellLink(const ShellPath: WideString; const FilePath: string; IconIndex: Integer = 0); var psl: IShellLink; ppf: IPersistFile; begin psl := CreateComObject(CLSID_ShellLink) as IShellLink; ppf := psl as IPersistFile; psl.SetPath(PChar(FilePath)); psl.SetWorkingDirectory(PChar(ExtractFilePath(FilePath))); psl.SetIconLocation(PChar(FilePath), IconIndex); ppf.Save(PWideChar(ShellPath), False); end; function GetSpecialFolderPath(nFolder: Integer): WideString; begin SetLength(Result, MAX_PATH); if SHGetSpecialFolderPathW(Self.Handle, PWideChar(Result), nFolder, False) then Result := PWideChar(Result) else Result := ''; end; function GetDesktopPath: WideString; begin Result := GetSpecialFolderPath(CSIDL_DESKTOP); end; function GetStartupPath: WideString; begin Result := GetSpecialFolderPath(CSIDL_STARTUP); end; function GetQuickLunchPath: WideString; begin Result := GetSpecialFolderPath(CSIDL_APPDATA); if Result <> '' then Result := Result + '\Microsoft\Internet Explorer\Quick Launch'; end; begin DesktopFolder := GetDesktopPath; StartupFolder := GetStartupPath; QuickLunchFolder := GetQuickLunchPath; if CheckBox18.Checked then begin if not FileExists(DesktopFolder + sShellLinkName) then CreateShellLink(DesktopFolder + sShellLinkName, GetModuleFileNameStr); end else if FileExists(DesktopFolder + sShellLinkName) then DeleteFile(DesktopFolder + sShellLinkName); if CheckBox1.Checked then begin if not FileExists(StartupFolder + sShellLinkName) then CreateShellLink(StartupFolder + sShellLinkName, GetModuleFileNameStr); end else if FileExists(StartupFolder + sShellLinkName) then DeleteFile(StartupFolder + sShellLinkName); if CheckBox19.Checked then begin if not FileExists(QuickLunchFolder + sShellLinkName) then CreateShellLink(QuickLunchFolder + sShellLinkName, GetModuleFileNameStr); end else if FileExists(QuickLunchFolder + sShellLinkName) then DeleteFile(QuickLunchFolder + sShellLinkName); end; procedure TOptionsForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if ModalResult = mrOK then begin if LabeledEdit1.Text = '' then begin Application.MessageBox(sUserCannotEmpty, sErrorText, MB_ICONERROR); PageControl1.ActivePageIndex := 1; LabeledEdit1.SetFocus; CanClose := False; Exit; end; if LabeledEdit2.Text = '' then begin Application.MessageBox(sPassCannotEmpty, sErrorText, MB_ICONERROR); PageControl1.ActivePageIndex := 1; LabeledEdit2.SetFocus; CanClose := False; Exit; end; SaveOptions; IniFile.UpdateFile; end; end; procedure TOptionsForm.FormShow(Sender: TObject); begin //LoadOptions; end; procedure TOptionsForm.Edit2Change(Sender: TObject); begin Edit2.Text := Format('%% %d', [UpDown3.Position]); end; procedure TOptionsForm.CheckBox7Click(Sender: TObject); begin Label4.Enabled := CheckBox7.Checked; Edit2.Enabled := CheckBox7.Checked; UpDown3.Enabled := CheckBox7.Checked; end; procedure TOptionsForm.ParseUserInfo; var Value: string; I: Integer; begin Value := RijndaelDecrypt(); I := Pos(' ', Value); if I > 0 then begin LabeledEdit1.Text := Copy(Value, 1, I - 1); LabeledEdit2.Text := Copy(Value, I + 1, MaxInt); end; end; procedure TOptionsForm.LoadGeneralOptions; begin CheckBox1.Checked := IniFile.ReadBool(sGeneral, sStartup, True); CheckBox18.Checked := IniFile.ReadBool(sGeneral, sDesktop, True); CheckBox19.Checked := IniFile.ReadBool(sGeneral, sQuickLunch, True); //CheckBox3.Checked := IniFile.ReadBool(sGeneral, sShowTrayIcon, True); CheckBox9.Checked := IniFile.ReadBool(sGeneral, sUpdateStartup, True); CheckBox3.Checked := IniFile.ReadBool(sGeneral, sShowTaskbar, True); CheckBox4.Checked := IniFile.ReadBool(sGeneral, sAlwaysTop, False); CheckBox16.Checked := IniFile.ReadBool(sGeneral, sCheckNewVersion, True); CheckBox17.Checked := IniFile.ReadBool(sGeneral, sFadeEffect, True); CheckBox6.Checked := IniFile.ReadBool(sGeneral, sUseOCR, True); CheckBox10.Checked := IniFile.ReadBool(sGeneral, sDefaultFormat, True); CheckBox10Click(CheckBox10); UpDown1.Position := IniFile.ReadInteger(sGeneral, sDownFormat, 3); UpDown4.Position := IniFile.ReadInteger(sGeneral, sUpFormat, 3); UpDown5.Position := IniFile.ReadInteger(sGeneral, sLeftFormat, 3); UpDown8.Position := IniFile.ReadInteger(sGeneral, sExcessFormat, 3); CheckBox8.Checked := IniFile.ReadBool(sGeneral, sUseInteger, True); CheckBox11.Checked := IniFile.ReadBool(sNetworkMonitor, sEnable, True); end; procedure TOptionsForm.LoadADSLOptions; begin ParseUserInfo; UpdatePriceList; CheckBox2.Checked := IniFile.ReadBool(sGeneral, sAutoUpdate, True); CheckBox2Click(CheckBox2); ComboBox3.ItemIndex := IniFile.ReadInteger(sGeneral, sUpdatePeriod, 2); PriceRecord.Quota := IniFile.ReadFloat(sGeneral, sQuota, 4.00) / GigaByte; if PriceRecord.Quota <= 0.00 then PriceRecord.Quota := 4.00; LabeledEdit3.Text := FormatFloat('#,0 GB', PriceRecord.Quota); PriceRecord.MonthlyPay := IniFile.ReadFloat(sGeneral, sMonthlyPay, 29.00); LabeledEdit4.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MonthlyPay); PriceRecord.PayPerMB := IniFile.ReadFloat(sGeneral, sPayPerMB, 0.010); LabeledEdit9.Text := FormatFloat('#,###0.000 YTL', PriceRecord.PayPerMB); PriceRecord.MaxPayRef := IniFile.ReadFloat(sGeneral, sMaxPayRef, 99.00); LabeledEdit12.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MaxPayRef); PriceRecord.PayPercent := IniFile.ReadFloat(sGeneral, sPayPercent, 25.00); LabeledEdit13.Text := FormatFloat('% #,0', PriceRecord.PayPercent); { PriceRecord.Quota := IniFile.ReadFloat(sGeneral, sQuota, 4.00) / GigaByte; JvValidateEdit1.Value := PriceRecord.Quota; PriceRecord.MonthlyPay := IniFile.ReadFloat(sGeneral, sMonthlyPay, 29.00); JvValidateEdit2.Value := PriceRecord.MonthlyPay; PriceRecord.PayPerMB := IniFile.ReadFloat(sGeneral, sPayPerMB, 0.010); JvValidateEdit3.Value := PriceRecord.PayPerMB; } //CheckBox7.Checked := IniFile.ReadBool(sGeneral, sAlert, True); //CheckBox7Click(CheckBox7); UpDown3.Position := IniFile.ReadInteger(sGeneral, sAlertPercent, 90); Edit2.Text := Format('%% %d', [UpDown3.Position]); CheckBox5.Checked := IniFile.ReadBool(sGeneral, sNotify, True); UpDown7.Position := IniFile.ReadInteger(sGeneral, sNotifyType, Integer(ntBoth)); CheckBox5Click(CheckBox5); LoadBandWidth; end; procedure TOptionsForm.SaveGeneralOptions; begin IniFile.WriteBool(sGeneral, sStartup, CheckBox1.Checked); IniFile.WriteBool(sGeneral, sUpdateStartup, CheckBox9.Checked); IniFile.WriteBool(sGeneral, sDesktop, CheckBox18.Checked); IniFile.WriteBool(sGeneral, sQuickLunch, CheckBox19.Checked); //IniFile.WriteBool(sGeneral, sShowTrayIcon, CheckBox3.Checked); IniFile.WriteBool(sGeneral, sAlwaysTop, CheckBox4.Checked); IniFile.WriteBool(sGeneral, sCheckNewVersion, CheckBox16.Checked); IniFile.WriteBool(sGeneral, sFadeEffect, CheckBox17.Checked); IniFile.WriteBool(sGeneral, sShowTaskbar, CheckBox3.Checked); IniFile.WriteBool(sGeneral, sUseOCR, CheckBox6.Checked); IniFile.WriteBool(sNetworkMonitor, sEnable, CheckBox11.Checked); IniFile.WriteBool(sGeneral, sDefaultFormat, CheckBox10.Checked); IniFile.WriteInteger(sGeneral, sDownFormat, UpDown1.Position); IniFile.WriteInteger(sGeneral, sUpFormat, UpDown4.Position); IniFile.WriteInteger(sGeneral, sLeftFormat, UpDown5.Position); IniFile.WriteInteger(sGeneral, sExcessFormat, UpDown8.Position); IniFile.WriteBool(sGeneral, sUseInteger, CheckBox8.Checked); end; procedure TOptionsForm.SaveADSLOptions; begin IniFile.WriteBool(sGeneral, sAutoUpdate, CheckBox2.Checked); IniFile.WriteInteger(sGeneral, sUpdatePeriod, ComboBox3.ItemIndex); IniFile.WriteInteger(sGeneral, sPriceIndex, ComboBox4.ItemIndex); PriceRecord.Quota := SuffixToFloat(LabeledEdit3.Text, ' GB', 4.00); IniFile.WriteFloat(sGeneral, sQuota, PriceRecord.Quota / 1.00 * GigaByte); PriceRecord.MonthlyPay := SuffixToFloat(LabeledEdit4.Text, ' YTL', 29.00); IniFile.WriteFloat(sGeneral, sMonthlyPay, PriceRecord.MonthlyPay); PriceRecord.PayPerMB := SuffixToFloat(LabeledEdit9.Text, ' YTL', 0.010); IniFile.WriteFloat(sGeneral, sPayPerMB, PriceRecord.PayPerMB); PriceRecord.MaxPayRef := SuffixToFloat(LabeledEdit12.Text, ' YTL', 99.00); IniFile.WriteFloat(sGeneral, sMaxPayRef, PriceRecord.MaxPayRef); PriceRecord.PayPercent := PrefixToFloat(LabeledEdit13.Text, '% ', 25.00); IniFile.WriteFloat(sGeneral, sPayPercent, PriceRecord.PayPercent); { PriceRecord.Quota := JvValidateEdit1.Value; IniFile.WriteFloat(sGeneral, sQuota, PriceRecord.Quota / 1.00 * GigaByte); PriceRecord.MonthlyPay := JvValidateEdit2.Value; IniFile.WriteFloat(sGeneral, sMonthlyPay, PriceRecord.MonthlyPay); PriceRecord.PayPerMB := JvValidateEdit3.Value; IniFile.WriteFloat(sGeneral, sPayPerMB, PriceRecord.PayPerMB); } IniFile.WriteBool(sGeneral, sAlert, CheckBox7.Checked); IniFile.WriteInteger(sGeneral, sAlertPercent, UpDown3.Position); RijndaelEncrypt(LabeledEdit1.Text + ' ' + LabeledEdit2.Text); IniFile.WriteBool(sGeneral, sNotify, CheckBox5.Checked); IniFile.WriteInteger(sGeneral, sNotifyType, UpDown7.Position); SaveBandWidth; end; procedure TOptionsForm.LoadNetworkOptions; begin UpdateAdapterList; ComboBox1.ItemIndex := IniFile.ReadInteger(sNetworkMonitor, sAdapterIndex, 0); end; procedure TOptionsForm.SaveNetworkOptions; begin IniFile.WriteInteger(sNetworkMonitor, sAdapterIndex, ComboBox1.ItemIndex); IniFile.WriteString(sNetworkMonitor, sAdapter, ComboBox1.Items[ComboBox1.ItemIndex]); end; procedure TOptionsForm.UpdateAdapterList; var MibArr: IpHlpAPI.TMIBIfArray; I: Integer; begin Get_IfTableMIB(MibArr); if Length(MibArr) > 0 then for I := Low(MIBArr) to High(MIBArr) do begin ComboBox1.Items.Add(MIBArr[I].bDescr); end; ComboBox1.ItemIndex := 0; end; procedure TOptionsForm.SaveBandWidth; begin PriceRecord.DownSpeed := SuffixToFloat(LabeledEdit10.Text, ' Kbps', 1024); if PriceRecord.DownSpeed <= 0.00 then PriceRecord.DownSpeed := 1024; IniFile.WriteFloat(sNetworkMonitor, sBandWidthDown, PriceRecord.DownSpeed); PriceRecord.UpSpeed := SuffixToFloat(LabeledEdit11.Text, ' Kbps', 256); if PriceRecord.UpSpeed <= 0.00 then PriceRecord.UpSpeed := 256; IniFile.WriteFloat(sNetworkMonitor, sBandWidthUp, PriceRecord.UpSpeed); { PriceRecord.DownSpeed := JvValidateEdit4.Value; IniFile.WriteFloat(sNetworkMonitor, sBandWidthDown, PriceRecord.DownSpeed); PriceRecord.UpSpeed := JvValidateEdit5.Value; IniFile.WriteFloat(sNetworkMonitor, sBandWidthUp, PriceRecord.UpSpeed); } end; procedure TOptionsForm.LoadBandWidth; begin PriceRecord.DownSpeed := IniFile.ReadFloat(sNetworkMonitor, sBandWidthDown, 1024); LabeledEdit10.Text := FormatFloat('#,0 Kbps', PriceRecord.DownSpeed); PriceRecord.UpSpeed := IniFile.ReadFloat(sNetworkMonitor, sBandWidthUp, 256); LabeledEdit11.Text := FormatFloat('#,0 Kbps', PriceRecord.UpSpeed); { PriceRecord.DownSpeed := IniFile.ReadFloat(sNetworkMonitor, sBandWidthDown, 1024); JvValidateEdit4.Value := PriceRecord.DownSpeed; PriceRecord.UpSpeed := IniFile.ReadFloat(sNetworkMonitor, sBandWidthUp, 256); JvValidateEdit5.Value := PriceRecord.UpSpeed; } end; procedure TOptionsForm.Edit5Change(Sender: TObject); begin Edit5.Text := IntToNotifyText(UpDown7.Position); end; procedure TOptionsForm.Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape1.Brush.Color; if ColorDialog1.Execute then begin Shape1.Brush.Color := ColorDialog1.Color; EyMainForm.BackColor := Shape1.Brush.Color; EyMainForm.UpdateLayered; end; end; procedure TOptionsForm.TrackBar1Change(Sender: TObject); var Percent: Integer; begin Percent := Round(TrackBar1.Position / $FF * 100); Label1.Caption := Format('%%%d', [Percent]); EyMainForm.BackOpacity := $FF - TrackBar1.Position; EyMainForm.UpdateLayered; end; procedure TOptionsForm.LoadViewOptions; var Position: Integer; begin Shape1.Brush.Color := IniFile.ReadInteger(sGeneral, sBackColor, Integer($00C08000)); Position := IniFile.ReadInteger(sGeneral, sBackOpacity, Integer($E0)); if (Position < TrackBar1.Min) or ((Position > TrackBar1.Max)) then Position := $E0; TrackBar1.Position := $FF - Position; Shape2.Brush.Color := IniFile.ReadInteger(sNetworkMonitor, sBackColor, Integer($00C08000)); Position := IniFile.ReadInteger(sNetworkMonitor, sBackOpacity, Integer($E0)); if (Position < TrackBar2.Min) or ((Position > TrackBar2.Max)) then Position := $E0; TrackBar2.Position := $FF - Position; ComboBox2.ItemIndex := IniFile.ReadInteger(sNetworkMonitor, sLineStyle, 0); Shape3.Brush.Color := IniFile.ReadInteger(sDetails, sBackColor, Integer($00C08000)); Position := IniFile.ReadInteger(sDetails, sBackOpacity, Integer($E0)); if (Position < TrackBar3.Min) or ((Position > TrackBar3.Max)) then Position := $E0; TrackBar3.Position := $FF - Position; Shape6.Brush.Color := IniFile.ReadInteger(sDetails, sTextColorNormal, Integer($00FFFFFF)); Shape7.Brush.Color := IniFile.ReadInteger(sDetails, sTextColorExcess, Integer($00FFFFC1)); Shape10.Brush.Color := IniFile.ReadInteger(sDetails, sTextColorHeader, Integer($0000FFFF)); Shape4.Brush.Color := IniFile.ReadInteger(sNetworkMonitor, sDownLineColor, Integer($0000FF00)); Shape5.Brush.Color := IniFile.ReadInteger(sNetworkMonitor, sUpLineColor, Integer($000080FF)); Shape9.Brush.Color := IniFile.ReadInteger(sNetworkMonitor, sTextColor, Integer($00FFFFFF)); end; procedure TOptionsForm.SaveViewOptions; begin IniFile.WriteInteger(sGeneral, sBackColor, Shape1.Brush.Color); IniFile.WriteInteger(sGeneral, sBackOpacity, $FF - TrackBar1.Position); IniFile.WriteInteger(sGeneral, sTextColor, Shape8.Brush.Color); IniFile.WriteInteger(sNetworkMonitor, sBackColor, Shape2.Brush.Color); IniFile.WriteInteger(sNetworkMonitor, sBackOpacity, $FF - TrackBar2.Position); IniFile.WriteInteger(sNetworkMonitor, sLineStyle, ComboBox2.ItemIndex); IniFile.WriteInteger(sNetworkMonitor, sDownLineColor, Shape4.Brush.Color); IniFile.WriteInteger(sNetworkMonitor, sUpLineColor, Shape5.Brush.Color); IniFile.WriteInteger(sNetworkMonitor, sTextColor, Shape9.Brush.Color); IniFile.WriteInteger(sDetails, sBackColor, Shape3.Brush.Color); IniFile.WriteInteger(sDetails, sBackOpacity, $FF - TrackBar3.Position); IniFile.WriteInteger(sDetails, sTextColorNormal, Shape6.Brush.Color); IniFile.WriteInteger(sDetails, sTextColorExcess, Shape7.Brush.Color); IniFile.WriteInteger(sDetails, sTextColorHeader, Shape10.Brush.Color); end; procedure TOptionsForm.Shape2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape2.Brush.Color; if ColorDialog1.Execute then begin Shape2.Brush.Color := ColorDialog1.Color; EyMainForm.TrafficForm.BackColor := Shape2.Brush.Color; EyMainForm.TrafficForm.UpdateLayered; end; end; procedure TOptionsForm.TrackBar2Change(Sender: TObject); var Percent: Integer; begin Percent := Round(TrackBar2.Position / $FF * 100); Label9.Caption := Format('%%%d', [Percent]); EyMainForm.TrafficForm.BackOpacity := $FF - TrackBar2.Position; EyMainForm.TrafficForm.UpdateLayered; end; procedure TOptionsForm.LabeledEdit1Change(Sender: TObject); begin UserChanged := True; end; procedure TOptionsForm.LabeledEdit2Change(Sender: TObject); begin UserChanged := True; end; procedure TOptionsForm.TrackBar3Change(Sender: TObject); var Percent: Integer; begin Percent := Round(TrackBar3.Position / $FF * 100); Label16.Caption := Format('%%%d', [Percent]); EyMainForm.DetailsForm.BackOpacity := $FF - TrackBar3.Position; EyMainForm.DetailsForm.UpdateLayered; end; procedure TOptionsForm.Shape3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape3.Brush.Color; if ColorDialog1.Execute then begin Shape3.Brush.Color := ColorDialog1.Color; EyMainForm.DetailsForm.BackColor := Shape3.Brush.Color; EyMainForm.DetailsForm.UpdateLayered; end; end; procedure TOptionsForm.ComboBox1Change(Sender: TObject); begin AdapterChanged := True; end; procedure TOptionsForm.Shape4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape4.Brush.Color; if ColorDialog1.Execute then begin Shape4.Brush.Color := ColorDialog1.Color; EyMainForm.TrafficForm.InLineColor := Shape4.Brush.Color; EyMainForm.TrafficForm.ChangeDrawingItems; EyMainForm.TrafficForm.UpdateLayered; end; end; procedure TOptionsForm.Shape5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape5.Brush.Color; if ColorDialog1.Execute then begin Shape5.Brush.Color := ColorDialog1.Color; EyMainForm.TrafficForm.OutLineColor := Shape5.Brush.Color; EyMainForm.TrafficForm.ChangeDrawingItems; EyMainForm.TrafficForm.UpdateLayered; end; end; procedure TOptionsForm.LabeledEdit5Change(Sender: TObject); begin LabeledEdit5.Text := IntToSizeTextFormat(UpDown1.Position); end; procedure TOptionsForm.LabeledEdit6Change(Sender: TObject); begin LabeledEdit6.Text := IntToSizeTextFormat(UpDown4.Position); end; procedure TOptionsForm.LabeledEdit7Change(Sender: TObject); begin LabeledEdit7.Text := IntToSizeTextFormat(UpDown5.Position); end; procedure TOptionsForm.LabeledEdit8Change(Sender: TObject); begin LabeledEdit8.Text := IntToSizeTextFormat(UpDown8.Position); end; procedure TOptionsForm.CheckBox10Click(Sender: TObject); begin LabeledEdit5.Enabled := not CheckBox10.Checked; UpDown1.Enabled := not CheckBox10.Checked; LabeledEdit6.Enabled := not CheckBox10.Checked; UpDown4.Enabled := not CheckBox10.Checked; LabeledEdit7.Enabled := not CheckBox10.Checked; UpDown5.Enabled := not CheckBox10.Checked; LabeledEdit8.Enabled := not CheckBox10.Checked; UpDown8.Enabled := not CheckBox10.Checked; end; procedure TOptionsForm.CheckBox5Click(Sender: TObject); begin Edit5.Enabled := CheckBox5.Checked; UpDown7.Enabled := CheckBox5.Checked; Label8.Enabled := CheckBox5.Checked; end; procedure TOptionsForm.UpdatePriceScreen; begin LabeledEdit3.Text := FormatFloat('#,0 GB', PriceRecord.Quota); LabeledEdit4.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MonthlyPay); LabeledEdit9.Text := FormatFloat('#,###0.000 YTL', PriceRecord.PayPerMB); LabeledEdit10.Text := FormatFloat('#,0 Kbps', PriceRecord.DownSpeed); LabeledEdit11.Text := FormatFloat('#,0 Kbps', PriceRecord.UpSpeed); LabeledEdit12.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MaxPayRef); LabeledEdit13.Text := FormatFloat('% #,0', PriceRecord.PayPercent); { JvValidateEdit1.Value := PriceRecord.Quota; JvValidateEdit2.Value := PriceRecord.MonthlyPay; JvValidateEdit3.Value := PriceRecord.PayPerMB; JvValidateEdit4.Value := PriceRecord.DownSpeed; JvValidateEdit5.Value := PriceRecord.UpSpeed; } end; procedure TOptionsForm.UpdatePriceList; var Index, Count: Integer; PriceRecord: TPriceRecord; begin ComboBox4.Clear; Count := GetPriceListCount(); for Index := 0 to Count - 1 do begin GetPriceListData(Index, PriceRecord); ComboBox4.Items.Add(PriceRecord.Description); end; Index := IniFile.ReadInteger(sGeneral, sPriceIndex, 0); if (Index < 0) or (Index > Count) then Index := 0; ComboBox4.ItemIndex := Index; end; procedure TOptionsForm.ComboBox4Change(Sender: TObject); begin if ComboBox4.ItemIndex <> -1 then begin GetPriceListData(ComboBox4.ItemIndex, PriceRecord); UpdatePriceScreen; end; end; procedure TOptionsForm.LabeledEdit3KeyPress(Sender: TObject; var Key: Char); begin if not (Key in [#8, '0'..'9', DecimalSeparator]) then Key := #0; end; procedure TOptionsForm.LabeledEdit3Enter(Sender: TObject); begin LabeledEdit3.Text := FormatFloat('#,0', PriceRecord.Quota); end; procedure TOptionsForm.LabeledEdit3Exit(Sender: TObject); begin PriceRecord.Quota := SuffixToFloat(LabeledEdit3.Text, ' GB', 4.00); LabeledEdit3.Text := FormatFloat('#,0 GB', PriceRecord.Quota); end; procedure TOptionsForm.LabeledEdit4Enter(Sender: TObject); begin LabeledEdit4.Text := FormatFloat('#,##0.00', PriceRecord.MonthlyPay); end; procedure TOptionsForm.LabeledEdit4Exit(Sender: TObject); begin PriceRecord.MonthlyPay := SuffixToFloat(LabeledEdit4.Text, ' YTL', 29.00); LabeledEdit4.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MonthlyPay); end; procedure TOptionsForm.LabeledEdit9Enter(Sender: TObject); begin LabeledEdit9.Text := FormatFloat('#,###0.000', PriceRecord.PayPerMB); end; procedure TOptionsForm.LabeledEdit9Exit(Sender: TObject); begin PriceRecord.PayPerMB := SuffixToFloat(LabeledEdit9.Text, ' YTL', 0.010); LabeledEdit9.Text := FormatFloat('#,###0.000 YTL', PriceRecord.PayPerMB); end; procedure TOptionsForm.LabeledEdit10Enter(Sender: TObject); begin LabeledEdit10.Text := FormatFloat('#,0', PriceRecord.DownSpeed); end; procedure TOptionsForm.LabeledEdit10Exit(Sender: TObject); begin PriceRecord.DownSpeed := SuffixToFloat(LabeledEdit10.Text, ' Kbps', 1024); LabeledEdit10.Text := FormatFloat('#,0 Kbps', PriceRecord.DownSpeed); end; procedure TOptionsForm.LabeledEdit11Enter(Sender: TObject); begin LabeledEdit11.Text := FormatFloat('#,0', PriceRecord.UpSpeed); end; procedure TOptionsForm.LabeledEdit11Exit(Sender: TObject); begin PriceRecord.UpSpeed := SuffixToFloat(LabeledEdit11.Text, ' Kbps', 256); LabeledEdit11.Text := FormatFloat('#,0 Kbps', PriceRecord.UpSpeed); end; procedure TOptionsForm.Shape8MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape8.Brush.Color; if ColorDialog1.Execute then begin Shape8.Brush.Color := ColorDialog1.Color; EyMainForm.TextColor := Shape8.Brush.Color; EyMainForm.UpdateLayered; end; end; procedure TOptionsForm.Shape6MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape6.Brush.Color; if ColorDialog1.Execute then begin Shape6.Brush.Color := ColorDialog1.Color; EyMainForm.DetailsForm.TextColorNormal := Shape6.Brush.Color; EyMainForm.DetailsForm.UpdateLayered; end; end; procedure TOptionsForm.Shape7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape7.Brush.Color; if ColorDialog1.Execute then begin Shape7.Brush.Color := ColorDialog1.Color; EyMainForm.DetailsForm.TextColorExcess := Shape7.Brush.Color; EyMainForm.DetailsForm.UpdateLayered; end; end; procedure TOptionsForm.Shape9MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape9.Brush.Color; if ColorDialog1.Execute then begin Shape9.Brush.Color := ColorDialog1.Color; EyMainForm.TrafficForm.TextColor := Shape9.Brush.Color; EyMainForm.TrafficForm.ChangeDrawingItems; EyMainForm.TrafficForm.UpdateLayered; end; end; procedure TOptionsForm.Shape10MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorDialog1.Color := Shape10.Brush.Color; if ColorDialog1.Execute then begin Shape10.Brush.Color := ColorDialog1.Color; EyMainForm.DetailsForm.TextColorHeader := Shape10.Brush.Color; EyMainForm.DetailsForm.UpdateLayered; end; end; procedure TOptionsForm.CheckBox3Click(Sender: TObject); begin EyMainForm.ShowTaskbarButton(CheckBox3.Checked); end; procedure TOptionsForm.LabeledEdit12Enter(Sender: TObject); begin LabeledEdit12.Text := FormatFloat('#,##0.00', PriceRecord.MaxPayRef); end; procedure TOptionsForm.LabeledEdit12Exit(Sender: TObject); begin PriceRecord.MaxPayRef := SuffixToFloat(LabeledEdit12.Text, ' YTL', 99.00); LabeledEdit12.Text := FormatFloat('#,##0.00 YTL', PriceRecord.MaxPayRef); end; procedure TOptionsForm.LabeledEdit13Enter(Sender: TObject); begin LabeledEdit13.Text := FormatFloat('#,0', PriceRecord.PayPercent); end; procedure TOptionsForm.LabeledEdit13Exit(Sender: TObject); begin PriceRecord.PayPercent := PrefixToFloat(LabeledEdit13.Text, '% ', 25.00); LabeledEdit13.Text := FormatFloat('% #,0', PriceRecord.PayPercent); end; initialization //SetPasswordText; end.