| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace comal.timesheets
- {
- public partial class ToolEntry : Grid
- {
- public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(ToolEntry), "");
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(ImageSource), typeof(ToolEntry), null);
- public ImageSource Image
- {
- get { return (ImageSource)GetValue(ImageProperty); }
- set { SetValue(ImageProperty, value); }
- }
- public int ID { get; set; }
- public event EventHandler OnTapped;
- public ToolEntry(string notification = "")
- {
- InitializeComponent();
- if (!string.IsNullOrEmpty(notification))
- {
- notificationFrame.IsVisible = true;
- toolEntryLbl.Text = notification;
- Timer t = new Timer(NotificationJump, null, 0, 5000);
- }
- }
- public ToolEntry()
- {
- InitializeComponent();
- }
- async void NotificationJump(object o)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- await notificationFrame.TranslateTo(0, -10, 250);
- await notificationFrame.TranslateTo(0, 0, 250);
- });
- }
- public ToolEntry(bool invisible)
- {
- InitializeComponent();
- if (invisible)
- {
- toolFrame.IsVisible = false;
- }
- }
- async void ImageTapped(System.Object sender, System.EventArgs e)
- {
- await toolFrame.TranslateTo(0, -15, 150);
- await toolFrame.TranslateTo(0, 0, 150);
- OnTapped?.Invoke(this, new EventArgs());
- }
- }
- }
|