129 lines
4.7 KiB
C#
129 lines
4.7 KiB
C#
using Sarand.Net.Mobile.Maui.Controls;
|
|
using Sarand.Net.Mobile.Maui.Layouts;
|
|
using Sarand.Net.Mobile.Maui.Utils;
|
|
using Sarand.Net.Mobile.Maui.Views;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Helpers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sarand.Net.Mobile.Maui.Panels
|
|
{
|
|
//=======================================================================
|
|
/// <summary>
|
|
/// Panel to display with item list where no filter required, eg. items associated with parent.
|
|
/// <para>- Message shown to left</para>
|
|
/// <para>- Buttons shown to right</para>
|
|
/// </summary>
|
|
public class SamPanel_ItemListSummary : SamContentView
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private SacsMessage? message;
|
|
private bool showAddButton = false;
|
|
private double actionButtonSpacing = 4.0;
|
|
// Panel layout.
|
|
private SamStackLayout panelLayout = new SamStackLayout() { Orientation = StackOrientation.Horizontal };
|
|
private SamContentView panelMessage = new SamContentView();
|
|
private SamLabel labelMessage = new SamLabel() { HorizontalOptions = LayoutOptions.Start };
|
|
// Action buttons.
|
|
private SamStackLayout panelActions = new SamStackLayout() { Orientation = StackOrientation.Horizontal };
|
|
private SamImageButton buttonAddItem = new SamImageButton() { IsVisible = false, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start };
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SamPanel_ItemListSummary()
|
|
{
|
|
// Panel layout.
|
|
panelLayout.HorizontalOptions = LayoutOptions.Fill;
|
|
Content = panelLayout;
|
|
|
|
// Message.
|
|
panelMessage.HorizontalOptions = LayoutOptions.Fill;
|
|
panelMessage.VerticalOptions = LayoutOptions.Fill;
|
|
//panelMessage.BackgroundColor = Color.LightGoldenrodYellow;
|
|
panelLayout.Children.Add(panelMessage);
|
|
labelMessage.HorizontalOptions = LayoutOptions.Center;
|
|
labelMessage.VerticalOptions = LayoutOptions.Center;
|
|
panelMessage.Content = labelMessage;
|
|
|
|
// Action buttons.
|
|
panelActions.HorizontalOptions = LayoutOptions.EndAndExpand;
|
|
panelLayout.Children.Add(panelActions);
|
|
|
|
// 'Add' button.
|
|
buttonAddItem.IsVisible = showAddButton;
|
|
buttonAddItem.Padding = new Thickness(0, 0, actionButtonSpacing, 0);
|
|
buttonAddItem.BackgroundColor = Colors.Transparent;
|
|
buttonAddItem.Source = SamImageUtil.GetImageFromByteArray(SacsResourceHelper.GetResourceImage(SacsResourceHelper.ImageResource.IconShock_Add_Green_72_png));
|
|
buttonAddItem.Clicked += ButtonAddItem_Clicked;
|
|
panelActions.Children.Add(buttonAddItem);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
// Message.
|
|
public double MessageFontSizeDefault { get { return labelMessage.FontSizeDefault; } }
|
|
public double MessageFontSize
|
|
{
|
|
get { return labelMessage.FontSize; }
|
|
set { labelMessage.FontSize = value; }
|
|
}
|
|
// Action buttons.
|
|
public double ActionButtonSpacing
|
|
{
|
|
get { return actionButtonSpacing; }
|
|
set
|
|
{
|
|
if (actionButtonSpacing == value) return;
|
|
buttonAddItem.Padding = new Thickness(0, 0, actionButtonSpacing, 0);
|
|
}
|
|
}
|
|
public bool ShowAddButton
|
|
{
|
|
get { return showAddButton; }
|
|
set { if (showAddButton == value) return; showAddButton = value; buttonAddItem.IsVisible = showAddButton; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// M e s s a g e
|
|
//-------------------------------------------------------------------
|
|
public void ClearMessage()
|
|
{
|
|
message = null;
|
|
labelMessage.Text = "";
|
|
}
|
|
public void SetMessage(String message, SaMessageLevel messageLevel = SaMessageLevel.Info)
|
|
{
|
|
SetMessage(new SacsMessage(message, messageLevel));
|
|
}
|
|
public void SetMessage(SacsMessage message)
|
|
{
|
|
this.message = message;
|
|
labelMessage.Text = (message != null ? message.Message : "");
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// A c t i o n B u t t o n s
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a n e l E v e n t s
|
|
//-------------------------------------------------------------------
|
|
public event EventHandler<EventArgs>? AddClicked;
|
|
protected virtual void ButtonAddItem_Clicked(object? sender, EventArgs e)
|
|
{
|
|
if (AddClicked != null) AddClicked.Invoke(sender, e);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|