unit View.Form.MainView;
interface
uses
de.itnets.Events,
de.itnets.References,
MVVM.ViewModel.ViewModelBase,
ViewModel.MainViewModel,
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
View.Form.WorkspaceView, MVVM.View.FMX.Frame.Base,
FMX.Objects, System.Actions, FMX.ActnList, FMX.Layouts,
View.Frame.AcitivityView,
View.Frame.ProgressAcitivityView;
type
TMainView =
class( TWorkspaceView )
ActivityCurtain: TRectangle;
ActivityView1: TActivityView;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
ActionList1: TActionList;
SomeActionAction: TAction;
CloseAction: TAction;
SpeedButton2: TSpeedButton;
SomeProgressActionAction: TAction;
SpeedButton3: TSpeedButton;
ProgressActivityView1: TProgressActivityView;
SomeRandomActionAction: TAction;
SpeedButton4: TSpeedButton;
procedure SomeActionActionExecute( Sender: TObject );
procedure SomeActionActionUpdate( Sender: TObject );
procedure CloseActionExecute( Sender: TObject );
procedure CloseActionUpdate( Sender: TObject );
procedure SomeProgressActionActionExecute( Sender: TObject );
procedure SomeProgressActionActionUpdate( Sender: TObject );
procedure SomeRandomActionActionExecute( Sender: TObject );
procedure SomeRandomActionActionUpdate( Sender: TObject );
private
FMain: WeakRef<TMainViewModel>;
protected
procedure AttachToViewModel( AViewModel: TViewModelBase );
override;
procedure DetachFromViewModel( AViewModel: TViewModelBase );
override;
procedure ViewModelPropertyChanged( Sender: TObject;
const e: TPropertyChangedArgs );
override;
public
end;
var
MainView: TMainView;
implementation
{$R *.fmx}
uses
System.StrUtils,
ViewModel.ActivityViewModel;
{ TMainView }
procedure TMainView.SomeProgressActionActionExecute( Sender: TObject );
begin
inherited;
FMain.Reference.SomeProgressActionCommand.Execute;
end;
procedure TMainView.SomeProgressActionActionUpdate( Sender: TObject );
begin
inherited;
TAction( Sender ).Enabled := FMain.IsAssigned
and FMain.Reference.SomeProgressActionCommand.CanExecute;
end;
procedure TMainView.SomeRandomActionActionExecute( Sender: TObject );
begin
inherited;
FMain.Reference.SomeRandomActionCommand.Execute;
end;
procedure TMainView.SomeRandomActionActionUpdate( Sender: TObject );
begin
inherited;
TAction( Sender ).Enabled := FMain.IsAssigned
and FMain.Reference.SomeRandomActionCommand.CanExecute;
end;
procedure TMainView.ViewModelPropertyChanged( Sender: TObject;
const e: TPropertyChangedArgs );
begin
inherited;
if FMain.IsAssigned
then
begin
if e.Matches( ['
Active', '
DisplayName'] )
then
begin
Caption := FMain.Reference.DisplayName + '
(' + IfThen( FMain.Reference.Active, '
Active', '
Inactive' ) + '
)';
end;
if e.Match( '
Activity' )
then
begin
ActivityCurtain.BringToFront;
ActivityCurtain.Visible := Assigned( FMain.Reference.Activity );
if FMain.Reference.Activity
is TProgressActivityViewModel
then
begin
ActivityView1.Visible := False;
ActivityView1.SetViewModel(
nil );
ProgressActivityView1.Visible := True;
ProgressActivityView1.BringToFront;
ProgressActivityView1.SetViewModel( FMain.Reference.Activity );
end
else if FMain.Reference.Activity
is TActivityViewModel
then
begin
ProgressActivityView1.Visible := False;
ProgressActivityView1.SetViewModel(
nil );
ActivityView1.Visible := Assigned( FMain.Reference.Activity );
ActivityView1.BringToFront;
ActivityView1.SetViewModel( FMain.Reference.Activity );
end
else
begin
ActivityView1.Visible := False;
ActivityView1.SetViewModel(
nil );
ProgressActivityView1.Visible := False;
ProgressActivityView1.SetViewModel(
nil );
end;
end;
end
end;
end.