Exemplo n.º 1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var promptConfig = new PromptConfig();

            promptConfig.InputType     = InputType.Url;
            promptConfig.IsCancellable = true;
            promptConfig.Message       = "URL을 입력해주세요.";
            var result = await UserDialogs.Instance.PromptAsync(promptConfig);

            if (result.Ok)
            {
                var elem = new DownloadElement(result.Text);
                List.Children.Insert(0, elem);
                //DDMBM.Add((null, result.Text));
            }
        }
Exemplo n.º 2
0
 private void DownloadPage_Appearing(object sender, EventArgs e)
 {
     if (loaded)
     {
         return;
     }
     loaded = true;
     Task.Run(() =>
     {
         foreach (var dbm in DownloadDBManager.Instance.QueryAll())
         {
             var elem = new DownloadElement(dbm);
             Device.BeginInvokeOnMainThread(() =>
             {
                 List.Children.Insert(0, elem);
                 //DDMBM.Add((dbm, null));
             });
             Thread.Sleep(200);
         }
     });
 }
Exemplo n.º 3
0
        public DownloadInfoPage(DownloadDBModel dbm)
        {
            InitializeComponent();

            DBM = dbm;

            if (!string.IsNullOrWhiteSpace(dbm.ShortInfo))
            {
                Information.Text = dbm.ShortInfo;
            }
            else
            {
                Information.Text = dbm.Url;
            }

            var model = ExtractorManager.Instance.GetExtractor(dbm.Url);

            if (model != null)
            {
                Type.Text = model.GetType().Name.Replace("Extractor", " 추출기");
            }
            else
            {
                Type.Text      = "찾을 수 없음";
                Type.TextColor = Color.Red;
            }

            Date.Text = dbm.StartsTime.ToString();

            switch (dbm.State)
            {
            case DownloadDBState.Aborted:
                State.Text      = "다운로드 취소됨";
                State.TextColor = Color.Orange;
                break;

            case DownloadDBState.Downloaded:
                State.Text = "다운로드됨";
                break;

            case DownloadDBState.ErrorOccured:
                State.Text      = "다운로드 중 오류가 발생함";
                State.TextColor = Color.Red;
                break;

            case DownloadDBState.Forbidden:
                State.Text      = "다운로드 금지됨";
                State.TextColor = Color.Red;
                break;

            case DownloadDBState.Downloading:
                State.Text      = "다운로드 도중 중단됨";
                State.TextColor = Color.Orange;
                break;
            }

            Capacity.Text = $"{dbm.CountOfFiles}개 항목 [{DownloadElement.convert_bytes2string(dbm.SizeOfContents)}]";

            if (!string.IsNullOrWhiteSpace(dbm.Directory))
            {
                Witch.Text = dbm.Directory;
            }
            else
            {
                Witch.Text = "?";
            }

            if (!string.IsNullOrWhiteSpace(dbm.InfoCache))
            {
                if (CacheManager.Instance.Exists(dbm.InfoCache))
                {
                    var ss   = CacheManager.Instance.Find(dbm.InfoCache);
                    var info = JToken.Parse(CacheManager.Instance.Find(dbm.InfoCache))["Type"].ToObject <ExtractedInfo.ExtractedType>();
                    switch (info)
                    {
                    case ExtractedInfo.ExtractedType.WorksComic:
                        Genre.Text = "만화";
                        break;

                    case ExtractedInfo.ExtractedType.Group:
                    case ExtractedInfo.ExtractedType.UserArtist:
                        Genre.Text = "일러스트 및 사진";
                        break;

                    case ExtractedInfo.ExtractedType.Community:
                        Genre.Text = "게시글";
                        break;
                    }
                }
            }

            Thumbnail.Success += (s, e) =>
            {
                var h = e.ImageInformation.OriginalHeight;
                var w = e.ImageInformation.OriginalWidth;

                if (h < 200 && w < 200)
                {
                    ThumbnailFrame.HeightRequest = h;
                    ThumbnailFrame.WidthRequest  = w;
                }
                else
                {
                    ThumbnailFrame.HeightRequest = 300;
                    ThumbnailFrame.WidthRequest  = 300;
                }
            };

            if (!string.IsNullOrWhiteSpace(dbm.ThumbnailCahce))
            {
                Task.Run(() =>
                {
                    Thread.Sleep(100);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        var thumbnail           = dbm.ThumbnailCahce;
                        Thumbnail.HeightRequest = Height;
                        Thumbnail.IsVisible     = true;
                        Thumbnail.Source        = thumbnail;

                        Background.HeightRequest = Height;
                        Background.WidthRequest  = Width;
                        Background.IsVisible     = true;
                        Background.Source        = thumbnail;
                    });
                });
            }
        }