Example #1
0
        private async void LoadUser()
        {
            Application.UseWaitCursor = true;
            lStatus.Text = lDetected.Text = "";
            string act = "Подготовка строки запроса.";

            ApiPath             = lApi.Text + tUser.Text + "/";
            Program.LocalBase   = tLocal.Text;
            Program.VirtualBase = ApiPath;

            fWork fw = new fWork();

            fw.Show();
            try
            {
                act          = "Загрузка API";
                lStatus.Text = "Запрос " + ApiPath;
                Stream atomStream = await Program.Open(ApiPath);

                fw.Hide();

                act          = "Обработка Atom";
                lStatus.Text = "Получен ответ сервера. Разборка...";
                XmlReader xr = XmlReader.Create(atomStream);

                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element)
                    {
                        if (xr.Name == "app:workspace")
                        {
                            ParseWorkspace(xr);
                        }
                    }
                }

                act = "Okay";
                if (Program.LocalOnly)
                {
                    lStatus.Text = "Готово. Работа с локальной базой.";
                }
                else
                {
                    lStatus.Text = "Готово. Сетевой режим.";
                }
                atomStream.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Не выполнено: " + act);
                lStatus.Text = "Ошибка.";
            }
            finally
            {
                Application.UseWaitCursor = false;
                fw.Dispose();
            }
        }
Example #2
0
        private async void bAllPhoto_Click(object sender, EventArgs e)
        {
            fWork fw = new fWork();

            fw.Show();

            fList fa = new fList();

            fa.Show();
            fa.LoadAlbums(await Program.Open(bAllPhoto.Tag.ToString()), true, "Все фото: ", true);

            fw.Hide();
        }
Example #3
0
        private async void bNext_Click(object sender, EventArgs e, bool All = false)
        {
            if (nextWindow != null)
            {
                nextWindow.Activate(); return;
            }


            fWork fw = new fWork();

            fw.Show();

            fList fa = new fList();

            fa.Show();
            fa.LoadAlbums(await Program.Open(bNext.Tag.ToString()), isAlbum, winTitle, All);
            nextWindow = fa;

            fw.Hide();
        }
Example #4
0
        public async void Process(string URL, bool IsAlbum, string WinTitle = "", bool All = false, bool Close = false)
        {
            //открыть конкретный пункт
            fWork fw = new fWork();

            fw.Show();
            try
            {
                if (URL.Contains("/photo/"))
                {
                    fPhoto fp = new fPhoto();
                    fp.Show();
                    fp.LoadPhoto(await Program.Open(URL));
                    if (Close)
                    {
                        fp.Hide();
                    }
                }
                else
                {
                    fList fap = new fList();
                    fap.Show();
                    if (WinTitle == "")
                    {
                        WinTitle = winTitle;
                    }
                    fap.LoadAlbums(await Program.Open(URL), IsAlbum, WinTitle, All);
                    if (Close)
                    {
                        fap.Hide();
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Список по адресу\n" + URL + "\nне открывается. " + ex.Message + "\n" + ex.StackTrace);
            }

            fw.Hide();
        }
Example #5
0
        //<entry></>
        private async void ParseEntry(XmlReader XR)
        {
            AlbumEntry ae = new AlbumEntry();

            while (XR.Read())
            {
                if (XR.NodeType == XmlNodeType.Element)
                {
                    if (XR.Name == "id")
                    {
                        ae.id = XR.ReadInnerXml();
                    }
                    if (XR.Name == "name")
                    {
                        ae.authorName = XR.ReadInnerXml();
                    }
                    if (XR.Name == "f:uid")
                    {
                        ae.authorFuid = XR.ReadInnerXml();
                    }
                    if (XR.Name == "title")
                    {
                        ae.title = XR.ReadInnerXml();
                    }
                    if (XR.Name == "summary")
                    {
                        ae.summary = XR.ReadInnerXml();
                    }
                    if (XR.Name == "link" && XR.GetAttribute("rel") == "self")
                    {
                        ae.self = XR.GetAttribute("href");
                    }
                    if (XR.Name == "link" && XR.GetAttribute("rel") == "photos")
                    {
                        ae.photos = XR.GetAttribute("href");
                    }
                    if (XR.Name == "link" && XR.GetAttribute("rel") == "cover")
                    {
                        ae.cover = XR.GetAttribute("href");
                    }
                    if (XR.Name == "published")
                    {
                        ae.published = XR.ReadInnerXml();
                    }
                    if (XR.Name == "app:edited")
                    {
                        ae.edited = XR.ReadInnerXml();
                    }
                    if (XR.Name == "updated")
                    {
                        ae.updated = XR.ReadInnerXml();
                    }
                    if (XR.Name == "f:protected")
                    {
                        ae.fProtected = XR.GetAttribute("value");
                    }
                    if (XR.Name == "f:image-count")
                    {
                        ae.fTmageCount = XR.GetAttribute("value");
                    }

                    if (XR.Name == "link" && XR.GetAttribute("rel") == "edit-media")
                    {
                        ae.editMedia = XR.GetAttribute("href");
                    }
                    if (XR.Name == "f:created")
                    {
                        ae.fCreated = XR.ReadInnerXml();
                    }
                    if (XR.Name == "access")
                    {
                        ae.access = XR.GetAttribute("value");
                    }
                    if (XR.Name == "xxx")
                    {
                        ae.xxx = XR.GetAttribute("value");
                    }
                    if (XR.Name == "hide_original")
                    {
                        ae.hideOriginal = XR.GetAttribute("value");
                    }
                    if (XR.Name == "disable_comments")
                    {
                        ae.disableComments = XR.GetAttribute("value");
                    }
                    if (XR.Name == "category" && XR.GetAttribute("scheme").Contains("tags"))
                    {
                        ae.tags.Add(XR.GetAttribute("term"));
                    }
                    if (XR.Name == "georss:point")
                    {
                        ae.edited = XR.ReadOuterXml();
                    }
                    if (XR.Name == "f:pod-date")
                    {
                        ae.fPodDate = XR.ReadInnerXml();
                    }
                    if (XR.Name == "f:address-binding")
                    {
                        ae.fAddressBinding = XR.ReadInnerXml();
                    }
                    if (XR.Name == "f:img" && XR.GetAttribute("size") == "orig")
                    {
                        ae.fImgOrig = XR.GetAttribute("href");
                    }
                    if (Program.SavePics && ae.fImgOrig != null)
                    {
                        fWork fw = new fWork();
                        fw.Show();
                        try { await Program.Open(ae.fImgOrig); }
                        catch { /*On Error Resume Next 'по барабану, качается же */ }
                        fw.Dispose();
                    }
                }
                if (XR.NodeType == XmlNodeType.EndElement)
                {
                    if (XR.Name == "entry")
                    {
                        break;
                    }
                }
            }
            lbItems.Items.Add(ae);
        }