Ejemplo n.º 1
0
        public void DoSearch(SynchronizationContext context)
        {
            NijieSearchOption option = new NijieSearchOption();

            option.Sort     = Sort;
            option.Query    = Query;
            option.Page     = Page;
            option.SearchBy = SearchBy;
            option.Matching = Matching;

            try
            {
                _search = MainWindow.Bot.Search(option);

                Images = new ObservableCollection <NijieImageViewModel>();
                foreach (var image in _search.Images)
                {
                    var temp = new NijieImageViewModel(image);
                    context.Send((x) =>
                    {
                        Images.Add(temp);
                    }, null);
                }

                onPropertyChanged("TotalImages");
            }
            catch (NijieException ne)
            {
                Status = "Error: " + ne.Message;
            }
        }
Ejemplo n.º 2
0
        public ImagePage()
        {
            ViewData = new NijieImageViewModel();
            InitializeComponent();
            #if DEBUG

            //iewData.ImageId = 15880;
            ViewData.ImageId = 67940;
            #endif
            this.DataContext = ViewData;
        }
        public void GetMember(SynchronizationContext context)
        {
            try
            {
                _member       = MainWindow.Bot.ParseMember(this.MemberId, this.Mode, this.Page);
                this.UserName = _member.UserName;

                ImageLoader.LoadImage(_member.AvatarUrl, _member.MemberUrl,
                                      new Action <BitmapImage, string>((image, status) =>
                {
                    this.AvatarImage   = null;
                    this.AvatarImage   = image;
                    _avatarImageStatus = status;
                }
                                                                       ));

                if (_member.Images != null)
                {
                    Images = new ObservableCollection <NijieImageViewModel>();
                    foreach (var image in _member.Images)
                    {
                        var temp = new NijieImageViewModel(image);
                        context.Send((x) =>
                        {
                            Images.Add(temp);
                        }, null);
                    }

                    this.Status = String.Format("Loaded: {0} images.", _member.Images.Count);
                    onPropertyChanged("TotalImages");
                    this.HasError = false;
                }
            }
            catch (NijieException ne)
            {
                MainWindow.Log.Error(ne.Message, ne);

                this.UserName    = null;
                this.AvatarImage = ViewModelHelper.NoAvatar;
                context.Send((x) =>
                {
                    if (Images != null)
                    {
                        Images.Clear();
                        Images = null;
                    }
                }, null);

                this.HasError = true;
                this.Status   = "[Error] " + ne.Message;
            }
        }
Ejemplo n.º 4
0
        public void GetMyImagesBookmark(SynchronizationContext context)
        {
            try
            {
                var result = MainWindow.Bot.ParseMyImageBookmark(this.Page);

                this.Images = new ObservableCollection <NijieImageViewModel>();
                foreach (var item in result.Item1)
                {
                    NijieImageViewModel m = new NijieImageViewModel(item);
                    context.Send((x) =>
                    {
                        this.Images.Add(m);
                    }, null);
                }
                this.IsNextPageAvailable = result.Item2;
                this.Status = String.Format("Found {0} images(s).", this.Images.Count);
            }
            catch (NijieException ne)
            {
                this.Status = "Error: " + ne.Message;
            }
        }
        public void GetMember(SynchronizationContext context)
        {
            try
            {
                _member = MainWindow.Bot.ParseMember(this.MemberId, this.Mode, this.Page);
                this.UserName = _member.UserName;

                ImageLoader.LoadImage(_member.AvatarUrl, _member.MemberUrl,
                            new Action<BitmapImage, string>((image, status) =>
                            {
                                this.AvatarImage = null;
                                this.AvatarImage = image;
                                _avatarImageStatus = status;
                            }
                        ));

                if (_member.Images != null)
                {
                    Images = new ObservableCollection<NijieImageViewModel>();
                    foreach (var image in _member.Images)
                    {
                        var temp = new NijieImageViewModel(image);
                        context.Send((x) =>
                        {
                            Images.Add(temp);
                        }, null);
                    }

                    this.Status = String.Format("Loaded: {0} images.", _member.Images.Count);
                    onPropertyChanged("TotalImages");
                    this.HasError = false;
                }
            }
            catch (NijieException ne)
            {
                MainWindow.Log.Error(ne.Message, ne);

                this.UserName = null;
                this.AvatarImage = ViewModelHelper.NoAvatar;
                context.Send((x) =>
                    {
                        if (Images != null)
                        {
                            Images.Clear();
                            Images = null;
                        }
                    }, null);

                this.HasError = true;
                this.Status = "[Error] " + ne.Message;
            }
        }
Ejemplo n.º 6
0
        private void ExecuteGetImageCommand(object sender, ExecutedRoutedEventArgs e)
        {
            ViewData = new NijieImageViewModel() { ImageId = ViewData.ImageId };
            ModernDialog d = new ModernDialog();
            d.Content = "Loading data...";
            //d.Closed += new EventHandler((s, ex) => { ViewData.Message = "Still loading..."; });
            System.Threading.ThreadPool.QueueUserWorkItem(
             (x) =>
             {
                 ViewData.GetImage();
                 this.Dispatcher.BeginInvoke(
                          new Action<ImagePage>((y) =>
                          {
                              this.DataContext = ViewData;
                              d.Close();
                              //ViewData.Message = "Image(s) Loaded";
                          }),
                          new object[] { this }
                       );
             }, null
            );

            d.ShowDialog();
        }
        public void DoSearch(SynchronizationContext context)
        {
            NijieSearchOption option = new NijieSearchOption();
            option.Sort = Sort;
            option.Query = Query;
            option.Page = Page;
            option.SearchBy = SearchBy;
            option.Matching = Matching;

            try
            {
                _search = MainWindow.Bot.Search(option);

                Images = new ObservableCollection<NijieImageViewModel>();
                foreach (var image in _search.Images)
                {
                    var temp = new NijieImageViewModel(image);
                    context.Send((x) =>
                    {
                        Images.Add(temp);
                    }, null);
                }

                onPropertyChanged("TotalImages");
            }
            catch (NijieException ne)
            {
                Status = "Error: " + ne.Message;
            }
        }
        public void GetMyImagesBookmark(SynchronizationContext context)
        {
            try
            {
                var result = MainWindow.Bot.ParseMyImageBookmark(this.Page);

                this.Images = new ObservableCollection<NijieImageViewModel>();
                foreach (var item in result.Item1)
                {
                    NijieImageViewModel m = new NijieImageViewModel(item);
                    context.Send((x) =>
                    {
                        this.Images.Add(m);
                    }, null);
                }
                this.IsNextPageAvailable = result.Item2;
                this.Status = String.Format("Found {0} images(s).", this.Images.Count);
            }
            catch (NijieException ne)
            {
                this.Status = "Error: " + ne.Message;
            }
        }