From 17fdde66d94155fc62a034fa6658995bef6fd6e5 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Mar 2016 13:02:25 -0700 Subject: Initial import --- Xamarin.Forms.Core/TableModel.cs | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Xamarin.Forms.Core/TableModel.cs (limited to 'Xamarin.Forms.Core/TableModel.cs') diff --git a/Xamarin.Forms.Core/TableModel.cs b/Xamarin.Forms.Core/TableModel.cs new file mode 100644 index 00000000..866b7a69 --- /dev/null +++ b/Xamarin.Forms.Core/TableModel.cs @@ -0,0 +1,76 @@ +using System; + +namespace Xamarin.Forms +{ + internal abstract class TableModel + { + public virtual Cell GetCell(int section, int row) + { + object item = GetItem(section, row); + var cell = item as Cell; + if (cell != null) + return cell; + + return new TextCell { Text = item.ToString() }; + } + + public virtual Cell GetHeaderCell(int section) + { + return null; + } + + public abstract object GetItem(int section, int row); + + public abstract int GetRowCount(int section); + + public abstract int GetSectionCount(); + + public virtual string[] GetSectionIndexTitles() + { + return null; + } + + public virtual string GetSectionTitle(int section) + { + return null; + } + + public event EventHandler> ItemLongPressed; + + public event EventHandler> ItemSelected; + + public void RowLongPressed(int section, int row) + { + RowLongPressed(GetItem(section, row)); + } + + public void RowLongPressed(object item) + { + if (ItemLongPressed != null) + ItemLongPressed(this, new EventArg(item)); + + OnRowLongPressed(item); + } + + public void RowSelected(int section, int row) + { + RowSelected(GetItem(section, row)); + } + + public void RowSelected(object item) + { + if (ItemSelected != null) + ItemSelected(this, new EventArg(item)); + + OnRowSelected(item); + } + + protected virtual void OnRowLongPressed(object item) + { + } + + protected virtual void OnRowSelected(object item) + { + } + } +} \ No newline at end of file -- cgit v1.2.3