| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 | using System;using Xamarin.Forms;namespace comal.timesheets{    public interface IToolItem    {        string Text { get; set; }        ImageSource Image { get; set; }        string Indicator { get; set; }        bool IsEnabled { get; set; }        bool IsVisible { get; set; }        int ID { get; set; }        event EventHandler Tapped;        void DoTap();    }    public partial class ToolItem : BindableObject, IToolItem    {                public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(ToolItem), "");        public string Text        {            get { return (string)GetValue(TextProperty); }            set { SetValue(TextProperty, value); }        }        public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(ImageSource), typeof(ToolItem), null);        public ImageSource Image        {            get { return (ImageSource)GetValue(ImageProperty); }            set { SetValue(ImageProperty, value); }        }                public static readonly BindableProperty IndicatorProperty = BindableProperty.Create(nameof(Indicator), typeof(string), typeof(ToolItem), null);        public string Indicator        {            get { return (string)GetValue(IndicatorProperty); }            set {                 SetValue(IndicatorProperty, value);                UpdateIndicator();             }        }                public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(            nameof(BackgroundColor),            typeof(Color),            typeof(ToolItem),            Color.White);        public Color BackgroundColor        {            get => (Color)GetValue(BackgroundColorProperty);            set => SetValue(BackgroundColorProperty, value);        }        public static readonly BindableProperty TextColorProperty = BindableProperty.Create(            nameof(TextColor),            typeof(Color),            typeof(ToolItem),            Color.Black);        public Color TextColor        {            get => (Color)GetValue(TextColorProperty);            set => SetValue(TextColorProperty, value);        }                        public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(ToolItem), true);        public bool IsEnabled        {            get { return (bool)GetValue(IsEnabledProperty); }            set { SetValue(IsEnabledProperty, value); }        }                                        public static readonly BindableProperty IsVisibleProperty = BindableProperty.Create(nameof(IsVisible), typeof(bool), typeof(ToolItem), true);        public bool IsVisible        {            get { return (bool)GetValue(IsVisibleProperty); }            set { SetValue(IsVisibleProperty, value); }        }                public int ID { get; set; }        public event EventHandler Tapped;                private void UpdateIndicator()        {            // if (!String.IsNullOrWhiteSpace(Indicator))            // {            //     indicatorLbl.Text = Indicator;            //     indicatorFrame.IsVisible = true;            //     Task.Run(() =>            //     {            //         Thread.Sleep(1000);            //         Device.BeginInvokeOnMainThread(() =>            //         {            //             indicatorFrame.TranslateTo(0, -10, 250);            //             indicatorFrame.TranslateTo(0, 0, 250);            //         });            //     });            // }            // else            //     indicatorFrame.IsVisible = false;        }        public void DoTap()        {            //await toolFrame.TranslateTo(0, -15, 150);            //await toolFrame.TranslateTo(0, 0, 150);            Tapped?.Invoke(this, EventArgs.Empty);        }            }}
 |