//evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString);
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string texto = "";
            string texto1 = "";

            if (NavigationContext.QueryString.TryGetValue("name", out texto))
                this.name = texto;
            if (NavigationContext.QueryString.TryGetValue("uri", out texto1))
                this.uri = texto1;

            //---------------------------------------------------------------------------------------------------------

            using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
            {
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(uri)){
                        Favorite fav = new Favorite { Name = name, Uri = uri };
                        context.Favorites.InsertOnSubmit(fav);
                        context.SubmitChanges();
                }

                // Define query to fetch all customers in database.
                var favv = from Favorite todo in context.Favorites
                           select todo;

                // Execute query and place results into a collection.
                aux = new ObservableCollection<Favorite>(favv);
                listBox.ItemsSource = aux.ToList();
            }
        }
 public void reloadList()
 {
     using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
     {
         var aux = from Favorite x in context.Favorites
                   select x;
         listBox.ItemsSource = aux.ToList();
     }
 }
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the history","Warning", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
                {
                    var a = from x in context.Histories
                            select x;
                    context.Histories.DeleteAllOnSubmit(a);
                    context.SubmitChanges();
                    listBox1.ItemsSource = null;
                }
            }
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
                {
                    var aux = from x in context.Histories
                              select x;

                    listBox1.ItemsSource = aux.ToList();
                }

            }
            catch {

            }
        }
        private void image1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the element?",
              "Warning", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
                {
                    var aux = (from Favorite x in context.Favorites
                               where x.Id == Int32.Parse(((Image)sender).Tag.ToString())
                               select x).Single();

                    context.Favorites.DeleteOnSubmit(aux);
                    context.SubmitChanges();
                    // NavigationService.Navigate(new Uri("/favorite.xaml",UriKind.Relative));
                }
                reloadList();
            }
        }
        // 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)
        {
            checkLicense();
            try
            {
                using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
                {
                    if (!context.DatabaseExists())
                    {
                        // create database if it does not exist
                        context.CreateDatabase();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex.Message, "Creating data base",

                        MessageBoxButton.OK);
            }

             string[] addr = new string[3] { "/EvolucionBrowser;component/share/facebook.jpg", "/EvolucionBrowser;component/share/twitter.jpg", "/EvolucionBrowser;component/share/googleplus.jpg" };
            string[] isol = new string[3] { "facebook.jpg", "twitter.jpg", "googleplus.jpg" };

            string[] fileLocal = new string[7] { "source/source.html", "source/highlight.js", "source/highlight.css", "share/app.html", "share/jquery.min.js", "share/jquery.mobile.min.css", "share/jquery.mobile.min.js" };
            string[] fileIsol = new string[7] { "source.html", "highlight.js", "highlight.css", "app.html", "jquery.min.js", "jquery.mobile.min.css", "jquery.mobile.min.js" };

            SaveImagesToIsoStore(addr,isol);
            saveFileToIsoStore(fileLocal, fileIsol);

            Util util = new Util();
            if(string.IsNullOrEmpty(util.readSEngine_file()) )
            util.setSEngine_file("Google");
        }
        private void webBrowser4_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            _navigationStack4.Push(e.Uri);

            if (webBrowser4.Source != null && webBrowser4.Source != new Uri("/app.html", UriKind.Relative) && webBrowser4.Source != new Uri("/source.html", UriKind.Relative) && webBrowser4.Source != new Uri("about:blank", UriKind.Absolute))
                textBox4.Text = webBrowser4.Source.ToString();

            saveAllinBrowser();

            ProgBar4.Visibility = Visibility.Collapsed;
            setImageBackgroundButton(button4, "Images/reload.jpg");
            button4.Click += new RoutedEventHandler(button4_Click);

            string tit = "";
            try
            {
                tit = (string)webBrowser4.InvokeScript("eval", "document.title.toString()");
            }
            catch { }

            if (pivot1.SelectedIndex == 3 )
            {
                using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
                {
                    History aux = new History { Name = tit, Uri = (textBox4.Text.Length > 1000) ? textBox4.Text.Substring(0, 999) : textBox4.Text };
                    context.Histories.InsertOnSubmit(aux);
                    context.SubmitChanges();
                }
            }
        }