Beispiel #1
0
        private void wep_Changedevent()
        {
            if (!loaded)
            {
                lock (IsolatedStorageSettings.ApplicationSettings)
                {
                    var articles = new List <Article>();
                    var art      = new Article();
                    try
                    {
                        articles = (List <Article>)userSettings["Articles"];
                        art      = articles[0];
                        articles.RemoveAt(0);
                    }
                    catch (Exception ex)
                    {
                        return;
                    }
                    loaded = true;
                    HelperMetjods.UpdateOrAdd(userSettings, "Articles", articles);

                    WikiParser.WikiArticleParser w = new WikiParser.WikiArticleParser(art.ArticleName, art.MainContent, art.ArticleLink, art.ImageLinks);
                    HelperMetjods.UpdateCurrentArticleStorage(w);

                    userSettings.Save();
                    App.ViewModel.wap = w;
                }


                loadData();
            }
        }
Beispiel #2
0
        void Instance_ShakeGesture(object sender, ShakeGestureEventArgs e)
        {
            try
            {
                List <Article> articles = new List <Article>();
                Article        art      = new Article();
                try
                {
                    articles = (List <Article>)userSettings["Articles"];
                    art      = articles[0];
                    articles.RemoveAt(0);
                }
                catch (Exception ex)
                {
                    if (!NetworkInterface.GetIsNetworkAvailable())
                    {
                        offlineGrid.Visibility = Visibility.Visible;
                    }
                    return;
                }

                HelperMetjods.UpdateOrAdd(userSettings, "Articles", articles);

                var w = new WikiParser.WikiArticleParser(art.ArticleName, art.MainContent, art.ArticleLink, art.ImageLinks);

                HelperMetjods.UpdateCurrentArticleStorage(w);

                App.ViewModel.wap = w;
                App.ViewModel.LoadData();
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #3
0
        void MainPage_BackKeyPress()
        {
            try
            {
                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault();

                List <Article> articles = new List <Article>();
                Article        art      = new Article();
                try
                {
                    articles = (List <Article>)userSettings["Articles"];
                    art      = articles[0];
                    articles.RemoveAt(0);
                }
                catch (Exception ex)
                {
                    return;
                }

                HelperMetjods.UpdateOrAdd(userSettings, "Articles", articles);

                WikiParser.WikiArticleParser w = new WikiParser.WikiArticleParser(art.ArticleName, art.MainContent, art.ArticleLink, art.ImageLinks);

                HelperMetjods.UpdateCurrentArticleStorage(w);

                Uri bg = null;
                try
                {
                    bg = new Uri(w.ImageLinks[0].Replace("150px", "250px"), UriKind.Absolute);
                }
                catch
                {
                    bg = new Uri("http://dl.dropbox.com/u/109923/wiki.png", UriKind.Absolute);
                }

                if (w.ArticleName.Length > 15)
                {
                    w.ArticleName = w.ArticleName.Substring(0, 15) + "...";
                }

                //test if Tile was created
                if (TileToFind != null)
                {
                    TileToFind.Update(new StandardTileData
                    {
                        Title           = w.ArticleName,
                        BackgroundImage = bg,
                        Count           = 0,

                        BackTitle           = w.ArticleName,
                        BackBackgroundImage = new Uri("http://dl.dropbox.com/u/109923/wiki.png", UriKind.Absolute)
                    });
                }
            }
            catch (Exception ex)
            {
                int a = 1;
            }
        }
Beispiel #4
0
        void image1_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            string link = ((BitmapImage)((Image)sender).Source).UriSource.AbsoluteUri;

            HelperMetjods.UpdateOrAdd(userSettings, "BigImageLink", link.Replace("150px", "480px"));

            Uri i = new Uri("/ImageShow.xaml", UriKind.Relative);

            NavigationService.Navigate(i);
        }
Beispiel #5
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            if (wap != null)
            {
                wap_Changedevent();
            }
            else
            {
                wap = new WikiArticleParser(HelperMetjods.GetLanguage(), false);
                wap.Changedevent += new WikiArticleParser.ArticleDownHanlder(wap_Changedevent);
            }

            this.IsDataLoaded = true;
        }
Beispiel #6
0
        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            loadData();

            Thread t = new Thread(() => {
                while (!loaded)
                {
                    Thread.Sleep(5000);
                    wep_Changedevent();
                }
            });

            t.Start();

            HelperMetjods.getFutureArticles();
        }
Beispiel #7
0
        private void ResetArticles()
        {
            Thread t = new Thread(() =>
            {
                try
                {
                    List <Article> articles = new List <Article>();
                    try
                    {
                        articles = (List <Article>)userSettings["Articles"];
                    }
                    catch { }

                    articles.Clear();

                    HelperMetjods.UpdateOrAdd(userSettings, "Articles", articles);

                    HelperMetjods.getFutureArticles();
                }
                catch { }
            });

            t.Start();
        }
Beispiel #8
0
        void ViewModel_LoadImagesEvent(List <string> imageLinks)
        {
            this.Dispatcher.BeginInvoke(
                () =>
            {
                loaded = true;
                firstBootgrid.Visibility = Visibility.Collapsed;

                App.ViewModel.ArticleName = App.ViewModel.wap.ArticleName;
                App.ViewModel.ArticleLink = App.ViewModel.wap.ArticleLink;

                try
                {
                    if (ContentStack.Children.Count == 3)
                    {
                        ContentStack.Children.RemoveAt(0);
                    }

                    TextBlock textBlock = (XamlReader.Load(App.ViewModel.wap.MainContent) as TextBlock);
                    ContentStack.Children.Insert(0, textBlock);
                }
                catch (Exception ex)
                {
                    int a = 1;
                }

                ImageStack.Children.Clear();
                int i = 0;
                foreach (var link in imageLinks)
                {
                    Image image1 = new Image();

                    image1.Stretch              = Stretch.Uniform;
                    image1.Width                = 150;
                    Uri uri                     = new Uri(link, UriKind.Absolute);
                    image1.Source               = new BitmapImage(uri);
                    image1.MouseLeftButtonDown += image1_MouseLeftButtonDown;

                    ImageStack.Children.Add(image1);
                    i++;

                    if (i == 10)
                    {
                        break;
                    }
                }
            });

            List <Article> articles = new List <Article>();

            try
            {
                articles = (List <Article>)userSettings["Articles"];
            }
            catch
            {
            }

            int maks = 15;

            if (articles.Count < maks)
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    WikiParser.WikiArticleParser wep = new WikiArticleParser(HelperMetjods.GetLanguage(), true);
                }
            }
        }
Beispiel #9
0
 private void ToggleSwitch_Unchecked(object sender, System.Windows.RoutedEventArgs e)
 {
     HelperMetjods.UpdateOrAdd(userSettings, "lang", false);
     ResetArticles();
 }