Berthing and Tasks

This commit is contained in:
Andy Howard
2019-08-07 09:11:16 +01:00
parent 79b37d1b5c
commit 3e25524057
65 changed files with 1800 additions and 2216 deletions
@@ -10,7 +10,7 @@ using Xamarin.Forms;
namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
{
//=======================================================================
public class SlmControlView : SlmContentView
public abstract class SlmControlView : SlmContentView
{
//-------------------------------------------------------------------
// Definitions.
@@ -48,6 +48,9 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
//-------------------------------------------------------------------
// Properties.
// Label.
public SlmLabel Label { get; } = new SlmLabel() { Text = "" };
public String LabelText { get { return Label.Text; } set { if (Label.Text.Equals(value)) return; Label.Text = value; } }
// Styling.
public Thickness BorderThickness
{
@@ -17,21 +17,20 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
//-------------------------------------------------------------------
// Data members.
private readonly SlmDatePicker datePicker = new SlmDatePicker();
//-------------------------------------------------------------------
// Construction.
public SlmDatePickerView (SlmDatePicker suppliedPicker = null)
{
// Control configuration.
if (suppliedPicker != null) datePicker = suppliedPicker;
datePicker.BackgroundColor = Color.Transparent;
if (suppliedPicker != null) DatePicker = suppliedPicker;
DatePicker.BackgroundColor = Color.Transparent;
// Control events.
datePicker.BackgroundColor = Color.Transparent;
datePicker.DateSelected += DatePicker_DateSelected;
datePicker.Focused += DatePicker_Focused;
datePicker.Unfocused += DatePicker_Unfocused;
DatePicker.BackgroundColor = Color.Transparent;
DatePicker.DateSelected += DatePicker_DateSelected;
DatePicker.Focused += DatePicker_Focused;
DatePicker.Unfocused += DatePicker_Unfocused;
ConfigureComponents();
SetControlActivity();
@@ -39,11 +38,11 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
//-------------------------------------------------------------------
// Properties.
protected SlmDatePicker DatePicker { get { return datePicker; } }
protected SlmDatePicker DatePicker { get; } = new SlmDatePicker();
public DateTime Date
{
get { return datePicker.Date; }
set { if (datePicker.Date == value) return; datePicker.Date = value; }
get { return DatePicker.Date; }
set { if (DatePicker.Date == value) return; DatePicker.Date = value; }
}
//-------------------------------------------------------------------
@@ -66,7 +65,7 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
protected override void SetControlsReadOnly ()
{
base.SetControlsReadOnly();
if (!ReadOnly) Content = datePicker;
if (!ReadOnly) Content = DatePicker;
}
//-------------------------------------------------------------------
@@ -107,7 +106,7 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
public event EventHandler<DateChangedEventArgs> DateSelected;
private void DatePicker_DateSelected (object sender, DateChangedEventArgs e)
{
ReadOnlyText = datePicker.Date != null ? DateUtil.Format(datePicker.Date, datePicker.Format) : "";
ReadOnlyText = DatePicker.FormattedDate;
if (ReadOnly) return;
if (DateSelected != null) DateSelected.Invoke(sender, e);
}
@@ -1,4 +1,5 @@
using Sarand.Core.Mobile.Forms.Controls;
using Sarand.LogisticsMgr.Core.WebService;
using Sarand.LogisticsMgr.Mobile.Core.App;
using Sarand.LogisticsMgr.Mobile.Core.Mgr;
using System;
@@ -29,8 +30,10 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
//-------------------------------------------------------------------
// Data members.
private readonly Config config;
private SlmAccountMgr_Mobile accountMgr = null;
private SlmAssetMgr_Mobile assetMgr = null;
private SlmAccountMgr_Mobile accountMgr;
private SlmBerthingMgr_Mobile berthingMgr;
private SlmAssetMgr_Mobile assetMgr;
private SlmWebServiceClient webServiceClient;
// Main grid.
private SlmGrid gridPage = new SlmGrid();
// Caption bar.
@@ -57,14 +60,34 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
//-------------------------------------------------------------------
// Properties.
protected virtual String MessageTitle { get { return Title; } }
protected virtual String DataPreparationMessage { get { return "Loading data. Please wait ..."; } }
// Session.
protected SlmUserContext_Mobile UserContext { get { return SlmGlobals_Mobile.SessionProfile.UserContext_Mobile; } }
protected SlmSessionContext_Mobile SessionContext { get { return SlmGlobals_Mobile.SessionProfile.SessionContext_Mobile; } }
// Layout.
protected SlmContentView FormBodyView { get { return contentViewBody; } }
// Process control.
public bool AddMode { get; protected set; } = true;
public bool Changed { get; protected set; } = false;
public bool Cancelled { get; private set; } = true;
// Managers.
protected SlmAccountMgr_Mobile AccountMgr { get { if (accountMgr == null) accountMgr = new SlmAccountMgr_Mobile(SessionContext); return accountMgr; } }
protected SlmBerthingMgr_Mobile BerthingMgr { get { if (berthingMgr == null) berthingMgr = new SlmBerthingMgr_Mobile(SessionContext); return berthingMgr; } }
protected SlmAssetMgr_Mobile AssetMgr { get { if (assetMgr == null) assetMgr = new SlmAssetMgr_Mobile(SessionContext); return assetMgr; } }
public SlmWebServiceClient WebServiceClient { get { if (webServiceClient == null) webServiceClient = new SlmWebServiceClient(); return webServiceClient; } }
//-------------------------------------------------------------------
// C l o s e F o r m
//-------------------------------------------------------------------
protected void CloseFormWithAlert (String message)
{
Device.BeginInvokeOnMainThread(async () =>
{
await DisplayAlert(MessageTitle, message, "OK");
await Navigation.PopModalAsync();
});
}
//-------------------------------------------------------------------
// I n i t i a l i s e
@@ -120,6 +143,20 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Base
buttonClose.Clicked += ButtonClose_Clicked;
}
//-------------------------------------------------------------------
/// <summary>
/// Add label and control to form grid.
/// <para>NB Control takes up 2 rows by default to allow for control pairs (control + button etc).</para>
/// </summary>
protected static void AddControlViewToGrid (SlmGrid grid, SlmControlView controlView)
{
int rowIdx = grid.RowDefinitions.Count;
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
grid.Children.Add(controlView.Label, 0, rowIdx);
grid.Children.Add(controlView, 1, rowIdx);
Grid.SetColumnSpan(controlView, 2);
}
//-------------------------------------------------------------------
// C o n f i g u r e F o r m
//-------------------------------------------------------------------
@@ -1,7 +1,9 @@
using Sarand.Core.App;
using Sarand.Core.Mobile.Utils;
using Sarand.LogisticsMgr.Core.WebService;
using Sarand.LogisticsMgr.Mobile.Core.App;
using Sarand.LogisticsMgr.Mobile.Core.Forms.Base;
using Sarand.LogisticsMgr.Mobile.Core.Mgr;
using System;
using System.Collections.Generic;
using System.Text;
@@ -21,6 +23,11 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Panels
//-------------------------------------------------------------------
// Data members.
private Config config;
private SlmAccountMgr_Mobile accountMgr;
private SlmBerthingMgr_Mobile berthingMgr;
private SlmAssetMgr_Mobile assetMgr;
private SlmWebServiceClient webServiceClient;
// Layout.
private SlmFrame viewPanel = new SlmFrame();
private SlmStackLayout stackLayout = new SlmStackLayout() { Orientation = StackOrientation.Vertical };
private SlmGrid gridCaption = new SlmGrid();
@@ -111,8 +118,18 @@ namespace Sarand.LogisticsMgr.Mobile.Core.Forms.Panels
get { return labelCaption.Text; }
set { if (labelCaption.Text.Equals(value)) return; labelCaption.Text = value; }
}
// Session.
protected SlmUserContext_Mobile UserContext { get { return SlmGlobals_Mobile.SessionProfile.UserContext_Mobile; } }
protected SlmSessionContext_Mobile SessionContext { get { return SlmGlobals_Mobile.SessionProfile.SessionContext_Mobile; } }
// Layout.
protected SlmPanel SummaryPanel { get { return panelSummary; } }
protected SlmPanel DetailsPanel { get { return panelDetails; } }
protected String ErrorStateMessage { get; set; }
// Managers.
protected SlmAccountMgr_Mobile AccountMgr { get { if (accountMgr == null) accountMgr = new SlmAccountMgr_Mobile(SessionContext); return accountMgr; } }
protected SlmBerthingMgr_Mobile BerthingMgr { get { if (berthingMgr == null) berthingMgr = new SlmBerthingMgr_Mobile(SessionContext); return berthingMgr; } }
protected SlmAssetMgr_Mobile AssetMgr { get { if (assetMgr == null) assetMgr = new SlmAssetMgr_Mobile(SessionContext); return assetMgr; } }
public SlmWebServiceClient WebServiceClient { get { if (webServiceClient == null) webServiceClient = new SlmWebServiceClient(); return webServiceClient; } }
//-------------------------------------------------------------------
// I t e m s T o g g l e