Skip to content

Commit

Permalink
added demo to show reactive UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sglienke committed Jun 15, 2015
1 parent adade4c commit 96f2940
Show file tree
Hide file tree
Showing 5 changed files with 452 additions and 0 deletions.
15 changes: 15 additions & 0 deletions TournamentDemo.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
program TournamentDemo;

uses
Forms,
TournamentView in 'TournamentView.pas' {TournamentViewForm},
TournamentViewModel in 'TournamentViewModel.pas';

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TTournamentViewForm, TournamentViewForm);
Application.Run;
end.
109 changes: 109 additions & 0 deletions TournamentDemo.dproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{47EB8284-96E4-4E1C-9C4D-8F0BAD61081B}</ProjectGuid>
<ProjectVersion>12.3</ProjectVersion>
<MainSource>TournamentDemo.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform>Win32</Platform>
<AppType>Application</AppType>
<FrameworkType>VCL</FrameworkType>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_UNSUPPORTED_CONSTRUCT>error</DCC_UNSUPPORTED_CONSTRUCT>
<DCC_DcuOutput>.\$(Config)\$(Platform)</DCC_DcuOutput>
<DCC_ExeOutput>.\$(Config)\$(Platform)</DCC_ExeOutput>
<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
<DCC_ImageBase>00400000</DCC_ImageBase>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_DebugDCUs>true</DCC_DebugDCUs>
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
<DCC_Optimize>false</DCC_Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="TournamentDemo.dpr">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="TournamentView.pas">
<Form>TournamentViewForm</Form>
</DCCReference>
<DCCReference Include="TournamentViewModel.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Debug">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
<Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Delphi.Personality>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1031</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
</VersionInfoKeys>
<Source>
<Source Name="MainSource">TournamentDemo.dpr</Source>
</Source>
</Delphi.Personality>
<Platforms>
<Platform value="Win32">True</Platform>
</Platforms>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>
138 changes: 138 additions & 0 deletions TournamentView.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
object TournamentViewForm: TTournamentViewForm
Left = 0
Top = 0
Caption = 'TournamentViewForm'
ClientHeight = 289
ClientWidth = 554
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 16
Top = 32
Width = 31
Height = 13
Caption = 'Label1'
end
object Label2: TLabel
Left = 16
Top = 75
Width = 31
Height = 13
Caption = 'Label1'
end
object Label3: TLabel
Left = 16
Top = 144
Width = 31
Height = 13
Caption = 'Label1'
end
object Label4: TLabel
Left = 16
Top = 187
Width = 31
Height = 13
Caption = 'Label1'
end
object Label5: TLabel
Left = 240
Top = 56
Width = 31
Height = 13
Caption = 'Label1'
end
object Label6: TLabel
Left = 240
Top = 168
Width = 31
Height = 13
Caption = 'Label1'
end
object Label7: TLabel
Left = 464
Top = 128
Width = 31
Height = 13
Caption = 'Label1'
end
object Edit1: TEdit
Left = 16
Top = 48
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
end
object Edit2: TEdit
Left = 16
Top = 91
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit2'
end
object Edit3: TEdit
Left = 16
Top = 160
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit1'
end
object Edit4: TEdit
Left = 16
Top = 203
Width = 121
Height = 21
TabOrder = 3
Text = 'Edit2'
end
object Edit5: TEdit
Left = 240
Top = 72
Width = 121
Height = 21
TabOrder = 4
Text = 'Edit1'
end
object Edit6: TEdit
Left = 240
Top = 184
Width = 121
Height = 21
TabOrder = 5
Text = 'Edit2'
end
object Button1: TButton
Left = 143
Top = 70
Width = 75
Height = 25
Caption = 'Save score'
TabOrder = 6
end
object Button2: TButton
Left = 143
Top = 172
Width = 75
Height = 25
Caption = 'Save score'
TabOrder = 7
end
object Button3: TButton
Left = 368
Top = 123
Width = 75
Height = 25
Caption = 'Save score'
TabOrder = 8
end
end
70 changes: 70 additions & 0 deletions TournamentView.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
unit TournamentView;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SimpleMVVM.Binding;

type
TTournamentViewForm = class(TForm)

[Bind('Value', 'SemiFinalOne.HomeScore')]
Edit1: TEdit;
[Bind('Value', 'SemiFinalOne.AwayScore')]
Edit2: TEdit;
[Bind('Value', 'SemiFinalTwo.HomeScore')]
Edit3: TEdit;
[Bind('Value', 'SemiFinalTwo.AwayScore')]
Edit4: TEdit;
[Bind('Enabled', 'Finale.CanPlay')]
[Bind('Value', 'Finale.HomeScore')]
Edit5: TEdit;
[Bind('Enabled', 'Finale.CanPlay')]
[Bind('Value', 'Finale.AwayScore')]
Edit6: TEdit;

[Bind('Text', 'SemiFinalOne.HomeTeam')]
Label1: TLabel;
[Bind('Text', 'SemiFinalOne.AwayTeam')]
Label2: TLabel;
[Bind('Text', 'SemiFinalTwo.HomeTeam')]
Label3: TLabel;
[Bind('Text', 'SemiFinalTwo.AwayTeam')]
Label4: TLabel;
[Bind('Text', 'Finale.HomeTeam')]
Label5: TLabel;
[Bind('Text', 'Finale.AwayTeam')]
Label6: TLabel;
[Bind('Text', 'Finale.Winner')]
Label7: TLabel;

[Bind('Click', 'SemiFinalOne_SaveScore')]
Button1: TButton;
[Bind('Click', 'SemiFinalTwo_SaveScore')]
Button2: TButton;
[Bind('Click', 'Finale_SaveScore')]
Button3: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
TournamentViewForm: TTournamentViewForm;

implementation

{$R *.dfm}

uses
TournamentViewModel;

procedure TTournamentViewForm.FormCreate(Sender: TObject);
begin
ApplyBindings(Self, TTournamentViewModel.Create);
end;

end.
Loading

0 comments on commit 96f2940

Please sign in to comment.