Exemplo n.º 1
0
        public override void Awake(NSObject context)
        {
            base.Awake(context);

            // Configure interface objects here.
            Console.WriteLine("{0} awake with context", this);

            //HACK: no app group
            var appGroupContainerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            Console.WriteLine("agcpath: " + appGroupContainerPath);

            var sqliteFilename = "TodoSQLite.db3";
            var path           = Path.Combine(appGroupContainerPath, sqliteFilename);
            var conn           = new SQLiteConnection(path);

            Database = new TodoItemDatabase(conn);

            if (Database.GetItems().Count() == 0)
            {
                Database.SaveItem(new TodoItem {
                    Name = "Buy Pineapple"
                });
                Database.SaveItem(new TodoItem {
                    Name = "Buy Plum", Done = true
                });
                Database.SaveItem(new TodoItem {
                    Name = "Buy Kiwi"
                });
                Database.SaveItem(new TodoItem {
                    Name = "Buy Apple", Notes = "iPhone6s"
                });
            }
        }
partial         void WKInterfaceButton5_Activated(WatchKit.WKInterfaceButton sender)
        {
            if (entryMode) {
                Console.WriteLine("EntryMode=true");

                // Straight to dictation (no suggestions)
            //				PresentTextInputController(new string[0], WatchKit.WKTextInputMode.Plain, (a) => {
            //					Console.WriteLine("Dictation was accepted");
            //					if (a != null && a.Count > 0) {
            //						enteredText = a.GetItem<NSObject>(0).ToString();
            //						Console.WriteLine("   " + a.GetItem<NSObject>(0));
            //						Name.SetText (a.GetItem<NSObject>(0).ToString());
            //						entryMode = false;
            //						EnterText.SetTitle ("Save");
            //					} else {
            //						Console.WriteLine("Error");
            //					}
            //				});

                var suggest = new string[]{"Get groceries", "Buy gas", "Post letter"};
                PresentTextInputController( suggest, WatchKit.WKTextInputMode.AllowEmoji, (a) => {
                    Console.WriteLine("Text was selected");
                    if (a != null && a.Count > 0) {
                        enteredText = a.GetItem<NSObject>(0).ToString();
                        Console.WriteLine("   " + a.GetItem<NSObject>(0));
                        Name.SetText (a.GetItem<NSObject>(0).ToString());
                        entryMode = false;
                        EnterText.SetTitle ("Save");
                    } else {
                        Console.WriteLine("Error");
                    }

                });
            } else {
                Console.WriteLine("EntryMode=false  must save");
                // TODO: save!
                TodoItemDatabase Database = null;
                var todo = new TodoItem{Name = enteredText, Done = false};

                if (Database == null)
                {
                    var FileManager = new NSFileManager ();
                    var appGroupContainer = FileManager.GetContainerUrl ("group.co.conceptdev.WatchTodo");
                    var appGroupContainerPath = appGroupContainer.Path;
                    Console.WriteLine ("agcpath: " + appGroupContainerPath);

                    var sqliteFilename = "TodoSQLite.db3";
                    //			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
                    //			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
                    var path = Path.Combine(appGroupContainerPath, sqliteFilename);
                    var conn = new SQLiteConnection (path);

                    Database = new TodoItemDatabase(conn);
                }
                Database.SaveItem(todo);
                Database.Close();

                PopController();
            }
        }
        partial void WKInterfaceButton5_Activated(WatchKit.WKInterfaceButton sender)
        {
            if (entryMode)
            {
                Console.WriteLine("EntryMode=true");
                var suggest = new string[] { "Get groceries", "Buy gas", "Post letter" };

                PresentTextInputController(suggest, WatchKit.WKTextInputMode.AllowEmoji, (a) => {
                    Console.WriteLine("Text was selected");
                    if (a != null && a.Count > 0)
                    {
                        enteredText = a.GetItem <NSObject>(0).ToString();
                        Console.WriteLine("   " + a.GetItem <NSObject>(0));
                        Name.SetText(a.GetItem <NSObject>(0).ToString());
                        entryMode = false;
                        EnterText.SetTitle("Save");
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                });
            }
            else
            {
                Console.WriteLine("EntryMode=false  must save");
                // TODO: save!
                TodoItemDatabase Database = null;
                var todo = new TodoItem {
                    Name = enteredText, Done = false
                };

                if (Database == null)
                {
                    var FileManager           = new NSFileManager();
                    var appGroupContainer     = FileManager.GetContainerUrl("group.com.conceptdevelopment.WatchTodo");
                    var appGroupContainerPath = appGroupContainer.Path;
                    Console.WriteLine("agcpath: " + appGroupContainerPath);

                    var sqliteFilename = "TodoSQLite.db3";
                    //			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
                    //			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
                    var path = Path.Combine(appGroupContainerPath, sqliteFilename);
                    var conn = new SQLiteConnection(path);

                    Database = new TodoItemDatabase(conn);
                }
                Database.SaveItem(todo);
                Database.Close();

                PopController();
            }
        }
Exemplo n.º 4
0
        partial void Save()
        {
            if (Database == null)
            {
                var appGroupContainerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                Console.WriteLine("agcpath: " + appGroupContainerPath);

                var sqliteFilename = "TodoSQLite.db3";
                var path           = Path.Combine(appGroupContainerPath, sqliteFilename);
                var conn           = new SQLiteConnection(path);

                Database = new TodoItemDatabase(conn);
            }
            Console.WriteLine("Save the todo " + todo.Name);
            Database.SaveItem(todo.As());

            PopController();
        }
partial         void Save()
        {
            if (Database == null)
            {
                var appGroupContainerPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
                Console.WriteLine ("agcpath: " + appGroupContainerPath);

                var sqliteFilename = "TodoSQLite.db3";
                var path = Path.Combine(appGroupContainerPath, sqliteFilename);
                var conn = new SQLiteConnection (path);

                Database = new TodoItemDatabase(conn);
            }
            Console.WriteLine ("Save the todo " + todo.Name);
            Database.SaveItem(todo.As());

            PopController();
        }
Exemplo n.º 6
0
        public override void Awake(NSObject context)
        {
            base.Awake(context);

            // Configure interface objects here.
            Console.WriteLine("{0} awake with context", this);

            var FileManager           = new NSFileManager();
            var appGroupContainer     = FileManager.GetContainerUrl("group.co.conceptdev.WatchTodo");
            var appGroupContainerPath = appGroupContainer.Path;

            Console.WriteLine("agcpath: " + appGroupContainerPath);


            var sqliteFilename = "TodoSQLite.db3";
            var path           = Path.Combine(appGroupContainerPath, sqliteFilename);
            var conn           = new SQLiteConnection(path);

            Database = new TodoItemDatabase(conn);
        }
        partial void Save()
        {
            if (Database == null)
            {
                var FileManager           = new NSFileManager();
                var appGroupContainer     = FileManager.GetContainerUrl("group.com.conceptdevelopment.WatchTodo");
                var appGroupContainerPath = appGroupContainer.Path;
                Console.WriteLine("agcpath: " + appGroupContainerPath);

                var sqliteFilename = "TodoSQLite.db3";
                //			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
                //			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
                var path = Path.Combine(appGroupContainerPath, sqliteFilename);
                var conn = new SQLiteConnection(path);

                Database = new TodoItemDatabase(conn);
            }
            Database.SaveItem(todo.As());

            PopController();
        }
        public override void Awake(NSObject context)
        {
            base.Awake (context);

            // Configure interface objects here.
            Console.WriteLine ("{0} awake with context", this);

            //HACK: no app group
            var appGroupContainerPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
            Console.WriteLine ("agcpath: " + appGroupContainerPath);

            var sqliteFilename = "TodoSQLite.db3";
            var path = Path.Combine(appGroupContainerPath, sqliteFilename);
            var conn = new SQLiteConnection (path);

            Database = new TodoItemDatabase(conn);

            if (Database.GetItems ().Count() == 0) {
                Database.SaveItem (new TodoItem { Name = "Buy Pineapple" });
                Database.SaveItem (new TodoItem { Name = "Buy Plum", Done = true });
                Database.SaveItem (new TodoItem { Name = "Buy Kiwi" });
                Database.SaveItem (new TodoItem { Name = "Buy Apple", Notes="iPhone6s" });
            }
        }
partial         void Save()
        {
            if (Database == null)
            {
                var FileManager = new NSFileManager ();
                var appGroupContainer = FileManager.GetContainerUrl ("group.co.conceptdev.WatchTodo");
                var appGroupContainerPath = appGroupContainer.Path;
                Console.WriteLine ("agcpath: " + appGroupContainerPath);

                var sqliteFilename = "TodoSQLite.db3";
                //			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
                //			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
                var path = Path.Combine(appGroupContainerPath, sqliteFilename);
                var conn = new SQLiteConnection (path);

                Database = new TodoItemDatabase(conn);
            }
            Console.WriteLine ("Save the todo " + todo.Name);
            Database.SaveItem(todo.As());

            PopController();
        }
        partial void WKInterfaceButton5_Activated(WatchKit.WKInterfaceButton sender)
        {
            if (entryMode)
            {
                Console.WriteLine("EntryMode=true");

                // Straight to dictation (no suggestions)
//				PresentTextInputController(new string[0], WatchKit.WKTextInputMode.Plain, (a) => {
//					Console.WriteLine("Dictation was accepted");
//					if (a != null && a.Count > 0) {
//						enteredText = a.GetItem<NSObject>(0).ToString();
//						Console.WriteLine("   " + a.GetItem<NSObject>(0));
//						Name.SetText (a.GetItem<NSObject>(0).ToString());
//						entryMode = false;
//						EnterText.SetTitle ("Save");
//					} else {
//						Console.WriteLine("Error");
//					}
//				});

                var suggest = new string[] { "Get groceries", "Buy gas", "Post letter" };
                PresentTextInputController(suggest, WatchKit.WKTextInputMode.AllowEmoji, (a) => {
                    Console.WriteLine("Text was selected");
                    if (a != null && a.Count > 0)
                    {
                        enteredText = a.GetItem <NSObject>(0).ToString();
                        Console.WriteLine("   " + a.GetItem <NSObject>(0));
                        Name.SetText(a.GetItem <NSObject>(0).ToString());
                        entryMode = false;
                        EnterText.SetTitle("Save");
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                });
            }
            else
            {
                Console.WriteLine("EntryMode=false  must save " + enteredText + ".");
                // TODO: save!
                TodoItemDatabase Database = null;
                var todo = new TodoItem {
                    Name = enteredText, Done = false
                };

                if (Database == null)
                {
                    //HACK: no app group
                    var appGroupContainerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    Console.WriteLine("agcpath: " + appGroupContainerPath);

                    var sqliteFilename = "TodoSQLite.db3";
                    var path           = Path.Combine(appGroupContainerPath, sqliteFilename);
                    var conn           = new SQLiteConnection(path);

                    Database = new TodoItemDatabase(conn);
                }
                Database.SaveItem(todo);
                Database.Close();

                PopController();
            }
        }