Пример #1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            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(libraryPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                File.Copy(sqliteFilename, path);
            }


            var db     = new ADODatabase(path);
            var taskdb = new TodoItemDatabase(db);

            // Set the database connection string
            App.SetDatabaseConnection(taskdb);


            window.RootViewController = new RazorViewController();

            // make the window visible
            window.MakeKeyAndVisible();

            return(true);
        }
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			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(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}


			var db = new ADODatabase(path);
			var taskdb = new TodoItemDatabase(db);

			// Set the database connection string
			App.SetDatabaseConnection (taskdb);


			window.RootViewController = new RazorViewController ();

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            #region Database setup
            var    sqliteFilename = "TodoSQLite.db3";
            string documentsPath  = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);             // Documents folder
            var    path           = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                var s = Resources.OpenRawResource(RazorTodo.Resource.Raw.TodoSQLite);                  // RESOURCE NAME ###

                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }

            var db     = new ADODatabase(path);
            var taskdb = new TodoItemDatabase(db);

            // Set the database connection string
            App.SetDatabaseConnection(taskdb);
            #endregion

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView> (Resource.Id.webView);
            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new RazorWebViewClient(this));

            // Render the view from the type generated from RazorView.cshtml
            var model    = App.Database.GetItems().ToList();
            var template = new TodoList()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			#region Database setup
			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
			var path = Path.Combine(documentsPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists(path))
			{
				var s = Resources.OpenRawResource(RazorTodo.Resource.Raw.TodoSQLite);  // RESOURCE NAME ###

				// create a write stream
				FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				// write to the stream
				ReadWriteStream(s, writeStream);
			}

			var db = new ADODatabase(path);
			var taskdb = new TodoItemDatabase(db);

			// Set the database connection string
			App.SetDatabaseConnection (taskdb);
			#endregion

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			var webView = FindViewById<WebView> (Resource.Id.webView);
			webView.Settings.JavaScriptEnabled = true;

			// Use subclassed WebViewClient to intercept hybrid native calls
			webView.SetWebViewClient (new RazorWebViewClient (this));

			// Render the view from the type generated from RazorView.cshtml
			var model = App.Database.GetItems ().ToList();
			var template = new TodoList () { Model = model };
			var page = template.GenerateString ();

			// Load the rendered HTML into the view with a base URL 
			// that points to the root of the bundled Assets folder
			webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
		}
Пример #5
0
 public static void SetDatabaseConnection(TodoItemDatabase db)
 {
     database = db;
 }
Пример #6
0
 public static void SetDatabaseConnection(SQLite.Net.SQLiteConnection connection)
 {
     conn     = connection;
     database = new TodoItemDatabase(conn);
 }
Пример #7
0
		public static void SetDatabaseConnection (TodoItemDatabase db)
		{
			database = db;
		}
Пример #8
0
		public static void SetDatabaseConnection (SQLite.Net.SQLiteConnection connection)
		{
			conn = connection;
			database = new TodoItemDatabase (conn);
		}