Saxonite 1.2.11.3. Sandtrap.
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
using Microsoft.Maui.Controls;
|
||||
using Sarand.Net.Mobile.Maui.Views;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.Net.Mobile.Maui.Pages
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SamContentPage : ContentPage
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SamContentPage()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public abstract String MessageTitleDefault { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n f i g u r e C o m p o n e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected virtual void ConfigureComponents()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void ConfigureChildComponents()
|
||||
{
|
||||
// Configure child components.
|
||||
if (Content != null)
|
||||
{
|
||||
ConfigureChildComponent(Content);
|
||||
foreach (var descendent in Content.GetVisualTreeDescendants())
|
||||
{
|
||||
View? childView = descendent as View;
|
||||
if (childView != null)
|
||||
ConfigureChildComponent(childView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureChildComponent(View view)
|
||||
{
|
||||
if (view is ISamView)
|
||||
{
|
||||
ISamView? samView = view as ISamView;
|
||||
if (samView != null)
|
||||
samView.ConfigureComponents();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l A c t i v i t y
|
||||
//-------------------------------------------------------------------
|
||||
protected virtual void SetControlActivity()
|
||||
{
|
||||
SetControlsReadOnly();
|
||||
|
||||
// Child component control activity.
|
||||
if (Content != null)
|
||||
{
|
||||
SetChildControlActivity(Content);
|
||||
foreach (var descendent in Content.GetVisualTreeDescendants())
|
||||
{
|
||||
View? childView = descendent as View;
|
||||
if (childView != null)
|
||||
SetChildControlActivity(childView);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SetChildControlActivity(View view)
|
||||
{
|
||||
if (view is ISamView)
|
||||
{
|
||||
ISamView? samView = view as ISamView;
|
||||
if (samView != null)
|
||||
samView.SetControlActivity();
|
||||
}
|
||||
}
|
||||
protected virtual void SetControlsReadOnly()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u p M e s s a g e s
|
||||
//-------------------------------------------------------------------
|
||||
public enum AlertMode
|
||||
{
|
||||
OK,
|
||||
Close,
|
||||
}
|
||||
public Task DisplayAlert(String message, AlertMode alertMode = AlertMode.OK)
|
||||
{
|
||||
String title = StringUtil.OnEmpty(Title, MessageTitleDefault);
|
||||
String cancel = "OK";
|
||||
if (alertMode == AlertMode.Close)
|
||||
cancel = "Close";
|
||||
return DisplayAlert(title, message, cancel);
|
||||
}
|
||||
public enum ConfirmMode
|
||||
{
|
||||
YesNo,
|
||||
OkCancel
|
||||
}
|
||||
public async Task<bool> DisplayConfirm(String message, ConfirmMode confirmMode = ConfirmMode.OkCancel)
|
||||
{
|
||||
String title = StringUtil.OnEmpty(Title, MessageTitleDefault);
|
||||
String accept = "Yes";
|
||||
String cancel = "No";
|
||||
if (confirmMode == ConfirmMode.OkCancel)
|
||||
{
|
||||
accept = "OK";
|
||||
cancel = "Cancel";
|
||||
}
|
||||
return await DisplayAlert(title, message, accept, cancel);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a g e E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnParentSet()
|
||||
{
|
||||
base.OnParentSet();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
base.OnPropertyChanged(propertyName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
ConfigureComponents();
|
||||
ConfigureChildComponents();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Layout changes.
|
||||
private bool inOnSizeAllocated = false;
|
||||
protected override void OnSizeAllocated(double width, double height)
|
||||
{
|
||||
bool alreadyInOnSizeAllocated = inOnSizeAllocated;
|
||||
inOnSizeAllocated = true;
|
||||
base.OnSizeAllocated(width, height);
|
||||
// Only configure components if this is the first entry to this event
|
||||
// // to avoid iterative layout changes caused by components being configured.
|
||||
if (!alreadyInOnSizeAllocated)
|
||||
{
|
||||
if (Width > 0 && Height > 0)
|
||||
{
|
||||
ConfigureComponents();
|
||||
ConfigureChildComponents();
|
||||
}
|
||||
inOnSizeAllocated = false;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user