| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- public delegate void DigitalFormsHeaderTapped(bool Collapsed);
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class DigitalFormsHeader : ContentView
- {
- public event DigitalFormsHeaderTapped OnTapped;
- public bool bCollapsed { get; set; }
- public int Number { get; set; }
- public DigitalFormsHeader (bool collapsed = false)
- {
- InitializeComponent ();
- bCollapsed = collapsed;
- Number = 0;
- }
- public void SetHeaderValue(string value)
- {
- headerBtn.Text = value;
- }
- private void HeaderBtn_Tapped(object sender, EventArgs e)
- {
- OnTapped?.Invoke(bCollapsed);
- AdjustHeaderArrow();
- }
- private void AdjustHeaderArrow()
- {
- if (bCollapsed)
- {
- bCollapsed = false;
- Expand();
- }
- else
- {
- bCollapsed = true;
- Collapse();
- }
- }
- private void Expand()
- {
- collapseColumn.Width = 40;
- collapseImage.IsVisible = true;
- expandColumn.Width = 0;
- expandImage.IsVisible = false;
- }
- public void Collapse()
- {
- collapseColumn.Width = 0;
- collapseImage.IsVisible = false;
- expandColumn.Width = 40;
- expandImage.IsVisible = true;
- }
- public void SetHeaderStyle(DFLayoutHeader label)
- {
- headerBtn.FontAttributes = label.Style.IsBold ? FontAttributes.Bold
- : label.Style.IsItalic ? FontAttributes.Italic
- : FontAttributes.None;
- headerBtn.FontSize = label.Style.FontSize > 5 && label.Style.FontSize < 37 ? label.Style.FontSize
- : Device.GetNamedSize(NamedSize.Medium, headerBtn);
- headerBtn.TextColor = label.Style.ForegroundColour;
- headerBtn.BackgroundColor = label.Style.BackgroundColour;
- headerBtn.HorizontalOptions = label.Style.HorizontalTextAlignment == DFLayoutAlignment.Start ? LayoutOptions.Start
- : label.Style.HorizontalTextAlignment == DFLayoutAlignment.Middle ? LayoutOptions.Center
- : label.Style.HorizontalTextAlignment == DFLayoutAlignment.End ? LayoutOptions.End
- : label.Style.HorizontalTextAlignment == DFLayoutAlignment.Stretch ? LayoutOptions.FillAndExpand
- : LayoutOptions.StartAndExpand;
- headerBtn.VerticalOptions = label.Style.VerticalTextAlignment == DFLayoutAlignment.Start ? LayoutOptions.Start
- : label.Style.VerticalTextAlignment == DFLayoutAlignment.Middle ? LayoutOptions.Center
- : label.Style.VerticalTextAlignment == DFLayoutAlignment.End ? LayoutOptions.End
- : label.Style.VerticalTextAlignment == DFLayoutAlignment.Stretch ? LayoutOptions.FillAndExpand
- : LayoutOptions.Center;
- }
- }
- }
|