Skip to content

Commit

Permalink
Urls are updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Majid committed Dec 15, 2017
1 parent 9fc1e9e commit 294be51
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 48 deletions.
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

# Created by https://www.gitignore.io/api/delphi

### Delphi ###
# Uncomment these types if you want even more clean repository. But be careful.
# It can make harm to an existing project source. Read explanations below.
#
# Resource files are binaries containing manifest, project icon and version info.
# They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files.
#*.res
#
# Type library file (binary). In old Delphi versions it should be stored.
# Since Delphi 2009 it is produced from .ridl file and can safely be ignored.
#*.tlb
#
# Diagram Portfolio file. Used by the diagram editor up to Delphi 7.
# Uncomment this if you are not using diagrams or use newer Delphi version.
#*.ddp
#
# Visual LiveBindings file. Added in Delphi XE2.
# Uncomment this if you are not using LiveBindings Designer.
#*.vlb
#
# Deployment Manager configuration file for your project. Added in Delphi XE2.
# Uncomment this if it is not mobile development and you do not use remote debug feature.
#*.deployproj
#
# C++ object files produced when C/C++ Output file generation is configured.
# Uncomment this if you are not using external objects (zlib library for example).
#*.obj
#

# Delphi compiler-generated binaries (safe to delete)
*.exe
*.dll
*.bpl
*.bpi
*.dcp
*.so
*.apk
*.drc
*.map
*.dres
*.rsm
*.tds
*.dcu
*.lib
*.a
*.o
*.ocx

# Delphi autogenerated files (duplicated info)
*.cfg
*.hpp
*Resource.rc

# Delphi local files (user-specific info)
*.local
*.identcache
*.projdata
*.tvsconfig
*.dsk

# Delphi history and backups
__history/
__recovery/
*.~*

# Castalia statistics file (since XE7 Castalia is distributed with Delphi)
*.stat

# End of https://www.gitignore.io/api/delphi
19 changes: 13 additions & 6 deletions PersianTT.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,43 @@ program PersianTT;

{$R *.dres}


uses
Vcl.Forms,
System.SysUtils,
UfrmMain in 'Units\UfrmMain.pas' {frmMain},
UfrmMain in 'Units\UfrmMain.pas' {frmMain} ,
UTextDrawer in 'Units\UTextDrawer.pas',
UKeyboard in 'Units\UKeyboard.pas' {Keyboard: TFrame},
UKeyboard in 'Units\UKeyboard.pas' {Keyboard: TFrame} ,
UKeyboardKey in 'Units\UKeyboardKey.pas',
UGlobalUnit in 'Units\UGlobalUnit.pas',
UFingerCaption in 'Units\UFingerCaption.pas',
UHand in 'Units\UHand.pas' {Hand: TFrame},
UHand in 'Units\UHand.pas' {Hand: TFrame} ,
UObserver in 'Units\UObserver.pas',
UTutor in 'Units\UTutor.pas' {Tutor: TFrame},
UTutor in 'Units\UTutor.pas' {Tutor: TFrame} ,
UTutorController in 'Units\UTutorController.pas',
UfrmSplash in 'Units\UfrmSplash.pas' {frmSplash},
UfrmSplash in 'Units\UfrmSplash.pas' {frmSplash} ,
UfrmAbout in 'Units\UfrmAbout.pas' {frmAbout};

{$R *.res}

var
Version: string;

begin
ReportMemoryLeaksOnShutdown := DebugHook <> 0;
Application.MainFormOnTaskbar := True;
frmSplash := TfrmSplash.Create(Application);
frmSplash.Show;
frmSplash.Update;
Sleep(2000);
GetLatestVersion;
if LatestVersion = '' then
Sleep(1500);
Application.Initialize;
Application.CreateForm(TfrmMain, frmMain);
Application.CreateForm(TfrmAbout, frmAbout);
frmSplash.Hide;
frmSplash.Free;
frmSplash := nil;
Application.Run;

end.
4 changes: 2 additions & 2 deletions PersianTT.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<VerInfo_MinorVer>7</VerInfo_MinorVer>
<VerInfo_MinorVer>8</VerInfo_MinorVer>
<Icon_MainIcon>PersianTT_Icon.ico</Icon_MainIcon>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Keys>CompanyName=http://persiantt.codeplex.com/;FileDescription=Persian and English type tutor. Developed by Majid Shamkhani;FileVersion=1.7.0.0;InternalName=;LegalCopyright=GNU General Public License version 2 (GPLv2);LegalTrademarks=;OriginalFilename=;ProductName=Persian Type Tutor;ProductVersion=1.7.0.0;Comments=</VerInfo_Keys>
<VerInfo_Keys>CompanyName=https://github.com/Majid110/PersianTypeTutor;FileDescription=Persian and English type tutor. Developed by Majid Shamkhani;FileVersion=1.8.0.0;InternalName=;LegalCopyright=GNU General Public License version 2 (GPLv2);LegalTrademarks=;OriginalFilename=;ProductName=Persian Type Tutor;ProductVersion=1.8.0.0;Comments=</VerInfo_Keys>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
Expand Down
Binary file modified PersianTT.res
Binary file not shown.
4 changes: 2 additions & 2 deletions Src/PersianTT.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Var run_app_text
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Persian Type Tutor"
!define SETUP_NAME "PersianTypeTutor"
!define PRODUCT_VERSION "1.7"
!define PRODUCT_VERSION "1.8"
!define PRODUCT_PUBLISHER "Majid Shamkhani"
!define PRODUCT_WEB_SITE "http://www.persiantt.codeplex.com"
!define PRODUCT_WEB_SITE "https://github.com/Majid110/PersianTypeTutor"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\PersianTT.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
Expand Down
66 changes: 59 additions & 7 deletions Units/UGlobalUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ interface

uses
System.SysUtils,
IdHTTP,
System.Classes,
System.RegularExpressions,
IdSSLOpenSSL,
Vcl.Forms;

type
//TTypeLanguage = (tlPersian, tlEnglish);
TTutorState = (tsNon, tsReady, tsStarted, tsFinished);
// TTypeLanguage = (tlPersian, tlEnglish);
TTutorState = (tsNon, tsReady, tsStarted, tsFinished);
TKeyboardLayout = (klEnglish, klMicrosoftPersian, klPersian);

const
NULL_CHAR = #13;
TUTOR_EXT = '.ttd';
NULL_CHAR_INDEX = -1;
APPLICATION_VERSION = '1.7';
VIRTUAL_SPACE = #$200C;
NULL_CHAR = #13;
TUTOR_EXT = '.ttd';
NULL_CHAR_INDEX = -1;
APPLICATION_VERSION = '1.8';
VIRTUAL_SPACE = #$200C;

var
LatestVersion : string;

function ApplicationPath: String;
procedure GetLatestVersion;

implementation

Expand All @@ -26,4 +35,47 @@ function ApplicationPath: String;
Result := ExtractFilePath(Application.ExeName);
end;

Function ExtractVersion(InputtedTerm: String): String;
var
RegularExpression: TRegEx;
Match : TMatch;
begin
try
Result := '';
Match := RegularExpression.Match(InputtedTerm, '("tag_name": ")(.*?)(")');
if Match.Groups.Count <> 4 then
begin
Exit;
end;
Result := Match.Groups[2].Value;
finally
end;
end;

procedure GetLatestVersion;
var
lHTTP : TIdHTTP;
LHandler : TIdSSLIOHandlerSocketOpenSSL;
Src : String;
LastVersion: String;
begin
try
lHTTP := TIdHTTP.Create(nil);
try
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
lHTTP.IOHandler := LHandler;
lHTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0';
Src := lHTTP.Get('https://api.github.com/repos/majid110/PersianTypeTutor/releases/latest');
LatestVersion := ExtractVersion(Src);
finally
LHandler.Free;
end;
finally
FreeAndNil(lHTTP);
end;
except
end;
end;

end.
20 changes: 10 additions & 10 deletions Units/UfrmAbout.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -692,31 +692,31 @@ object frmAbout: TfrmAbout
IsControl = True
end
object ProductName: TLabel
Left = 204
Top = 104
Left = 124
Top = 124
Width = 90
Height = 13
Caption = 'Persian Type Tutor'
IsControl = True
end
object Version: TLabel
Left = 204
Top = 128
Left = 124
Top = 143
Width = 53
Height = 13
Caption = 'Version 1.0'
IsControl = True
end
object WebSite: TLabel
Left = 204
Top = 152
Width = 140
Left = 124
Top = 163
Width = 225
Height = 13
Cursor = crHandPoint
Caption = 'http://persiantt.codeplex.com'
Caption = 'https://github.com/Majid110/PersianTypeTutor'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Height = -12
Font.Name = 'MS Sans Serif'
Font.Style = [fsUnderline]
ParentFont = False
Expand All @@ -733,7 +733,7 @@ object frmAbout: TfrmAbout
Default = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Height = -12
Font.Name = 'Tahoma'
Font.Style = []
ModalResult = 1
Expand Down
2 changes: 1 addition & 1 deletion Units/UfrmAbout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ procedure TfrmAbout.FormCreate(Sender: TObject);

procedure TfrmAbout.WebSiteClick(Sender: TObject);
begin
shellExecute(Application.Handle, 'open', 'http://persiantt.codeplex.com', nil, nil, SW_NORMAL);
ShellExecute(Application.Handle, 'open', 'https://github.com/Majid110/PersianTypeTutor', nil, nil, SW_NORMAL);
end;

end.
3 changes: 2 additions & 1 deletion Units/UfrmMain.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object frmMain: TfrmMain
Position = poScreenCenter
OnCreate = FormCreate
OnKeyDown = FormKeyDown
OnShow = FormShow
DesignSize = (
1024
748)
Expand Down Expand Up @@ -256,7 +257,7 @@ object frmMain: TfrmMain
Left = 788
Top = 271
Width = 231
Height = 472
Height = 471
AutoSize = True
BiDiMode = bdRightToLeft
ParentBiDiMode = False
Expand Down
12 changes: 12 additions & 0 deletions Units/UfrmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TfrmMain = class(TForm, IObserver)
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Tutor1imgOSKClick(Sender: TObject);
procedure Tutor1imgAboutClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
FTextDrawer : TTextDrawer;
Expand Down Expand Up @@ -95,6 +96,17 @@ procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftStat
FTutorController.CheckKey(Key, Shift);
end;

procedure TfrmMain.FormShow(Sender: TObject);
begin
if (LatestVersion <> '') and (LatestVersion <> APPLICATION_VERSION) then
begin
if MessageDlg('New version available. Do you want open download page?', mtConfirmation, mbYesNo, 0) = mrYes Then
begin
ShellExecute(Application.Handle, 'open', 'https://github.com/Majid110/PersianTypeTutor/releases', nil, nil, SW_NORMAL);
end;
end;
end;

procedure TfrmMain.Tutor1imgAboutClick(Sender: TObject);
begin
frmAbout := TfrmAbout.Create(Application);
Expand Down
20 changes: 2 additions & 18 deletions Units/UfrmSplash.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,9 @@ object frmSplash: TfrmSplash
Height = 300
OnClick = imgBackClick
end
object lblWebsite: TLabel
Left = 18
Top = 264
Width = 145
Height = 13
Cursor = crHandPoint
BiDiMode = bdLeftToRight
Caption = 'http://persiantt.codeplex.com'
Font.Charset = ARABIC_CHARSET
Font.Color = clSilver
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentBiDiMode = False
ParentFont = False
end
object lblVersion: TLabel
Left = 18
Top = 250
Left = 22
Top = 262
Width = 45
Height = 13
Alignment = taRightJustify
Expand Down
1 change: 0 additions & 1 deletion Units/UfrmSplash.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface
type
TfrmSplash = class(TForm)
imgBack: TImage;
lblWebsite: TLabel;
lblVersion: TLabel;
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
Expand Down

0 comments on commit 294be51

Please sign in to comment.