141 lines
4.7 KiB
C#
141 lines
4.7 KiB
C#
using Sarand.Net.Standard.Mobile.Forms.Controls;
|
|
using Sarand.Net.Standard.Mobile.Forms.Templates;
|
|
using Sarand.Net.Standard.Mobile.Forms.Views;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Sarand.Net.Standard.Mobile.Forms.Panels
|
|
{
|
|
//=======================================================================
|
|
public class SaxPanel_PropertySummary : SaxContentView
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
private class PropertyData
|
|
{
|
|
public String Caption { get; set; }
|
|
public String Value { get; set; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private float internalFrameRadiusFactor = 0.8f;
|
|
private readonly List<PropertyData> properties = new List<PropertyData>();
|
|
// Panel components.
|
|
private SaxFrame framePanel = new SaxFrame();
|
|
private SaxFrame frameInternal = new SaxFrame();
|
|
private SaxGrid gridProperties = new SaxGrid();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SaxPanel_PropertySummary ()
|
|
{
|
|
// View properties.
|
|
//BackgroundColor = Color.Transparent;
|
|
framePanel.CornerRadius = 8.0f;
|
|
framePanel.Padding = new Thickness(2.0);
|
|
framePanel.BackgroundColor = Color.Transparent;
|
|
framePanel.BorderColor = framePanel.BorderColor;
|
|
Content = framePanel;
|
|
|
|
// Frame.
|
|
frameInternal.CornerRadius = framePanel.CornerRadius * internalFrameRadiusFactor;
|
|
frameInternal.Padding = new Thickness(0);
|
|
frameInternal.BorderColor = Color.White;
|
|
frameInternal.BackgroundColor = Color.White;
|
|
framePanel.Content = frameInternal;
|
|
frameInternal.Content = gridProperties;
|
|
|
|
// Properties grid.
|
|
gridProperties.Padding = new Thickness(4.0);
|
|
gridProperties.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
|
|
gridProperties.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
|
|
|
|
// Property styling.
|
|
DefaultFontSize = new SaxLabel().FontSize;
|
|
FontSize = DefaultFontSize;
|
|
|
|
ConfigureComponents();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public Color BorderColor
|
|
{
|
|
get { return framePanel.BorderColor; }
|
|
set
|
|
{
|
|
framePanel.BorderColor = value;
|
|
framePanel.BackgroundColor = value;
|
|
}
|
|
}
|
|
public Thickness BorderWidth { get { return framePanel.Padding; } set { framePanel.Padding = value; } }
|
|
public float CornerRadius
|
|
{
|
|
get { return framePanel.CornerRadius; }
|
|
set
|
|
{
|
|
framePanel.CornerRadius = value;
|
|
frameInternal.CornerRadius = framePanel.CornerRadius * internalFrameRadiusFactor;
|
|
}
|
|
}
|
|
public Color PanelBackgroundColor
|
|
{
|
|
get { return frameInternal.BackgroundColor; }
|
|
set
|
|
{
|
|
frameInternal.BorderColor = value;
|
|
frameInternal.BackgroundColor = value;
|
|
}
|
|
}
|
|
// Property label styling.
|
|
public double DefaultFontSize { get; }
|
|
public double FontSize { get; set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// S u m m a r y P r o p e r t i e s
|
|
//-------------------------------------------------------------------
|
|
public void AddProperty (String caption, String value)
|
|
{
|
|
properties.Add(new PropertyData() { Caption = caption, Value = value });
|
|
RefreshProperties();
|
|
}
|
|
public void ClearProperties ()
|
|
{
|
|
properties.Clear();
|
|
RefreshProperties();
|
|
}
|
|
private void RefreshProperties ()
|
|
{
|
|
// Clear existing properties.
|
|
gridProperties.Children.Clear();
|
|
gridProperties.RowDefinitions.Clear();
|
|
|
|
foreach (PropertyData property in properties)
|
|
{
|
|
int rowIdx = gridProperties.RowDefinitions.Count;
|
|
gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
|
|
gridProperties.Children.Add(new SaxLabel() { Text = property.Caption, FontSize = FontSize, HorizontalOptions = LayoutOptions.End }, 0, rowIdx);
|
|
gridProperties.Children.Add(new SaxLabel() { Text = property.Value, FontSize = FontSize, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand }, 1, rowIdx);
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n f i g u r e C o m p o n e n t s
|
|
//-------------------------------------------------------------------
|
|
protected override void ConfigureComponents ()
|
|
{
|
|
base.ConfigureComponents();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a n e l E v e n t s
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|