Пример #1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            free = new NNFreeAPI(PublicData.host, PublicData.port);

            if (free.Connect() == 1)
            {
                MessageBox.Show("Мы не можем подключиться к серверу\nВозможно отсутствует подключение к интернету");
                IsolatedStorageSettings.ApplicationSettings.Save();
                Application.Current.Terminate();
            }
            else
            {
                advert_id = free.NumberOfAds();
                string   value = free.ListAds(advert_id.ToString());
                string[] ads   = value.Split(new Char[] { '/' });
                int      n     = 0;

                foreach (string s in ads)
                {
                    // если строка не пустая
                    if (s.Trim() != "")
                    {
                        string[] text     = s.Split(new Char[] { '|' });
                        string[] big_text = free.GetAdvert(text[0]).Split(new Char[] { '/' });
                        list_ads.Items.Add(new Adverts()
                        {
                            owner = big_text[0], low_text = text[1], name = big_text[3], big_text = big_text[2], advert_id = "# " + text[0], ImagePath = "http://109.120.164.212/photos/" + text[0] + ".jpg" + "?" + Guid.NewGuid().ToString()
                        });
                        n = Int32.Parse(text[0]);
                    }
                }
                advert_id = n - 1;
            }
        }
Пример #2
0
        private static void OnListVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MenuPage     page   = d as MenuPage;
            ScrollViewer viewer = page.scrollViewer;
            //Checks if the Scroll has reached the last item based on the ScrollableHeight
            bool atBottom = viewer.VerticalOffset >= viewer.ScrollableHeight / 30;

            if (atBottom)
            {
                //MessageBox.Show("here");
                if (advert_id < 0)
                {
                    return;
                }

                string   value = free.ListAds(advert_id.ToString());
                string[] ads   = value.Split(new Char[] { '/' });
                int      n     = 0;

                //MessageBox.Show(value);
                foreach (string s in ads)
                {
                    // если строка не пустая
                    if (s.Trim() != "")
                    {
                        string[] text     = s.Split(new Char[] { '|' });
                        string[] big_text = free.GetAdvert(text[0]).Split(new Char[] { '/' });
                        page.list_ads.Items.Add(new Adverts()
                        {
                            owner = big_text[0], low_text = text[1], name = big_text[3], big_text = big_text[2], advert_id = "# " + text[0], ImagePath = "http://109.120.164.212/photos/" + text[0] + ".jpg" + "?" + Guid.NewGuid().ToString()
                        });
                        n = Int32.Parse(text[0]);
                    }
                }
                advert_id = n - 1;
            }
        }