123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using Xamarin.Forms;
- namespace InABox.Mobile
- {
- public interface IMobileToolItem
- {
- 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();
- int Row { get; set; }
- int Column { get; set; }
- }
- public partial class MobileMobileToolItem : BindableObject, IMobileToolItem
- {
-
- public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(MobileMobileToolItem), "");
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(ImageSource), typeof(MobileMobileToolItem), 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(MobileMobileToolItem), null);
- public string Indicator
- {
- get { return (string)GetValue(IndicatorProperty); }
- set {
- SetValue(IndicatorProperty, value);
- OnPropertyChanged(nameof(HasIndicator));
- }
- }
- public bool HasIndicator => !String.IsNullOrWhiteSpace(Indicator);
- public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
- nameof(BackgroundColor),
- typeof(Color),
- typeof(MobileMobileToolItem),
- 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(MobileMobileToolItem),
- 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(MobileMobileToolItem), 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(MobileMobileToolItem), true);
- public bool IsVisible
- {
- get { return (bool)GetValue(IsVisibleProperty); }
- set { SetValue(IsVisibleProperty, value); }
- }
-
-
- public static readonly BindableProperty RowProperty = BindableProperty.Create(nameof(Row), typeof(Int32), typeof(MobileMobileToolItem));
- public Int32 Row
- {
- get { return (Int32)GetValue(RowProperty); }
- set { SetValue(RowProperty, value); }
- }
-
- public static readonly BindableProperty ColumnProperty = BindableProperty.Create(nameof(Column), typeof(Int32), typeof(MobileMobileToolItem));
- public Int32 Column
- {
- get { return (Int32)GetValue(ColumnProperty); }
- set { SetValue(ColumnProperty, 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);
- }
-
- }
- }
|