diff --git a/.gitignore b/.gitignore
index 9e9b2a7..b86dd92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,7 @@
*/*/*/bin/*
*/*/*/obj/*
*_ReSharper.*/
+
+*/*/Resource.designer.cs
+*/*/*/Resource.designer.cs
+*/*/*/*/Resource.designer.cs
\ No newline at end of file
diff --git a/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll b/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll
new file mode 100644
index 0000000..80a162f
Binary files /dev/null and b/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll differ
diff --git a/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb b/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb
new file mode 100644
index 0000000..2575615
Binary files /dev/null and b/TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb differ
diff --git a/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll b/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll
new file mode 100644
index 0000000..44d59b1
Binary files /dev/null and b/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll differ
diff --git a/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb b/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb
new file mode 100644
index 0000000..ac620fd
Binary files /dev/null and b/TaskyProCloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb differ
diff --git a/TaskyProCloned/Tasky.Core.Cloned/About.txt b/TaskyProCloned/Tasky.Core.Cloned/About.txt
new file mode 100644
index 0000000..205d076
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/About.txt
@@ -0,0 +1,3 @@
+The Tasky.Core library is the reusable portion of the Tasky application. It contains the Business
+Layer (BL), Data Access Layer (DAL), and Data Layer (DL). All of the Tasky.Core code is shared between
+the iOS and Android versions of the application without modification.
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/BL/About.txt b/TaskyProCloned/Tasky.Core.Cloned/BL/About.txt
new file mode 100644
index 0000000..1b5507d
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/BL/About.txt
@@ -0,0 +1,15 @@
+Business Layer (BL)
+===================
+Sometimes also called the Business Logic Layer (BLL), the BL contains entitiy definitions and
+business logic.
+
+Business Entities
+-----------------
+Business entites are classes that represent real-world objects. They're the core of
+Object-Oriented-Programming (OOP).
+
+Manager Classes
+---------------
+In this particular architecture, we're using the façade pattern (like we did with the DAL)
+which is represented by static Manager classes. The manager classes are an abstraction on
+the DAL and SAL layers and perform any business logic.
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/BusinessEntityBase.cs b/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/BusinessEntityBase.cs
new file mode 100644
index 0000000..0a0a2b7
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/BusinessEntityBase.cs
@@ -0,0 +1,20 @@
+using System;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL.Contracts {
+ ///
+ /// Business entity base class. Provides the ID property.
+ ///
+ public abstract class BusinessEntityBase : IBusinessEntity {
+ public BusinessEntityBase ()
+ {
+ }
+
+ ///
+ /// Gets or sets the Database ID.
+ ///
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/IBusinessEntity.cs b/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/IBusinessEntity.cs
new file mode 100644
index 0000000..15ba377
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/IBusinessEntity.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace Tasky.BL.Contracts {
+ public interface IBusinessEntity {
+ int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProCloned/Tasky.Core.Cloned/BL/Managers/TaskManager.cs b/TaskyProCloned/Tasky.Core.Cloned/BL/Managers/TaskManager.cs
new file mode 100644
index 0000000..ed52849
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/BL/Managers/TaskManager.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using Tasky.BL;
+
+namespace Tasky.BL.Managers
+{
+ public static class TaskManager
+ {
+ static TaskManager ()
+ {
+ }
+
+ public static Task GetTask(int id)
+ {
+ return DAL.TaskRepository.GetTask(id);
+ }
+
+ public static IList GetTasks ()
+ {
+ return new List(DAL.TaskRepository.GetTasks());
+ }
+
+ public static int SaveTask (Task item)
+ {
+ return DAL.TaskRepository.SaveTask(item);
+ }
+
+ public static int DeleteTask(int id)
+ {
+ return DAL.TaskRepository.DeleteTask(id);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/BL/Task.cs b/TaskyProCloned/Tasky.Core.Cloned/BL/Task.cs
new file mode 100644
index 0000000..0d334d9
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/BL/Task.cs
@@ -0,0 +1,24 @@
+using System;
+using Tasky.BL.Contracts;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL
+{
+ ///
+ /// Represents a Task.
+ ///
+ public class Task : IBusinessEntity
+ {
+ public Task ()
+ {
+ }
+
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Notes { get; set; }
+ // new property
+ public bool Done { get; set; }
+ }
+}
+
diff --git a/TaskyProCloned/Tasky.Core.Cloned/DAL/About.txt b/TaskyProCloned/Tasky.Core.Cloned/DAL/About.txt
new file mode 100644
index 0000000..7825750
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/DAL/About.txt
@@ -0,0 +1,13 @@
+Data Access Layer (DAL)
+=======================
+The data access layer is responsible for providing an abstraction to the data layer. It makes
+sure that no matter what technology(ies) are used for data persistance, a single entry point
+that is technology agnostic exists.
+
+Often, the façade pattern is used, and many times the underlying data persistence technology is
+actually more than one. for example, you might have some data store in xml, other data stored in
+a SQL database, etc. The DAL makes sure that any complexity associated with accessing and aggregating
+these technologies is isolated from the rest of the application.
+
+The DAL is also considered a sibling to the Service Access Layer (SAL), which is responsible for
+access to cloud services, and other network related resources.
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/DAL/TaskRepository.cs b/TaskyProCloned/Tasky.Core.Cloned/DAL/TaskRepository.cs
new file mode 100644
index 0000000..2bae5f9
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/DAL/TaskRepository.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Tasky.BL;
+
+namespace Tasky.DAL {
+ public class TaskRepository {
+ DL.TaskDatabase db = null;
+ protected static string dbLocation;
+ protected static TaskRepository me;
+
+ static TaskRepository ()
+ {
+ me = new TaskRepository();
+ }
+
+ protected TaskRepository()
+ {
+ // set the db location
+ dbLocation = DatabaseFilePath;
+
+ // instantiate the database
+ db = new Tasky.DL.TaskDatabase(dbLocation);
+ }
+
+ public static string DatabaseFilePath {
+ get {
+ var sqliteFilename = "TaskDB.db3";
+#if SILVERLIGHT
+ // Windows Phone expects a local path, not absolute
+ var path = sqliteFilename;
+#else
+
+#if __ANDROID__
+ // Just use whatever directory SpecialFolder.Personal returns
+ string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ;
+#else
+ // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
+ // (they don't want non-user-generated data in Documents)
+ string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
+ string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder
+#endif
+ var path = Path.Combine (libraryPath, sqliteFilename);
+#endif
+ return path;
+ }
+ }
+
+ public static Task GetTask(int id)
+ {
+ return me.db.GetItem(id);
+ }
+
+ public static IEnumerable GetTasks ()
+ {
+ return me.db.GetItems();
+ }
+
+ public static int SaveTask (Task item)
+ {
+ return me.db.SaveItem(item);
+ }
+
+ public static int DeleteTask(int id)
+ {
+ return me.db.DeleteItem(id);
+ }
+ }
+}
+
diff --git a/TaskyProCloned/Tasky.Core.Cloned/DL/About.txt b/TaskyProCloned/Tasky.Core.Cloned/DL/About.txt
new file mode 100644
index 0000000..ee62d45
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/DL/About.txt
@@ -0,0 +1,19 @@
+Data Layer:
+===========
+The data layer is typically the lowest level layer of an application. Typically it consists
+of data persistence/retreival code. In this particular application, it contains two classes:
+ - SQLite.cs
+ - TaskDatabase.cs
+
+SQLite
+------
+This is the SQLite.NET library, created by Frank Krueger. It's a lightweight Object Relational
+Model (ORM) that allows you to define your database schema via classes and automatically
+handles the nitty gritty of data persistance and retrieval into/from SQLite as well as actual
+database creation. It also has limited support for LINQ queries.
+
+TaskDatabase
+------------
+TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB.
+It contains methods for retreival and persistance as well as db creation, all based on the
+underlying ORM.
diff --git a/TaskyProCloned/Tasky.Core.Cloned/DL/SQLite.cs b/TaskyProCloned/Tasky.Core.Cloned/DL/SQLite.cs
new file mode 100644
index 0000000..6752f3b
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/DL/SQLite.cs
@@ -0,0 +1,1940 @@
+//
+// Copyright (c) 2009-2011 Krueger Systems, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#if WINDOWS_PHONE
+#define USE_CSHARP_SQLITE
+#endif
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+
+#if USE_CSHARP_SQLITE
+using Community.CsharpSqlite;
+using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
+using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
+#else
+using Sqlite3DatabaseHandle = System.IntPtr;
+using Sqlite3Statement = System.IntPtr;
+#endif
+
+namespace Tasky.DL.SQLite {
+ public class SQLiteException : System.Exception {
+ public SQLite3.Result Result { get; private set; }
+
+ protected SQLiteException(SQLite3.Result r, string message)
+ : base(message)
+ {
+ Result = r;
+ }
+
+ public static SQLiteException New(SQLite3.Result r, string message)
+ {
+ return new SQLiteException(r, message);
+ }
+ }
+
+ ///
+ /// Represents an open connection to a SQLite database.
+ ///
+ public class SQLiteConnection : IDisposable {
+ private bool _open;
+ private TimeSpan _busyTimeout;
+ private Dictionary _mappings = null;
+ private Dictionary _tables = null;
+ private System.Diagnostics.Stopwatch _sw;
+ private long _elapsedMilliseconds = 0;
+
+ public Sqlite3DatabaseHandle Handle { get; private set; }
+#if USE_CSHARP_SQLITE
+ internal static readonly Sqlite3DatabaseHandle NullHandle = null;
+#else
+ internal static readonly Sqlite3DatabaseHandle NullHandle = IntPtr.Zero;
+#endif
+
+ public string DatabasePath { get; private set; }
+
+ public bool TimeExecution { get; set; }
+
+ public bool Trace { get; set; }
+
+ ///
+ /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath.
+ ///
+ ///
+ /// Specifies the path to the database file.
+ ///
+ public SQLiteConnection(string databasePath)
+ {
+ DatabasePath = databasePath;
+ Sqlite3DatabaseHandle handle;
+ var r = SQLite3.Open(DatabasePath, out handle);
+ Handle = handle;
+ if (r != SQLite3.Result.OK) {
+ throw SQLiteException.New(r, "Could not open database file: " + DatabasePath);
+ }
+ _open = true;
+
+ BusyTimeout = TimeSpan.FromSeconds(0.1);
+ }
+
+ static SQLiteConnection()
+ {
+ if (_preserveDuringLinkMagic) {
+ var ti = new TableInfo();
+ ti.name = "magic";
+ }
+ }
+
+ ///
+ /// Used to list some code that we want the MonoTouch linker
+ /// to see, but that we never want to actually execute.
+ ///
+ static bool _preserveDuringLinkMagic = false;
+
+ ///
+ /// Sets a busy handler to sleep the specified amount of time when a table is locked.
+ /// The handler will sleep multiple times until a total time of has accumulated.
+ ///
+ public TimeSpan BusyTimeout
+ {
+ get { return _busyTimeout; }
+ set
+ {
+ _busyTimeout = value;
+ if (Handle != NullHandle) {
+ SQLite3.BusyTimeout(Handle, (int)_busyTimeout.TotalMilliseconds);
+ }
+ }
+ }
+
+ ///
+ /// Returns the mappings from types to tables that the connection
+ /// currently understands.
+ ///
+ public IEnumerable TableMappings
+ {
+ get
+ {
+ if (_tables == null) {
+ return Enumerable.Empty();
+ } else {
+ return _tables.Values;
+ }
+ }
+ }
+
+ ///
+ /// Retrieves the mapping that is automatically generated for the given type.
+ ///
+ ///
+ /// The type whose mapping to the database is returned.
+ ///
+ ///
+ /// The mapping represents the schema of the columns of the database and contains
+ /// methods to set and get properties of objects.
+ ///
+ public TableMapping GetMapping(Type type)
+ {
+ if (_mappings == null) {
+ _mappings = new Dictionary();
+ }
+ TableMapping map;
+ if (!_mappings.TryGetValue(type.FullName, out map)) {
+ map = new TableMapping(type);
+ _mappings[type.FullName] = map;
+ }
+ return map;
+ }
+
+ ///
+ /// Executes a "create table if not exists" on the database. It also
+ /// creates any specified indexes on the columns of the table. It uses
+ /// a schema automatically generated from the specified type. You can
+ /// later access this schema by calling GetMapping.
+ ///
+ ///
+ /// The number of entries added to the database schema.
+ ///
+ public int CreateTable()
+ {
+ var ty = typeof(T);
+
+ if (_tables == null) {
+ _tables = new Dictionary();
+ }
+ TableMapping map;
+ if (!_tables.TryGetValue(ty.FullName, out map)) {
+ map = GetMapping(ty);
+ _tables.Add(ty.FullName, map);
+ }
+ var query = "create table if not exists \"" + map.TableName + "\"(\n";
+
+ var decls = map.Columns.Select(p => Orm.SqlDecl(p));
+ var decl = string.Join(",\n", decls.ToArray());
+ query += decl;
+ query += ")";
+
+ var count = Execute(query);
+
+ if (count == 0) { //Possible bug: This always seems to return 0?
+ // Table already exists, migrate it
+ MigrateTable(map);
+ }
+
+ foreach (var p in map.Columns.Where(x => x.IsIndexed)) {
+ var indexName = map.TableName + "_" + p.Name;
+ var q = string.Format("create index if not exists \"{0}\" on \"{1}\"(\"{2}\")", indexName, map.TableName, p.Name);
+ count += Execute(q);
+ }
+
+ return count;
+ }
+
+ public class TableInfo {
+ public int cid { get; set; }
+
+ public string name { get; set; }
+
+ public string type { get; set; }
+
+ public int notnull { get; set; }
+
+ public string dflt_value { get; set; }
+
+ public int pk { get; set; }
+ }
+
+ void MigrateTable(TableMapping map)
+ {
+ var query = "pragma table_info(\"" + map.TableName + "\")";
+
+ var existingCols = Query(query);
+
+ var toBeAdded = new List();
+
+ foreach (var p in map.Columns) {
+ var found = false;
+ foreach (var c in existingCols) {
+ found = p.Name == c.name;
+ if (found)
+ break;
+ }
+ if (!found) {
+ toBeAdded.Add(p);
+ }
+ }
+
+ foreach (var p in toBeAdded) {
+ var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl(p);
+ Execute(addCol);
+ }
+ }
+
+ ///
+ /// Creates a new SQLiteCommand given the command text with arguments. Place a '?'
+ /// in the command text for each of the arguments.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the command text.
+ ///
+ ///
+ /// A
+ ///
+ public SQLiteCommand CreateCommand(string cmdText, params object[] ps)
+ {
+ if (!_open) {
+ throw SQLiteException.New(SQLite3.Result.Error, "Cannot create commands from unopened database");
+ } else {
+ var cmd = new SQLiteCommand(this);
+ cmd.CommandText = cmdText;
+ foreach (var o in ps) {
+ cmd.Bind(o);
+ }
+ return cmd;
+ }
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// Use this method instead of Query when you don't expect rows back. Such cases include
+ /// INSERTs, UPDATEs, and DELETEs.
+ /// You can set the Trace or TimeExecution properties of the connection
+ /// to profile execution.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// The number of rows modified in the database as a result of this execution.
+ ///
+ public int Execute(string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+
+ if (TimeExecution) {
+ if (_sw == null) {
+ _sw = new System.Diagnostics.Stopwatch();
+ }
+ _sw.Reset();
+ _sw.Start();
+ }
+
+ int r = cmd.ExecuteNonQuery();
+
+ if (TimeExecution) {
+ _sw.Stop();
+ _elapsedMilliseconds += _sw.ElapsedMilliseconds;
+#if DEBUG
+ Console.WriteLine("Finished in {0} ms ({1:0.0} s total)", _sw.ElapsedMilliseconds, _elapsedMilliseconds / 1000.0);
+#endif
+ }
+
+ return r;
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public List Query(string query, params object[] args) where T : new()
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public IEnumerable DeferredQuery(string query, params object[] args) where T : new()
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteDeferredQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public List Query(TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteQuery(map);
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public IEnumerable DeferredQuery(TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteDeferredQuery(map);
+ }
+
+ ///
+ /// Returns a queryable interface to the table represented by the given type.
+ ///
+ ///
+ /// A queryable object that is able to translate Where, OrderBy, and Take
+ /// queries into native SQL.
+ ///
+ public TableQuery Table() where T : new()
+ {
+ return new TableQuery(this);
+ }
+
+ ///
+ /// Attempts to retrieve an object with the given primary key from the table
+ /// associated with the specified type. Use of this method requires that
+ /// the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).
+ ///
+ ///
+ /// The primary key.
+ ///
+ ///
+ /// The object with the given primary key. Throws a not found exception
+ /// if the object is not found.
+ ///
+ public T Get(object pk) where T : new()
+ {
+ var map = GetMapping(typeof(T));
+ string query = string.Format("select * from \"{0}\" where \"{1}\" = ?", map.TableName, map.PK.Name);
+ return Query(query, pk).First();
+ }
+
+ ///
+ /// Whether has been called and the database is waiting for a .
+ ///
+ public bool IsInTransaction { get; private set; }
+
+ ///
+ /// Begins a new transaction. Call to end the transaction.
+ ///
+ public void BeginTransaction()
+ {
+ if (!IsInTransaction) {
+ Execute("begin transaction");
+ IsInTransaction = true;
+ }
+ }
+
+ ///
+ /// Rolls back the transaction that was begun by .
+ ///
+ public void Rollback()
+ {
+ if (IsInTransaction) {
+ Execute("rollback");
+ IsInTransaction = false;
+ }
+ }
+
+ ///
+ /// Commits the transaction that was begun by .
+ ///
+ public void Commit()
+ {
+ if (IsInTransaction) {
+ Execute("commit");
+ IsInTransaction = false;
+ }
+ }
+
+ ///
+ /// Executes within a transaction and automatically rollsback the transaction
+ /// if an exception occurs. The exception is rethrown.
+ ///
+ ///
+ /// The to perform within a transaction. can contain any number
+ /// of operations on the connection but should never call ,
+ /// , or .
+ ///
+ public void RunInTransaction(Action action)
+ {
+ if (IsInTransaction) {
+ throw new InvalidOperationException("The connection must not already be in a transaction when RunInTransaction is called");
+ }
+ try {
+ BeginTransaction();
+ action();
+ Commit();
+ } catch (Exception) {
+ Rollback();
+ throw;
+ }
+ }
+
+ ///
+ /// Inserts all specified objects.
+ ///
+ ///
+ /// An of the objects to insert.
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int InsertAll(System.Collections.IEnumerable objects)
+ {
+ BeginTransaction();
+ var c = 0;
+ foreach (var r in objects) {
+ c += Insert(r);
+ }
+ Commit();
+ return c;
+ }
+
+ ///
+ /// Inserts the given object and retrieves its
+ /// auto incremented primary key if it has one.
+ ///
+ ///
+ /// The object to insert.
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int Insert(object obj)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Insert(obj, "", obj.GetType());
+ }
+
+ public int Insert(object obj, Type objType)
+ {
+ return Insert(obj, "", objType);
+ }
+
+ public int Insert(object obj, string extra)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Insert(obj, extra, obj.GetType());
+ }
+
+ ///
+ /// Inserts the given object and retrieves its
+ /// auto incremented primary key if it has one.
+ ///
+ ///
+ /// The object to insert.
+ ///
+ ///
+ /// Literal SQL code that gets placed into the command. INSERT {extra} INTO ...
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int Insert(object obj, string extra, Type objType)
+ {
+ if (obj == null || objType == null) {
+ return 0;
+ }
+
+ var map = GetMapping(objType);
+
+ var cols = map.InsertColumns;
+ var vals = new object[cols.Length];
+ for (var i = 0; i < vals.Length; i++) {
+ vals[i] = cols[i].GetValue(obj);
+ }
+
+ var insertCmd = map.GetInsertCommand(this, extra);
+ var count = insertCmd.ExecuteNonQuery(vals);
+
+ if (map.HasAutoIncPK) {
+ var id = SQLite3.LastInsertRowid(Handle);
+ map.SetAutoIncPK(obj, id);
+ }
+
+ return count;
+ }
+
+ ///
+ /// Updates all of the columns of a table using the specified object
+ /// except for its primary key.
+ /// The object is required to have a primary key.
+ ///
+ ///
+ /// The object to update. It must have a primary key designated using the PrimaryKeyAttribute.
+ ///
+ ///
+ /// The number of rows updated.
+ ///
+ public int Update(object obj)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Update(obj, obj.GetType());
+ }
+
+ public int Update(object obj, Type objType)
+ {
+ if (obj == null || objType == null) {
+ return 0;
+ }
+
+ var map = GetMapping(objType);
+
+ var pk = map.PK;
+
+ if (pk == null) {
+ throw new NotSupportedException("Cannot update " + map.TableName + ": it has no PK");
+ }
+
+ var cols = from p in map.Columns
+ where p != pk
+ select p;
+ var vals = from c in cols
+ select c.GetValue(obj);
+ var ps = new List(vals);
+ ps.Add(pk.GetValue(obj));
+ var q = string.Format("update \"{0}\" set {1} where {2} = ? ", map.TableName, string.Join(",", (from c in cols
+ select "\"" + c.Name + "\" = ? ").ToArray()), pk.Name);
+ return Execute(q, ps.ToArray());
+ }
+
+ ///
+ /// Deletes the given object from the database using its primary key.
+ ///
+ ///
+ /// The object to delete. It must have a primary key designated using the PrimaryKeyAttribute.
+ ///
+ ///
+ /// The number of rows deleted.
+ ///
+ public int Delete(T obj)
+ {
+ var map = GetMapping(obj.GetType());
+ var pk = map.PK;
+ if (pk == null) {
+ throw new NotSupportedException("Cannot delete " + map.TableName + ": it has no PK");
+ }
+ var q = string.Format("delete from \"{0}\" where \"{1}\" = ?", map.TableName, pk.Name);
+ return Execute(q, pk.GetValue(obj));
+ }
+
+ public void Dispose()
+ {
+ Close();
+ }
+
+ public void Close()
+ {
+ if (_open && Handle != NullHandle) {
+ try {
+ foreach (var sqlInsertCommand in _mappings.Values) {
+ sqlInsertCommand.Dispose();
+ }
+ var r = SQLite3.Close(Handle);
+ if (r != SQLite3.Result.OK) {
+ string msg = SQLite3.GetErrmsg(Handle);
+ throw SQLiteException.New(r, msg);
+ }
+ } finally {
+ Handle = NullHandle;
+ _open = false;
+ }
+ }
+ }
+ }
+
+ public class PrimaryKeyAttribute : Attribute {
+ }
+
+ public class AutoIncrementAttribute : Attribute {
+ }
+
+ public class IndexedAttribute : Attribute {
+ }
+
+ public class IgnoreAttribute : Attribute {
+ }
+
+ public class MaxLengthAttribute : Attribute {
+ public int Value { get; private set; }
+
+ public MaxLengthAttribute(int length)
+ {
+ Value = length;
+ }
+ }
+
+ public class CollationAttribute : Attribute {
+ public string Value { get; private set; }
+
+ public CollationAttribute(string collation)
+ {
+ Value = collation;
+ }
+ }
+
+ public class TableMapping {
+ public Type MappedType { get; private set; }
+
+ public string TableName { get; private set; }
+
+ public Column[] Columns { get; private set; }
+
+ public Column PK { get; private set; }
+
+ Column _autoPk = null;
+ Column[] _insertColumns = null;
+
+ public TableMapping(Type type)
+ {
+ MappedType = type;
+ TableName = MappedType.Name;
+ var props = MappedType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);
+ var cols = new List();
+ foreach (var p in props) {
+ var ignore = p.GetCustomAttributes(typeof(IgnoreAttribute), true).Length > 0;
+ if (p.CanWrite && !ignore) {
+ cols.Add(new PropColumn(p));
+ }
+ }
+ Columns = cols.ToArray();
+ foreach (var c in Columns) {
+ if (c.IsAutoInc && c.IsPK) {
+ _autoPk = c;
+ }
+ if (c.IsPK) {
+ PK = c;
+ }
+ }
+
+ HasAutoIncPK = _autoPk != null;
+ }
+
+ public bool HasAutoIncPK { get; private set; }
+
+ public void SetAutoIncPK(object obj, long id)
+ {
+ if (_autoPk != null) {
+ _autoPk.SetValue(obj, Convert.ChangeType(id, _autoPk.ColumnType, null));
+ }
+ }
+
+ public Column[] InsertColumns
+ {
+ get
+ {
+ if (_insertColumns == null) {
+ _insertColumns = Columns.Where(c => !c.IsAutoInc).ToArray();
+ }
+ return _insertColumns;
+ }
+ }
+
+ public Column FindColumn(string name)
+ {
+ var exact = Columns.Where(c => c.Name == name).FirstOrDefault();
+ return exact;
+ }
+
+
+ PreparedSqlLiteInsertCommand _insertCommand;
+ string _insertCommandExtra = null;
+
+ public PreparedSqlLiteInsertCommand GetInsertCommand(SQLiteConnection conn, string extra)
+ {
+
+ if (_insertCommand == null) {
+ _insertCommand = CreateInsertCommand(conn, extra);
+ _insertCommandExtra = extra;
+ } else if (_insertCommandExtra != extra) {
+ _insertCommand.Dispose();
+ _insertCommand = CreateInsertCommand(conn, extra);
+ _insertCommandExtra = extra;
+ }
+ return _insertCommand;
+ }
+
+ private PreparedSqlLiteInsertCommand CreateInsertCommand(SQLiteConnection conn, string extra)
+ {
+ var cols = InsertColumns;
+ var insertSql = string.Format("insert {3} into \"{0}\"({1}) values ({2})", TableName,
+ string.Join(",", (from c in cols
+ select "\"" + c.Name + "\"").ToArray()),
+ string.Join(",", (from c in cols
+ select "?").ToArray()), extra);
+
+ var insertCommand = new PreparedSqlLiteInsertCommand(conn);
+ insertCommand.CommandText = insertSql;
+ return insertCommand;
+ }
+
+ protected internal void Dispose()
+ {
+ if (_insertCommand != null) {
+ _insertCommand.Dispose();
+ _insertCommand = null;
+ }
+ }
+
+ public abstract class Column {
+ public string Name { get; protected set; }
+
+ public Type ColumnType { get; protected set; }
+
+ public string Collation { get; protected set; }
+
+ public bool IsAutoInc { get; protected set; }
+
+ public bool IsPK { get; protected set; }
+
+ public bool IsIndexed { get; protected set; }
+
+ public bool IsNullable { get; protected set; }
+
+ public int MaxStringLength { get; protected set; }
+
+ public abstract void SetValue(object obj, object val);
+
+ public abstract object GetValue(object obj);
+ }
+
+ public class PropColumn : Column {
+ PropertyInfo _prop;
+
+ public PropColumn(PropertyInfo prop)
+ {
+ _prop = prop;
+ Name = prop.Name;
+ //If this type is Nullable then Nullable.GetUnderlyingType returns the T, otherwise it returns null, so get the the actual type instead
+ ColumnType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
+ Collation = Orm.Collation(prop);
+ IsAutoInc = Orm.IsAutoInc(prop);
+ IsPK = Orm.IsPK(prop);
+ IsIndexed = Orm.IsIndexed(prop);
+ IsNullable = !IsPK;
+ MaxStringLength = Orm.MaxStringLength(prop);
+ }
+
+ public override void SetValue(object obj, object val)
+ {
+ _prop.SetValue(obj, val, null);
+ }
+
+ public override object GetValue(object obj)
+ {
+ return _prop.GetValue(obj, null);
+ }
+ }
+ }
+
+ public static class Orm {
+ public const int DefaultMaxStringLength = 140;
+
+ public static string SqlDecl(TableMapping.Column p)
+ {
+ string decl = "\"" + p.Name + "\" " + SqlType(p) + " ";
+
+ if (p.IsPK) {
+ decl += "primary key ";
+ }
+ if (p.IsAutoInc) {
+ decl += "autoincrement ";
+ }
+ if (!p.IsNullable) {
+ decl += "not null ";
+ }
+ if (!string.IsNullOrEmpty(p.Collation)) {
+ decl += "collate " + p.Collation + " ";
+ }
+
+ return decl;
+ }
+
+ public static string SqlType(TableMapping.Column p)
+ {
+ var clrType = p.ColumnType;
+ if (clrType == typeof(Boolean) || clrType == typeof(Byte) || clrType == typeof(UInt16) || clrType == typeof(SByte) || clrType == typeof(Int16) || clrType == typeof(Int32)) {
+ return "integer";
+ } else if (clrType == typeof(UInt32) || clrType == typeof(Int64)) {
+ return "bigint";
+ } else if (clrType == typeof(Single) || clrType == typeof(Double) || clrType == typeof(Decimal)) {
+ return "float";
+ } else if (clrType == typeof(String)) {
+ int len = p.MaxStringLength;
+ return "varchar(" + len + ")";
+ } else if (clrType == typeof(DateTime)) {
+ return "datetime";
+ } else if (clrType.IsEnum) {
+ return "integer";
+ } else if (clrType == typeof(byte[])) {
+ return "blob";
+ } else {
+ throw new NotSupportedException("Don't know about " + clrType);
+ }
+ }
+
+ public static bool IsPK(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static string Collation(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(CollationAttribute), true);
+ if (attrs.Length > 0) {
+ return ((CollationAttribute)attrs[0]).Value;
+ } else {
+ return string.Empty;
+ }
+ }
+
+ public static bool IsAutoInc(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(AutoIncrementAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static bool IsIndexed(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(IndexedAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static int MaxStringLength(PropertyInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(MaxLengthAttribute), true);
+ if (attrs.Length > 0) {
+ return ((MaxLengthAttribute)attrs[0]).Value;
+ } else {
+ return DefaultMaxStringLength;
+ }
+ }
+ }
+
+ public class SQLiteCommand {
+ SQLiteConnection _conn;
+ private List _bindings;
+
+ public string CommandText { get; set; }
+
+ internal SQLiteCommand(SQLiteConnection conn)
+ {
+ _conn = conn;
+ _bindings = new List();
+ CommandText = "";
+ }
+
+ public int ExecuteNonQuery()
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing: " + this);
+#endif
+ }
+
+ var r = SQLite3.Result.OK;
+ var stmt = Prepare();
+ r = SQLite3.Step(stmt);
+ Finalize(stmt);
+ if (r == SQLite3.Result.Done) {
+ int rowsAffected = SQLite3.Changes(_conn.Handle);
+ return rowsAffected;
+ } else if (r == SQLite3.Result.Error) {
+ string msg = SQLite3.GetErrmsg(_conn.Handle);
+ throw SQLiteException.New(r, msg);
+ } else {
+ throw SQLiteException.New(r, r.ToString());
+ }
+ }
+
+ public IEnumerable ExecuteDeferredQuery() where T : new()
+ {
+ return ExecuteDeferredQuery(_conn.GetMapping(typeof(T)));
+ }
+
+ public List ExecuteQuery() where T : new()
+ {
+ return ExecuteDeferredQuery(_conn.GetMapping(typeof(T))).ToList();
+ }
+
+ public List ExecuteQuery(TableMapping map)
+ {
+ return ExecuteDeferredQuery(map).ToList();
+ }
+
+ public IEnumerable ExecuteDeferredQuery(TableMapping map)
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing Query: " + this);
+#endif
+ }
+
+ var stmt = Prepare();
+ try {
+ var cols = new TableMapping.Column[SQLite3.ColumnCount(stmt)];
+
+ for (int i = 0; i < cols.Length; i++) {
+ var name = SQLite3.ColumnName16(stmt, i);
+ cols[i] = map.FindColumn(name);
+ }
+
+ while (SQLite3.Step(stmt) == SQLite3.Result.Row) {
+ var obj = Activator.CreateInstance(map.MappedType);
+ for (int i = 0; i < cols.Length; i++) {
+ if (cols[i] == null)
+ continue;
+ var colType = SQLite3.ColumnType(stmt, i);
+ var val = ReadCol(stmt, i, colType, cols[i].ColumnType);
+ cols[i].SetValue(obj, val);
+ }
+ yield return (T)obj;
+ }
+ } finally {
+ SQLite3.Finalize(stmt);
+ }
+ }
+
+ public T ExecuteScalar()
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing Query: " + this);
+#endif
+ }
+
+ T val = default(T);
+
+ var stmt = Prepare();
+ if (SQLite3.Step(stmt) == SQLite3.Result.Row) {
+ var colType = SQLite3.ColumnType(stmt, 0);
+ val = (T)ReadCol(stmt, 0, colType, typeof(T));
+ }
+ Finalize(stmt);
+
+ return val;
+ }
+
+ public void Bind(string name, object val)
+ {
+ _bindings.Add(new Binding {
+ Name = name,
+ Value = val
+ });
+ }
+
+ public void Bind(object val)
+ {
+ Bind(null, val);
+ }
+
+ public override string ToString()
+ {
+ var parts = new string[1 + _bindings.Count];
+ parts[0] = CommandText;
+ var i = 1;
+ foreach (var b in _bindings) {
+ parts[i] = string.Format(" {0}: {1}", i - 1, b.Value);
+ i++;
+ }
+ return string.Join(Environment.NewLine, parts);
+ }
+
+ Sqlite3Statement Prepare()
+ {
+ var stmt = SQLite3.Prepare2(_conn.Handle, CommandText);
+ BindAll(stmt);
+ return stmt;
+ }
+
+ void Finalize(Sqlite3Statement stmt)
+ {
+ SQLite3.Finalize(stmt);
+ }
+
+ void BindAll(Sqlite3Statement stmt)
+ {
+ int nextIdx = 1;
+ foreach (var b in _bindings) {
+ if (b.Name != null) {
+ b.Index = SQLite3.BindParameterIndex(stmt, b.Name);
+ } else {
+ b.Index = nextIdx++;
+ }
+ }
+ foreach (var b in _bindings) {
+ BindParameter(stmt, b.Index, b.Value);
+ }
+ }
+
+ internal static IntPtr NegativePointer = new IntPtr(-1);
+
+ internal static void BindParameter(Sqlite3Statement stmt, int index, object value)
+ {
+ if (value == null) {
+ SQLite3.BindNull(stmt, index);
+ } else {
+ if (value is Int32) {
+ SQLite3.BindInt(stmt, index, (int)value);
+ } else if (value is String) {
+ SQLite3.BindText(stmt, index, (string)value, -1, NegativePointer);
+ } else if (value is Byte || value is UInt16 || value is SByte || value is Int16) {
+ SQLite3.BindInt(stmt, index, Convert.ToInt32(value));
+ } else if (value is Boolean) {
+ SQLite3.BindInt(stmt, index, (bool)value ? 1 : 0);
+ } else if (value is UInt32 || value is Int64) {
+ SQLite3.BindInt64(stmt, index, Convert.ToInt64(value));
+ } else if (value is Single || value is Double || value is Decimal) {
+ SQLite3.BindDouble(stmt, index, Convert.ToDouble(value));
+ } else if (value is DateTime) {
+ SQLite3.BindText(stmt, index, ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), -1, NegativePointer);
+ } else if (value.GetType().IsEnum) {
+ SQLite3.BindInt(stmt, index, Convert.ToInt32(value));
+ } else if (value is byte[]) {
+ SQLite3.BindBlob(stmt, index, (byte[])value, ((byte[])value).Length, NegativePointer);
+ } else {
+ throw new NotSupportedException("Cannot store type: " + value.GetType());
+ }
+ }
+ }
+
+ class Binding {
+ public string Name { get; set; }
+
+ public object Value { get; set; }
+
+ public int Index { get; set; }
+ }
+
+ object ReadCol(Sqlite3Statement stmt, int index, SQLite3.ColType type, Type clrType)
+ {
+ if (type == SQLite3.ColType.Null) {
+ return null;
+ } else {
+ if (clrType == typeof(String)) {
+ return SQLite3.ColumnString(stmt, index);
+ } else if (clrType == typeof(Int32)) {
+ return (int)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Boolean)) {
+ return SQLite3.ColumnInt(stmt, index) == 1;
+ } else if (clrType == typeof(double)) {
+ return SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(float)) {
+ return (float)SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(DateTime)) {
+ var text = SQLite3.ColumnString(stmt, index);
+ return DateTime.Parse(text);
+ } else if (clrType.IsEnum) {
+ return SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Int64)) {
+ return SQLite3.ColumnInt64(stmt, index);
+ } else if (clrType == typeof(UInt32)) {
+ return (uint)SQLite3.ColumnInt64(stmt, index);
+ } else if (clrType == typeof(decimal)) {
+ return (decimal)SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(Byte)) {
+ return (byte)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(UInt16)) {
+ return (ushort)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Int16)) {
+ return (short)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(sbyte)) {
+ return (sbyte)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(byte[])) {
+ return SQLite3.ColumnByteArray(stmt, index);
+ } else {
+ throw new NotSupportedException("Don't know how to read " + clrType);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Since the insert never changed, we only need to prepare once.
+ ///
+ public class PreparedSqlLiteInsertCommand : IDisposable {
+ public bool Initialized { get; set; }
+
+ protected SQLiteConnection Connection { get; set; }
+
+ public string CommandText { get; set; }
+
+ protected Sqlite3Statement Statement { get; set; }
+#if USE_CSHARP_SQLITE
+ internal static readonly Sqlite3Statement NullStatement = null;
+#else
+ internal static readonly Sqlite3Statement NullStatement = IntPtr.Zero;
+#endif
+
+ internal PreparedSqlLiteInsertCommand(SQLiteConnection conn)
+ {
+ Connection = conn;
+ }
+
+ public int ExecuteNonQuery(object[] source)
+ {
+ if (Connection.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing: " + CommandText);
+#endif
+ }
+
+ var r = SQLite3.Result.OK;
+
+ if (!Initialized) {
+ Statement = Prepare();
+ Initialized = true;
+ }
+
+ //bind the values.
+ if (source != null) {
+ for (int i = 0; i < source.Length; i++) {
+ SQLiteCommand.BindParameter(Statement, i + 1, source[i]);
+ }
+ }
+ r = SQLite3.Step(Statement);
+
+ if (r == SQLite3.Result.Done) {
+ int rowsAffected = SQLite3.Changes(Connection.Handle);
+ SQLite3.Reset(Statement);
+ return rowsAffected;
+ } else if (r == SQLite3.Result.Error) {
+ string msg = SQLite3.GetErrmsg(Connection.Handle);
+ SQLite3.Reset(Statement);
+ throw SQLiteException.New(r, msg);
+ } else {
+ SQLite3.Reset(Statement);
+ throw SQLiteException.New(r, r.ToString());
+ }
+ }
+
+ protected virtual Sqlite3Statement Prepare()
+ {
+ var stmt = SQLite3.Prepare2(Connection.Handle, CommandText);
+ return stmt;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (Statement != NullStatement) {
+ try {
+ SQLite3.Finalize(Statement);
+ } finally {
+ Statement = NullStatement;
+ Connection = null;
+ }
+ }
+ }
+
+ ~PreparedSqlLiteInsertCommand()
+ {
+ Dispose(false);
+ }
+ }
+
+ public class TableQuery : IEnumerable where T : new() {
+ public SQLiteConnection Connection { get; private set; }
+
+ public TableMapping Table { get; private set; }
+
+ Expression _where;
+ List _orderBys;
+ int? _limit;
+ int? _offset;
+
+ class Ordering {
+ public string ColumnName { get; set; }
+
+ public bool Ascending { get; set; }
+ }
+
+ TableQuery(SQLiteConnection conn, TableMapping table)
+ {
+ Connection = conn;
+ Table = table;
+ }
+
+ public TableQuery(SQLiteConnection conn)
+ {
+ Connection = conn;
+ Table = Connection.GetMapping(typeof(T));
+ }
+
+ public TableQuery Clone()
+ {
+ var q = new TableQuery(Connection, Table);
+ q._where = _where;
+ q._deferred = _deferred;
+ if (_orderBys != null) {
+ q._orderBys = new List(_orderBys);
+ }
+ q._limit = _limit;
+ q._offset = _offset;
+ return q;
+ }
+
+ public TableQuery Where(Expression> predExpr)
+ {
+ if (predExpr.NodeType == ExpressionType.Lambda) {
+ var lambda = (LambdaExpression)predExpr;
+ var pred = lambda.Body;
+ var q = Clone();
+ q.AddWhere(pred);
+ return q;
+ } else {
+ throw new NotSupportedException("Must be a predicate");
+ }
+ }
+
+ public TableQuery Take(int n)
+ {
+ var q = Clone();
+ q._limit = n;
+ return q;
+ }
+
+ public TableQuery Skip(int n)
+ {
+ var q = Clone();
+ q._offset = n;
+ return q;
+ }
+
+ bool _deferred = false;
+ public TableQuery Deferred()
+ {
+ var q = Clone();
+ q._deferred = true;
+ return q;
+ }
+
+ public TableQuery OrderBy(Expression> orderExpr)
+ {
+ return AddOrderBy(orderExpr, true);
+ }
+
+ public TableQuery OrderByDescending(Expression> orderExpr)
+ {
+ return AddOrderBy(orderExpr, false);
+ }
+
+ private TableQuery AddOrderBy(Expression> orderExpr, bool asc)
+ {
+ if (orderExpr.NodeType == ExpressionType.Lambda) {
+ var lambda = (LambdaExpression)orderExpr;
+ var mem = lambda.Body as MemberExpression;
+ if (mem != null && (mem.Expression.NodeType == ExpressionType.Parameter)) {
+ var q = Clone();
+ if (q._orderBys == null) {
+ q._orderBys = new List();
+ }
+ q._orderBys.Add(new Ordering {
+ ColumnName = mem.Member.Name,
+ Ascending = asc
+ });
+ return q;
+ } else {
+ throw new NotSupportedException("Order By does not support: " + orderExpr);
+ }
+ } else {
+ throw new NotSupportedException("Must be a predicate");
+ }
+ }
+
+ private void AddWhere(Expression pred)
+ {
+ if (_where == null) {
+ _where = pred;
+ } else {
+ _where = Expression.AndAlso(_where, pred);
+ }
+ }
+
+ private SQLiteCommand GenerateCommand(string selectionList)
+ {
+ var cmdText = "select " + selectionList + " from \"" + Table.TableName + "\"";
+ var args = new List();
+ if (_where != null) {
+ var w = CompileExpr(_where, args);
+ cmdText += " where " + w.CommandText;
+ }
+ if ((_orderBys != null) && (_orderBys.Count > 0)) {
+ var t = string.Join(", ", _orderBys.Select(o => "\"" + o.ColumnName + "\"" + (o.Ascending ? "" : " desc")).ToArray());
+ cmdText += " order by " + t;
+ }
+ if (_limit.HasValue) {
+ cmdText += " limit " + _limit.Value;
+ }
+ if (_offset.HasValue) {
+ if (!_limit.HasValue) {
+ cmdText += " limit -1 ";
+ }
+ cmdText += " offset " + _offset.Value;
+ }
+ return Connection.CreateCommand(cmdText, args.ToArray());
+ }
+
+ class CompileResult {
+ public string CommandText { get; set; }
+
+ public object Value { get; set; }
+ }
+
+ private CompileResult CompileExpr(Expression expr, List queryArgs)
+ {
+ if (expr == null) {
+ throw new NotSupportedException("Expression is NULL");
+ } else if (expr is BinaryExpression) {
+ var bin = (BinaryExpression)expr;
+
+ var leftr = CompileExpr(bin.Left, queryArgs);
+ var rightr = CompileExpr(bin.Right, queryArgs);
+
+ //If either side is a parameter and is null, then handle the other side specially (for "is null"/"is not null")
+ string text;
+ if (leftr.CommandText == "?" && leftr.Value == null)
+ text = CompileNullBinaryExpression(bin, rightr);
+ else if (rightr.CommandText == "?" && rightr.Value == null)
+ text = CompileNullBinaryExpression(bin, leftr);
+ else
+ text = "(" + leftr.CommandText + " " + GetSqlName(bin) + " " + rightr.CommandText + ")";
+ return new CompileResult { CommandText = text };
+ } else if (expr.NodeType == ExpressionType.Call) {
+
+ var call = (MethodCallExpression)expr;
+ var args = new CompileResult[call.Arguments.Count];
+
+ for (var i = 0; i < args.Length; i++) {
+ args[i] = CompileExpr(call.Arguments[i], queryArgs);
+ }
+
+ var sqlCall = "";
+
+ if (call.Method.Name == "Like" && args.Length == 2) {
+ sqlCall = "(" + args[0].CommandText + " like " + args[1].CommandText + ")";
+ } else if (call.Method.Name == "Contains" && args.Length == 2) {
+ sqlCall = "(" + args[1].CommandText + " in " + args[0].CommandText + ")";
+ } else {
+ sqlCall = call.Method.Name.ToLower() + "(" + string.Join(",", args.Select(a => a.CommandText).ToArray()) + ")";
+ }
+ return new CompileResult { CommandText = sqlCall };
+
+ } else if (expr.NodeType == ExpressionType.Constant) {
+ var c = (ConstantExpression)expr;
+ queryArgs.Add(c.Value);
+ return new CompileResult {
+ CommandText = "?",
+ Value = c.Value
+ };
+ } else if (expr.NodeType == ExpressionType.Convert) {
+ var u = (UnaryExpression)expr;
+ var ty = u.Type;
+ var valr = CompileExpr(u.Operand, queryArgs);
+ return new CompileResult {
+ CommandText = valr.CommandText,
+ Value = valr.Value != null ? Convert.ChangeType(valr.Value, ty, null) : null
+ };
+ } else if (expr.NodeType == ExpressionType.MemberAccess) {
+ var mem = (MemberExpression)expr;
+
+ if (mem.Expression.NodeType == ExpressionType.Parameter) {
+ //
+ // This is a column of our table, output just the column name
+ //
+ return new CompileResult { CommandText = "\"" + mem.Member.Name + "\"" };
+ } else {
+ object obj = null;
+ if (mem.Expression != null) {
+ var r = CompileExpr(mem.Expression, queryArgs);
+ if (r.Value == null) {
+ throw new NotSupportedException("Member access failed to compile expression");
+ }
+ if (r.CommandText == "?") {
+ queryArgs.RemoveAt(queryArgs.Count - 1);
+ }
+ obj = r.Value;
+ }
+
+ //
+ // Get the member value
+ //
+ object val = null;
+
+ if (mem.Member.MemberType == MemberTypes.Property) {
+ var m = (PropertyInfo)mem.Member;
+ val = m.GetValue(obj, null);
+ } else if (mem.Member.MemberType == MemberTypes.Field) {
+#if SILVERLIGHT
+ val = Expression.Lambda(expr).Compile().DynamicInvoke();
+#else
+ var m = (FieldInfo)mem.Member;
+ var eee = Expression.Lambda (expr);
+ val = m.GetValue (obj);
+#endif
+ } else {
+ throw new NotSupportedException("MemberExpr: " + mem.Member.MemberType.ToString());
+ }
+
+ //
+ // Work special magic for enumerables
+ //
+ if (val != null && val is System.Collections.IEnumerable && !(val is string)) {
+ var sb = new System.Text.StringBuilder();
+ sb.Append("(");
+ var head = "";
+ foreach (var a in (System.Collections.IEnumerable)val) {
+ queryArgs.Add(a);
+ sb.Append(head);
+ sb.Append("?");
+ head = ",";
+ }
+ sb.Append(")");
+ return new CompileResult {
+ CommandText = sb.ToString(),
+ Value = val
+ };
+ } else {
+ queryArgs.Add(val);
+ return new CompileResult {
+ CommandText = "?",
+ Value = val
+ };
+ }
+ }
+ }
+ throw new NotSupportedException("Cannot compile: " + expr.NodeType.ToString());
+ }
+
+ ///
+ /// Compiles a BinaryExpression where one of the parameters is null.
+ ///
+ /// The non-null parameter
+ private string CompileNullBinaryExpression(BinaryExpression expression, CompileResult parameter)
+ {
+ if (expression.NodeType == ExpressionType.Equal)
+ return "(" + parameter.CommandText + " is ?)";
+ else if (expression.NodeType == ExpressionType.NotEqual)
+ return "(" + parameter.CommandText + " is not ?)";
+ else
+ throw new NotSupportedException("Cannot compile Null-BinaryExpression with type " + expression.NodeType.ToString());
+ }
+
+ string GetSqlName(Expression expr)
+ {
+ var n = expr.NodeType;
+ if (n == ExpressionType.GreaterThan)
+ return ">";
+ else if (n == ExpressionType.GreaterThanOrEqual) {
+ return ">=";
+ } else if (n == ExpressionType.LessThan) {
+ return "<";
+ } else if (n == ExpressionType.LessThanOrEqual) {
+ return "<=";
+ } else if (n == ExpressionType.And) {
+ return "and";
+ } else if (n == ExpressionType.AndAlso) {
+ return "and";
+ } else if (n == ExpressionType.Or) {
+ return "or";
+ } else if (n == ExpressionType.OrElse) {
+ return "or";
+ } else if (n == ExpressionType.Equal) {
+ return "=";
+ } else if (n == ExpressionType.NotEqual) {
+ return "!=";
+ } else {
+ throw new System.NotSupportedException("Cannot get SQL for: " + n.ToString());
+ }
+ }
+
+ public int Count()
+ {
+ return GenerateCommand("count(*)").ExecuteScalar();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ if (!_deferred)
+ return GenerateCommand("*").ExecuteQuery().GetEnumerator();
+
+ return GenerateCommand("*").ExecuteDeferredQuery().GetEnumerator();
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+
+ public static class SQLite3 {
+ public enum Result : int {
+ OK = 0,
+ Error = 1,
+ Internal = 2,
+ Perm = 3,
+ Abort = 4,
+ Busy = 5,
+ Locked = 6,
+ NoMem = 7,
+ ReadOnly = 8,
+ Interrupt = 9,
+ IOError = 10,
+ Corrupt = 11,
+ NotFound = 12,
+ TooBig = 18,
+ Constraint = 19,
+ Row = 100,
+ Done = 101
+ }
+
+ public enum ConfigOption : int {
+ SingleThread = 1,
+ MultiThread = 2,
+ Serialized = 3
+ }
+
+#if !USE_CSHARP_SQLITE
+ [DllImport("sqlite3", EntryPoint = "sqlite3_open")]
+ public static extern Result Open (string filename, out IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_close")]
+ public static extern Result Close (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_config")]
+ public static extern Result Config (ConfigOption option);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_busy_timeout")]
+ public static extern Result BusyTimeout (IntPtr db, int milliseconds);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_changes")]
+ public static extern int Changes (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_prepare_v2")]
+ public static extern Result Prepare2 (IntPtr db, string sql, int numBytes, out IntPtr stmt, IntPtr pzTail);
+
+ public static IntPtr Prepare2 (IntPtr db, string query)
+ {
+ IntPtr stmt;
+ var r = Prepare2 (db, query, query.Length, out stmt, IntPtr.Zero);
+ if (r != Result.OK) {
+ throw SQLiteException.New (r, GetErrmsg (db));
+ }
+ return stmt;
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_step")]
+ public static extern Result Step (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_reset")]
+ public static extern Result Reset (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_finalize")]
+ public static extern Result Finalize (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_last_insert_rowid")]
+ public static extern long LastInsertRowid (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_errmsg16")]
+ public static extern IntPtr Errmsg (IntPtr db);
+
+ public static string GetErrmsg (IntPtr db)
+ {
+ return Marshal.PtrToStringUni (Errmsg (db));
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_parameter_index")]
+ public static extern int BindParameterIndex (IntPtr stmt, string name);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_null")]
+ public static extern int BindNull (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_int")]
+ public static extern int BindInt (IntPtr stmt, int index, int val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_int64")]
+ public static extern int BindInt64 (IntPtr stmt, int index, long val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_double")]
+ public static extern int BindDouble (IntPtr stmt, int index, double val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_text")]
+ public static extern int BindText (IntPtr stmt, int index, string val, int n, IntPtr free);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_blob")]
+ public static extern int BindBlob (IntPtr stmt, int index, byte[] val, int n, IntPtr free);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_count")]
+ public static extern int ColumnCount (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_name")]
+ public static extern IntPtr ColumnName (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_name16")]
+ private static extern IntPtr ColumnName16Internal (IntPtr stmt, int index);
+ public static string ColumnName16(IntPtr stmt, int index)
+ {
+ return Marshal.PtrToStringUni(ColumnName16Internal(stmt, index));
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_type")]
+ public static extern ColType ColumnType (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_int")]
+ public static extern int ColumnInt (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_int64")]
+ public static extern long ColumnInt64 (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_double")]
+ public static extern double ColumnDouble (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_text")]
+ public static extern IntPtr ColumnText (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_text16")]
+ public static extern IntPtr ColumnText16 (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_blob")]
+ public static extern IntPtr ColumnBlob (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_bytes")]
+ public static extern int ColumnBytes (IntPtr stmt, int index);
+
+ public static string ColumnString (IntPtr stmt, int index)
+ {
+ return Marshal.PtrToStringUni (SQLite3.ColumnText16 (stmt, index));
+ }
+
+ public static byte[] ColumnByteArray (IntPtr stmt, int index)
+ {
+ int length = ColumnBytes (stmt, index);
+ byte[] result = new byte[length];
+ if (length > 0)
+ Marshal.Copy (ColumnBlob (stmt, index), result, 0, length);
+ return result;
+ }
+#else
+ public static Result Open(string filename, out Sqlite3.sqlite3 db)
+ {
+ db = new Sqlite3.sqlite3();
+ return (Result)Sqlite3.sqlite3_open(filename, ref db);
+ }
+
+ public static Result Close(Sqlite3.sqlite3 db)
+ {
+ return (Result)Sqlite3.sqlite3_close(db);
+ }
+
+ public static Result BusyTimeout(Sqlite3.sqlite3 db, int milliseconds)
+ {
+ return (Result)Sqlite3.sqlite3_busy_timeout(db, milliseconds);
+ }
+
+ public static int Changes(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_changes(db);
+ }
+
+ public static Sqlite3.Vdbe Prepare2(Sqlite3.sqlite3 db, string query)
+ {
+ Sqlite3.Vdbe stmt = new Sqlite3.Vdbe();
+ var r = Sqlite3.sqlite3_prepare_v2(db, query, query.Length, ref stmt, 0);
+ if (r != 0) {
+ throw SQLiteException.New((Result)r, GetErrmsg(db));
+ }
+ return stmt;
+ }
+
+ public static Result Step(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_step(stmt);
+ }
+
+ public static Result Reset(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_reset(stmt);
+ }
+
+ public static Result Finalize(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_finalize(ref stmt);
+ }
+
+ public static long LastInsertRowid(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_last_insert_rowid(db);
+ }
+
+ public static string GetErrmsg(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_errmsg(db);
+ }
+
+ public static int BindParameterIndex(Sqlite3.Vdbe stmt, string name)
+ {
+ return Sqlite3.sqlite3_bind_parameter_index(stmt, name);
+ }
+
+ public static int BindNull(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_bind_null(stmt, index);
+ }
+
+ public static int BindInt(Sqlite3.Vdbe stmt, int index, int val)
+ {
+ return Sqlite3.sqlite3_bind_int(stmt, index, val);
+ }
+
+ public static int BindInt64(Sqlite3.Vdbe stmt, int index, long val)
+ {
+ return Sqlite3.sqlite3_bind_int64(stmt, index, val);
+ }
+
+ public static int BindDouble(Sqlite3.Vdbe stmt, int index, double val)
+ {
+ return Sqlite3.sqlite3_bind_double(stmt, index, val);
+ }
+
+ public static int BindText(Sqlite3.Vdbe stmt, int index, string val, int n, IntPtr free)
+ {
+ return Sqlite3.sqlite3_bind_text(stmt, index, val, n, null);
+ }
+
+ public static int BindBlob(Sqlite3.Vdbe stmt, int index, byte[] val, int n, IntPtr free)
+ {
+ return Sqlite3.sqlite3_bind_blob(stmt, index, val, n, null);
+ }
+
+ public static int ColumnCount(Sqlite3.Vdbe stmt)
+ {
+ return Sqlite3.sqlite3_column_count(stmt);
+ }
+
+ public static string ColumnName(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_name(stmt, index);
+ }
+
+ public static string ColumnName16(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_name(stmt, index);
+ }
+
+ public static ColType ColumnType(Sqlite3.Vdbe stmt, int index)
+ {
+ return (ColType)Sqlite3.sqlite3_column_type(stmt, index);
+ }
+
+ public static int ColumnInt(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_int(stmt, index);
+ }
+
+ public static long ColumnInt64(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_int64(stmt, index);
+ }
+
+ public static double ColumnDouble(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_double(stmt, index);
+ }
+
+ public static string ColumnText(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static string ColumnText16(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static byte[] ColumnBlob(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_blob(stmt, index);
+ }
+
+ public static int ColumnBytes(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_bytes(stmt, index);
+ }
+
+ public static string ColumnString(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static byte[] ColumnByteArray(Sqlite3.Vdbe stmt, int index)
+ {
+ return ColumnBlob(stmt, index);
+ }
+#endif
+
+ public enum ColType : int {
+ Integer = 1,
+ Float = 2,
+ Text = 3,
+ Blob = 4,
+ Null = 5
+ }
+ }
+
+}
+
diff --git a/TaskyProCloned/Tasky.Core.Cloned/DL/TaskDatabase.cs b/TaskyProCloned/Tasky.Core.Cloned/DL/TaskDatabase.cs
new file mode 100644
index 0000000..4ea921b
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/DL/TaskDatabase.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Linq;
+using Tasky.BL;
+using System.Collections.Generic;
+using Tasky.DL.SQLite;
+
+namespace Tasky.DL
+{
+ ///
+ /// TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB.
+ /// It contains methods for retrieval and persistance as well as db creation, all based on the
+ /// underlying ORM.
+ ///
+ public class TaskDatabase : SQLiteConnection
+ {
+ static object locker = new object ();
+
+ ///
+ /// Initializes a new instance of the TaskDatabase.
+ /// if the database doesn't exist, it will create the database and all the tables.
+ ///
+ ///
+ /// Path.
+ ///
+ public TaskDatabase (string path) : base (path)
+ {
+ // create the tables
+ CreateTable ();
+ }
+
+ public IEnumerable GetItems () where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return (from i in Table () select i).ToList ();
+ }
+ }
+
+ public T GetItem (int id) where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return Table().FirstOrDefault(x => x.ID == id);
+ // Following throws NotSupportedException - thanks aliegeni
+ //return (from i in Table ()
+ // where i.ID == id
+ // select i).FirstOrDefault ();
+ }
+ }
+
+ public int SaveItem (T item) where T : BL.Contracts.IBusinessEntity
+ {
+ lock (locker) {
+ if (item.ID != 0) {
+ Update (item);
+ return item.ID;
+ } else {
+ return Insert (item);
+ }
+ }
+ }
+
+ public int DeleteItem(int id) where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return Delete (new T () { ID = id });
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.Android.Cloned.csproj b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.Android.Cloned.csproj
new file mode 100755
index 0000000..473a06b
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.Android.Cloned.csproj
@@ -0,0 +1,59 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}
+ {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Tasky
+ Assets
+ Resources
+ Tasky.Core.Anroid
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+ false
+ SdkOnly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.WP7.Cloned.csproj b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.WP7.Cloned.csproj
new file mode 100755
index 0000000..1beda15
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.WP7.Cloned.csproj
@@ -0,0 +1,82 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {5E634ED0-7A59-4A39-8415-175034A02C16}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ Tasky
+ Tasky.Core.WP7
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ false
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+ ..\Dependencies\Community.CsharpSqlite\Community.CsharpSqlite.WP7.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.iOS.Cloned.csproj b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.iOS.Cloned.csproj
new file mode 100755
index 0000000..ad0ddeb
--- /dev/null
+++ b/TaskyProCloned/Tasky.Core.Cloned/Tasky.Core.iOS.Cloned.csproj
@@ -0,0 +1,56 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}
+ {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Tasky
+ Tasky.Core
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Adapters/TaskListAdapter.cs b/TaskyProCloned/TaskyAndroid/Adapters/TaskListAdapter.cs
new file mode 100644
index 0000000..734b1bb
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Adapters/TaskListAdapter.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using Android.Widget;
+using Tasky.BL;
+using Android.App;
+using Android;
+
+namespace TaskyAndroid.Adapters {
+ public class TaskListAdapter : BaseAdapter {
+ protected Activity context = null;
+ protected IList tasks = new List();
+
+ public TaskListAdapter (Activity context, IList tasks) : base ()
+ {
+ this.context = context;
+ this.tasks = tasks;
+ }
+
+ public override Task this[int position]
+ {
+ get { return tasks[position]; }
+ }
+
+ public override long GetItemId (int position)
+ {
+ return position;
+ }
+
+ public override int Count
+ {
+ get { return tasks.Count; }
+ }
+
+ public override Android.Views.View GetView (int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
+ {
+ // Get our object for position
+ var item = tasks[position];
+
+ //Try to reuse convertView if it's not null, otherwise inflate it from our item layout
+ // gives us some performance gains by not always inflating a new view
+ // will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell()
+ var view = (convertView ??
+ context.LayoutInflater.Inflate(
+ Android.Resource.Layout.SimpleListItemChecked,
+ parent,
+ false)) as CheckedTextView;
+
+ view.SetText (item.Name==""?"":item.Name, TextView.BufferType.Normal);
+ view.Checked = item.Done;
+
+ //Finally return the view
+ return view;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Assets/AboutAssets.txt b/TaskyProCloned/TaskyAndroid/Assets/AboutAssets.txt
new file mode 100644
index 0000000..ee39886
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Assets/AboutAssets.txt
@@ -0,0 +1,19 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories) and given a Build Action of "AndroidAsset".
+
+These files will be deployed with you package and will be accessible using Android's
+AssetManager, like this:
+
+public class ReadAsset : Activity
+{
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+ InputStream input = Assets.Open ("my_asset.txt");
+ }
+}
+
+Additionally, some Android functions will automatically load asset files:
+
+Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Properties/AndroidManifest.xml b/TaskyProCloned/TaskyAndroid/Properties/AndroidManifest.xml
new file mode 100644
index 0000000..5caeef7
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Properties/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Properties/AssemblyInfo.cs b/TaskyProCloned/TaskyAndroid/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..920873d
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using Android.App;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("TaskyAndroid")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("xamarin")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
+// This app uses the internet, this can be removed if not needed
+[assembly: UsesPermission("android.permission.INTERNET")]
diff --git a/TaskyProCloned/TaskyAndroid/Resources/AboutResources.txt b/TaskyProCloned/TaskyAndroid/Resources/AboutResources.txt
new file mode 100644
index 0000000..10f52d4
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/AboutResources.txt
@@ -0,0 +1,44 @@
+Images, layout descriptions, binary blobs and string dictionaries can be included
+in your application as resource files. Various Android APIs are designed to
+operate on the resource IDs instead of dealing with images, strings or binary blobs
+directly.
+
+For example, a sample Android app that contains a user interface layout (main.axml),
+an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
+would keep its resources in the "Resources" directory of the application:
+
+Resources/
+ drawable/
+ icon.png
+
+ layout/
+ main.axml
+
+ values/
+ strings.xml
+
+In order to get the build system to recognize Android resources, set the build action to
+"AndroidResource". The native Android APIs do not operate directly with filenames, but
+instead operate on resource IDs. When you compile an Android application that uses resources,
+the build system will package the resources for distribution and generate a class called "R"
+(this is an Android convention) that contains the tokens for each one of the resources
+included. For example, for the above Resources layout, this is what the R class would expose:
+
+public class R {
+ public class drawable {
+ public const int icon = 0x123;
+ }
+
+ public class layout {
+ public const int main = 0x456;
+ }
+
+ public class strings {
+ public const int first_string = 0xabc;
+ public const int second_string = 0xbcd;
+ }
+}
+
+You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
+to reference the layout/main.axml file, or R.strings.first_string to reference the first
+string in the dictionary file values/strings.xml.
diff --git a/TaskyProCloned/TaskyAndroid/Resources/drawable-hdpi/launcher.png b/TaskyProCloned/TaskyAndroid/Resources/drawable-hdpi/launcher.png
new file mode 100755
index 0000000..27e8dc1
Binary files /dev/null and b/TaskyProCloned/TaskyAndroid/Resources/drawable-hdpi/launcher.png differ
diff --git a/TaskyProCloned/TaskyAndroid/Resources/drawable-ldpi/launcher.png b/TaskyProCloned/TaskyAndroid/Resources/drawable-ldpi/launcher.png
new file mode 100644
index 0000000..08915d9
Binary files /dev/null and b/TaskyProCloned/TaskyAndroid/Resources/drawable-ldpi/launcher.png differ
diff --git a/TaskyProCloned/TaskyAndroid/Resources/drawable-mdpi/launcher.png b/TaskyProCloned/TaskyAndroid/Resources/drawable-mdpi/launcher.png
new file mode 100644
index 0000000..f784e5c
Binary files /dev/null and b/TaskyProCloned/TaskyAndroid/Resources/drawable-mdpi/launcher.png differ
diff --git a/TaskyProCloned/TaskyAndroid/Resources/drawable-xhdpi/launcher.png b/TaskyProCloned/TaskyAndroid/Resources/drawable-xhdpi/launcher.png
new file mode 100644
index 0000000..32f4a0d
Binary files /dev/null and b/TaskyProCloned/TaskyAndroid/Resources/drawable-xhdpi/launcher.png differ
diff --git a/TaskyProCloned/TaskyAndroid/Resources/drawable/bluebutton.axml b/TaskyProCloned/TaskyAndroid/Resources/drawable/bluebutton.axml
new file mode 100644
index 0000000..d74ebc4
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/drawable/bluebutton.axml
@@ -0,0 +1,61 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Resources/layout/HomeScreen.axml b/TaskyProCloned/TaskyAndroid/Resources/layout/HomeScreen.axml
new file mode 100644
index 0000000..9f74e60
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/layout/HomeScreen.axml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Resources/layout/TaskDetails.axml b/TaskyProCloned/TaskyAndroid/Resources/layout/TaskDetails.axml
new file mode 100644
index 0000000..3a86c12
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/layout/TaskDetails.axml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Resources/layout/TaskListItem.axml b/TaskyProCloned/TaskyAndroid/Resources/layout/TaskListItem.axml
new file mode 100644
index 0000000..707e83c
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/layout/TaskListItem.axml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Resources/values/Strings.xml b/TaskyProCloned/TaskyAndroid/Resources/values/Strings.xml
new file mode 100644
index 0000000..ea47191
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Resources/values/Strings.xml
@@ -0,0 +1,5 @@
+
+
+ Hello World, Click Me!
+ TaskyAndroid
+
diff --git a/TaskyProCloned/TaskyAndroid/Screens/HomeScreen.cs b/TaskyProCloned/TaskyAndroid/Screens/HomeScreen.cs
new file mode 100644
index 0000000..7ef5656
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Screens/HomeScreen.cs
@@ -0,0 +1,70 @@
+using System.Collections.Generic;
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Widget;
+using Tasky.BL;
+using Android.Graphics;
+using Android.Views;
+
+namespace TaskyAndroid.Screens {
+ [Activity (Label = "TaskyPro", MainLauncher = true, Icon="@drawable/launcher")]
+ public class HomeScreen : Activity {
+ protected Adapters.TaskListAdapter taskList;
+ protected IList tasks;
+ protected Button addTaskButton = null;
+ protected ListView taskListView = null;
+
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+
+ View titleView = Window.FindViewById(Android.Resource.Id.Title);
+ if (titleView != null) {
+ IViewParent parent = titleView.Parent;
+ if (parent != null && (parent is View)) {
+ View parentView = (View)parent;
+ parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75 ,0xFF)); //38, 117 ,255
+ }
+ }
+
+
+ // set our layout to be the home screen
+ SetContentView(Resource.Layout.HomeScreen);
+
+ //Find our controls
+ taskListView = FindViewById (Resource.Id.lstTasks);
+ addTaskButton = FindViewById (Resource.Id.btnAddTask);
+
+ // wire up add task button handler
+ if(addTaskButton != null) {
+ addTaskButton.Click += (sender, e) => {
+ StartActivity(typeof(TaskDetailsScreen));
+ };
+ }
+
+ // wire up task click handler
+ if(taskListView != null) {
+ taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
+ var taskDetails = new Intent (this, typeof (TaskDetailsScreen));
+ taskDetails.PutExtra ("TaskID", tasks[e.Position].ID);
+ StartActivity (taskDetails);
+ };
+ }
+ }
+
+ protected override void OnResume ()
+ {
+ base.OnResume ();
+
+ tasks = Tasky.BL.Managers.TaskManager.GetTasks();
+
+ // create our adapter
+ taskList = new Adapters.TaskListAdapter(this, tasks);
+
+ //Hook up our adapter to our ListView
+ taskListView.Adapter = taskList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/Screens/TaskDetailsScreen.cs b/TaskyProCloned/TaskyAndroid/Screens/TaskDetailsScreen.cs
new file mode 100644
index 0000000..9eba316
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/Screens/TaskDetailsScreen.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Widget;
+using Android.Graphics;
+using Android.Views;
+
+using Tasky.BL;
+
+namespace TaskyAndroid.Screens {
+ //TODO: implement proper lifecycle methods
+ [Activity (Label = "Task Details")]
+ public class TaskDetailsScreen : Activity {
+ protected Task task = new Task();
+ protected Button cancelDeleteButton = null;
+ protected EditText notesTextEdit = null;
+ protected EditText nameTextEdit = null;
+ protected Button saveButton = null;
+ CheckBox doneCheckbox;
+
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+ View titleView = Window.FindViewById(Android.Resource.Id.Title);
+ if (titleView != null) {
+ IViewParent parent = titleView.Parent;
+ if (parent != null && (parent is View)) {
+ View parentView = (View)parent;
+ parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75 ,0xFF)); //38, 117 ,255
+ }
+ }
+
+ int taskID = Intent.GetIntExtra("TaskID", 0);
+ if(taskID > 0) {
+ task = Tasky.BL.Managers.TaskManager.GetTask(taskID);
+ }
+
+ // set our layout to be the home screen
+ SetContentView(Resource.Layout.TaskDetails);
+ nameTextEdit = FindViewById(Resource.Id.txtName);
+ notesTextEdit = FindViewById(Resource.Id.txtNotes);
+ saveButton = FindViewById(Resource.Id.btnSave);
+ doneCheckbox = FindViewById(Resource.Id.chkDone);
+
+ // find all our controls
+ cancelDeleteButton = FindViewById(Resource.Id.btnCancelDelete);
+
+
+ // set the cancel delete based on whether or not it's an existing task
+ if(cancelDeleteButton != null)
+ { cancelDeleteButton.Text = (task.ID == 0 ? "Cancel" : "Delete"); }
+
+ // name
+ if(nameTextEdit != null) { nameTextEdit.Text = task.Name; }
+
+ // notes
+ if(notesTextEdit != null) { notesTextEdit.Text = task.Notes; }
+
+ if(doneCheckbox != null) { doneCheckbox.Checked = task.Done; }
+
+ // button clicks
+ cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
+ saveButton.Click += (sender, e) => { Save(); };
+ }
+
+ protected void Save()
+ {
+ task.Name = nameTextEdit.Text;
+ task.Notes = notesTextEdit.Text;
+ task.Done = doneCheckbox.Checked;
+ Tasky.BL.Managers.TaskManager.SaveTask(task);
+ Finish();
+ }
+
+ protected void CancelDelete()
+ {
+ if(task.ID != 0) {
+ Tasky.BL.Managers.TaskManager.DeleteTask(task.ID);
+ }
+ Finish();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyAndroid/TaskyAndroid.csproj b/TaskyProCloned/TaskyAndroid/TaskyAndroid.csproj
new file mode 100755
index 0000000..9d02dd3
--- /dev/null
+++ b/TaskyProCloned/TaskyAndroid/TaskyAndroid.csproj
@@ -0,0 +1,81 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}
+ {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ TaskyAndroid
+ Resources
+ Assets
+ Resource
+ True
+ Resources\Resource.designer.cs
+ TaskyAndroid
+ Properties\AndroidManifest.xml
+ false
+ armeabi%3barmeabi-v7a%3bx86
+
+
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+ SdkOnly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}
+ Tasky.Core.Android.Cloned
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyProCloned.sln b/TaskyProCloned/TaskyProCloned.sln
new file mode 100755
index 0000000..5119df5
--- /dev/null
+++ b/TaskyProCloned/TaskyProCloned.sln
@@ -0,0 +1,99 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyiOS", "TaskyiOS\TaskyiOS.csproj", "{08FAE550-E302-4022-A871-17E0462E99F3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyAndroid", "TaskyAndroid\TaskyAndroid.csproj", "{82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.iOS.Cloned", "Tasky.Core.Cloned\Tasky.Core.iOS.Cloned.csproj", "{3A95B215-DC1A-4A51-A2FD-AB811103F1CE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.Android.Cloned", "Tasky.Core.Cloned\Tasky.Core.Android.Cloned.csproj", "{508E0D21-01E5-4A8C-A09F-AC121EDADEB8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.WP7.Cloned", "Tasky.Core.Cloned\Tasky.Core.WP7.Cloned.csproj", "{5E634ED0-7A59-4A39-8415-175034A02C16}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyWP7", "TaskyWP7\TaskyWP7.csproj", "{8FD09DFC-EE0E-448C-8E0A-6FD727332081}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|iPhone = Debug|iPhone
+ Debug|iPhoneSimulator = Debug|iPhoneSimulator
+ Release|Any CPU = Release|Any CPU
+ Release|iPhone = Release|iPhone
+ Release|iPhoneSimulator = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhone.Build.0 = Debug|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhone.ActiveCfg = Release|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhone.Build.0 = Release|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhone.Build.0 = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhone.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhone.Build.0 = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = TaskyiOS\TaskyiOS.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/TaskyProCloned/TaskyWP7/App.xaml b/TaskyProCloned/TaskyWP7/App.xaml
new file mode 100644
index 0000000..c94aa28
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/App.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/App.xaml.cs b/TaskyProCloned/TaskyWP7/App.xaml.cs
new file mode 100644
index 0000000..289d465
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/App.xaml.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+using Microsoft.Phone.Shell;
+
+namespace TaskyWP7 {
+ public partial class App : Application {
+ ///
+ /// Provides easy access to the root frame of the Phone Application.
+ ///
+ /// The root frame of the Phone Application.
+ public PhoneApplicationFrame RootFrame { get; private set; }
+
+ ///
+ /// Constructor for the Application object.
+ ///
+ public App()
+ {
+ // Global handler for uncaught exceptions.
+ UnhandledException += Application_UnhandledException;
+
+ // Standard Silverlight initialization
+ InitializeComponent();
+
+ // Phone-specific initialization
+ InitializePhoneApplication();
+
+ // Show graphics profiling information while debugging.
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // Display the current frame rate counters.
+ Application.Current.Host.Settings.EnableFrameRateCounter = true;
+
+ // Show the areas of the app that are being redrawn in each frame.
+ //Application.Current.Host.Settings.EnableRedrawRegions = true;
+
+ // Enable non-production analysis visualization mode,
+ // which shows areas of a page that are handed off to GPU with a colored overlay.
+ //Application.Current.Host.Settings.EnableCacheVisualization = true;
+
+ // Disable the application idle detection by setting the UserIdleDetectionMode property of the
+ // application's PhoneApplicationService object to Disabled.
+ // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
+ // and consume battery power when the user is not using the phone.
+ PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
+ }
+
+ }
+
+ // Code to execute when the application is launching (eg, from Start)
+ // This code will not execute when the application is reactivated
+ private void Application_Launching(object sender, LaunchingEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is activated (brought to foreground)
+ // This code will not execute when the application is first launched
+ private void Application_Activated(object sender, ActivatedEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is deactivated (sent to background)
+ // This code will not execute when the application is closing
+ private void Application_Deactivated(object sender, DeactivatedEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is closing (eg, user hit Back)
+ // This code will not execute when the application is deactivated
+ private void Application_Closing(object sender, ClosingEventArgs e)
+ {
+ }
+
+ // Code to execute if a navigation fails
+ private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // A navigation has failed; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ // Code to execute on Unhandled Exceptions
+ private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // An unhandled exception has occurred; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ #region Phone application initialization
+
+ // Avoid double-initialization
+ private bool phoneApplicationInitialized = false;
+
+ // Do not add any additional code to this method
+ private void InitializePhoneApplication()
+ {
+ if (phoneApplicationInitialized)
+ return;
+
+ // Create the frame but don't set it as RootVisual yet; this allows the splash
+ // screen to remain active until the application is ready to render.
+ RootFrame = new PhoneApplicationFrame();
+ RootFrame.Navigated += CompleteInitializePhoneApplication;
+
+ // Handle navigation failures
+ RootFrame.NavigationFailed += RootFrame_NavigationFailed;
+
+ // Ensure we don't initialize again
+ phoneApplicationInitialized = true;
+ }
+
+ // Do not add any additional code to this method
+ private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
+ {
+ // Set the root visual to allow the application to render
+ if (RootVisual != RootFrame)
+ RootVisual = RootFrame;
+
+ // Remove this handler since it is no longer needed
+ RootFrame.Navigated -= CompleteInitializePhoneApplication;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/ApplicationIcon.png b/TaskyProCloned/TaskyWP7/ApplicationIcon.png
new file mode 100644
index 0000000..5859393
Binary files /dev/null and b/TaskyProCloned/TaskyWP7/ApplicationIcon.png differ
diff --git a/TaskyProCloned/TaskyWP7/Background.png b/TaskyProCloned/TaskyWP7/Background.png
new file mode 100644
index 0000000..e46f21d
Binary files /dev/null and b/TaskyProCloned/TaskyWP7/Background.png differ
diff --git a/TaskyProCloned/TaskyWP7/MainPage.xaml b/TaskyProCloned/TaskyWP7/MainPage.xaml
new file mode 100644
index 0000000..08ef33f
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/MainPage.xaml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/MainPage.xaml.cs b/TaskyProCloned/TaskyWP7/MainPage.xaml.cs
new file mode 100644
index 0000000..e5cf3d3
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/MainPage.xaml.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+
+namespace TaskyWP7 {
+ public partial class MainPage : PhoneApplicationPage {
+ // Constructor
+ public MainPage()
+ {
+ InitializeComponent();
+
+ DataContext = new TaskListViewModel();
+ Loaded += new RoutedEventHandler(MainPage_Loaded);
+ }
+
+ void MainPage_Loaded(object sender, RoutedEventArgs e)
+ {
+ ((TaskListViewModel)DataContext).BeginUpdate(Dispatcher);
+ }
+
+ private void HandleAdd(object sender, EventArgs e)
+ {
+ NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=-1", UriKind.RelativeOrAbsolute));
+ }
+
+ private void HandleTaskTap(object sender, System.Windows.Input.GestureEventArgs e)
+ {
+ var item = ((Grid)sender).DataContext as TaskViewModel;
+
+ if (item != null) {
+ NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=" + item.ID, UriKind.RelativeOrAbsolute));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/Properties/AppManifest.xml b/TaskyProCloned/TaskyWP7/Properties/AppManifest.xml
new file mode 100644
index 0000000..6712a11
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/Properties/AppManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/TaskyProCloned/TaskyWP7/Properties/AssemblyInfo.cs b/TaskyProCloned/TaskyWP7/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..83c0351
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/Properties/AssemblyInfo.cs
@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TaskyWP7")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TaskyWP7")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("34fa2e2e-440b-4778-abf7-4d5d09dcff14")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/TaskyProCloned/TaskyWP7/Properties/WMAppManifest.xml b/TaskyProCloned/TaskyWP7/Properties/WMAppManifest.xml
new file mode 100644
index 0000000..70be6bd
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/Properties/WMAppManifest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ ApplicationIcon.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Background.png
+ 0
+ TaskyWP7
+
+
+
+
+
diff --git a/TaskyProCloned/TaskyWP7/SplashScreenImage.jpg b/TaskyProCloned/TaskyWP7/SplashScreenImage.jpg
new file mode 100644
index 0000000..353b192
Binary files /dev/null and b/TaskyProCloned/TaskyWP7/SplashScreenImage.jpg differ
diff --git a/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml b/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml
new file mode 100644
index 0000000..d610c0e
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml.cs b/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml.cs
new file mode 100644
index 0000000..9e62d64
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/TaskDetailsPage.xaml.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+using Tasky.BL.Managers;
+using Tasky.BL;
+
+namespace TaskyWP7 {
+ public partial class TaskDetailsPage : PhoneApplicationPage {
+ public TaskDetailsPage()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New) {
+ var vm = new TaskViewModel();
+ var task = default(Task);
+
+ if (NavigationContext.QueryString.ContainsKey("id")) {
+ var id = int.Parse(NavigationContext.QueryString["id"]);
+ task = TaskManager.GetTask(id);
+ }
+
+ if (task != null) {
+ vm.Update(task);
+ }
+
+ DataContext = vm;
+ }
+ }
+
+ private void HandleSave(object sender, EventArgs e)
+ {
+ var taskvm = (TaskViewModel)DataContext;
+ var task = taskvm.GetTask();
+ TaskManager.SaveTask(task);
+ }
+
+ private void HandleDelete(object sender, EventArgs e)
+ {
+ var taskvm = (TaskViewModel)DataContext;
+ if (taskvm.ID >= 0)
+ TaskManager.DeleteTask(taskvm.ID);
+
+ NavigationService.GoBack();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/TaskyWP7.csproj b/TaskyProCloned/TaskyWP7/TaskyWP7.csproj
new file mode 100755
index 0000000..0f0c4d7
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/TaskyWP7.csproj
@@ -0,0 +1,124 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ TaskyWP7
+ TaskyWP7
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ true
+
+
+ true
+ true
+ TaskyWP7.xap
+ Properties\AppManifest.xml
+ TaskyWP7.App
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+
+ ..\Dependencies\Microsoft.Phone.Controls.Toolkit\Microsoft.Phone.Controls.Toolkit.dll
+
+
+
+
+
+
+
+
+
+
+
+ App.xaml
+
+
+ MainPage.xaml
+
+
+
+ TaskDetailsPage.xaml
+
+
+
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+ {5E634ED0-7A59-4A39-8415-175034A02C16}
+ Tasky.Core.WP7.Cloned
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyWP7/ViewModels/TaskListViewModel.cs b/TaskyProCloned/TaskyWP7/ViewModels/TaskListViewModel.cs
new file mode 100644
index 0000000..8665697
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/ViewModels/TaskListViewModel.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.ComponentModel;
+using System.Windows.Threading;
+using Tasky.BL;
+using System.Collections.ObjectModel;
+using Tasky.BL.Managers;
+using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace TaskyWP7 {
+ public class TaskListViewModel : ViewModelBase {
+
+ public ObservableCollection Items { get; private set; }
+
+ public bool IsUpdating { get; set; }
+ public Visibility ListVisibility { get; set; }
+ public Visibility NoDataVisibility { get; set; }
+
+ public Visibility UpdatingVisibility
+ {
+ get
+ {
+ return (IsUpdating || Items == null || Items.Count == 0) ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+
+ Dispatcher dispatcher;
+
+ public void BeginUpdate(Dispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+
+ IsUpdating = true;
+
+ ThreadPool.QueueUserWorkItem(delegate {
+ var entries = TaskManager.GetTasks();
+ PopulateData(entries);
+ });
+ }
+
+ void PopulateData(IEnumerable entries)
+ {
+ dispatcher.BeginInvoke(delegate {
+ //
+ // Set all the news items
+ //
+ Items = new ObservableCollection(
+ from e in entries
+ select new TaskViewModel(e));
+
+ //
+ // Update the properties
+ //
+ OnPropertyChanged("Items");
+
+ ListVisibility = Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
+ NoDataVisibility = Items.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
+
+ OnPropertyChanged("ListVisibility");
+ OnPropertyChanged("NoDataVisibility");
+ OnPropertyChanged("IsUpdating");
+ OnPropertyChanged("UpdatingVisibility");
+ });
+ }
+
+
+
+ }
+}
diff --git a/TaskyProCloned/TaskyWP7/ViewModels/TaskViewModel.cs b/TaskyProCloned/TaskyWP7/ViewModels/TaskViewModel.cs
new file mode 100644
index 0000000..57d2d55
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/ViewModels/TaskViewModel.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Tasky.BL;
+
+namespace TaskyWP7 {
+ public class TaskViewModel : ViewModelBase {
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Notes { get; set; }
+ public bool Done { get; set; }
+
+ public TaskViewModel ()
+ {
+ }
+ public TaskViewModel (Task item)
+ {
+ Update (item);
+ }
+
+ public void Update (Task item)
+ {
+ ID = item.ID;
+ Name = item.Name;
+ Notes = item.Notes;
+ Done = item.Done;
+ }
+
+ public Task GetTask() {
+ return new Task {
+ ID = this.ID,
+ Name = this.Name,
+ Notes = this.Notes,
+ Done = this.Done
+ };
+ }
+ }
+}
diff --git a/TaskyProCloned/TaskyWP7/ViewModels/ViewModelBase.cs b/TaskyProCloned/TaskyWP7/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..4f2c49c
--- /dev/null
+++ b/TaskyProCloned/TaskyWP7/ViewModels/ViewModelBase.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.ComponentModel;
+
+namespace TaskyWP7 {
+ public class ViewModelBase : INotifyPropertyChanged {
+
+#region IPropertyChanged
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null) {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+#endregion
+ }
+}
diff --git a/TaskyProCloned/TaskyiOS/AL/EditingSource.cs b/TaskyProCloned/TaskyiOS/AL/EditingSource.cs
new file mode 100644
index 0000000..7460aee
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/AL/EditingSource.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+using MonoTouch.Foundation;
+using Tasky.BL;
+
+namespace Tasky.AL
+{
+ // This is our subclass of the fixed-size Source that allows editing
+ public class EditingSource : DialogViewController.Source {
+ public EditingSource (DialogViewController dvc) : base (dvc) {}
+
+ public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath)
+ {
+ // Trivial implementation: we let all rows be editable, regardless of section or row
+ return true;
+ }
+
+ public override UITableViewCellEditingStyle EditingStyleForRow (UITableView tableView, NSIndexPath indexPath)
+ {
+ // trivial implementation: show a delete button always
+ return UITableViewCellEditingStyle.Delete;
+ }
+
+ public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
+ {
+ //
+ // In this method, we need to actually carry out the request
+ //
+ var section = Container.Root [indexPath.Section];
+ var element = section [indexPath.Row] as StringElement;
+ section.Remove (element);
+
+ var dvc = Container as Tasky.Screens.iPhone.Home.controller_iPhone;
+ dvc.DeleteTaskRow (indexPath.Row);
+ }
+ }
+}
+
diff --git a/TaskyProCloned/TaskyiOS/AL/LocalizableBindingContext.cs b/TaskyProCloned/TaskyiOS/AL/LocalizableBindingContext.cs
new file mode 100644
index 0000000..fef2ccc
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/AL/LocalizableBindingContext.cs
@@ -0,0 +1,401 @@
+//
+// Reflect.cs: Creates Element classes from an instance
+//
+// Author:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// Copyright 2010, Novell, Inc.
+//
+// Code licensed under the MIT X11 license
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using MonoTouch.UIKit;
+using System.Drawing;
+using MonoTouch.Foundation;
+using MonoTouch.Dialog;
+
+/*
+ Cloned from https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/MonoTouch.Dialog/Reflect.cs
+ to add localization ability. Unfortunately RootElement.group is marked 'internal' in MonoTouch.Dialog
+ so this implementation is missing RadioGroup functionality ~ scroll to the end of the file to see
+ the commented-out lines.
+
+ Patch to original file
+ https://github.com/conceptdev/MonoTouch.Dialog/commit/74a7898861d542b367af3b98b7d84079f08926f4
+ */
+namespace MonoTouch.Dialog
+{
+ [AttributeUsage (AttributeTargets.Field | AttributeTargets.Property, Inherited=false)]
+ public class LocalizeAttribute : Attribute {}
+
+ public class LocalizableBindingContext : IDisposable {
+ public RootElement Root;
+ Dictionary mappings;
+
+ class MemberAndInstance {
+ public MemberAndInstance (MemberInfo mi, object o)
+ {
+ Member = mi;
+ Obj = o;
+ }
+ public MemberInfo Member;
+ public object Obj;
+ }
+
+ static object GetValue (MemberInfo mi, object o)
+ {
+ var fi = mi as FieldInfo;
+ if (fi != null)
+ return fi.GetValue (o);
+ var pi = mi as PropertyInfo;
+
+ var getMethod = pi.GetGetMethod ();
+ return getMethod.Invoke (o, new object [0]);
+ }
+
+ static void SetValue (MemberInfo mi, object o, object val)
+ {
+ var fi = mi as FieldInfo;
+ if (fi != null){
+ fi.SetValue (o, val);
+ return;
+ }
+ var pi = mi as PropertyInfo;
+ var setMethod = pi.GetSetMethod ();
+ setMethod.Invoke (o, new object [] { val });
+ }
+
+ static string MakeCaption (string name)
+ {
+ var sb = new StringBuilder (name.Length);
+ bool nextUp = true;
+
+ foreach (char c in name){
+ if (nextUp){
+ sb.Append (Char.ToUpper (c));
+ nextUp = false;
+ } else {
+ if (c == '_'){
+ sb.Append (' ');
+ continue;
+ }
+ if (Char.IsUpper (c))
+ sb.Append (' ');
+ sb.Append (c);
+ }
+ }
+ return sb.ToString ();
+ }
+
+ // Returns the type for fields and properties and null for everything else
+ static Type GetTypeForMember (MemberInfo mi)
+ {
+ if (mi is FieldInfo)
+ return ((FieldInfo) mi).FieldType;
+ else if (mi is PropertyInfo)
+ return ((PropertyInfo) mi).PropertyType;
+ return null;
+ }
+
+ public LocalizableBindingContext (object callbacks, object o, string title)
+ {
+ if (o == null)
+ throw new ArgumentNullException ("o");
+
+ mappings = new Dictionary ();
+
+ Root = new RootElement (title);
+ Populate (callbacks, o, Root);
+ }
+
+ void Populate (object callbacks, object o, RootElement root)
+ {
+ MemberInfo last_radio_index = null;
+ var members = o.GetType ().GetMembers (BindingFlags.DeclaredOnly | BindingFlags.Public |
+ BindingFlags.NonPublic | BindingFlags.Instance
+ );
+
+ Section section = null;
+
+ foreach (var mi in members) {
+ Type mType = GetTypeForMember (mi);
+
+ if (mType == null)
+ continue;
+
+ string caption = null;
+ string key = null; // l18n
+ object [] attrs = mi.GetCustomAttributes (false);
+ bool skip = false;
+ bool localize = false;
+ foreach (var attr in attrs) {
+ if (attr is LocalizeAttribute) {
+ localize = true;
+ break;
+ }
+ }
+ foreach (var attr in attrs) {
+ if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
+ skip = true;
+ else if (attr is CaptionAttribute) {
+ caption = ((CaptionAttribute)attr).Caption;
+ if (localize)
+ caption = NSBundle.MainBundle.LocalizedString (caption, caption);
+ } else if (attr is SectionAttribute) {
+ if (section != null)
+ root.Add (section);
+ var sa = attr as SectionAttribute;
+ var header = sa.Caption;
+ var footer = sa.Footer;
+ if (localize) {
+ header = NSBundle.MainBundle.LocalizedString (header, header);
+ footer = NSBundle.MainBundle.LocalizedString (footer, footer);
+ }
+ section = new Section (header, footer);
+ }
+ }
+ if (skip)
+ continue;
+
+ if (caption == null) {
+ caption = MakeCaption (mi.Name);
+ if (localize)
+ caption = NSBundle.MainBundle.LocalizedString (caption, caption);
+ }
+
+ if (section == null)
+ section = new Section ();
+
+ Element element = null;
+ if (mType == typeof(string)) {
+ PasswordAttribute pa = null;
+ AlignmentAttribute align = null;
+ EntryAttribute ea = null;
+ object html = null;
+ NSAction invoke = null;
+ bool multi = false;
+
+ foreach (object attr in attrs) {
+ if (attr is PasswordAttribute)
+ pa = attr as PasswordAttribute;
+ else if (attr is EntryAttribute)
+ ea = attr as EntryAttribute;
+ else if (attr is MultilineAttribute)
+ multi = true;
+ else if (attr is HtmlAttribute)
+ html = attr;
+ else if (attr is AlignmentAttribute)
+ align = attr as AlignmentAttribute;
+
+ if (attr is OnTapAttribute) {
+ string mname = ((OnTapAttribute)attr).Method;
+
+ if (callbacks == null) {
+ throw new Exception ("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor");
+ }
+
+ var method = callbacks.GetType ().GetMethod (mname);
+ if (method == null)
+ throw new Exception ("Did not find method " + mname);
+ invoke = delegate {
+ method.Invoke (method.IsStatic ? null : callbacks, new object [0]);
+ };
+ }
+ }
+
+
+
+ string value = (string)GetValue (mi, o);
+ if (pa != null) {
+ var placeholder = pa.Placeholder;
+ if (localize)
+ placeholder = NSBundle.MainBundle.LocalizedString (placeholder, placeholder);
+ element = new EntryElement (caption, placeholder, value, true);
+ } else if (ea != null) {
+ var placeholder = ea.Placeholder;
+ if (localize)
+ placeholder = NSBundle.MainBundle.LocalizedString (placeholder, placeholder);
+ element = new EntryElement (caption, placeholder, value) { KeyboardType = ea.KeyboardType, AutocapitalizationType = ea.AutocapitalizationType, AutocorrectionType = ea.AutocorrectionType, ClearButtonMode = ea.ClearButtonMode };
+ } else if (multi)
+ element = new MultilineElement (caption, value);
+ else if (html != null)
+ element = new HtmlElement (caption, value);
+ else {
+ var selement = new StringElement (caption, value);
+ element = selement;
+
+ if (align != null)
+ selement.Alignment = align.Alignment;
+ }
+
+ if (invoke != null)
+ ((StringElement)element).Tapped += invoke;
+ } else if (mType == typeof(float)) {
+ var floatElement = new FloatElement (null, null, (float)GetValue (mi, o));
+ floatElement.Caption = caption;
+ element = floatElement;
+
+ foreach (object attr in attrs) {
+ if (attr is RangeAttribute) {
+ var ra = attr as RangeAttribute;
+ floatElement.MinValue = ra.Low;
+ floatElement.MaxValue = ra.High;
+ floatElement.ShowCaption = ra.ShowCaption;
+ }
+ }
+ } else if (mType == typeof(bool)) {
+ bool checkbox = false;
+ foreach (object attr in attrs) {
+ if (attr is CheckboxAttribute)
+ checkbox = true;
+ }
+
+ if (checkbox)
+ element = new CheckboxElement (caption, (bool)GetValue (mi, o));
+ else
+ element = new BooleanElement (caption, (bool)GetValue (mi, o));
+ } else if (mType == typeof(DateTime)) {
+ var dateTime = (DateTime)GetValue (mi, o);
+ bool asDate = false, asTime = false;
+
+ foreach (object attr in attrs) {
+ if (attr is DateAttribute)
+ asDate = true;
+ else if (attr is TimeAttribute)
+ asTime = true;
+ }
+
+ if (asDate)
+ element = new DateElement (caption, dateTime);
+ else if (asTime)
+ element = new TimeElement (caption, dateTime);
+ else
+ element = new DateTimeElement (caption, dateTime);
+ } else if (mType.IsEnum) {
+ var csection = new Section ();
+ ulong evalue = Convert.ToUInt64 (GetValue (mi, o), null);
+ int idx = 0;
+ int selected = 0;
+
+ foreach (var fi in mType.GetFields (BindingFlags.Public | BindingFlags.Static)) {
+ ulong v = Convert.ToUInt64 (GetValue (fi, null));
+
+ if (v == evalue)
+ selected = idx;
+
+ CaptionAttribute ca = Attribute.GetCustomAttribute (fi, typeof(CaptionAttribute)) as CaptionAttribute;
+ var cap = ca != null ? ca.Caption : MakeCaption (fi.Name);
+ if (localize)
+ NSBundle.MainBundle.LocalizedString (cap, cap);
+ csection.Add (new RadioElement (cap));
+ idx++;
+ }
+
+ element = new RootElement (caption, new RadioGroup (null, selected)) { csection };
+ } else if (mType == typeof (UIImage)){
+ element = new ImageElement ((UIImage) GetValue (mi, o));
+ } else if (typeof (System.Collections.IEnumerable).IsAssignableFrom (mType)){
+ var csection = new Section ();
+ int count = 0;
+
+ if (last_radio_index == null)
+ throw new Exception ("IEnumerable found, but no previous int found");
+ foreach (var e in (IEnumerable) GetValue (mi, o)){
+ csection.Add (new RadioElement (e.ToString ()));
+ count++;
+ }
+ int selected = (int) GetValue (last_radio_index, o);
+ if (selected >= count || selected < 0)
+ selected = 0;
+ element = new RootElement (caption, new MemberRadioGroup (null, selected, last_radio_index)) { csection };
+ last_radio_index = null;
+ } else if (typeof (int) == mType){
+ foreach (object attr in attrs){
+ if (attr is RadioSelectionAttribute){
+ last_radio_index = mi;
+ break;
+ }
+ }
+ } else {
+ var nested = GetValue (mi, o);
+ if (nested != null){
+ var newRoot = new RootElement (caption);
+ Populate (callbacks, nested, newRoot);
+ element = newRoot;
+ }
+ }
+
+ if (element == null)
+ continue;
+ section.Add (element);
+ mappings [element] = new MemberAndInstance (mi, o);
+ }
+ root.Add (section);
+ }
+
+ class MemberRadioGroup : RadioGroup {
+ public MemberInfo mi;
+
+ public MemberRadioGroup (string key, int selected, MemberInfo mi) : base (key, selected)
+ {
+ this.mi = mi;
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (disposing){
+ foreach (var element in mappings.Keys){
+ element.Dispose ();
+ }
+ mappings = null;
+ }
+ }
+
+ public void Fetch ()
+ {
+ foreach (var dk in mappings){
+ Element element = dk.Key;
+ MemberInfo mi = dk.Value.Member;
+ object obj = dk.Value.Obj;
+
+ if (element is DateTimeElement)
+ SetValue (mi, obj, ((DateTimeElement) element).DateValue);
+ else if (element is FloatElement)
+ SetValue (mi, obj, ((FloatElement) element).Value);
+ else if (element is BooleanElement)
+ SetValue (mi, obj, ((BooleanElement) element).Value);
+ else if (element is CheckboxElement)
+ SetValue (mi, obj, ((CheckboxElement) element).Value);
+ else if (element is EntryElement){
+ var entry = (EntryElement) element;
+ entry.FetchValue ();
+ SetValue (mi, obj, entry.Value);
+ } else if (element is ImageElement)
+ SetValue (mi, obj, ((ImageElement) element).Value);
+ else if (element is RootElement){
+//HACK: RootElement.group is INTERNAL
+// var re = element as RootElement;
+// if (re.group as MemberRadioGroup != null){
+// var group = re.group as MemberRadioGroup;
+// SetValue (group.mi, obj, re.RadioSelected);
+// } else if (re.group as RadioGroup != null){
+// var mType = GetTypeForMember (mi);
+// var fi = mType.GetFields (BindingFlags.Public | BindingFlags.Static) [re.RadioSelected];
+//
+// SetValue (mi, obj, fi.GetValue (null));
+// }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/AL/TaskDialog.cs b/TaskyProCloned/TaskyiOS/AL/TaskDialog.cs
new file mode 100644
index 0000000..0114123
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/AL/TaskDialog.cs
@@ -0,0 +1,45 @@
+using System;
+using MonoTouch.UIKit;
+using Tasky.BL;
+using MonoTouch.Dialog;
+
+namespace Tasky {
+ ///
+ /// Wrapper class for Task, to use with MonoTouch.Dialog. If it was just iOS platform
+ /// we could apply these attributes directly to the Task class, but because we share that
+ /// with other platforms this wrapper provides a bridge to MonoTouch.Dialog.
+ ///
+ public class TaskDialog {
+ public TaskDialog (Task task)
+ {
+ Name = task.Name;
+ Notes = task.Notes;
+ Done = task.Done;
+ }
+
+ [Localize]
+ [Entry("task name")]
+ public string Name { get; set; }
+
+ [Localize]
+ [Entry("other task info")]
+ public string Notes { get; set; }
+
+ // new property
+ [Localize]
+ [Entry("Done")]
+ public bool Done { get; set; }
+
+ [Localize]
+ [Section ("")]
+ [OnTap ("SaveTask")]
+ [Alignment (UITextAlignment.Center)]
+ public string Save;
+
+ [Localize]
+ [Section ("")]
+ [OnTap ("DeleteTask")]
+ [Alignment (UITextAlignment.Center)]
+ public string Delete;
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/AppDelegate.cs b/TaskyProCloned/TaskyiOS/AppDelegate.cs
new file mode 100644
index 0000000..aa7f321
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/AppDelegate.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace Tasky {
+ [Register ("AppDelegate")]
+ public partial class AppDelegate : UIApplicationDelegate {
+ // class-level declarations
+ UIWindow window;
+ UINavigationController navController;
+ UITableViewController homeViewController;
+
+ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
+ {
+ // create a new window instance based on the screen size
+ window = new UIWindow (UIScreen.MainScreen.Bounds);
+
+ // make the window visible
+ window.MakeKeyAndVisible ();
+
+ // create our nav controller
+ navController = new UINavigationController ();
+
+ // create our home controller based on the device
+ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
+ homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
+ } else {
+// homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
+ }
+
+ // Styling
+ UINavigationBar.Appearance.TintColor = UIColor.FromRGB (38, 117 ,255); // nice blue
+ UITextAttributes ta = new UITextAttributes();
+ ta.Font = UIFont.FromName ("AmericanTypewriter-Bold", 0f);
+ UINavigationBar.Appearance.SetTitleTextAttributes(ta);
+ ta.Font = UIFont.FromName ("AmericanTypewriter", 0f);
+ UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);
+
+
+ // push the view controller onto the nav controller and show the window
+ navController.PushViewController(homeViewController, false);
+ window.RootViewController = navController;
+ window.MakeKeyAndVisible ();
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/Default-Landscape~ipad.png b/TaskyProCloned/TaskyiOS/Default-Landscape~ipad.png
new file mode 100755
index 0000000..5f9c39d
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Default-Landscape~ipad.png differ
diff --git a/TaskyProCloned/TaskyiOS/Default-Portrait~ipad.png b/TaskyProCloned/TaskyiOS/Default-Portrait~ipad.png
new file mode 100755
index 0000000..3a71820
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Default-Portrait~ipad.png differ
diff --git a/TaskyProCloned/TaskyiOS/Default.png b/TaskyProCloned/TaskyiOS/Default.png
new file mode 100755
index 0000000..f7bb4d9
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Default.png differ
diff --git a/TaskyProCloned/TaskyiOS/Default@2x.png b/TaskyProCloned/TaskyiOS/Default@2x.png
new file mode 100755
index 0000000..898f3a3
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Default@2x.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/114_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/114_icon.png
new file mode 100755
index 0000000..dcccfe6
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/114_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/29_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/29_icon.png
new file mode 100755
index 0000000..562cece
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/29_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/50_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/50_icon.png
new file mode 100755
index 0000000..f82972f
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/50_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/512_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/512_icon.png
new file mode 100755
index 0000000..dd7f8cd
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/512_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/57_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/57_icon.png
new file mode 100755
index 0000000..1a51d34
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/57_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/58_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/58_icon.png
new file mode 100755
index 0000000..0c2a723
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/58_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Images/Icons/72_icon.png b/TaskyProCloned/TaskyiOS/Images/Icons/72_icon.png
new file mode 100755
index 0000000..27e8dc1
Binary files /dev/null and b/TaskyProCloned/TaskyiOS/Images/Icons/72_icon.png differ
diff --git a/TaskyProCloned/TaskyiOS/Info.plist b/TaskyProCloned/TaskyiOS/Info.plist
new file mode 100644
index 0000000..50301d8
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/Info.plist
@@ -0,0 +1,40 @@
+
+
+
+
+ CFBundleDisplayName
+ Tasky
+ CFBundleIconFiles
+
+ Images/Icons/57_icon.png
+ Images/Icons/114_icon.png
+ Images/Icons/72_icon.png
+ Images/Icons/29_icon.png
+ Images/Icons/58_icon.png
+ Images/Icons/50_icon.png
+ Images/Icons/512_icon.png
+
+ CFBundleIdentifier
+ com.xamarin.samples.taskytouch
+ CFBundleVersion
+ 1
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/TaskyProCloned/TaskyiOS/Main.cs b/TaskyProCloned/TaskyiOS/Main.cs
new file mode 100644
index 0000000..2bdab5f
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/Main.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace Tasky {
+ public class Application {
+ // This is the main entry point of the application.
+ static void Main (string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main (args, null, "AppDelegate");
+ }
+ }
+}
diff --git a/TaskyProCloned/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs b/TaskyProCloned/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs
new file mode 100644
index 0000000..7e0e89e
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+using Tasky.AL;
+using Tasky.BL;
+
+namespace Tasky.Screens.iPhone.Home {
+ public class controller_iPhone : DialogViewController {
+ List tasks;
+
+ public controller_iPhone () : base (UITableViewStyle.Plain, null)
+ {
+ Initialize ();
+ }
+
+ protected void Initialize()
+ {
+ NavigationItem.SetRightBarButtonItem (new UIBarButtonItem (UIBarButtonSystemItem.Add), false);
+ NavigationItem.RightBarButtonItem.Clicked += (sender, e) => { ShowTaskDetails(new Task()); };
+ }
+
+
+ // MonoTouch.Dialog individual TaskDetails view (uses /AL/TaskDialog.cs wrapper class)
+ LocalizableBindingContext context;
+ TaskDialog taskDialog;
+ Task currentTask;
+ DialogViewController detailsScreen;
+ protected void ShowTaskDetails (Task task)
+ {
+ currentTask = task;
+ taskDialog = new TaskDialog (task);
+
+ var title = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Task Details", "Task Details");
+ context = new LocalizableBindingContext (this, taskDialog, title);
+ detailsScreen = new DialogViewController (context.Root, true);
+ ActivateController(detailsScreen);
+ }
+ public void SaveTask()
+ {
+ context.Fetch (); // re-populates with updated values
+ currentTask.Name = taskDialog.Name;
+ currentTask.Notes = taskDialog.Notes;
+ currentTask.Done = taskDialog.Done;
+ BL.Managers.TaskManager.SaveTask(currentTask);
+ NavigationController.PopViewControllerAnimated (true);
+ context.Dispose (); // per documentation
+ }
+ public void DeleteTask ()
+ {
+ if (currentTask.ID >= 0)
+ BL.Managers.TaskManager.DeleteTask (currentTask.ID);
+ NavigationController.PopViewControllerAnimated (true);
+ }
+
+
+
+ public override void ViewWillAppear (bool animated)
+ {
+ base.ViewWillAppear (animated);
+
+ // reload/refresh
+ PopulateTable();
+ }
+
+ protected void PopulateTable ()
+ {
+ tasks = BL.Managers.TaskManager.GetTasks ().ToList ();
+ var newTask = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("", "");
+ Root = new RootElement ("Tasky") {
+ new Section() {
+ from t in tasks
+ select (Element) new CheckboxElement((t.Name==""?newTask:t.Name), t.Done)
+ }
+ };
+ }
+ public override void Selected (MonoTouch.Foundation.NSIndexPath indexPath)
+ {
+ var task = tasks[indexPath.Row];
+ ShowTaskDetails(task);
+ }
+ public override Source CreateSizingSource (bool unevenRows)
+ {
+ return new EditingSource (this);
+ }
+ public void DeleteTaskRow(int rowId)
+ {
+ BL.Managers.TaskManager.DeleteTask(tasks[rowId].ID);
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/TaskyiOS.csproj b/TaskyProCloned/TaskyiOS/TaskyiOS.csproj
new file mode 100755
index 0000000..937b3f6
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/TaskyiOS.csproj
@@ -0,0 +1,97 @@
+
+
+
+ Debug
+ iPhoneSimulator
+ 10.0.0
+ 2.0
+ {08FAE550-E302-4022-A871-17E0462E99F3}
+ {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Exe
+ Tasky
+ Tasky
+
+
+ true
+ full
+ false
+ bin\iPhoneSimulator\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+ true
+
+
+ none
+ false
+ bin\iPhoneSimulator\Release
+ prompt
+ 4
+ false
+ None
+
+
+ true
+ full
+ false
+ bin\iPhone\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ true
+ iPhone Developer
+
+
+ none
+ false
+ bin\iPhone\Release
+ prompt
+ 4
+ false
+ iPhone Developer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}
+ Tasky.Core.iOS.Cloned
+
+
+
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/en.lproj/Localizable.strings b/TaskyProCloned/TaskyiOS/en.lproj/Localizable.strings
new file mode 100644
index 0000000..f5f97ee
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/en.lproj/Localizable.strings
@@ -0,0 +1,11 @@
+
+"" = "";
+
+"Task Details" = "Task Details";
+"Name" = "Name";
+"task name" = "task name";
+"Notes" = "Notes";
+"other task info"= "other task info";
+"Done" = "Done";
+"Save" = "Save";
+"Delete" = "Delete";
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/es.lproj/Localizable.strings b/TaskyProCloned/TaskyiOS/es.lproj/Localizable.strings
new file mode 100644
index 0000000..9552d2e
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/es.lproj/Localizable.strings
@@ -0,0 +1,12 @@
+/* MACHINE TRANSLATION : apologies for any mistakes */
+
+"" = "";
+
+"Task Details" = "Detalles de la tarea";
+"Name" = "Nombre";
+"task name" = "nombre de la tarea";
+"Notes" = "Notas";
+"other task info"= "otra información de tarea";
+"Done" = "Completo";
+"Save" = "Guardar";
+"Delete" = "Eliminar";
\ No newline at end of file
diff --git a/TaskyProCloned/TaskyiOS/ja.lproj/Localizable.strings b/TaskyProCloned/TaskyiOS/ja.lproj/Localizable.strings
new file mode 100644
index 0000000..0b30012
--- /dev/null
+++ b/TaskyProCloned/TaskyiOS/ja.lproj/Localizable.strings
@@ -0,0 +1,12 @@
+/* MACHINE TRANSLATION : apologies for any mistakes */
+
+"" = "<新しいタスク>";
+
+"Task Details" = "タスクの詳細";
+"Name" = "タイトル";
+"task name" = "タスク名";
+"Notes" = "注釈";
+"other task info"= "他のタスクの情報";
+"Done" = "削除する";
+"Save" = "はい";
+"Delete" = "削除する";
\ No newline at end of file
diff --git a/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll b/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll
new file mode 100644
index 0000000..80a162f
Binary files /dev/null and b/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll differ
diff --git a/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb b/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb
new file mode 100644
index 0000000..2575615
Binary files /dev/null and b/TaskyProLinked/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb differ
diff --git a/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll b/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll
new file mode 100644
index 0000000..44d59b1
Binary files /dev/null and b/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll differ
diff --git a/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb b/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb
new file mode 100644
index 0000000..ac620fd
Binary files /dev/null and b/TaskyProLinked/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb differ
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/About.txt b/TaskyProLinked/Tasky.Core.Android.Source/About.txt
new file mode 100644
index 0000000..205d076
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/About.txt
@@ -0,0 +1,3 @@
+The Tasky.Core library is the reusable portion of the Tasky application. It contains the Business
+Layer (BL), Data Access Layer (DAL), and Data Layer (DL). All of the Tasky.Core code is shared between
+the iOS and Android versions of the application without modification.
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/BL/About.txt b/TaskyProLinked/Tasky.Core.Android.Source/BL/About.txt
new file mode 100644
index 0000000..1b5507d
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/BL/About.txt
@@ -0,0 +1,15 @@
+Business Layer (BL)
+===================
+Sometimes also called the Business Logic Layer (BLL), the BL contains entitiy definitions and
+business logic.
+
+Business Entities
+-----------------
+Business entites are classes that represent real-world objects. They're the core of
+Object-Oriented-Programming (OOP).
+
+Manager Classes
+---------------
+In this particular architecture, we're using the façade pattern (like we did with the DAL)
+which is represented by static Manager classes. The manager classes are an abstraction on
+the DAL and SAL layers and perform any business logic.
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/BusinessEntityBase.cs b/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/BusinessEntityBase.cs
new file mode 100644
index 0000000..0a0a2b7
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/BusinessEntityBase.cs
@@ -0,0 +1,20 @@
+using System;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL.Contracts {
+ ///
+ /// Business entity base class. Provides the ID property.
+ ///
+ public abstract class BusinessEntityBase : IBusinessEntity {
+ public BusinessEntityBase ()
+ {
+ }
+
+ ///
+ /// Gets or sets the Database ID.
+ ///
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/IBusinessEntity.cs b/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/IBusinessEntity.cs
new file mode 100644
index 0000000..15ba377
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/BL/Contracts/IBusinessEntity.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace Tasky.BL.Contracts {
+ public interface IBusinessEntity {
+ int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/BL/Managers/TaskManager.cs b/TaskyProLinked/Tasky.Core.Android.Source/BL/Managers/TaskManager.cs
new file mode 100644
index 0000000..ed52849
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/BL/Managers/TaskManager.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using Tasky.BL;
+
+namespace Tasky.BL.Managers
+{
+ public static class TaskManager
+ {
+ static TaskManager ()
+ {
+ }
+
+ public static Task GetTask(int id)
+ {
+ return DAL.TaskRepository.GetTask(id);
+ }
+
+ public static IList GetTasks ()
+ {
+ return new List(DAL.TaskRepository.GetTasks());
+ }
+
+ public static int SaveTask (Task item)
+ {
+ return DAL.TaskRepository.SaveTask(item);
+ }
+
+ public static int DeleteTask(int id)
+ {
+ return DAL.TaskRepository.DeleteTask(id);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/BL/Task.cs b/TaskyProLinked/Tasky.Core.Android.Source/BL/Task.cs
new file mode 100644
index 0000000..0d334d9
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/BL/Task.cs
@@ -0,0 +1,24 @@
+using System;
+using Tasky.BL.Contracts;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL
+{
+ ///
+ /// Represents a Task.
+ ///
+ public class Task : IBusinessEntity
+ {
+ public Task ()
+ {
+ }
+
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Notes { get; set; }
+ // new property
+ public bool Done { get; set; }
+ }
+}
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/DAL/About.txt b/TaskyProLinked/Tasky.Core.Android.Source/DAL/About.txt
new file mode 100644
index 0000000..7825750
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/DAL/About.txt
@@ -0,0 +1,13 @@
+Data Access Layer (DAL)
+=======================
+The data access layer is responsible for providing an abstraction to the data layer. It makes
+sure that no matter what technology(ies) are used for data persistance, a single entry point
+that is technology agnostic exists.
+
+Often, the façade pattern is used, and many times the underlying data persistence technology is
+actually more than one. for example, you might have some data store in xml, other data stored in
+a SQL database, etc. The DAL makes sure that any complexity associated with accessing and aggregating
+these technologies is isolated from the rest of the application.
+
+The DAL is also considered a sibling to the Service Access Layer (SAL), which is responsible for
+access to cloud services, and other network related resources.
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/DAL/TaskRepository.cs b/TaskyProLinked/Tasky.Core.Android.Source/DAL/TaskRepository.cs
new file mode 100644
index 0000000..2bae5f9
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/DAL/TaskRepository.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Tasky.BL;
+
+namespace Tasky.DAL {
+ public class TaskRepository {
+ DL.TaskDatabase db = null;
+ protected static string dbLocation;
+ protected static TaskRepository me;
+
+ static TaskRepository ()
+ {
+ me = new TaskRepository();
+ }
+
+ protected TaskRepository()
+ {
+ // set the db location
+ dbLocation = DatabaseFilePath;
+
+ // instantiate the database
+ db = new Tasky.DL.TaskDatabase(dbLocation);
+ }
+
+ public static string DatabaseFilePath {
+ get {
+ var sqliteFilename = "TaskDB.db3";
+#if SILVERLIGHT
+ // Windows Phone expects a local path, not absolute
+ var path = sqliteFilename;
+#else
+
+#if __ANDROID__
+ // Just use whatever directory SpecialFolder.Personal returns
+ string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ;
+#else
+ // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
+ // (they don't want non-user-generated data in Documents)
+ string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
+ string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder
+#endif
+ var path = Path.Combine (libraryPath, sqliteFilename);
+#endif
+ return path;
+ }
+ }
+
+ public static Task GetTask(int id)
+ {
+ return me.db.GetItem(id);
+ }
+
+ public static IEnumerable GetTasks ()
+ {
+ return me.db.GetItems();
+ }
+
+ public static int SaveTask (Task item)
+ {
+ return me.db.SaveItem(item);
+ }
+
+ public static int DeleteTask(int id)
+ {
+ return me.db.DeleteItem(id);
+ }
+ }
+}
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/DL/About.txt b/TaskyProLinked/Tasky.Core.Android.Source/DL/About.txt
new file mode 100644
index 0000000..ee62d45
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/DL/About.txt
@@ -0,0 +1,19 @@
+Data Layer:
+===========
+The data layer is typically the lowest level layer of an application. Typically it consists
+of data persistence/retreival code. In this particular application, it contains two classes:
+ - SQLite.cs
+ - TaskDatabase.cs
+
+SQLite
+------
+This is the SQLite.NET library, created by Frank Krueger. It's a lightweight Object Relational
+Model (ORM) that allows you to define your database schema via classes and automatically
+handles the nitty gritty of data persistance and retrieval into/from SQLite as well as actual
+database creation. It also has limited support for LINQ queries.
+
+TaskDatabase
+------------
+TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB.
+It contains methods for retreival and persistance as well as db creation, all based on the
+underlying ORM.
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/DL/SQLite.cs b/TaskyProLinked/Tasky.Core.Android.Source/DL/SQLite.cs
new file mode 100644
index 0000000..6752f3b
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/DL/SQLite.cs
@@ -0,0 +1,1940 @@
+//
+// Copyright (c) 2009-2011 Krueger Systems, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#if WINDOWS_PHONE
+#define USE_CSHARP_SQLITE
+#endif
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+
+#if USE_CSHARP_SQLITE
+using Community.CsharpSqlite;
+using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
+using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
+#else
+using Sqlite3DatabaseHandle = System.IntPtr;
+using Sqlite3Statement = System.IntPtr;
+#endif
+
+namespace Tasky.DL.SQLite {
+ public class SQLiteException : System.Exception {
+ public SQLite3.Result Result { get; private set; }
+
+ protected SQLiteException(SQLite3.Result r, string message)
+ : base(message)
+ {
+ Result = r;
+ }
+
+ public static SQLiteException New(SQLite3.Result r, string message)
+ {
+ return new SQLiteException(r, message);
+ }
+ }
+
+ ///
+ /// Represents an open connection to a SQLite database.
+ ///
+ public class SQLiteConnection : IDisposable {
+ private bool _open;
+ private TimeSpan _busyTimeout;
+ private Dictionary _mappings = null;
+ private Dictionary _tables = null;
+ private System.Diagnostics.Stopwatch _sw;
+ private long _elapsedMilliseconds = 0;
+
+ public Sqlite3DatabaseHandle Handle { get; private set; }
+#if USE_CSHARP_SQLITE
+ internal static readonly Sqlite3DatabaseHandle NullHandle = null;
+#else
+ internal static readonly Sqlite3DatabaseHandle NullHandle = IntPtr.Zero;
+#endif
+
+ public string DatabasePath { get; private set; }
+
+ public bool TimeExecution { get; set; }
+
+ public bool Trace { get; set; }
+
+ ///
+ /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath.
+ ///
+ ///
+ /// Specifies the path to the database file.
+ ///
+ public SQLiteConnection(string databasePath)
+ {
+ DatabasePath = databasePath;
+ Sqlite3DatabaseHandle handle;
+ var r = SQLite3.Open(DatabasePath, out handle);
+ Handle = handle;
+ if (r != SQLite3.Result.OK) {
+ throw SQLiteException.New(r, "Could not open database file: " + DatabasePath);
+ }
+ _open = true;
+
+ BusyTimeout = TimeSpan.FromSeconds(0.1);
+ }
+
+ static SQLiteConnection()
+ {
+ if (_preserveDuringLinkMagic) {
+ var ti = new TableInfo();
+ ti.name = "magic";
+ }
+ }
+
+ ///
+ /// Used to list some code that we want the MonoTouch linker
+ /// to see, but that we never want to actually execute.
+ ///
+ static bool _preserveDuringLinkMagic = false;
+
+ ///
+ /// Sets a busy handler to sleep the specified amount of time when a table is locked.
+ /// The handler will sleep multiple times until a total time of has accumulated.
+ ///
+ public TimeSpan BusyTimeout
+ {
+ get { return _busyTimeout; }
+ set
+ {
+ _busyTimeout = value;
+ if (Handle != NullHandle) {
+ SQLite3.BusyTimeout(Handle, (int)_busyTimeout.TotalMilliseconds);
+ }
+ }
+ }
+
+ ///
+ /// Returns the mappings from types to tables that the connection
+ /// currently understands.
+ ///
+ public IEnumerable TableMappings
+ {
+ get
+ {
+ if (_tables == null) {
+ return Enumerable.Empty();
+ } else {
+ return _tables.Values;
+ }
+ }
+ }
+
+ ///
+ /// Retrieves the mapping that is automatically generated for the given type.
+ ///
+ ///
+ /// The type whose mapping to the database is returned.
+ ///
+ ///
+ /// The mapping represents the schema of the columns of the database and contains
+ /// methods to set and get properties of objects.
+ ///
+ public TableMapping GetMapping(Type type)
+ {
+ if (_mappings == null) {
+ _mappings = new Dictionary();
+ }
+ TableMapping map;
+ if (!_mappings.TryGetValue(type.FullName, out map)) {
+ map = new TableMapping(type);
+ _mappings[type.FullName] = map;
+ }
+ return map;
+ }
+
+ ///
+ /// Executes a "create table if not exists" on the database. It also
+ /// creates any specified indexes on the columns of the table. It uses
+ /// a schema automatically generated from the specified type. You can
+ /// later access this schema by calling GetMapping.
+ ///
+ ///
+ /// The number of entries added to the database schema.
+ ///
+ public int CreateTable()
+ {
+ var ty = typeof(T);
+
+ if (_tables == null) {
+ _tables = new Dictionary();
+ }
+ TableMapping map;
+ if (!_tables.TryGetValue(ty.FullName, out map)) {
+ map = GetMapping(ty);
+ _tables.Add(ty.FullName, map);
+ }
+ var query = "create table if not exists \"" + map.TableName + "\"(\n";
+
+ var decls = map.Columns.Select(p => Orm.SqlDecl(p));
+ var decl = string.Join(",\n", decls.ToArray());
+ query += decl;
+ query += ")";
+
+ var count = Execute(query);
+
+ if (count == 0) { //Possible bug: This always seems to return 0?
+ // Table already exists, migrate it
+ MigrateTable(map);
+ }
+
+ foreach (var p in map.Columns.Where(x => x.IsIndexed)) {
+ var indexName = map.TableName + "_" + p.Name;
+ var q = string.Format("create index if not exists \"{0}\" on \"{1}\"(\"{2}\")", indexName, map.TableName, p.Name);
+ count += Execute(q);
+ }
+
+ return count;
+ }
+
+ public class TableInfo {
+ public int cid { get; set; }
+
+ public string name { get; set; }
+
+ public string type { get; set; }
+
+ public int notnull { get; set; }
+
+ public string dflt_value { get; set; }
+
+ public int pk { get; set; }
+ }
+
+ void MigrateTable(TableMapping map)
+ {
+ var query = "pragma table_info(\"" + map.TableName + "\")";
+
+ var existingCols = Query(query);
+
+ var toBeAdded = new List();
+
+ foreach (var p in map.Columns) {
+ var found = false;
+ foreach (var c in existingCols) {
+ found = p.Name == c.name;
+ if (found)
+ break;
+ }
+ if (!found) {
+ toBeAdded.Add(p);
+ }
+ }
+
+ foreach (var p in toBeAdded) {
+ var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl(p);
+ Execute(addCol);
+ }
+ }
+
+ ///
+ /// Creates a new SQLiteCommand given the command text with arguments. Place a '?'
+ /// in the command text for each of the arguments.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the command text.
+ ///
+ ///
+ /// A
+ ///
+ public SQLiteCommand CreateCommand(string cmdText, params object[] ps)
+ {
+ if (!_open) {
+ throw SQLiteException.New(SQLite3.Result.Error, "Cannot create commands from unopened database");
+ } else {
+ var cmd = new SQLiteCommand(this);
+ cmd.CommandText = cmdText;
+ foreach (var o in ps) {
+ cmd.Bind(o);
+ }
+ return cmd;
+ }
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// Use this method instead of Query when you don't expect rows back. Such cases include
+ /// INSERTs, UPDATEs, and DELETEs.
+ /// You can set the Trace or TimeExecution properties of the connection
+ /// to profile execution.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// The number of rows modified in the database as a result of this execution.
+ ///
+ public int Execute(string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+
+ if (TimeExecution) {
+ if (_sw == null) {
+ _sw = new System.Diagnostics.Stopwatch();
+ }
+ _sw.Reset();
+ _sw.Start();
+ }
+
+ int r = cmd.ExecuteNonQuery();
+
+ if (TimeExecution) {
+ _sw.Stop();
+ _elapsedMilliseconds += _sw.ElapsedMilliseconds;
+#if DEBUG
+ Console.WriteLine("Finished in {0} ms ({1:0.0} s total)", _sw.ElapsedMilliseconds, _elapsedMilliseconds / 1000.0);
+#endif
+ }
+
+ return r;
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public List Query(string query, params object[] args) where T : new()
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public IEnumerable DeferredQuery(string query, params object[] args) where T : new()
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteDeferredQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public List Query(TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteQuery(map);
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public IEnumerable DeferredQuery(TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return cmd.ExecuteDeferredQuery(map);
+ }
+
+ ///
+ /// Returns a queryable interface to the table represented by the given type.
+ ///
+ ///
+ /// A queryable object that is able to translate Where, OrderBy, and Take
+ /// queries into native SQL.
+ ///
+ public TableQuery Table() where T : new()
+ {
+ return new TableQuery(this);
+ }
+
+ ///
+ /// Attempts to retrieve an object with the given primary key from the table
+ /// associated with the specified type. Use of this method requires that
+ /// the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).
+ ///
+ ///
+ /// The primary key.
+ ///
+ ///
+ /// The object with the given primary key. Throws a not found exception
+ /// if the object is not found.
+ ///
+ public T Get(object pk) where T : new()
+ {
+ var map = GetMapping(typeof(T));
+ string query = string.Format("select * from \"{0}\" where \"{1}\" = ?", map.TableName, map.PK.Name);
+ return Query(query, pk).First();
+ }
+
+ ///
+ /// Whether has been called and the database is waiting for a .
+ ///
+ public bool IsInTransaction { get; private set; }
+
+ ///
+ /// Begins a new transaction. Call to end the transaction.
+ ///
+ public void BeginTransaction()
+ {
+ if (!IsInTransaction) {
+ Execute("begin transaction");
+ IsInTransaction = true;
+ }
+ }
+
+ ///
+ /// Rolls back the transaction that was begun by .
+ ///
+ public void Rollback()
+ {
+ if (IsInTransaction) {
+ Execute("rollback");
+ IsInTransaction = false;
+ }
+ }
+
+ ///
+ /// Commits the transaction that was begun by .
+ ///
+ public void Commit()
+ {
+ if (IsInTransaction) {
+ Execute("commit");
+ IsInTransaction = false;
+ }
+ }
+
+ ///
+ /// Executes within a transaction and automatically rollsback the transaction
+ /// if an exception occurs. The exception is rethrown.
+ ///
+ ///
+ /// The to perform within a transaction. can contain any number
+ /// of operations on the connection but should never call ,
+ /// , or .
+ ///
+ public void RunInTransaction(Action action)
+ {
+ if (IsInTransaction) {
+ throw new InvalidOperationException("The connection must not already be in a transaction when RunInTransaction is called");
+ }
+ try {
+ BeginTransaction();
+ action();
+ Commit();
+ } catch (Exception) {
+ Rollback();
+ throw;
+ }
+ }
+
+ ///
+ /// Inserts all specified objects.
+ ///
+ ///
+ /// An of the objects to insert.
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int InsertAll(System.Collections.IEnumerable objects)
+ {
+ BeginTransaction();
+ var c = 0;
+ foreach (var r in objects) {
+ c += Insert(r);
+ }
+ Commit();
+ return c;
+ }
+
+ ///
+ /// Inserts the given object and retrieves its
+ /// auto incremented primary key if it has one.
+ ///
+ ///
+ /// The object to insert.
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int Insert(object obj)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Insert(obj, "", obj.GetType());
+ }
+
+ public int Insert(object obj, Type objType)
+ {
+ return Insert(obj, "", objType);
+ }
+
+ public int Insert(object obj, string extra)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Insert(obj, extra, obj.GetType());
+ }
+
+ ///
+ /// Inserts the given object and retrieves its
+ /// auto incremented primary key if it has one.
+ ///
+ ///
+ /// The object to insert.
+ ///
+ ///
+ /// Literal SQL code that gets placed into the command. INSERT {extra} INTO ...
+ ///
+ ///
+ /// The number of rows added to the table.
+ ///
+ public int Insert(object obj, string extra, Type objType)
+ {
+ if (obj == null || objType == null) {
+ return 0;
+ }
+
+ var map = GetMapping(objType);
+
+ var cols = map.InsertColumns;
+ var vals = new object[cols.Length];
+ for (var i = 0; i < vals.Length; i++) {
+ vals[i] = cols[i].GetValue(obj);
+ }
+
+ var insertCmd = map.GetInsertCommand(this, extra);
+ var count = insertCmd.ExecuteNonQuery(vals);
+
+ if (map.HasAutoIncPK) {
+ var id = SQLite3.LastInsertRowid(Handle);
+ map.SetAutoIncPK(obj, id);
+ }
+
+ return count;
+ }
+
+ ///
+ /// Updates all of the columns of a table using the specified object
+ /// except for its primary key.
+ /// The object is required to have a primary key.
+ ///
+ ///
+ /// The object to update. It must have a primary key designated using the PrimaryKeyAttribute.
+ ///
+ ///
+ /// The number of rows updated.
+ ///
+ public int Update(object obj)
+ {
+ if (obj == null) {
+ return 0;
+ }
+ return Update(obj, obj.GetType());
+ }
+
+ public int Update(object obj, Type objType)
+ {
+ if (obj == null || objType == null) {
+ return 0;
+ }
+
+ var map = GetMapping(objType);
+
+ var pk = map.PK;
+
+ if (pk == null) {
+ throw new NotSupportedException("Cannot update " + map.TableName + ": it has no PK");
+ }
+
+ var cols = from p in map.Columns
+ where p != pk
+ select p;
+ var vals = from c in cols
+ select c.GetValue(obj);
+ var ps = new List(vals);
+ ps.Add(pk.GetValue(obj));
+ var q = string.Format("update \"{0}\" set {1} where {2} = ? ", map.TableName, string.Join(",", (from c in cols
+ select "\"" + c.Name + "\" = ? ").ToArray()), pk.Name);
+ return Execute(q, ps.ToArray());
+ }
+
+ ///
+ /// Deletes the given object from the database using its primary key.
+ ///
+ ///
+ /// The object to delete. It must have a primary key designated using the PrimaryKeyAttribute.
+ ///
+ ///
+ /// The number of rows deleted.
+ ///
+ public int Delete(T obj)
+ {
+ var map = GetMapping(obj.GetType());
+ var pk = map.PK;
+ if (pk == null) {
+ throw new NotSupportedException("Cannot delete " + map.TableName + ": it has no PK");
+ }
+ var q = string.Format("delete from \"{0}\" where \"{1}\" = ?", map.TableName, pk.Name);
+ return Execute(q, pk.GetValue(obj));
+ }
+
+ public void Dispose()
+ {
+ Close();
+ }
+
+ public void Close()
+ {
+ if (_open && Handle != NullHandle) {
+ try {
+ foreach (var sqlInsertCommand in _mappings.Values) {
+ sqlInsertCommand.Dispose();
+ }
+ var r = SQLite3.Close(Handle);
+ if (r != SQLite3.Result.OK) {
+ string msg = SQLite3.GetErrmsg(Handle);
+ throw SQLiteException.New(r, msg);
+ }
+ } finally {
+ Handle = NullHandle;
+ _open = false;
+ }
+ }
+ }
+ }
+
+ public class PrimaryKeyAttribute : Attribute {
+ }
+
+ public class AutoIncrementAttribute : Attribute {
+ }
+
+ public class IndexedAttribute : Attribute {
+ }
+
+ public class IgnoreAttribute : Attribute {
+ }
+
+ public class MaxLengthAttribute : Attribute {
+ public int Value { get; private set; }
+
+ public MaxLengthAttribute(int length)
+ {
+ Value = length;
+ }
+ }
+
+ public class CollationAttribute : Attribute {
+ public string Value { get; private set; }
+
+ public CollationAttribute(string collation)
+ {
+ Value = collation;
+ }
+ }
+
+ public class TableMapping {
+ public Type MappedType { get; private set; }
+
+ public string TableName { get; private set; }
+
+ public Column[] Columns { get; private set; }
+
+ public Column PK { get; private set; }
+
+ Column _autoPk = null;
+ Column[] _insertColumns = null;
+
+ public TableMapping(Type type)
+ {
+ MappedType = type;
+ TableName = MappedType.Name;
+ var props = MappedType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);
+ var cols = new List();
+ foreach (var p in props) {
+ var ignore = p.GetCustomAttributes(typeof(IgnoreAttribute), true).Length > 0;
+ if (p.CanWrite && !ignore) {
+ cols.Add(new PropColumn(p));
+ }
+ }
+ Columns = cols.ToArray();
+ foreach (var c in Columns) {
+ if (c.IsAutoInc && c.IsPK) {
+ _autoPk = c;
+ }
+ if (c.IsPK) {
+ PK = c;
+ }
+ }
+
+ HasAutoIncPK = _autoPk != null;
+ }
+
+ public bool HasAutoIncPK { get; private set; }
+
+ public void SetAutoIncPK(object obj, long id)
+ {
+ if (_autoPk != null) {
+ _autoPk.SetValue(obj, Convert.ChangeType(id, _autoPk.ColumnType, null));
+ }
+ }
+
+ public Column[] InsertColumns
+ {
+ get
+ {
+ if (_insertColumns == null) {
+ _insertColumns = Columns.Where(c => !c.IsAutoInc).ToArray();
+ }
+ return _insertColumns;
+ }
+ }
+
+ public Column FindColumn(string name)
+ {
+ var exact = Columns.Where(c => c.Name == name).FirstOrDefault();
+ return exact;
+ }
+
+
+ PreparedSqlLiteInsertCommand _insertCommand;
+ string _insertCommandExtra = null;
+
+ public PreparedSqlLiteInsertCommand GetInsertCommand(SQLiteConnection conn, string extra)
+ {
+
+ if (_insertCommand == null) {
+ _insertCommand = CreateInsertCommand(conn, extra);
+ _insertCommandExtra = extra;
+ } else if (_insertCommandExtra != extra) {
+ _insertCommand.Dispose();
+ _insertCommand = CreateInsertCommand(conn, extra);
+ _insertCommandExtra = extra;
+ }
+ return _insertCommand;
+ }
+
+ private PreparedSqlLiteInsertCommand CreateInsertCommand(SQLiteConnection conn, string extra)
+ {
+ var cols = InsertColumns;
+ var insertSql = string.Format("insert {3} into \"{0}\"({1}) values ({2})", TableName,
+ string.Join(",", (from c in cols
+ select "\"" + c.Name + "\"").ToArray()),
+ string.Join(",", (from c in cols
+ select "?").ToArray()), extra);
+
+ var insertCommand = new PreparedSqlLiteInsertCommand(conn);
+ insertCommand.CommandText = insertSql;
+ return insertCommand;
+ }
+
+ protected internal void Dispose()
+ {
+ if (_insertCommand != null) {
+ _insertCommand.Dispose();
+ _insertCommand = null;
+ }
+ }
+
+ public abstract class Column {
+ public string Name { get; protected set; }
+
+ public Type ColumnType { get; protected set; }
+
+ public string Collation { get; protected set; }
+
+ public bool IsAutoInc { get; protected set; }
+
+ public bool IsPK { get; protected set; }
+
+ public bool IsIndexed { get; protected set; }
+
+ public bool IsNullable { get; protected set; }
+
+ public int MaxStringLength { get; protected set; }
+
+ public abstract void SetValue(object obj, object val);
+
+ public abstract object GetValue(object obj);
+ }
+
+ public class PropColumn : Column {
+ PropertyInfo _prop;
+
+ public PropColumn(PropertyInfo prop)
+ {
+ _prop = prop;
+ Name = prop.Name;
+ //If this type is Nullable then Nullable.GetUnderlyingType returns the T, otherwise it returns null, so get the the actual type instead
+ ColumnType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
+ Collation = Orm.Collation(prop);
+ IsAutoInc = Orm.IsAutoInc(prop);
+ IsPK = Orm.IsPK(prop);
+ IsIndexed = Orm.IsIndexed(prop);
+ IsNullable = !IsPK;
+ MaxStringLength = Orm.MaxStringLength(prop);
+ }
+
+ public override void SetValue(object obj, object val)
+ {
+ _prop.SetValue(obj, val, null);
+ }
+
+ public override object GetValue(object obj)
+ {
+ return _prop.GetValue(obj, null);
+ }
+ }
+ }
+
+ public static class Orm {
+ public const int DefaultMaxStringLength = 140;
+
+ public static string SqlDecl(TableMapping.Column p)
+ {
+ string decl = "\"" + p.Name + "\" " + SqlType(p) + " ";
+
+ if (p.IsPK) {
+ decl += "primary key ";
+ }
+ if (p.IsAutoInc) {
+ decl += "autoincrement ";
+ }
+ if (!p.IsNullable) {
+ decl += "not null ";
+ }
+ if (!string.IsNullOrEmpty(p.Collation)) {
+ decl += "collate " + p.Collation + " ";
+ }
+
+ return decl;
+ }
+
+ public static string SqlType(TableMapping.Column p)
+ {
+ var clrType = p.ColumnType;
+ if (clrType == typeof(Boolean) || clrType == typeof(Byte) || clrType == typeof(UInt16) || clrType == typeof(SByte) || clrType == typeof(Int16) || clrType == typeof(Int32)) {
+ return "integer";
+ } else if (clrType == typeof(UInt32) || clrType == typeof(Int64)) {
+ return "bigint";
+ } else if (clrType == typeof(Single) || clrType == typeof(Double) || clrType == typeof(Decimal)) {
+ return "float";
+ } else if (clrType == typeof(String)) {
+ int len = p.MaxStringLength;
+ return "varchar(" + len + ")";
+ } else if (clrType == typeof(DateTime)) {
+ return "datetime";
+ } else if (clrType.IsEnum) {
+ return "integer";
+ } else if (clrType == typeof(byte[])) {
+ return "blob";
+ } else {
+ throw new NotSupportedException("Don't know about " + clrType);
+ }
+ }
+
+ public static bool IsPK(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(PrimaryKeyAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static string Collation(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(CollationAttribute), true);
+ if (attrs.Length > 0) {
+ return ((CollationAttribute)attrs[0]).Value;
+ } else {
+ return string.Empty;
+ }
+ }
+
+ public static bool IsAutoInc(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(AutoIncrementAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static bool IsIndexed(MemberInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(IndexedAttribute), true);
+ return attrs.Length > 0;
+ }
+
+ public static int MaxStringLength(PropertyInfo p)
+ {
+ var attrs = p.GetCustomAttributes(typeof(MaxLengthAttribute), true);
+ if (attrs.Length > 0) {
+ return ((MaxLengthAttribute)attrs[0]).Value;
+ } else {
+ return DefaultMaxStringLength;
+ }
+ }
+ }
+
+ public class SQLiteCommand {
+ SQLiteConnection _conn;
+ private List _bindings;
+
+ public string CommandText { get; set; }
+
+ internal SQLiteCommand(SQLiteConnection conn)
+ {
+ _conn = conn;
+ _bindings = new List();
+ CommandText = "";
+ }
+
+ public int ExecuteNonQuery()
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing: " + this);
+#endif
+ }
+
+ var r = SQLite3.Result.OK;
+ var stmt = Prepare();
+ r = SQLite3.Step(stmt);
+ Finalize(stmt);
+ if (r == SQLite3.Result.Done) {
+ int rowsAffected = SQLite3.Changes(_conn.Handle);
+ return rowsAffected;
+ } else if (r == SQLite3.Result.Error) {
+ string msg = SQLite3.GetErrmsg(_conn.Handle);
+ throw SQLiteException.New(r, msg);
+ } else {
+ throw SQLiteException.New(r, r.ToString());
+ }
+ }
+
+ public IEnumerable ExecuteDeferredQuery() where T : new()
+ {
+ return ExecuteDeferredQuery(_conn.GetMapping(typeof(T)));
+ }
+
+ public List ExecuteQuery() where T : new()
+ {
+ return ExecuteDeferredQuery(_conn.GetMapping(typeof(T))).ToList();
+ }
+
+ public List ExecuteQuery(TableMapping map)
+ {
+ return ExecuteDeferredQuery(map).ToList();
+ }
+
+ public IEnumerable ExecuteDeferredQuery(TableMapping map)
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing Query: " + this);
+#endif
+ }
+
+ var stmt = Prepare();
+ try {
+ var cols = new TableMapping.Column[SQLite3.ColumnCount(stmt)];
+
+ for (int i = 0; i < cols.Length; i++) {
+ var name = SQLite3.ColumnName16(stmt, i);
+ cols[i] = map.FindColumn(name);
+ }
+
+ while (SQLite3.Step(stmt) == SQLite3.Result.Row) {
+ var obj = Activator.CreateInstance(map.MappedType);
+ for (int i = 0; i < cols.Length; i++) {
+ if (cols[i] == null)
+ continue;
+ var colType = SQLite3.ColumnType(stmt, i);
+ var val = ReadCol(stmt, i, colType, cols[i].ColumnType);
+ cols[i].SetValue(obj, val);
+ }
+ yield return (T)obj;
+ }
+ } finally {
+ SQLite3.Finalize(stmt);
+ }
+ }
+
+ public T ExecuteScalar()
+ {
+ if (_conn.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing Query: " + this);
+#endif
+ }
+
+ T val = default(T);
+
+ var stmt = Prepare();
+ if (SQLite3.Step(stmt) == SQLite3.Result.Row) {
+ var colType = SQLite3.ColumnType(stmt, 0);
+ val = (T)ReadCol(stmt, 0, colType, typeof(T));
+ }
+ Finalize(stmt);
+
+ return val;
+ }
+
+ public void Bind(string name, object val)
+ {
+ _bindings.Add(new Binding {
+ Name = name,
+ Value = val
+ });
+ }
+
+ public void Bind(object val)
+ {
+ Bind(null, val);
+ }
+
+ public override string ToString()
+ {
+ var parts = new string[1 + _bindings.Count];
+ parts[0] = CommandText;
+ var i = 1;
+ foreach (var b in _bindings) {
+ parts[i] = string.Format(" {0}: {1}", i - 1, b.Value);
+ i++;
+ }
+ return string.Join(Environment.NewLine, parts);
+ }
+
+ Sqlite3Statement Prepare()
+ {
+ var stmt = SQLite3.Prepare2(_conn.Handle, CommandText);
+ BindAll(stmt);
+ return stmt;
+ }
+
+ void Finalize(Sqlite3Statement stmt)
+ {
+ SQLite3.Finalize(stmt);
+ }
+
+ void BindAll(Sqlite3Statement stmt)
+ {
+ int nextIdx = 1;
+ foreach (var b in _bindings) {
+ if (b.Name != null) {
+ b.Index = SQLite3.BindParameterIndex(stmt, b.Name);
+ } else {
+ b.Index = nextIdx++;
+ }
+ }
+ foreach (var b in _bindings) {
+ BindParameter(stmt, b.Index, b.Value);
+ }
+ }
+
+ internal static IntPtr NegativePointer = new IntPtr(-1);
+
+ internal static void BindParameter(Sqlite3Statement stmt, int index, object value)
+ {
+ if (value == null) {
+ SQLite3.BindNull(stmt, index);
+ } else {
+ if (value is Int32) {
+ SQLite3.BindInt(stmt, index, (int)value);
+ } else if (value is String) {
+ SQLite3.BindText(stmt, index, (string)value, -1, NegativePointer);
+ } else if (value is Byte || value is UInt16 || value is SByte || value is Int16) {
+ SQLite3.BindInt(stmt, index, Convert.ToInt32(value));
+ } else if (value is Boolean) {
+ SQLite3.BindInt(stmt, index, (bool)value ? 1 : 0);
+ } else if (value is UInt32 || value is Int64) {
+ SQLite3.BindInt64(stmt, index, Convert.ToInt64(value));
+ } else if (value is Single || value is Double || value is Decimal) {
+ SQLite3.BindDouble(stmt, index, Convert.ToDouble(value));
+ } else if (value is DateTime) {
+ SQLite3.BindText(stmt, index, ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), -1, NegativePointer);
+ } else if (value.GetType().IsEnum) {
+ SQLite3.BindInt(stmt, index, Convert.ToInt32(value));
+ } else if (value is byte[]) {
+ SQLite3.BindBlob(stmt, index, (byte[])value, ((byte[])value).Length, NegativePointer);
+ } else {
+ throw new NotSupportedException("Cannot store type: " + value.GetType());
+ }
+ }
+ }
+
+ class Binding {
+ public string Name { get; set; }
+
+ public object Value { get; set; }
+
+ public int Index { get; set; }
+ }
+
+ object ReadCol(Sqlite3Statement stmt, int index, SQLite3.ColType type, Type clrType)
+ {
+ if (type == SQLite3.ColType.Null) {
+ return null;
+ } else {
+ if (clrType == typeof(String)) {
+ return SQLite3.ColumnString(stmt, index);
+ } else if (clrType == typeof(Int32)) {
+ return (int)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Boolean)) {
+ return SQLite3.ColumnInt(stmt, index) == 1;
+ } else if (clrType == typeof(double)) {
+ return SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(float)) {
+ return (float)SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(DateTime)) {
+ var text = SQLite3.ColumnString(stmt, index);
+ return DateTime.Parse(text);
+ } else if (clrType.IsEnum) {
+ return SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Int64)) {
+ return SQLite3.ColumnInt64(stmt, index);
+ } else if (clrType == typeof(UInt32)) {
+ return (uint)SQLite3.ColumnInt64(stmt, index);
+ } else if (clrType == typeof(decimal)) {
+ return (decimal)SQLite3.ColumnDouble(stmt, index);
+ } else if (clrType == typeof(Byte)) {
+ return (byte)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(UInt16)) {
+ return (ushort)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(Int16)) {
+ return (short)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(sbyte)) {
+ return (sbyte)SQLite3.ColumnInt(stmt, index);
+ } else if (clrType == typeof(byte[])) {
+ return SQLite3.ColumnByteArray(stmt, index);
+ } else {
+ throw new NotSupportedException("Don't know how to read " + clrType);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Since the insert never changed, we only need to prepare once.
+ ///
+ public class PreparedSqlLiteInsertCommand : IDisposable {
+ public bool Initialized { get; set; }
+
+ protected SQLiteConnection Connection { get; set; }
+
+ public string CommandText { get; set; }
+
+ protected Sqlite3Statement Statement { get; set; }
+#if USE_CSHARP_SQLITE
+ internal static readonly Sqlite3Statement NullStatement = null;
+#else
+ internal static readonly Sqlite3Statement NullStatement = IntPtr.Zero;
+#endif
+
+ internal PreparedSqlLiteInsertCommand(SQLiteConnection conn)
+ {
+ Connection = conn;
+ }
+
+ public int ExecuteNonQuery(object[] source)
+ {
+ if (Connection.Trace) {
+#if DEBUG
+ Console.WriteLine("Executing: " + CommandText);
+#endif
+ }
+
+ var r = SQLite3.Result.OK;
+
+ if (!Initialized) {
+ Statement = Prepare();
+ Initialized = true;
+ }
+
+ //bind the values.
+ if (source != null) {
+ for (int i = 0; i < source.Length; i++) {
+ SQLiteCommand.BindParameter(Statement, i + 1, source[i]);
+ }
+ }
+ r = SQLite3.Step(Statement);
+
+ if (r == SQLite3.Result.Done) {
+ int rowsAffected = SQLite3.Changes(Connection.Handle);
+ SQLite3.Reset(Statement);
+ return rowsAffected;
+ } else if (r == SQLite3.Result.Error) {
+ string msg = SQLite3.GetErrmsg(Connection.Handle);
+ SQLite3.Reset(Statement);
+ throw SQLiteException.New(r, msg);
+ } else {
+ SQLite3.Reset(Statement);
+ throw SQLiteException.New(r, r.ToString());
+ }
+ }
+
+ protected virtual Sqlite3Statement Prepare()
+ {
+ var stmt = SQLite3.Prepare2(Connection.Handle, CommandText);
+ return stmt;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (Statement != NullStatement) {
+ try {
+ SQLite3.Finalize(Statement);
+ } finally {
+ Statement = NullStatement;
+ Connection = null;
+ }
+ }
+ }
+
+ ~PreparedSqlLiteInsertCommand()
+ {
+ Dispose(false);
+ }
+ }
+
+ public class TableQuery : IEnumerable where T : new() {
+ public SQLiteConnection Connection { get; private set; }
+
+ public TableMapping Table { get; private set; }
+
+ Expression _where;
+ List _orderBys;
+ int? _limit;
+ int? _offset;
+
+ class Ordering {
+ public string ColumnName { get; set; }
+
+ public bool Ascending { get; set; }
+ }
+
+ TableQuery(SQLiteConnection conn, TableMapping table)
+ {
+ Connection = conn;
+ Table = table;
+ }
+
+ public TableQuery(SQLiteConnection conn)
+ {
+ Connection = conn;
+ Table = Connection.GetMapping(typeof(T));
+ }
+
+ public TableQuery Clone()
+ {
+ var q = new TableQuery(Connection, Table);
+ q._where = _where;
+ q._deferred = _deferred;
+ if (_orderBys != null) {
+ q._orderBys = new List(_orderBys);
+ }
+ q._limit = _limit;
+ q._offset = _offset;
+ return q;
+ }
+
+ public TableQuery Where(Expression> predExpr)
+ {
+ if (predExpr.NodeType == ExpressionType.Lambda) {
+ var lambda = (LambdaExpression)predExpr;
+ var pred = lambda.Body;
+ var q = Clone();
+ q.AddWhere(pred);
+ return q;
+ } else {
+ throw new NotSupportedException("Must be a predicate");
+ }
+ }
+
+ public TableQuery Take(int n)
+ {
+ var q = Clone();
+ q._limit = n;
+ return q;
+ }
+
+ public TableQuery Skip(int n)
+ {
+ var q = Clone();
+ q._offset = n;
+ return q;
+ }
+
+ bool _deferred = false;
+ public TableQuery Deferred()
+ {
+ var q = Clone();
+ q._deferred = true;
+ return q;
+ }
+
+ public TableQuery OrderBy(Expression> orderExpr)
+ {
+ return AddOrderBy(orderExpr, true);
+ }
+
+ public TableQuery OrderByDescending(Expression> orderExpr)
+ {
+ return AddOrderBy(orderExpr, false);
+ }
+
+ private TableQuery AddOrderBy(Expression> orderExpr, bool asc)
+ {
+ if (orderExpr.NodeType == ExpressionType.Lambda) {
+ var lambda = (LambdaExpression)orderExpr;
+ var mem = lambda.Body as MemberExpression;
+ if (mem != null && (mem.Expression.NodeType == ExpressionType.Parameter)) {
+ var q = Clone();
+ if (q._orderBys == null) {
+ q._orderBys = new List();
+ }
+ q._orderBys.Add(new Ordering {
+ ColumnName = mem.Member.Name,
+ Ascending = asc
+ });
+ return q;
+ } else {
+ throw new NotSupportedException("Order By does not support: " + orderExpr);
+ }
+ } else {
+ throw new NotSupportedException("Must be a predicate");
+ }
+ }
+
+ private void AddWhere(Expression pred)
+ {
+ if (_where == null) {
+ _where = pred;
+ } else {
+ _where = Expression.AndAlso(_where, pred);
+ }
+ }
+
+ private SQLiteCommand GenerateCommand(string selectionList)
+ {
+ var cmdText = "select " + selectionList + " from \"" + Table.TableName + "\"";
+ var args = new List();
+ if (_where != null) {
+ var w = CompileExpr(_where, args);
+ cmdText += " where " + w.CommandText;
+ }
+ if ((_orderBys != null) && (_orderBys.Count > 0)) {
+ var t = string.Join(", ", _orderBys.Select(o => "\"" + o.ColumnName + "\"" + (o.Ascending ? "" : " desc")).ToArray());
+ cmdText += " order by " + t;
+ }
+ if (_limit.HasValue) {
+ cmdText += " limit " + _limit.Value;
+ }
+ if (_offset.HasValue) {
+ if (!_limit.HasValue) {
+ cmdText += " limit -1 ";
+ }
+ cmdText += " offset " + _offset.Value;
+ }
+ return Connection.CreateCommand(cmdText, args.ToArray());
+ }
+
+ class CompileResult {
+ public string CommandText { get; set; }
+
+ public object Value { get; set; }
+ }
+
+ private CompileResult CompileExpr(Expression expr, List queryArgs)
+ {
+ if (expr == null) {
+ throw new NotSupportedException("Expression is NULL");
+ } else if (expr is BinaryExpression) {
+ var bin = (BinaryExpression)expr;
+
+ var leftr = CompileExpr(bin.Left, queryArgs);
+ var rightr = CompileExpr(bin.Right, queryArgs);
+
+ //If either side is a parameter and is null, then handle the other side specially (for "is null"/"is not null")
+ string text;
+ if (leftr.CommandText == "?" && leftr.Value == null)
+ text = CompileNullBinaryExpression(bin, rightr);
+ else if (rightr.CommandText == "?" && rightr.Value == null)
+ text = CompileNullBinaryExpression(bin, leftr);
+ else
+ text = "(" + leftr.CommandText + " " + GetSqlName(bin) + " " + rightr.CommandText + ")";
+ return new CompileResult { CommandText = text };
+ } else if (expr.NodeType == ExpressionType.Call) {
+
+ var call = (MethodCallExpression)expr;
+ var args = new CompileResult[call.Arguments.Count];
+
+ for (var i = 0; i < args.Length; i++) {
+ args[i] = CompileExpr(call.Arguments[i], queryArgs);
+ }
+
+ var sqlCall = "";
+
+ if (call.Method.Name == "Like" && args.Length == 2) {
+ sqlCall = "(" + args[0].CommandText + " like " + args[1].CommandText + ")";
+ } else if (call.Method.Name == "Contains" && args.Length == 2) {
+ sqlCall = "(" + args[1].CommandText + " in " + args[0].CommandText + ")";
+ } else {
+ sqlCall = call.Method.Name.ToLower() + "(" + string.Join(",", args.Select(a => a.CommandText).ToArray()) + ")";
+ }
+ return new CompileResult { CommandText = sqlCall };
+
+ } else if (expr.NodeType == ExpressionType.Constant) {
+ var c = (ConstantExpression)expr;
+ queryArgs.Add(c.Value);
+ return new CompileResult {
+ CommandText = "?",
+ Value = c.Value
+ };
+ } else if (expr.NodeType == ExpressionType.Convert) {
+ var u = (UnaryExpression)expr;
+ var ty = u.Type;
+ var valr = CompileExpr(u.Operand, queryArgs);
+ return new CompileResult {
+ CommandText = valr.CommandText,
+ Value = valr.Value != null ? Convert.ChangeType(valr.Value, ty, null) : null
+ };
+ } else if (expr.NodeType == ExpressionType.MemberAccess) {
+ var mem = (MemberExpression)expr;
+
+ if (mem.Expression.NodeType == ExpressionType.Parameter) {
+ //
+ // This is a column of our table, output just the column name
+ //
+ return new CompileResult { CommandText = "\"" + mem.Member.Name + "\"" };
+ } else {
+ object obj = null;
+ if (mem.Expression != null) {
+ var r = CompileExpr(mem.Expression, queryArgs);
+ if (r.Value == null) {
+ throw new NotSupportedException("Member access failed to compile expression");
+ }
+ if (r.CommandText == "?") {
+ queryArgs.RemoveAt(queryArgs.Count - 1);
+ }
+ obj = r.Value;
+ }
+
+ //
+ // Get the member value
+ //
+ object val = null;
+
+ if (mem.Member.MemberType == MemberTypes.Property) {
+ var m = (PropertyInfo)mem.Member;
+ val = m.GetValue(obj, null);
+ } else if (mem.Member.MemberType == MemberTypes.Field) {
+#if SILVERLIGHT
+ val = Expression.Lambda(expr).Compile().DynamicInvoke();
+#else
+ var m = (FieldInfo)mem.Member;
+ var eee = Expression.Lambda (expr);
+ val = m.GetValue (obj);
+#endif
+ } else {
+ throw new NotSupportedException("MemberExpr: " + mem.Member.MemberType.ToString());
+ }
+
+ //
+ // Work special magic for enumerables
+ //
+ if (val != null && val is System.Collections.IEnumerable && !(val is string)) {
+ var sb = new System.Text.StringBuilder();
+ sb.Append("(");
+ var head = "";
+ foreach (var a in (System.Collections.IEnumerable)val) {
+ queryArgs.Add(a);
+ sb.Append(head);
+ sb.Append("?");
+ head = ",";
+ }
+ sb.Append(")");
+ return new CompileResult {
+ CommandText = sb.ToString(),
+ Value = val
+ };
+ } else {
+ queryArgs.Add(val);
+ return new CompileResult {
+ CommandText = "?",
+ Value = val
+ };
+ }
+ }
+ }
+ throw new NotSupportedException("Cannot compile: " + expr.NodeType.ToString());
+ }
+
+ ///
+ /// Compiles a BinaryExpression where one of the parameters is null.
+ ///
+ /// The non-null parameter
+ private string CompileNullBinaryExpression(BinaryExpression expression, CompileResult parameter)
+ {
+ if (expression.NodeType == ExpressionType.Equal)
+ return "(" + parameter.CommandText + " is ?)";
+ else if (expression.NodeType == ExpressionType.NotEqual)
+ return "(" + parameter.CommandText + " is not ?)";
+ else
+ throw new NotSupportedException("Cannot compile Null-BinaryExpression with type " + expression.NodeType.ToString());
+ }
+
+ string GetSqlName(Expression expr)
+ {
+ var n = expr.NodeType;
+ if (n == ExpressionType.GreaterThan)
+ return ">";
+ else if (n == ExpressionType.GreaterThanOrEqual) {
+ return ">=";
+ } else if (n == ExpressionType.LessThan) {
+ return "<";
+ } else if (n == ExpressionType.LessThanOrEqual) {
+ return "<=";
+ } else if (n == ExpressionType.And) {
+ return "and";
+ } else if (n == ExpressionType.AndAlso) {
+ return "and";
+ } else if (n == ExpressionType.Or) {
+ return "or";
+ } else if (n == ExpressionType.OrElse) {
+ return "or";
+ } else if (n == ExpressionType.Equal) {
+ return "=";
+ } else if (n == ExpressionType.NotEqual) {
+ return "!=";
+ } else {
+ throw new System.NotSupportedException("Cannot get SQL for: " + n.ToString());
+ }
+ }
+
+ public int Count()
+ {
+ return GenerateCommand("count(*)").ExecuteScalar();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ if (!_deferred)
+ return GenerateCommand("*").ExecuteQuery().GetEnumerator();
+
+ return GenerateCommand("*").ExecuteDeferredQuery().GetEnumerator();
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+
+ public static class SQLite3 {
+ public enum Result : int {
+ OK = 0,
+ Error = 1,
+ Internal = 2,
+ Perm = 3,
+ Abort = 4,
+ Busy = 5,
+ Locked = 6,
+ NoMem = 7,
+ ReadOnly = 8,
+ Interrupt = 9,
+ IOError = 10,
+ Corrupt = 11,
+ NotFound = 12,
+ TooBig = 18,
+ Constraint = 19,
+ Row = 100,
+ Done = 101
+ }
+
+ public enum ConfigOption : int {
+ SingleThread = 1,
+ MultiThread = 2,
+ Serialized = 3
+ }
+
+#if !USE_CSHARP_SQLITE
+ [DllImport("sqlite3", EntryPoint = "sqlite3_open")]
+ public static extern Result Open (string filename, out IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_close")]
+ public static extern Result Close (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_config")]
+ public static extern Result Config (ConfigOption option);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_busy_timeout")]
+ public static extern Result BusyTimeout (IntPtr db, int milliseconds);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_changes")]
+ public static extern int Changes (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_prepare_v2")]
+ public static extern Result Prepare2 (IntPtr db, string sql, int numBytes, out IntPtr stmt, IntPtr pzTail);
+
+ public static IntPtr Prepare2 (IntPtr db, string query)
+ {
+ IntPtr stmt;
+ var r = Prepare2 (db, query, query.Length, out stmt, IntPtr.Zero);
+ if (r != Result.OK) {
+ throw SQLiteException.New (r, GetErrmsg (db));
+ }
+ return stmt;
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_step")]
+ public static extern Result Step (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_reset")]
+ public static extern Result Reset (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_finalize")]
+ public static extern Result Finalize (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_last_insert_rowid")]
+ public static extern long LastInsertRowid (IntPtr db);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_errmsg16")]
+ public static extern IntPtr Errmsg (IntPtr db);
+
+ public static string GetErrmsg (IntPtr db)
+ {
+ return Marshal.PtrToStringUni (Errmsg (db));
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_parameter_index")]
+ public static extern int BindParameterIndex (IntPtr stmt, string name);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_null")]
+ public static extern int BindNull (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_int")]
+ public static extern int BindInt (IntPtr stmt, int index, int val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_int64")]
+ public static extern int BindInt64 (IntPtr stmt, int index, long val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_double")]
+ public static extern int BindDouble (IntPtr stmt, int index, double val);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_text")]
+ public static extern int BindText (IntPtr stmt, int index, string val, int n, IntPtr free);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_blob")]
+ public static extern int BindBlob (IntPtr stmt, int index, byte[] val, int n, IntPtr free);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_count")]
+ public static extern int ColumnCount (IntPtr stmt);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_name")]
+ public static extern IntPtr ColumnName (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_name16")]
+ private static extern IntPtr ColumnName16Internal (IntPtr stmt, int index);
+ public static string ColumnName16(IntPtr stmt, int index)
+ {
+ return Marshal.PtrToStringUni(ColumnName16Internal(stmt, index));
+ }
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_type")]
+ public static extern ColType ColumnType (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_int")]
+ public static extern int ColumnInt (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_int64")]
+ public static extern long ColumnInt64 (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_double")]
+ public static extern double ColumnDouble (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_text")]
+ public static extern IntPtr ColumnText (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_text16")]
+ public static extern IntPtr ColumnText16 (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_blob")]
+ public static extern IntPtr ColumnBlob (IntPtr stmt, int index);
+
+ [DllImport("sqlite3", EntryPoint = "sqlite3_column_bytes")]
+ public static extern int ColumnBytes (IntPtr stmt, int index);
+
+ public static string ColumnString (IntPtr stmt, int index)
+ {
+ return Marshal.PtrToStringUni (SQLite3.ColumnText16 (stmt, index));
+ }
+
+ public static byte[] ColumnByteArray (IntPtr stmt, int index)
+ {
+ int length = ColumnBytes (stmt, index);
+ byte[] result = new byte[length];
+ if (length > 0)
+ Marshal.Copy (ColumnBlob (stmt, index), result, 0, length);
+ return result;
+ }
+#else
+ public static Result Open(string filename, out Sqlite3.sqlite3 db)
+ {
+ db = new Sqlite3.sqlite3();
+ return (Result)Sqlite3.sqlite3_open(filename, ref db);
+ }
+
+ public static Result Close(Sqlite3.sqlite3 db)
+ {
+ return (Result)Sqlite3.sqlite3_close(db);
+ }
+
+ public static Result BusyTimeout(Sqlite3.sqlite3 db, int milliseconds)
+ {
+ return (Result)Sqlite3.sqlite3_busy_timeout(db, milliseconds);
+ }
+
+ public static int Changes(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_changes(db);
+ }
+
+ public static Sqlite3.Vdbe Prepare2(Sqlite3.sqlite3 db, string query)
+ {
+ Sqlite3.Vdbe stmt = new Sqlite3.Vdbe();
+ var r = Sqlite3.sqlite3_prepare_v2(db, query, query.Length, ref stmt, 0);
+ if (r != 0) {
+ throw SQLiteException.New((Result)r, GetErrmsg(db));
+ }
+ return stmt;
+ }
+
+ public static Result Step(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_step(stmt);
+ }
+
+ public static Result Reset(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_reset(stmt);
+ }
+
+ public static Result Finalize(Sqlite3.Vdbe stmt)
+ {
+ return (Result)Sqlite3.sqlite3_finalize(ref stmt);
+ }
+
+ public static long LastInsertRowid(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_last_insert_rowid(db);
+ }
+
+ public static string GetErrmsg(Sqlite3.sqlite3 db)
+ {
+ return Sqlite3.sqlite3_errmsg(db);
+ }
+
+ public static int BindParameterIndex(Sqlite3.Vdbe stmt, string name)
+ {
+ return Sqlite3.sqlite3_bind_parameter_index(stmt, name);
+ }
+
+ public static int BindNull(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_bind_null(stmt, index);
+ }
+
+ public static int BindInt(Sqlite3.Vdbe stmt, int index, int val)
+ {
+ return Sqlite3.sqlite3_bind_int(stmt, index, val);
+ }
+
+ public static int BindInt64(Sqlite3.Vdbe stmt, int index, long val)
+ {
+ return Sqlite3.sqlite3_bind_int64(stmt, index, val);
+ }
+
+ public static int BindDouble(Sqlite3.Vdbe stmt, int index, double val)
+ {
+ return Sqlite3.sqlite3_bind_double(stmt, index, val);
+ }
+
+ public static int BindText(Sqlite3.Vdbe stmt, int index, string val, int n, IntPtr free)
+ {
+ return Sqlite3.sqlite3_bind_text(stmt, index, val, n, null);
+ }
+
+ public static int BindBlob(Sqlite3.Vdbe stmt, int index, byte[] val, int n, IntPtr free)
+ {
+ return Sqlite3.sqlite3_bind_blob(stmt, index, val, n, null);
+ }
+
+ public static int ColumnCount(Sqlite3.Vdbe stmt)
+ {
+ return Sqlite3.sqlite3_column_count(stmt);
+ }
+
+ public static string ColumnName(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_name(stmt, index);
+ }
+
+ public static string ColumnName16(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_name(stmt, index);
+ }
+
+ public static ColType ColumnType(Sqlite3.Vdbe stmt, int index)
+ {
+ return (ColType)Sqlite3.sqlite3_column_type(stmt, index);
+ }
+
+ public static int ColumnInt(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_int(stmt, index);
+ }
+
+ public static long ColumnInt64(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_int64(stmt, index);
+ }
+
+ public static double ColumnDouble(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_double(stmt, index);
+ }
+
+ public static string ColumnText(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static string ColumnText16(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static byte[] ColumnBlob(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_blob(stmt, index);
+ }
+
+ public static int ColumnBytes(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_bytes(stmt, index);
+ }
+
+ public static string ColumnString(Sqlite3.Vdbe stmt, int index)
+ {
+ return Sqlite3.sqlite3_column_text(stmt, index);
+ }
+
+ public static byte[] ColumnByteArray(Sqlite3.Vdbe stmt, int index)
+ {
+ return ColumnBlob(stmt, index);
+ }
+#endif
+
+ public enum ColType : int {
+ Integer = 1,
+ Float = 2,
+ Text = 3,
+ Blob = 4,
+ Null = 5
+ }
+ }
+
+}
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/DL/TaskDatabase.cs b/TaskyProLinked/Tasky.Core.Android.Source/DL/TaskDatabase.cs
new file mode 100644
index 0000000..4ea921b
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/DL/TaskDatabase.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Linq;
+using Tasky.BL;
+using System.Collections.Generic;
+using Tasky.DL.SQLite;
+
+namespace Tasky.DL
+{
+ ///
+ /// TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB.
+ /// It contains methods for retrieval and persistance as well as db creation, all based on the
+ /// underlying ORM.
+ ///
+ public class TaskDatabase : SQLiteConnection
+ {
+ static object locker = new object ();
+
+ ///
+ /// Initializes a new instance of the TaskDatabase.
+ /// if the database doesn't exist, it will create the database and all the tables.
+ ///
+ ///
+ /// Path.
+ ///
+ public TaskDatabase (string path) : base (path)
+ {
+ // create the tables
+ CreateTable ();
+ }
+
+ public IEnumerable GetItems () where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return (from i in Table () select i).ToList ();
+ }
+ }
+
+ public T GetItem (int id) where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return Table().FirstOrDefault(x => x.ID == id);
+ // Following throws NotSupportedException - thanks aliegeni
+ //return (from i in Table ()
+ // where i.ID == id
+ // select i).FirstOrDefault ();
+ }
+ }
+
+ public int SaveItem (T item) where T : BL.Contracts.IBusinessEntity
+ {
+ lock (locker) {
+ if (item.ID != 0) {
+ Update (item);
+ return item.ID;
+ } else {
+ return Insert (item);
+ }
+ }
+ }
+
+ public int DeleteItem(int id) where T : BL.Contracts.IBusinessEntity, new ()
+ {
+ lock (locker) {
+ return Delete (new T () { ID = id });
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Android.Source.csproj b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Android.Source.csproj
new file mode 100755
index 0000000..c7d61ce
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Android.Source.csproj
@@ -0,0 +1,60 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}
+ {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Tasky
+ Assets
+ Resources
+ Tasky.Core.Android
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+ false
+ SdkOnly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Portable.csproj b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Portable.csproj
new file mode 100644
index 0000000..166c958
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.Portable.csproj
@@ -0,0 +1,71 @@
+
+
+
+
+ 10.0
+ Debug
+ AnyCPU
+ {dbecb1bb-1cb3-4726-aba3-f3cd716b6d86}
+ Library
+ Properties
+ Tasky.Core.Portable
+ Tasky.Core.Portable
+ v4.0
+ Profile2
+ 512
+ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.WP7.csproj b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.WP7.csproj
new file mode 100644
index 0000000..442403d
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.WP7.csproj
@@ -0,0 +1,82 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {5E634ED0-7A59-4A39-8415-175034A02C16}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ Tasky
+ Tasky.Core.WP7
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ false
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+ ..\Dependencies\Community.CsharpSqlite\Community.CsharpSqlite.WP7.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.iOS.csproj b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.iOS.csproj
new file mode 100644
index 0000000..83103aa
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.Android.Source/Tasky.Core.iOS.csproj
@@ -0,0 +1,62 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}
+ {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Tasky
+ Tasky.Core
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.WP7.Linked/Tasky.Core.WP7.Linked.csproj b/TaskyProLinked/Tasky.Core.WP7.Linked/Tasky.Core.WP7.Linked.csproj
new file mode 100755
index 0000000..4f006f1
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.WP7.Linked/Tasky.Core.WP7.Linked.csproj
@@ -0,0 +1,105 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {5E634ED0-7A59-4A39-8415-175034A02C16}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ Tasky
+ Tasky.Core.WP7
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ false
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+ ..\Dependencies\Community.CsharpSqlite\Community.CsharpSqlite.WP7.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ BL\About.txt
+
+
+ DAL\About.txt
+
+
+ DL\About.txt
+
+
+ About.txt
+
+
+
+
+ BL\Task.cs
+
+
+ BL\Contracts\BusinessEntityBase.cs
+
+
+ BL\Contracts\IBusinessEntity.cs
+
+
+ BL\Managers\TaskManager.cs
+
+
+ DAL\TaskRepository.cs
+
+
+ DL\SQLite.cs
+
+
+ DL\TaskDatabase.cs
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/Tasky.Core.iOS.Linked/Tasky.Core.iOS.Linked.csproj b/TaskyProLinked/Tasky.Core.iOS.Linked/Tasky.Core.iOS.Linked.csproj
new file mode 100755
index 0000000..6eb8079
--- /dev/null
+++ b/TaskyProLinked/Tasky.Core.iOS.Linked/Tasky.Core.iOS.Linked.csproj
@@ -0,0 +1,79 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}
+ {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Tasky
+ Tasky.Core
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ BL\About.txt
+
+
+ DAL\About.txt
+
+
+ DL\About.txt
+
+
+ About.txt
+
+
+
+
+ BL\Task.cs
+
+
+ BL\Contracts\BusinessEntityBase.cs
+
+
+ BL\Contracts\IBusinessEntity.cs
+
+
+ BL\Managers\TaskManager.cs
+
+
+ DAL\TaskRepository.cs
+
+
+ DL\SQLite.cs
+
+
+ DL\TaskDatabase.cs
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Adapters/TaskListAdapter.cs b/TaskyProLinked/TaskyAndroid/Adapters/TaskListAdapter.cs
new file mode 100644
index 0000000..734b1bb
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Adapters/TaskListAdapter.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using Android.Widget;
+using Tasky.BL;
+using Android.App;
+using Android;
+
+namespace TaskyAndroid.Adapters {
+ public class TaskListAdapter : BaseAdapter {
+ protected Activity context = null;
+ protected IList tasks = new List();
+
+ public TaskListAdapter (Activity context, IList tasks) : base ()
+ {
+ this.context = context;
+ this.tasks = tasks;
+ }
+
+ public override Task this[int position]
+ {
+ get { return tasks[position]; }
+ }
+
+ public override long GetItemId (int position)
+ {
+ return position;
+ }
+
+ public override int Count
+ {
+ get { return tasks.Count; }
+ }
+
+ public override Android.Views.View GetView (int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
+ {
+ // Get our object for position
+ var item = tasks[position];
+
+ //Try to reuse convertView if it's not null, otherwise inflate it from our item layout
+ // gives us some performance gains by not always inflating a new view
+ // will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell()
+ var view = (convertView ??
+ context.LayoutInflater.Inflate(
+ Android.Resource.Layout.SimpleListItemChecked,
+ parent,
+ false)) as CheckedTextView;
+
+ view.SetText (item.Name==""?"":item.Name, TextView.BufferType.Normal);
+ view.Checked = item.Done;
+
+ //Finally return the view
+ return view;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Assets/AboutAssets.txt b/TaskyProLinked/TaskyAndroid/Assets/AboutAssets.txt
new file mode 100644
index 0000000..ee39886
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Assets/AboutAssets.txt
@@ -0,0 +1,19 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories) and given a Build Action of "AndroidAsset".
+
+These files will be deployed with you package and will be accessible using Android's
+AssetManager, like this:
+
+public class ReadAsset : Activity
+{
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+ InputStream input = Assets.Open ("my_asset.txt");
+ }
+}
+
+Additionally, some Android functions will automatically load asset files:
+
+Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Properties/AndroidManifest.xml b/TaskyProLinked/TaskyAndroid/Properties/AndroidManifest.xml
new file mode 100644
index 0000000..5caeef7
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Properties/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Properties/AssemblyInfo.cs b/TaskyProLinked/TaskyAndroid/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..920873d
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using Android.App;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("TaskyAndroid")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("xamarin")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
+// This app uses the internet, this can be removed if not needed
+[assembly: UsesPermission("android.permission.INTERNET")]
diff --git a/TaskyProLinked/TaskyAndroid/Resources/AboutResources.txt b/TaskyProLinked/TaskyAndroid/Resources/AboutResources.txt
new file mode 100644
index 0000000..10f52d4
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/AboutResources.txt
@@ -0,0 +1,44 @@
+Images, layout descriptions, binary blobs and string dictionaries can be included
+in your application as resource files. Various Android APIs are designed to
+operate on the resource IDs instead of dealing with images, strings or binary blobs
+directly.
+
+For example, a sample Android app that contains a user interface layout (main.axml),
+an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
+would keep its resources in the "Resources" directory of the application:
+
+Resources/
+ drawable/
+ icon.png
+
+ layout/
+ main.axml
+
+ values/
+ strings.xml
+
+In order to get the build system to recognize Android resources, set the build action to
+"AndroidResource". The native Android APIs do not operate directly with filenames, but
+instead operate on resource IDs. When you compile an Android application that uses resources,
+the build system will package the resources for distribution and generate a class called "R"
+(this is an Android convention) that contains the tokens for each one of the resources
+included. For example, for the above Resources layout, this is what the R class would expose:
+
+public class R {
+ public class drawable {
+ public const int icon = 0x123;
+ }
+
+ public class layout {
+ public const int main = 0x456;
+ }
+
+ public class strings {
+ public const int first_string = 0xabc;
+ public const int second_string = 0xbcd;
+ }
+}
+
+You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
+to reference the layout/main.axml file, or R.strings.first_string to reference the first
+string in the dictionary file values/strings.xml.
diff --git a/TaskyProLinked/TaskyAndroid/Resources/drawable-hdpi/launcher.png b/TaskyProLinked/TaskyAndroid/Resources/drawable-hdpi/launcher.png
new file mode 100755
index 0000000..27e8dc1
Binary files /dev/null and b/TaskyProLinked/TaskyAndroid/Resources/drawable-hdpi/launcher.png differ
diff --git a/TaskyProLinked/TaskyAndroid/Resources/drawable-ldpi/launcher.png b/TaskyProLinked/TaskyAndroid/Resources/drawable-ldpi/launcher.png
new file mode 100644
index 0000000..08915d9
Binary files /dev/null and b/TaskyProLinked/TaskyAndroid/Resources/drawable-ldpi/launcher.png differ
diff --git a/TaskyProLinked/TaskyAndroid/Resources/drawable-mdpi/launcher.png b/TaskyProLinked/TaskyAndroid/Resources/drawable-mdpi/launcher.png
new file mode 100644
index 0000000..f784e5c
Binary files /dev/null and b/TaskyProLinked/TaskyAndroid/Resources/drawable-mdpi/launcher.png differ
diff --git a/TaskyProLinked/TaskyAndroid/Resources/drawable-xhdpi/launcher.png b/TaskyProLinked/TaskyAndroid/Resources/drawable-xhdpi/launcher.png
new file mode 100644
index 0000000..32f4a0d
Binary files /dev/null and b/TaskyProLinked/TaskyAndroid/Resources/drawable-xhdpi/launcher.png differ
diff --git a/TaskyProLinked/TaskyAndroid/Resources/drawable/bluebutton.axml b/TaskyProLinked/TaskyAndroid/Resources/drawable/bluebutton.axml
new file mode 100644
index 0000000..d74ebc4
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/drawable/bluebutton.axml
@@ -0,0 +1,61 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Resources/layout/HomeScreen.axml b/TaskyProLinked/TaskyAndroid/Resources/layout/HomeScreen.axml
new file mode 100644
index 0000000..9f74e60
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/layout/HomeScreen.axml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Resources/layout/TaskDetails.axml b/TaskyProLinked/TaskyAndroid/Resources/layout/TaskDetails.axml
new file mode 100644
index 0000000..3a86c12
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/layout/TaskDetails.axml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Resources/layout/TaskListItem.axml b/TaskyProLinked/TaskyAndroid/Resources/layout/TaskListItem.axml
new file mode 100644
index 0000000..707e83c
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/layout/TaskListItem.axml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Resources/values/Strings.xml b/TaskyProLinked/TaskyAndroid/Resources/values/Strings.xml
new file mode 100644
index 0000000..ea47191
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Resources/values/Strings.xml
@@ -0,0 +1,5 @@
+
+
+ Hello World, Click Me!
+ TaskyAndroid
+
diff --git a/TaskyProLinked/TaskyAndroid/Screens/HomeScreen.cs b/TaskyProLinked/TaskyAndroid/Screens/HomeScreen.cs
new file mode 100644
index 0000000..7ef5656
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Screens/HomeScreen.cs
@@ -0,0 +1,70 @@
+using System.Collections.Generic;
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Widget;
+using Tasky.BL;
+using Android.Graphics;
+using Android.Views;
+
+namespace TaskyAndroid.Screens {
+ [Activity (Label = "TaskyPro", MainLauncher = true, Icon="@drawable/launcher")]
+ public class HomeScreen : Activity {
+ protected Adapters.TaskListAdapter taskList;
+ protected IList tasks;
+ protected Button addTaskButton = null;
+ protected ListView taskListView = null;
+
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+
+ View titleView = Window.FindViewById(Android.Resource.Id.Title);
+ if (titleView != null) {
+ IViewParent parent = titleView.Parent;
+ if (parent != null && (parent is View)) {
+ View parentView = (View)parent;
+ parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75 ,0xFF)); //38, 117 ,255
+ }
+ }
+
+
+ // set our layout to be the home screen
+ SetContentView(Resource.Layout.HomeScreen);
+
+ //Find our controls
+ taskListView = FindViewById (Resource.Id.lstTasks);
+ addTaskButton = FindViewById (Resource.Id.btnAddTask);
+
+ // wire up add task button handler
+ if(addTaskButton != null) {
+ addTaskButton.Click += (sender, e) => {
+ StartActivity(typeof(TaskDetailsScreen));
+ };
+ }
+
+ // wire up task click handler
+ if(taskListView != null) {
+ taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
+ var taskDetails = new Intent (this, typeof (TaskDetailsScreen));
+ taskDetails.PutExtra ("TaskID", tasks[e.Position].ID);
+ StartActivity (taskDetails);
+ };
+ }
+ }
+
+ protected override void OnResume ()
+ {
+ base.OnResume ();
+
+ tasks = Tasky.BL.Managers.TaskManager.GetTasks();
+
+ // create our adapter
+ taskList = new Adapters.TaskListAdapter(this, tasks);
+
+ //Hook up our adapter to our ListView
+ taskListView.Adapter = taskList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/Screens/TaskDetailsScreen.cs b/TaskyProLinked/TaskyAndroid/Screens/TaskDetailsScreen.cs
new file mode 100644
index 0000000..9eba316
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/Screens/TaskDetailsScreen.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Widget;
+using Android.Graphics;
+using Android.Views;
+
+using Tasky.BL;
+
+namespace TaskyAndroid.Screens {
+ //TODO: implement proper lifecycle methods
+ [Activity (Label = "Task Details")]
+ public class TaskDetailsScreen : Activity {
+ protected Task task = new Task();
+ protected Button cancelDeleteButton = null;
+ protected EditText notesTextEdit = null;
+ protected EditText nameTextEdit = null;
+ protected Button saveButton = null;
+ CheckBox doneCheckbox;
+
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+ View titleView = Window.FindViewById(Android.Resource.Id.Title);
+ if (titleView != null) {
+ IViewParent parent = titleView.Parent;
+ if (parent != null && (parent is View)) {
+ View parentView = (View)parent;
+ parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75 ,0xFF)); //38, 117 ,255
+ }
+ }
+
+ int taskID = Intent.GetIntExtra("TaskID", 0);
+ if(taskID > 0) {
+ task = Tasky.BL.Managers.TaskManager.GetTask(taskID);
+ }
+
+ // set our layout to be the home screen
+ SetContentView(Resource.Layout.TaskDetails);
+ nameTextEdit = FindViewById(Resource.Id.txtName);
+ notesTextEdit = FindViewById(Resource.Id.txtNotes);
+ saveButton = FindViewById(Resource.Id.btnSave);
+ doneCheckbox = FindViewById(Resource.Id.chkDone);
+
+ // find all our controls
+ cancelDeleteButton = FindViewById(Resource.Id.btnCancelDelete);
+
+
+ // set the cancel delete based on whether or not it's an existing task
+ if(cancelDeleteButton != null)
+ { cancelDeleteButton.Text = (task.ID == 0 ? "Cancel" : "Delete"); }
+
+ // name
+ if(nameTextEdit != null) { nameTextEdit.Text = task.Name; }
+
+ // notes
+ if(notesTextEdit != null) { notesTextEdit.Text = task.Notes; }
+
+ if(doneCheckbox != null) { doneCheckbox.Checked = task.Done; }
+
+ // button clicks
+ cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
+ saveButton.Click += (sender, e) => { Save(); };
+ }
+
+ protected void Save()
+ {
+ task.Name = nameTextEdit.Text;
+ task.Notes = notesTextEdit.Text;
+ task.Done = doneCheckbox.Checked;
+ Tasky.BL.Managers.TaskManager.SaveTask(task);
+ Finish();
+ }
+
+ protected void CancelDelete()
+ {
+ if(task.ID != 0) {
+ Tasky.BL.Managers.TaskManager.DeleteTask(task.ID);
+ }
+ Finish();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyAndroid/TaskyAndroid.csproj b/TaskyProLinked/TaskyAndroid/TaskyAndroid.csproj
new file mode 100755
index 0000000..bda8b52
--- /dev/null
+++ b/TaskyProLinked/TaskyAndroid/TaskyAndroid.csproj
@@ -0,0 +1,81 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.0
+ 2.0
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}
+ {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ TaskyAndroid
+ Resources
+ Assets
+ Resource
+ True
+ Resources\Resource.designer.cs
+ TaskyAndroid
+ Properties\AndroidManifest.xml
+ false
+ armeabi%3barmeabi-v7a%3bx86
+
+
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+ SdkOnly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}
+ Tasky.Core.Android.Source
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyProLinked.sln b/TaskyProLinked/TaskyProLinked.sln
new file mode 100644
index 0000000..e218115
--- /dev/null
+++ b/TaskyProLinked/TaskyProLinked.sln
@@ -0,0 +1,99 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyiOS", "TaskyiOS\TaskyiOS.csproj", "{08FAE550-E302-4022-A871-17E0462E99F3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyAndroid", "TaskyAndroid\TaskyAndroid.csproj", "{82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.iOS.Linked", "Tasky.Core.iOS.Linked\Tasky.Core.iOS.Linked.csproj", "{3A95B215-DC1A-4A51-A2FD-AB811103F1CE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.Android.Source", "Tasky.Core.Android.Source\Tasky.Core.Android.Source.csproj", "{508E0D21-01E5-4A8C-A09F-AC121EDADEB8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.Core.WP7", "Tasky.Core.WP7.Linked\Tasky.Core.WP7.Linked.csproj", "{5E634ED0-7A59-4A39-8415-175034A02C16}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskyWP7", "TaskyWP7\TaskyWP7.csproj", "{8FD09DFC-EE0E-448C-8E0A-6FD727332081}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|iPhone = Debug|iPhone
+ Debug|iPhoneSimulator = Debug|iPhoneSimulator
+ Release|Any CPU = Release|Any CPU
+ Release|iPhone = Release|iPhone
+ Release|iPhoneSimulator = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhone.Build.0 = Debug|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhone.ActiveCfg = Release|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhone.Build.0 = Release|iPhone
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {08FAE550-E302-4022-A871-17E0462E99F3}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhone.Build.0 = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhone.Build.0 = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {508E0D21-01E5-4A8C-A09F-AC121EDADEB8}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {5E634ED0-7A59-4A39-8415-175034A02C16}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhone.Build.0 = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {82F04C1E-2F0D-4396-ADC3-BC9EADEE8E7E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = TaskyiOS\TaskyiOS.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/TaskyProLinked/TaskyWP7/App.xaml b/TaskyProLinked/TaskyWP7/App.xaml
new file mode 100644
index 0000000..c94aa28
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/App.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/App.xaml.cs b/TaskyProLinked/TaskyWP7/App.xaml.cs
new file mode 100644
index 0000000..289d465
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/App.xaml.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+using Microsoft.Phone.Shell;
+
+namespace TaskyWP7 {
+ public partial class App : Application {
+ ///
+ /// Provides easy access to the root frame of the Phone Application.
+ ///
+ /// The root frame of the Phone Application.
+ public PhoneApplicationFrame RootFrame { get; private set; }
+
+ ///
+ /// Constructor for the Application object.
+ ///
+ public App()
+ {
+ // Global handler for uncaught exceptions.
+ UnhandledException += Application_UnhandledException;
+
+ // Standard Silverlight initialization
+ InitializeComponent();
+
+ // Phone-specific initialization
+ InitializePhoneApplication();
+
+ // Show graphics profiling information while debugging.
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // Display the current frame rate counters.
+ Application.Current.Host.Settings.EnableFrameRateCounter = true;
+
+ // Show the areas of the app that are being redrawn in each frame.
+ //Application.Current.Host.Settings.EnableRedrawRegions = true;
+
+ // Enable non-production analysis visualization mode,
+ // which shows areas of a page that are handed off to GPU with a colored overlay.
+ //Application.Current.Host.Settings.EnableCacheVisualization = true;
+
+ // Disable the application idle detection by setting the UserIdleDetectionMode property of the
+ // application's PhoneApplicationService object to Disabled.
+ // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
+ // and consume battery power when the user is not using the phone.
+ PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
+ }
+
+ }
+
+ // Code to execute when the application is launching (eg, from Start)
+ // This code will not execute when the application is reactivated
+ private void Application_Launching(object sender, LaunchingEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is activated (brought to foreground)
+ // This code will not execute when the application is first launched
+ private void Application_Activated(object sender, ActivatedEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is deactivated (sent to background)
+ // This code will not execute when the application is closing
+ private void Application_Deactivated(object sender, DeactivatedEventArgs e)
+ {
+ }
+
+ // Code to execute when the application is closing (eg, user hit Back)
+ // This code will not execute when the application is deactivated
+ private void Application_Closing(object sender, ClosingEventArgs e)
+ {
+ }
+
+ // Code to execute if a navigation fails
+ private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // A navigation has failed; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ // Code to execute on Unhandled Exceptions
+ private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached) {
+ // An unhandled exception has occurred; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ #region Phone application initialization
+
+ // Avoid double-initialization
+ private bool phoneApplicationInitialized = false;
+
+ // Do not add any additional code to this method
+ private void InitializePhoneApplication()
+ {
+ if (phoneApplicationInitialized)
+ return;
+
+ // Create the frame but don't set it as RootVisual yet; this allows the splash
+ // screen to remain active until the application is ready to render.
+ RootFrame = new PhoneApplicationFrame();
+ RootFrame.Navigated += CompleteInitializePhoneApplication;
+
+ // Handle navigation failures
+ RootFrame.NavigationFailed += RootFrame_NavigationFailed;
+
+ // Ensure we don't initialize again
+ phoneApplicationInitialized = true;
+ }
+
+ // Do not add any additional code to this method
+ private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
+ {
+ // Set the root visual to allow the application to render
+ if (RootVisual != RootFrame)
+ RootVisual = RootFrame;
+
+ // Remove this handler since it is no longer needed
+ RootFrame.Navigated -= CompleteInitializePhoneApplication;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/ApplicationIcon.png b/TaskyProLinked/TaskyWP7/ApplicationIcon.png
new file mode 100644
index 0000000..5859393
Binary files /dev/null and b/TaskyProLinked/TaskyWP7/ApplicationIcon.png differ
diff --git a/TaskyProLinked/TaskyWP7/Background.png b/TaskyProLinked/TaskyWP7/Background.png
new file mode 100644
index 0000000..e46f21d
Binary files /dev/null and b/TaskyProLinked/TaskyWP7/Background.png differ
diff --git a/TaskyProLinked/TaskyWP7/MainPage.xaml b/TaskyProLinked/TaskyWP7/MainPage.xaml
new file mode 100644
index 0000000..08ef33f
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/MainPage.xaml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/MainPage.xaml.cs b/TaskyProLinked/TaskyWP7/MainPage.xaml.cs
new file mode 100644
index 0000000..e5cf3d3
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/MainPage.xaml.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+
+namespace TaskyWP7 {
+ public partial class MainPage : PhoneApplicationPage {
+ // Constructor
+ public MainPage()
+ {
+ InitializeComponent();
+
+ DataContext = new TaskListViewModel();
+ Loaded += new RoutedEventHandler(MainPage_Loaded);
+ }
+
+ void MainPage_Loaded(object sender, RoutedEventArgs e)
+ {
+ ((TaskListViewModel)DataContext).BeginUpdate(Dispatcher);
+ }
+
+ private void HandleAdd(object sender, EventArgs e)
+ {
+ NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=-1", UriKind.RelativeOrAbsolute));
+ }
+
+ private void HandleTaskTap(object sender, System.Windows.Input.GestureEventArgs e)
+ {
+ var item = ((Grid)sender).DataContext as TaskViewModel;
+
+ if (item != null) {
+ NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=" + item.ID, UriKind.RelativeOrAbsolute));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/Properties/AppManifest.xml b/TaskyProLinked/TaskyWP7/Properties/AppManifest.xml
new file mode 100644
index 0000000..6712a11
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/Properties/AppManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/TaskyProLinked/TaskyWP7/Properties/AssemblyInfo.cs b/TaskyProLinked/TaskyWP7/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..83c0351
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/Properties/AssemblyInfo.cs
@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TaskyWP7")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TaskyWP7")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("34fa2e2e-440b-4778-abf7-4d5d09dcff14")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/TaskyProLinked/TaskyWP7/Properties/WMAppManifest.xml b/TaskyProLinked/TaskyWP7/Properties/WMAppManifest.xml
new file mode 100644
index 0000000..70be6bd
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/Properties/WMAppManifest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ ApplicationIcon.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Background.png
+ 0
+ TaskyWP7
+
+
+
+
+
diff --git a/TaskyProLinked/TaskyWP7/SplashScreenImage.jpg b/TaskyProLinked/TaskyWP7/SplashScreenImage.jpg
new file mode 100644
index 0000000..353b192
Binary files /dev/null and b/TaskyProLinked/TaskyWP7/SplashScreenImage.jpg differ
diff --git a/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml b/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml
new file mode 100644
index 0000000..d610c0e
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml.cs b/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml.cs
new file mode 100644
index 0000000..9e62d64
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/TaskDetailsPage.xaml.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+using Tasky.BL.Managers;
+using Tasky.BL;
+
+namespace TaskyWP7 {
+ public partial class TaskDetailsPage : PhoneApplicationPage {
+ public TaskDetailsPage()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New) {
+ var vm = new TaskViewModel();
+ var task = default(Task);
+
+ if (NavigationContext.QueryString.ContainsKey("id")) {
+ var id = int.Parse(NavigationContext.QueryString["id"]);
+ task = TaskManager.GetTask(id);
+ }
+
+ if (task != null) {
+ vm.Update(task);
+ }
+
+ DataContext = vm;
+ }
+ }
+
+ private void HandleSave(object sender, EventArgs e)
+ {
+ var taskvm = (TaskViewModel)DataContext;
+ var task = taskvm.GetTask();
+ TaskManager.SaveTask(task);
+ }
+
+ private void HandleDelete(object sender, EventArgs e)
+ {
+ var taskvm = (TaskViewModel)DataContext;
+ if (taskvm.ID >= 0)
+ TaskManager.DeleteTask(taskvm.ID);
+
+ NavigationService.GoBack();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/TaskyWP7.csproj b/TaskyProLinked/TaskyWP7/TaskyWP7.csproj
new file mode 100755
index 0000000..34a0920
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/TaskyWP7.csproj
@@ -0,0 +1,124 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {8FD09DFC-EE0E-448C-8E0A-6FD727332081}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ TaskyWP7
+ TaskyWP7
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ true
+
+
+ true
+ true
+ TaskyWP7.xap
+ Properties\AppManifest.xml
+ TaskyWP7.App
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+
+ ..\Dependencies\Microsoft.Phone.Controls.Toolkit\Microsoft.Phone.Controls.Toolkit.dll
+
+
+
+
+
+
+
+
+
+
+
+ App.xaml
+
+
+ MainPage.xaml
+
+
+
+ TaskDetailsPage.xaml
+
+
+
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+ {5E634ED0-7A59-4A39-8415-175034A02C16}
+ Tasky.Core.WP7
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyWP7/ViewModels/TaskListViewModel.cs b/TaskyProLinked/TaskyWP7/ViewModels/TaskListViewModel.cs
new file mode 100644
index 0000000..8665697
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/ViewModels/TaskListViewModel.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.ComponentModel;
+using System.Windows.Threading;
+using Tasky.BL;
+using System.Collections.ObjectModel;
+using Tasky.BL.Managers;
+using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace TaskyWP7 {
+ public class TaskListViewModel : ViewModelBase {
+
+ public ObservableCollection Items { get; private set; }
+
+ public bool IsUpdating { get; set; }
+ public Visibility ListVisibility { get; set; }
+ public Visibility NoDataVisibility { get; set; }
+
+ public Visibility UpdatingVisibility
+ {
+ get
+ {
+ return (IsUpdating || Items == null || Items.Count == 0) ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+
+ Dispatcher dispatcher;
+
+ public void BeginUpdate(Dispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+
+ IsUpdating = true;
+
+ ThreadPool.QueueUserWorkItem(delegate {
+ var entries = TaskManager.GetTasks();
+ PopulateData(entries);
+ });
+ }
+
+ void PopulateData(IEnumerable entries)
+ {
+ dispatcher.BeginInvoke(delegate {
+ //
+ // Set all the news items
+ //
+ Items = new ObservableCollection(
+ from e in entries
+ select new TaskViewModel(e));
+
+ //
+ // Update the properties
+ //
+ OnPropertyChanged("Items");
+
+ ListVisibility = Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
+ NoDataVisibility = Items.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
+
+ OnPropertyChanged("ListVisibility");
+ OnPropertyChanged("NoDataVisibility");
+ OnPropertyChanged("IsUpdating");
+ OnPropertyChanged("UpdatingVisibility");
+ });
+ }
+
+
+
+ }
+}
diff --git a/TaskyProLinked/TaskyWP7/ViewModels/TaskViewModel.cs b/TaskyProLinked/TaskyWP7/ViewModels/TaskViewModel.cs
new file mode 100644
index 0000000..57d2d55
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/ViewModels/TaskViewModel.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Tasky.BL;
+
+namespace TaskyWP7 {
+ public class TaskViewModel : ViewModelBase {
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Notes { get; set; }
+ public bool Done { get; set; }
+
+ public TaskViewModel ()
+ {
+ }
+ public TaskViewModel (Task item)
+ {
+ Update (item);
+ }
+
+ public void Update (Task item)
+ {
+ ID = item.ID;
+ Name = item.Name;
+ Notes = item.Notes;
+ Done = item.Done;
+ }
+
+ public Task GetTask() {
+ return new Task {
+ ID = this.ID,
+ Name = this.Name,
+ Notes = this.Notes,
+ Done = this.Done
+ };
+ }
+ }
+}
diff --git a/TaskyProLinked/TaskyWP7/ViewModels/ViewModelBase.cs b/TaskyProLinked/TaskyWP7/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..4f2c49c
--- /dev/null
+++ b/TaskyProLinked/TaskyWP7/ViewModels/ViewModelBase.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.ComponentModel;
+
+namespace TaskyWP7 {
+ public class ViewModelBase : INotifyPropertyChanged {
+
+#region IPropertyChanged
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null) {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+#endregion
+ }
+}
diff --git a/TaskyProLinked/TaskyiOS/AL/EditingSource.cs b/TaskyProLinked/TaskyiOS/AL/EditingSource.cs
new file mode 100644
index 0000000..7460aee
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/AL/EditingSource.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+using MonoTouch.Foundation;
+using Tasky.BL;
+
+namespace Tasky.AL
+{
+ // This is our subclass of the fixed-size Source that allows editing
+ public class EditingSource : DialogViewController.Source {
+ public EditingSource (DialogViewController dvc) : base (dvc) {}
+
+ public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath)
+ {
+ // Trivial implementation: we let all rows be editable, regardless of section or row
+ return true;
+ }
+
+ public override UITableViewCellEditingStyle EditingStyleForRow (UITableView tableView, NSIndexPath indexPath)
+ {
+ // trivial implementation: show a delete button always
+ return UITableViewCellEditingStyle.Delete;
+ }
+
+ public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
+ {
+ //
+ // In this method, we need to actually carry out the request
+ //
+ var section = Container.Root [indexPath.Section];
+ var element = section [indexPath.Row] as StringElement;
+ section.Remove (element);
+
+ var dvc = Container as Tasky.Screens.iPhone.Home.controller_iPhone;
+ dvc.DeleteTaskRow (indexPath.Row);
+ }
+ }
+}
+
diff --git a/TaskyProLinked/TaskyiOS/AL/LocalizableBindingContext.cs b/TaskyProLinked/TaskyiOS/AL/LocalizableBindingContext.cs
new file mode 100644
index 0000000..fef2ccc
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/AL/LocalizableBindingContext.cs
@@ -0,0 +1,401 @@
+//
+// Reflect.cs: Creates Element classes from an instance
+//
+// Author:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// Copyright 2010, Novell, Inc.
+//
+// Code licensed under the MIT X11 license
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using MonoTouch.UIKit;
+using System.Drawing;
+using MonoTouch.Foundation;
+using MonoTouch.Dialog;
+
+/*
+ Cloned from https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/MonoTouch.Dialog/Reflect.cs
+ to add localization ability. Unfortunately RootElement.group is marked 'internal' in MonoTouch.Dialog
+ so this implementation is missing RadioGroup functionality ~ scroll to the end of the file to see
+ the commented-out lines.
+
+ Patch to original file
+ https://github.com/conceptdev/MonoTouch.Dialog/commit/74a7898861d542b367af3b98b7d84079f08926f4
+ */
+namespace MonoTouch.Dialog
+{
+ [AttributeUsage (AttributeTargets.Field | AttributeTargets.Property, Inherited=false)]
+ public class LocalizeAttribute : Attribute {}
+
+ public class LocalizableBindingContext : IDisposable {
+ public RootElement Root;
+ Dictionary mappings;
+
+ class MemberAndInstance {
+ public MemberAndInstance (MemberInfo mi, object o)
+ {
+ Member = mi;
+ Obj = o;
+ }
+ public MemberInfo Member;
+ public object Obj;
+ }
+
+ static object GetValue (MemberInfo mi, object o)
+ {
+ var fi = mi as FieldInfo;
+ if (fi != null)
+ return fi.GetValue (o);
+ var pi = mi as PropertyInfo;
+
+ var getMethod = pi.GetGetMethod ();
+ return getMethod.Invoke (o, new object [0]);
+ }
+
+ static void SetValue (MemberInfo mi, object o, object val)
+ {
+ var fi = mi as FieldInfo;
+ if (fi != null){
+ fi.SetValue (o, val);
+ return;
+ }
+ var pi = mi as PropertyInfo;
+ var setMethod = pi.GetSetMethod ();
+ setMethod.Invoke (o, new object [] { val });
+ }
+
+ static string MakeCaption (string name)
+ {
+ var sb = new StringBuilder (name.Length);
+ bool nextUp = true;
+
+ foreach (char c in name){
+ if (nextUp){
+ sb.Append (Char.ToUpper (c));
+ nextUp = false;
+ } else {
+ if (c == '_'){
+ sb.Append (' ');
+ continue;
+ }
+ if (Char.IsUpper (c))
+ sb.Append (' ');
+ sb.Append (c);
+ }
+ }
+ return sb.ToString ();
+ }
+
+ // Returns the type for fields and properties and null for everything else
+ static Type GetTypeForMember (MemberInfo mi)
+ {
+ if (mi is FieldInfo)
+ return ((FieldInfo) mi).FieldType;
+ else if (mi is PropertyInfo)
+ return ((PropertyInfo) mi).PropertyType;
+ return null;
+ }
+
+ public LocalizableBindingContext (object callbacks, object o, string title)
+ {
+ if (o == null)
+ throw new ArgumentNullException ("o");
+
+ mappings = new Dictionary ();
+
+ Root = new RootElement (title);
+ Populate (callbacks, o, Root);
+ }
+
+ void Populate (object callbacks, object o, RootElement root)
+ {
+ MemberInfo last_radio_index = null;
+ var members = o.GetType ().GetMembers (BindingFlags.DeclaredOnly | BindingFlags.Public |
+ BindingFlags.NonPublic | BindingFlags.Instance
+ );
+
+ Section section = null;
+
+ foreach (var mi in members) {
+ Type mType = GetTypeForMember (mi);
+
+ if (mType == null)
+ continue;
+
+ string caption = null;
+ string key = null; // l18n
+ object [] attrs = mi.GetCustomAttributes (false);
+ bool skip = false;
+ bool localize = false;
+ foreach (var attr in attrs) {
+ if (attr is LocalizeAttribute) {
+ localize = true;
+ break;
+ }
+ }
+ foreach (var attr in attrs) {
+ if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
+ skip = true;
+ else if (attr is CaptionAttribute) {
+ caption = ((CaptionAttribute)attr).Caption;
+ if (localize)
+ caption = NSBundle.MainBundle.LocalizedString (caption, caption);
+ } else if (attr is SectionAttribute) {
+ if (section != null)
+ root.Add (section);
+ var sa = attr as SectionAttribute;
+ var header = sa.Caption;
+ var footer = sa.Footer;
+ if (localize) {
+ header = NSBundle.MainBundle.LocalizedString (header, header);
+ footer = NSBundle.MainBundle.LocalizedString (footer, footer);
+ }
+ section = new Section (header, footer);
+ }
+ }
+ if (skip)
+ continue;
+
+ if (caption == null) {
+ caption = MakeCaption (mi.Name);
+ if (localize)
+ caption = NSBundle.MainBundle.LocalizedString (caption, caption);
+ }
+
+ if (section == null)
+ section = new Section ();
+
+ Element element = null;
+ if (mType == typeof(string)) {
+ PasswordAttribute pa = null;
+ AlignmentAttribute align = null;
+ EntryAttribute ea = null;
+ object html = null;
+ NSAction invoke = null;
+ bool multi = false;
+
+ foreach (object attr in attrs) {
+ if (attr is PasswordAttribute)
+ pa = attr as PasswordAttribute;
+ else if (attr is EntryAttribute)
+ ea = attr as EntryAttribute;
+ else if (attr is MultilineAttribute)
+ multi = true;
+ else if (attr is HtmlAttribute)
+ html = attr;
+ else if (attr is AlignmentAttribute)
+ align = attr as AlignmentAttribute;
+
+ if (attr is OnTapAttribute) {
+ string mname = ((OnTapAttribute)attr).Method;
+
+ if (callbacks == null) {
+ throw new Exception ("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor");
+ }
+
+ var method = callbacks.GetType ().GetMethod (mname);
+ if (method == null)
+ throw new Exception ("Did not find method " + mname);
+ invoke = delegate {
+ method.Invoke (method.IsStatic ? null : callbacks, new object [0]);
+ };
+ }
+ }
+
+
+
+ string value = (string)GetValue (mi, o);
+ if (pa != null) {
+ var placeholder = pa.Placeholder;
+ if (localize)
+ placeholder = NSBundle.MainBundle.LocalizedString (placeholder, placeholder);
+ element = new EntryElement (caption, placeholder, value, true);
+ } else if (ea != null) {
+ var placeholder = ea.Placeholder;
+ if (localize)
+ placeholder = NSBundle.MainBundle.LocalizedString (placeholder, placeholder);
+ element = new EntryElement (caption, placeholder, value) { KeyboardType = ea.KeyboardType, AutocapitalizationType = ea.AutocapitalizationType, AutocorrectionType = ea.AutocorrectionType, ClearButtonMode = ea.ClearButtonMode };
+ } else if (multi)
+ element = new MultilineElement (caption, value);
+ else if (html != null)
+ element = new HtmlElement (caption, value);
+ else {
+ var selement = new StringElement (caption, value);
+ element = selement;
+
+ if (align != null)
+ selement.Alignment = align.Alignment;
+ }
+
+ if (invoke != null)
+ ((StringElement)element).Tapped += invoke;
+ } else if (mType == typeof(float)) {
+ var floatElement = new FloatElement (null, null, (float)GetValue (mi, o));
+ floatElement.Caption = caption;
+ element = floatElement;
+
+ foreach (object attr in attrs) {
+ if (attr is RangeAttribute) {
+ var ra = attr as RangeAttribute;
+ floatElement.MinValue = ra.Low;
+ floatElement.MaxValue = ra.High;
+ floatElement.ShowCaption = ra.ShowCaption;
+ }
+ }
+ } else if (mType == typeof(bool)) {
+ bool checkbox = false;
+ foreach (object attr in attrs) {
+ if (attr is CheckboxAttribute)
+ checkbox = true;
+ }
+
+ if (checkbox)
+ element = new CheckboxElement (caption, (bool)GetValue (mi, o));
+ else
+ element = new BooleanElement (caption, (bool)GetValue (mi, o));
+ } else if (mType == typeof(DateTime)) {
+ var dateTime = (DateTime)GetValue (mi, o);
+ bool asDate = false, asTime = false;
+
+ foreach (object attr in attrs) {
+ if (attr is DateAttribute)
+ asDate = true;
+ else if (attr is TimeAttribute)
+ asTime = true;
+ }
+
+ if (asDate)
+ element = new DateElement (caption, dateTime);
+ else if (asTime)
+ element = new TimeElement (caption, dateTime);
+ else
+ element = new DateTimeElement (caption, dateTime);
+ } else if (mType.IsEnum) {
+ var csection = new Section ();
+ ulong evalue = Convert.ToUInt64 (GetValue (mi, o), null);
+ int idx = 0;
+ int selected = 0;
+
+ foreach (var fi in mType.GetFields (BindingFlags.Public | BindingFlags.Static)) {
+ ulong v = Convert.ToUInt64 (GetValue (fi, null));
+
+ if (v == evalue)
+ selected = idx;
+
+ CaptionAttribute ca = Attribute.GetCustomAttribute (fi, typeof(CaptionAttribute)) as CaptionAttribute;
+ var cap = ca != null ? ca.Caption : MakeCaption (fi.Name);
+ if (localize)
+ NSBundle.MainBundle.LocalizedString (cap, cap);
+ csection.Add (new RadioElement (cap));
+ idx++;
+ }
+
+ element = new RootElement (caption, new RadioGroup (null, selected)) { csection };
+ } else if (mType == typeof (UIImage)){
+ element = new ImageElement ((UIImage) GetValue (mi, o));
+ } else if (typeof (System.Collections.IEnumerable).IsAssignableFrom (mType)){
+ var csection = new Section ();
+ int count = 0;
+
+ if (last_radio_index == null)
+ throw new Exception ("IEnumerable found, but no previous int found");
+ foreach (var e in (IEnumerable) GetValue (mi, o)){
+ csection.Add (new RadioElement (e.ToString ()));
+ count++;
+ }
+ int selected = (int) GetValue (last_radio_index, o);
+ if (selected >= count || selected < 0)
+ selected = 0;
+ element = new RootElement (caption, new MemberRadioGroup (null, selected, last_radio_index)) { csection };
+ last_radio_index = null;
+ } else if (typeof (int) == mType){
+ foreach (object attr in attrs){
+ if (attr is RadioSelectionAttribute){
+ last_radio_index = mi;
+ break;
+ }
+ }
+ } else {
+ var nested = GetValue (mi, o);
+ if (nested != null){
+ var newRoot = new RootElement (caption);
+ Populate (callbacks, nested, newRoot);
+ element = newRoot;
+ }
+ }
+
+ if (element == null)
+ continue;
+ section.Add (element);
+ mappings [element] = new MemberAndInstance (mi, o);
+ }
+ root.Add (section);
+ }
+
+ class MemberRadioGroup : RadioGroup {
+ public MemberInfo mi;
+
+ public MemberRadioGroup (string key, int selected, MemberInfo mi) : base (key, selected)
+ {
+ this.mi = mi;
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (disposing){
+ foreach (var element in mappings.Keys){
+ element.Dispose ();
+ }
+ mappings = null;
+ }
+ }
+
+ public void Fetch ()
+ {
+ foreach (var dk in mappings){
+ Element element = dk.Key;
+ MemberInfo mi = dk.Value.Member;
+ object obj = dk.Value.Obj;
+
+ if (element is DateTimeElement)
+ SetValue (mi, obj, ((DateTimeElement) element).DateValue);
+ else if (element is FloatElement)
+ SetValue (mi, obj, ((FloatElement) element).Value);
+ else if (element is BooleanElement)
+ SetValue (mi, obj, ((BooleanElement) element).Value);
+ else if (element is CheckboxElement)
+ SetValue (mi, obj, ((CheckboxElement) element).Value);
+ else if (element is EntryElement){
+ var entry = (EntryElement) element;
+ entry.FetchValue ();
+ SetValue (mi, obj, entry.Value);
+ } else if (element is ImageElement)
+ SetValue (mi, obj, ((ImageElement) element).Value);
+ else if (element is RootElement){
+//HACK: RootElement.group is INTERNAL
+// var re = element as RootElement;
+// if (re.group as MemberRadioGroup != null){
+// var group = re.group as MemberRadioGroup;
+// SetValue (group.mi, obj, re.RadioSelected);
+// } else if (re.group as RadioGroup != null){
+// var mType = GetTypeForMember (mi);
+// var fi = mType.GetFields (BindingFlags.Public | BindingFlags.Static) [re.RadioSelected];
+//
+// SetValue (mi, obj, fi.GetValue (null));
+// }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/AL/TaskDialog.cs b/TaskyProLinked/TaskyiOS/AL/TaskDialog.cs
new file mode 100644
index 0000000..0114123
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/AL/TaskDialog.cs
@@ -0,0 +1,45 @@
+using System;
+using MonoTouch.UIKit;
+using Tasky.BL;
+using MonoTouch.Dialog;
+
+namespace Tasky {
+ ///
+ /// Wrapper class for Task, to use with MonoTouch.Dialog. If it was just iOS platform
+ /// we could apply these attributes directly to the Task class, but because we share that
+ /// with other platforms this wrapper provides a bridge to MonoTouch.Dialog.
+ ///
+ public class TaskDialog {
+ public TaskDialog (Task task)
+ {
+ Name = task.Name;
+ Notes = task.Notes;
+ Done = task.Done;
+ }
+
+ [Localize]
+ [Entry("task name")]
+ public string Name { get; set; }
+
+ [Localize]
+ [Entry("other task info")]
+ public string Notes { get; set; }
+
+ // new property
+ [Localize]
+ [Entry("Done")]
+ public bool Done { get; set; }
+
+ [Localize]
+ [Section ("")]
+ [OnTap ("SaveTask")]
+ [Alignment (UITextAlignment.Center)]
+ public string Save;
+
+ [Localize]
+ [Section ("")]
+ [OnTap ("DeleteTask")]
+ [Alignment (UITextAlignment.Center)]
+ public string Delete;
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/AppDelegate.cs b/TaskyProLinked/TaskyiOS/AppDelegate.cs
new file mode 100644
index 0000000..aa7f321
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/AppDelegate.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace Tasky {
+ [Register ("AppDelegate")]
+ public partial class AppDelegate : UIApplicationDelegate {
+ // class-level declarations
+ UIWindow window;
+ UINavigationController navController;
+ UITableViewController homeViewController;
+
+ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
+ {
+ // create a new window instance based on the screen size
+ window = new UIWindow (UIScreen.MainScreen.Bounds);
+
+ // make the window visible
+ window.MakeKeyAndVisible ();
+
+ // create our nav controller
+ navController = new UINavigationController ();
+
+ // create our home controller based on the device
+ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
+ homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
+ } else {
+// homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
+ }
+
+ // Styling
+ UINavigationBar.Appearance.TintColor = UIColor.FromRGB (38, 117 ,255); // nice blue
+ UITextAttributes ta = new UITextAttributes();
+ ta.Font = UIFont.FromName ("AmericanTypewriter-Bold", 0f);
+ UINavigationBar.Appearance.SetTitleTextAttributes(ta);
+ ta.Font = UIFont.FromName ("AmericanTypewriter", 0f);
+ UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);
+
+
+ // push the view controller onto the nav controller and show the window
+ navController.PushViewController(homeViewController, false);
+ window.RootViewController = navController;
+ window.MakeKeyAndVisible ();
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/Default-Landscape~ipad.png b/TaskyProLinked/TaskyiOS/Default-Landscape~ipad.png
new file mode 100755
index 0000000..5f9c39d
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Default-Landscape~ipad.png differ
diff --git a/TaskyProLinked/TaskyiOS/Default-Portrait~ipad.png b/TaskyProLinked/TaskyiOS/Default-Portrait~ipad.png
new file mode 100755
index 0000000..3a71820
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Default-Portrait~ipad.png differ
diff --git a/TaskyProLinked/TaskyiOS/Default.png b/TaskyProLinked/TaskyiOS/Default.png
new file mode 100755
index 0000000..f7bb4d9
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Default.png differ
diff --git a/TaskyProLinked/TaskyiOS/Default@2x.png b/TaskyProLinked/TaskyiOS/Default@2x.png
new file mode 100755
index 0000000..898f3a3
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Default@2x.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/114_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/114_icon.png
new file mode 100755
index 0000000..dcccfe6
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/114_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/29_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/29_icon.png
new file mode 100755
index 0000000..562cece
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/29_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/50_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/50_icon.png
new file mode 100755
index 0000000..f82972f
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/50_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/512_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/512_icon.png
new file mode 100755
index 0000000..dd7f8cd
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/512_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/57_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/57_icon.png
new file mode 100755
index 0000000..1a51d34
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/57_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/58_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/58_icon.png
new file mode 100755
index 0000000..0c2a723
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/58_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Images/Icons/72_icon.png b/TaskyProLinked/TaskyiOS/Images/Icons/72_icon.png
new file mode 100755
index 0000000..27e8dc1
Binary files /dev/null and b/TaskyProLinked/TaskyiOS/Images/Icons/72_icon.png differ
diff --git a/TaskyProLinked/TaskyiOS/Info.plist b/TaskyProLinked/TaskyiOS/Info.plist
new file mode 100644
index 0000000..50301d8
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/Info.plist
@@ -0,0 +1,40 @@
+
+
+
+
+ CFBundleDisplayName
+ Tasky
+ CFBundleIconFiles
+
+ Images/Icons/57_icon.png
+ Images/Icons/114_icon.png
+ Images/Icons/72_icon.png
+ Images/Icons/29_icon.png
+ Images/Icons/58_icon.png
+ Images/Icons/50_icon.png
+ Images/Icons/512_icon.png
+
+ CFBundleIdentifier
+ com.xamarin.samples.taskytouch
+ CFBundleVersion
+ 1
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/TaskyProLinked/TaskyiOS/Main.cs b/TaskyProLinked/TaskyiOS/Main.cs
new file mode 100644
index 0000000..2bdab5f
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/Main.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace Tasky {
+ public class Application {
+ // This is the main entry point of the application.
+ static void Main (string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main (args, null, "AppDelegate");
+ }
+ }
+}
diff --git a/TaskyProLinked/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs b/TaskyProLinked/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs
new file mode 100644
index 0000000..7e0e89e
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+using Tasky.AL;
+using Tasky.BL;
+
+namespace Tasky.Screens.iPhone.Home {
+ public class controller_iPhone : DialogViewController {
+ List tasks;
+
+ public controller_iPhone () : base (UITableViewStyle.Plain, null)
+ {
+ Initialize ();
+ }
+
+ protected void Initialize()
+ {
+ NavigationItem.SetRightBarButtonItem (new UIBarButtonItem (UIBarButtonSystemItem.Add), false);
+ NavigationItem.RightBarButtonItem.Clicked += (sender, e) => { ShowTaskDetails(new Task()); };
+ }
+
+
+ // MonoTouch.Dialog individual TaskDetails view (uses /AL/TaskDialog.cs wrapper class)
+ LocalizableBindingContext context;
+ TaskDialog taskDialog;
+ Task currentTask;
+ DialogViewController detailsScreen;
+ protected void ShowTaskDetails (Task task)
+ {
+ currentTask = task;
+ taskDialog = new TaskDialog (task);
+
+ var title = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Task Details", "Task Details");
+ context = new LocalizableBindingContext (this, taskDialog, title);
+ detailsScreen = new DialogViewController (context.Root, true);
+ ActivateController(detailsScreen);
+ }
+ public void SaveTask()
+ {
+ context.Fetch (); // re-populates with updated values
+ currentTask.Name = taskDialog.Name;
+ currentTask.Notes = taskDialog.Notes;
+ currentTask.Done = taskDialog.Done;
+ BL.Managers.TaskManager.SaveTask(currentTask);
+ NavigationController.PopViewControllerAnimated (true);
+ context.Dispose (); // per documentation
+ }
+ public void DeleteTask ()
+ {
+ if (currentTask.ID >= 0)
+ BL.Managers.TaskManager.DeleteTask (currentTask.ID);
+ NavigationController.PopViewControllerAnimated (true);
+ }
+
+
+
+ public override void ViewWillAppear (bool animated)
+ {
+ base.ViewWillAppear (animated);
+
+ // reload/refresh
+ PopulateTable();
+ }
+
+ protected void PopulateTable ()
+ {
+ tasks = BL.Managers.TaskManager.GetTasks ().ToList ();
+ var newTask = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("", "");
+ Root = new RootElement ("Tasky") {
+ new Section() {
+ from t in tasks
+ select (Element) new CheckboxElement((t.Name==""?newTask:t.Name), t.Done)
+ }
+ };
+ }
+ public override void Selected (MonoTouch.Foundation.NSIndexPath indexPath)
+ {
+ var task = tasks[indexPath.Row];
+ ShowTaskDetails(task);
+ }
+ public override Source CreateSizingSource (bool unevenRows)
+ {
+ return new EditingSource (this);
+ }
+ public void DeleteTaskRow(int rowId)
+ {
+ BL.Managers.TaskManager.DeleteTask(tasks[rowId].ID);
+ }
+ }
+}
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/TaskyiOS.csproj b/TaskyProLinked/TaskyiOS/TaskyiOS.csproj
new file mode 100755
index 0000000..bc88c04
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/TaskyiOS.csproj
@@ -0,0 +1,100 @@
+
+
+
+ Debug
+ iPhoneSimulator
+ 10.0.0
+ 2.0
+ {08FAE550-E302-4022-A871-17E0462E99F3}
+ {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Exe
+ Tasky
+ Tasky
+
+
+ true
+ full
+ false
+ bin\iPhoneSimulator\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ None
+ true
+
+
+ none
+ false
+ bin\iPhoneSimulator\Release
+ prompt
+ 4
+ false
+ None
+
+
+ true
+ full
+ false
+ bin\iPhone\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ true
+ iPhone Developer
+
+
+ none
+ false
+ bin\iPhone\Release
+ prompt
+ 4
+ false
+ iPhone Developer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {3A95B215-DC1A-4A51-A2FD-AB811103F1CE}
+ Tasky.Core.iOS.Linked
+
+
+
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/en.lproj/Localizable.strings b/TaskyProLinked/TaskyiOS/en.lproj/Localizable.strings
new file mode 100644
index 0000000..f5f97ee
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/en.lproj/Localizable.strings
@@ -0,0 +1,11 @@
+
+"" = "";
+
+"Task Details" = "Task Details";
+"Name" = "Name";
+"task name" = "task name";
+"Notes" = "Notes";
+"other task info"= "other task info";
+"Done" = "Done";
+"Save" = "Save";
+"Delete" = "Delete";
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/es.lproj/Localizable.strings b/TaskyProLinked/TaskyiOS/es.lproj/Localizable.strings
new file mode 100644
index 0000000..9552d2e
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/es.lproj/Localizable.strings
@@ -0,0 +1,12 @@
+/* MACHINE TRANSLATION : apologies for any mistakes */
+
+"" = "";
+
+"Task Details" = "Detalles de la tarea";
+"Name" = "Nombre";
+"task name" = "nombre de la tarea";
+"Notes" = "Notas";
+"other task info"= "otra información de tarea";
+"Done" = "Completo";
+"Save" = "Guardar";
+"Delete" = "Eliminar";
\ No newline at end of file
diff --git a/TaskyProLinked/TaskyiOS/ja.lproj/Localizable.strings b/TaskyProLinked/TaskyiOS/ja.lproj/Localizable.strings
new file mode 100644
index 0000000..0b30012
--- /dev/null
+++ b/TaskyProLinked/TaskyiOS/ja.lproj/Localizable.strings
@@ -0,0 +1,12 @@
+/* MACHINE TRANSLATION : apologies for any mistakes */
+
+"" = "<新しいタスク>";
+
+"Task Details" = "タスクの詳細";
+"Name" = "タイトル";
+"task name" = "タスク名";
+"Notes" = "注釈";
+"other task info"= "他のタスクの情報";
+"Done" = "削除する";
+"Save" = "はい";
+"Delete" = "削除する";
\ No newline at end of file
diff --git a/TaskyProPortable/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll b/TaskyProPortable/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll
new file mode 100644
index 0000000..80a162f
Binary files /dev/null and b/TaskyProPortable/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll differ
diff --git a/TaskyProPortable/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll b/TaskyProPortable/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll
new file mode 100644
index 0000000..44d59b1
Binary files /dev/null and b/TaskyProPortable/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll differ
diff --git a/TaskyProPortable/Tasky.Core.Portable/About.txt b/TaskyProPortable/Tasky.Core.Portable/About.txt
new file mode 100644
index 0000000..205d076
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/About.txt
@@ -0,0 +1,3 @@
+The Tasky.Core library is the reusable portion of the Tasky application. It contains the Business
+Layer (BL), Data Access Layer (DAL), and Data Layer (DL). All of the Tasky.Core code is shared between
+the iOS and Android versions of the application without modification.
\ No newline at end of file
diff --git a/TaskyProPortable/Tasky.Core.Portable/BL/About.txt b/TaskyProPortable/Tasky.Core.Portable/BL/About.txt
new file mode 100644
index 0000000..1b5507d
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/BL/About.txt
@@ -0,0 +1,15 @@
+Business Layer (BL)
+===================
+Sometimes also called the Business Logic Layer (BLL), the BL contains entitiy definitions and
+business logic.
+
+Business Entities
+-----------------
+Business entites are classes that represent real-world objects. They're the core of
+Object-Oriented-Programming (OOP).
+
+Manager Classes
+---------------
+In this particular architecture, we're using the façade pattern (like we did with the DAL)
+which is represented by static Manager classes. The manager classes are an abstraction on
+the DAL and SAL layers and perform any business logic.
\ No newline at end of file
diff --git a/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/BusinessEntityBase.cs b/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/BusinessEntityBase.cs
new file mode 100644
index 0000000..0a0a2b7
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/BusinessEntityBase.cs
@@ -0,0 +1,20 @@
+using System;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL.Contracts {
+ ///
+ /// Business entity base class. Provides the ID property.
+ ///
+ public abstract class BusinessEntityBase : IBusinessEntity {
+ public BusinessEntityBase ()
+ {
+ }
+
+ ///
+ /// Gets or sets the Database ID.
+ ///
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/IBusinessEntity.cs b/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/IBusinessEntity.cs
new file mode 100644
index 0000000..15ba377
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/BL/Contracts/IBusinessEntity.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace Tasky.BL.Contracts {
+ public interface IBusinessEntity {
+ int ID { get; set; }
+ }
+}
+
diff --git a/TaskyProPortable/Tasky.Core.Portable/BL/Managers/TaskManager.cs b/TaskyProPortable/Tasky.Core.Portable/BL/Managers/TaskManager.cs
new file mode 100644
index 0000000..a5460da
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/BL/Managers/TaskManager.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using Tasky.BL;
+using Tasky.DL.SQLiteBase;
+
+namespace Tasky.BL.Managers
+{
+ public class TaskManager
+ {
+ DAL.TaskRepository repository;
+
+ public TaskManager (SQLiteConnection conn)
+ {
+ repository = new DAL.TaskRepository(conn, "");
+ }
+
+ public Task GetTask(int id)
+ {
+ return repository.GetTask(id);
+ }
+
+ public IList GetTasks ()
+ {
+ return new List(repository.GetTasks());
+ }
+
+ public int SaveTask (Task item)
+ {
+ return repository.SaveTask(item);
+ }
+
+ public int DeleteTask(int id)
+ {
+ return repository.DeleteTask(id);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/TaskyProPortable/Tasky.Core.Portable/BL/Task.cs b/TaskyProPortable/Tasky.Core.Portable/BL/Task.cs
new file mode 100644
index 0000000..0d334d9
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/BL/Task.cs
@@ -0,0 +1,24 @@
+using System;
+using Tasky.BL.Contracts;
+using Tasky.DL.SQLite;
+
+namespace Tasky.BL
+{
+ ///
+ /// Represents a Task.
+ ///
+ public class Task : IBusinessEntity
+ {
+ public Task ()
+ {
+ }
+
+ [PrimaryKey, AutoIncrement]
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Notes { get; set; }
+ // new property
+ public bool Done { get; set; }
+ }
+}
+
diff --git a/TaskyProPortable/Tasky.Core.Portable/DAL/About.txt b/TaskyProPortable/Tasky.Core.Portable/DAL/About.txt
new file mode 100644
index 0000000..7825750
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/DAL/About.txt
@@ -0,0 +1,13 @@
+Data Access Layer (DAL)
+=======================
+The data access layer is responsible for providing an abstraction to the data layer. It makes
+sure that no matter what technology(ies) are used for data persistance, a single entry point
+that is technology agnostic exists.
+
+Often, the façade pattern is used, and many times the underlying data persistence technology is
+actually more than one. for example, you might have some data store in xml, other data stored in
+a SQL database, etc. The DAL makes sure that any complexity associated with accessing and aggregating
+these technologies is isolated from the rest of the application.
+
+The DAL is also considered a sibling to the Service Access Layer (SAL), which is responsible for
+access to cloud services, and other network related resources.
\ No newline at end of file
diff --git a/TaskyProPortable/Tasky.Core.Portable/DAL/TaskRepository.cs b/TaskyProPortable/Tasky.Core.Portable/DAL/TaskRepository.cs
new file mode 100644
index 0000000..8e07362
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/DAL/TaskRepository.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Tasky.BL;
+using Tasky.DL.SQLiteBase;
+
+namespace Tasky.DAL {
+ public class TaskRepository {
+ DL.TaskDatabase db = null;
+ protected static string dbLocation;
+ //protected static TaskRepository me;
+
+ public TaskRepository(SQLiteConnection conn, string dbLocation)
+ {
+ // set the db location
+// dbLocation = DatabaseFilePath;
+
+ // instantiate the database
+ db = new Tasky.DL.TaskDatabase(conn, dbLocation);
+ }
+
+// public static string DatabaseFilePath {
+// get {
+// var sqliteFilename = "TaskDB.db3";
+//#if SILVERLIGHT
+// // Windows Phone expects a local path, not absolute
+// var path = sqliteFilename;
+//#else
+
+//#if __ANDROID__
+// // Just use whatever directory SpecialFolder.Personal returns
+// string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ;
+//#else
+// // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
+// // (they don't want non-user-generated data in Documents)
+// string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
+// string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder
+//#endif
+// var path = Path.Combine (libraryPath, sqliteFilename);
+//#endif
+// return path;
+// }
+// }
+
+ public Task GetTask(int id)
+ {
+ return db.GetItem(id);
+ }
+
+ public IEnumerable GetTasks ()
+ {
+ return db.GetItems();
+ }
+
+ public int SaveTask (Task item)
+ {
+ return db.SaveItem(item);
+ }
+
+ public int DeleteTask(int id)
+ {
+ return db.DeleteItem(id);
+ }
+ }
+}
+
diff --git a/TaskyProPortable/Tasky.Core.Portable/DL/About.txt b/TaskyProPortable/Tasky.Core.Portable/DL/About.txt
new file mode 100644
index 0000000..ee62d45
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/DL/About.txt
@@ -0,0 +1,19 @@
+Data Layer:
+===========
+The data layer is typically the lowest level layer of an application. Typically it consists
+of data persistence/retreival code. In this particular application, it contains two classes:
+ - SQLite.cs
+ - TaskDatabase.cs
+
+SQLite
+------
+This is the SQLite.NET library, created by Frank Krueger. It's a lightweight Object Relational
+Model (ORM) that allows you to define your database schema via classes and automatically
+handles the nitty gritty of data persistance and retrieval into/from SQLite as well as actual
+database creation. It also has limited support for LINQ queries.
+
+TaskDatabase
+------------
+TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB.
+It contains methods for retreival and persistance as well as db creation, all based on the
+underlying ORM.
diff --git a/TaskyProPortable/Tasky.Core.Portable/DL/SQLite.Implementation.cs b/TaskyProPortable/Tasky.Core.Portable/DL/SQLite.Implementation.cs
new file mode 100644
index 0000000..5b574a4
--- /dev/null
+++ b/TaskyProPortable/Tasky.Core.Portable/DL/SQLite.Implementation.cs
@@ -0,0 +1,1913 @@
+//
+// Copyright (c) 2009-2011 Krueger Systems, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#if WINDOWS_PHONE
+#define USE_CSHARP_SQLITE
+#endif
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+
+#if USE_CSHARP_SQLITE
+using Community.CsharpSqlite;
+using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
+using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
+#else
+using Sqlite3DatabaseHandle = System.IntPtr;
+using Sqlite3Statement = System.IntPtr;
+#endif
+
+namespace Tasky.DL.SQLite {
+ public class SQLiteException : System.Exception {
+ public SQLite3.Result Result { get; private set; }
+
+ protected SQLiteException(SQLite3.Result r, string message)
+ : base(message)
+ {
+ Result = r;
+ }
+
+ public static SQLiteException New(SQLite3.Result r, string message)
+ {
+ return new SQLiteException(r, message);
+ }
+ }
+
+ ///
+ /// Represents an open connection to a SQLite database.
+ ///
+ public class Connection : SQLiteBase.SQLiteConnection {
+ private bool _open;
+ private TimeSpan _busyTimeout;
+ private Dictionary _mappings = null;
+ private Dictionary _tables = null;
+ private System.Diagnostics.Stopwatch _sw;
+ private long _elapsedMilliseconds = 0;
+
+ public Sqlite3DatabaseHandle Handle { get; private set; }
+#if USE_CSHARP_SQLITE
+ internal static readonly Sqlite3DatabaseHandle NullHandle = null;
+#else
+ internal static readonly Sqlite3DatabaseHandle NullHandle = IntPtr.Zero;
+#endif
+
+ public string DatabasePath { get; private set; }
+
+ public bool TimeExecution { get; set; }
+
+ public bool Trace { get; set; }
+
+ ///
+ /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath.
+ ///
+ ///
+ /// Specifies the path to the database file.
+ ///
+ public Connection(string databasePath) : base (databasePath)
+ {
+ DatabasePath = databasePath;
+ Sqlite3DatabaseHandle handle;
+ var r = SQLite3.Open(DatabasePath, out handle);
+ Handle = handle;
+ if (r != SQLite3.Result.OK) {
+ throw SQLiteException.New(r, "Could not open database file: " + DatabasePath);
+ }
+ _open = true;
+
+ BusyTimeout = TimeSpan.FromSeconds(0.1);
+ }
+
+ //static SQLiteConnection()
+ //{
+ // if (_preserveDuringLinkMagic) {
+ // var ti = new TableInfo();
+ // ti.name = "magic";
+ // }
+ //}
+
+ ///
+ /// Used to list some code that we want the MonoTouch linker
+ /// to see, but that we never want to actually execute.
+ ///
+ static bool _preserveDuringLinkMagic = false;
+
+ ///
+ /// Sets a busy handler to sleep the specified amount of time when a table is locked.
+ /// The handler will sleep multiple times until a total time of has accumulated.
+ ///
+ public TimeSpan BusyTimeout
+ {
+ get { return _busyTimeout; }
+ set
+ {
+ _busyTimeout = value;
+ if (Handle != NullHandle) {
+ SQLite3.BusyTimeout(Handle, (int)_busyTimeout.TotalMilliseconds);
+ }
+ }
+ }
+
+ ///
+ /// Returns the mappings from types to tables that the connection
+ /// currently understands.
+ ///
+ public IEnumerable TableMappings
+ {
+ get
+ {
+ if (_tables == null) {
+ return Enumerable.Empty();
+ } else {
+ return _tables.Values;
+ }
+ }
+ }
+
+ ///
+ /// Retrieves the mapping that is automatically generated for the given type.
+ ///
+ ///
+ /// The type whose mapping to the database is returned.
+ ///
+ ///
+ /// The mapping represents the schema of the columns of the database and contains
+ /// methods to set and get properties of objects.
+ ///
+ public TableMapping GetMapping(Type type)
+ {
+ if (_mappings == null) {
+ _mappings = new Dictionary();
+ }
+ TableMapping map;
+ if (!_mappings.TryGetValue(type.FullName, out map)) {
+ map = new TableMapping(type);
+ _mappings[type.FullName] = map;
+ }
+ return map;
+ }
+
+ ///
+ /// Executes a "create table if not exists" on the database. It also
+ /// creates any specified indexes on the columns of the table. It uses
+ /// a schema automatically generated from the specified type. You can
+ /// later access this schema by calling GetMapping.
+ ///
+ ///
+ /// The number of entries added to the database schema.
+ ///
+ public override int CreateTable()
+ {
+ var ty = typeof(T);
+
+ if (_tables == null) {
+ _tables = new Dictionary();
+ }
+ TableMapping map;
+ if (!_tables.TryGetValue(ty.FullName, out map)) {
+ map = GetMapping(ty);
+ _tables.Add(ty.FullName, map);
+ }
+ var query = "create table if not exists \"" + map.TableName + "\"(\n";
+
+ var decls = map.Columns.Select(p => Orm.SqlDecl(p));
+ var decl = string.Join(",\n", decls.ToArray());
+ query += decl;
+ query += ")";
+
+ var count = Execute(query);
+
+ if (count == 0) { //Possible bug: This always seems to return 0?
+ // Table already exists, migrate it
+ MigrateTable(map);
+ }
+
+ foreach (var p in map.Columns.Where(x => x.IsIndexed)) {
+ var indexName = map.TableName + "_" + p.Name;
+ var q = string.Format("create index if not exists \"{0}\" on \"{1}\"(\"{2}\")", indexName, map.TableName, p.Name);
+ count += Execute(q);
+ }
+
+ return count;
+ }
+
+ public class TableInfo {
+ public int cid { get; set; }
+
+ public string name { get; set; }
+
+ public string type { get; set; }
+
+ public int notnull { get; set; }
+
+ public string dflt_value { get; set; }
+
+ public int pk { get; set; }
+ }
+
+ void MigrateTable(TableMapping map)
+ {
+ var query = "pragma table_info(\"" + map.TableName + "\")";
+
+ var existingCols = Query(query);
+
+ var toBeAdded = new List();
+
+ foreach (var p in map.Columns) {
+ var found = false;
+ foreach (var c in existingCols) {
+ found = p.Name == c.name;
+ if (found)
+ break;
+ }
+ if (!found) {
+ toBeAdded.Add(p);
+ }
+ }
+
+ foreach (var p in toBeAdded) {
+ var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl(p);
+ Execute(addCol);
+ }
+ }
+
+ ///
+ /// Creates a new SQLiteCommand given the command text with arguments. Place a '?'
+ /// in the command text for each of the arguments.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the command text.
+ ///
+ ///
+ /// A
+ ///
+ public override SQLiteBase.SQLiteCommand CreateCommand(string cmdText, params object[] ps)
+ {
+ if (!_open) {
+ throw SQLiteException.New(SQLite3.Result.Error, "Cannot create commands from unopened database");
+ } else {
+ var cmd = new SQLiteCommand(this);
+ cmd.CommandText = cmdText;
+ foreach (var o in ps) {
+ cmd.Bind(o);
+ }
+ return cmd;
+ }
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// Use this method instead of Query when you don't expect rows back. Such cases include
+ /// INSERTs, UPDATEs, and DELETEs.
+ /// You can set the Trace or TimeExecution properties of the connection
+ /// to profile execution.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// The number of rows modified in the database as a result of this execution.
+ ///
+ public override int Execute(string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+
+ if (TimeExecution) {
+ if (_sw == null) {
+ _sw = new System.Diagnostics.Stopwatch();
+ }
+ _sw.Reset();
+ _sw.Start();
+ }
+
+ int r = (cmd as SQLiteCommand).ExecuteNonQuery();
+
+ if (TimeExecution) {
+ _sw.Stop();
+ _elapsedMilliseconds += _sw.ElapsedMilliseconds;
+#if DEBUG
+ Console.WriteLine("Finished in {0} ms ({1:0.0} s total)", _sw.ElapsedMilliseconds, _elapsedMilliseconds / 1000.0);
+#endif
+ }
+
+ return r;
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public override List Query(string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return (cmd as SQLiteCommand).ExecuteQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the mapping automatically generated for
+ /// the given type.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public override IEnumerable DeferredQuery(string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return (cmd as SQLiteCommand).ExecuteDeferredQuery();
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ ///
+ public override List Query(SQLiteBase.TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return (cmd as SQLiteCommand).ExecuteQuery(map);
+ }
+
+ ///
+ /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
+ /// in the command text for each of the arguments and then executes that command.
+ /// It returns each row of the result using the specified mapping. This function is
+ /// only used by libraries in order to query the database via introspection. It is
+ /// normally not used.
+ ///
+ ///
+ /// A to use to convert the resulting rows
+ /// into objects.
+ ///
+ ///
+ /// The fully escaped SQL.
+ ///
+ ///
+ /// Arguments to substitute for the occurences of '?' in the query.
+ ///
+ ///
+ /// An enumerable with one result for each row returned by the query.
+ /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
+ /// connection must remain open for the lifetime of the enumerator.
+ ///
+ public override IEnumerable DeferredQuery(SQLiteBase.TableMapping map, string query, params object[] args)
+ {
+ var cmd = CreateCommand(query, args);
+ return (cmd as SQLiteCommand).ExecuteDeferredQuery(map);
+ }
+
+ ///