コード例 #1
0
ファイル: ImageList.xaml.cs プロジェクト: HaiqTop/HWallpaper
 /// <summary>
 /// 显示大图
 /// </summary>
 private void ShowBigPic(ImgInfo imgInfo)
 {
     if (imgInfo != null)
     {
         loading.Visibility   = Visibility.Visible;
         zoomImage.Visibility = Visibility.Hidden;
         downQueue.Queue(zoomImage, imgInfo);
         zoomGrid.Tag    = imgInfo.Index;
         lb_picName.Text = "文件名称:" + imgInfo.GetFileName();
         lb_picDate.Text = "上传时间:" + imgInfo.create_time;
         lb_picTags.Text = "标签:" + string.Join(" ", imgInfo.GetTagList());
     }
 }
コード例 #2
0
 /// <summary>
 /// 添加下载任务到队列
 /// </summary>
 /// <param name="image"></param>
 /// <param name="imgInfo"></param>
 public void Queue(Image image, ImgInfo imgInfo)
 {
     if (imgInfo == null)
     {
         return;
     }
     lock (this.Stacks)
     {
         this.Stacks.Enqueue(new ImageQueueInfo()
         {
             ImgInfo = imgInfo, image = image, Url = imgInfo.url, Name = imgInfo.GetFileName()
         });
         this.autoEvent.Set();
     }
 }
コード例 #3
0
        private void InitBtnState(ImgInfo imgInfo)
        {
            btn_love.Foreground    = Brushes.White;
            btn_dislike.Foreground = Brushes.White;
            btn_down.Foreground    = Brushes.White;

            Love love = UserDataManage.GetLove(imgInfo.Id);

            if (love != null)
            {
                if (love.Type == 1)
                {
                    btn_love.Foreground = Brushes.Red;
                }
                else if (love.Type == -1)
                {
                    btn_dislike.Foreground = Brushes.Red;
                }
            }
            Download down     = UserDataManage.GetDown(imgInfo.Id);
            string   fullName = System.IO.Path.Combine(this.DownPath, imgInfo.GetFileName());

            if (System.IO.File.Exists(fullName))
            {
                btn_down.Foreground = Brushes.Red;
                if (down == null)
                {
                    down = new Download()
                    {
                        PictureId = imgInfo.Id, Time = DateTime.Now, FullName = fullName, Valid = 1
                    };
                }
                else if (down.Valid == 0)
                {
                    down.Valid = 1;
                }
                UserDataManage.SaveDown(down, imgInfo);
            }
        }
コード例 #4
0
ファイル: ImageList.xaml.cs プロジェクト: HaiqTop/HWallpaper
        /// <summary>
        /// 初始化壁纸上显示的按钮状态
        /// </summary>
        /// <param name="imgInfo"></param>
        private void InitBtnState(ImgInfo imgInfo)
        {
            if (imgInfo == null)
            {
                return;
            }
            btnPanel.Tag             = imgInfo;
            btn_love.Foreground      = Brushes.White;
            btn_wallpaper.Foreground = Brushes.White;
            btn_dislike.Foreground   = Brushes.White;
            btn_down.Foreground      = Brushes.White;

            btnPanel.Visibility = Visibility.Visible;

            Love love = UserDataManage.GetLove(imgInfo.Id);

            if (love != null)
            {
                if (love.Type == 1)
                {
                    btn_love.Foreground = Brushes.Red;
                }
                else if (love.Type == -1)
                {
                    btn_dislike.Foreground = Brushes.Red;
                }
            }
            Download down     = UserDataManage.GetDown(imgInfo.Id);
            string   fullName = System.IO.Path.Combine(this.DownPath, imgInfo.GetFileName());

            if (System.IO.File.Exists(fullName))
            {
                btn_down.Foreground = Brushes.Red;
                UserDataManage.SetDown(fullName, imgInfo);
            }
        }
コード例 #5
0
        private void Btn_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn == null)
            {
                return;
            }
            ImgInfo imgInfo = (btn.Parent as StackPanel).Tag as ImgInfo;

            switch (btn.Name)
            {
            case "btn_down":
            {
                if (btn.Foreground == Brushes.White)
                {
                    string imgFullName = System.IO.Path.Combine(this.DownPath, imgInfo.GetFileName());
                    if (!System.IO.File.Exists(imgFullName))
                    {
                        System.Drawing.Image img = WebHelper.GetImage(imgInfo.url);
                        img.Save(imgFullName);
                        img.Dispose();
                    }
                    btn.Foreground = Brushes.Red;
                    UserDataManage.SetDown(imgFullName, imgInfo);
                    Growl.Success("下载成功。");

                    if (btn_love.Foreground == Brushes.White)
                    {
                        UserDataManage.SetLove(LoveType.Love, imgInfo);
                        btn_love.Foreground    = Brushes.Red;
                        btn_dislike.Foreground = Brushes.White;
                    }
                }
            }
            break;

            case "btn_wallpaper":
            {
                if (btn.Foreground == Brushes.White)
                {
                    string imgFullName = System.IO.Path.Combine(this.CachePath, imgInfo.GetFileName());
                    if (!System.IO.File.Exists(imgFullName))
                    {
                        System.Drawing.Image img = WebHelper.GetImage(imgInfo.url);
                        img.Save(imgFullName);
                        img.Dispose();
                    }
                    WinApi.SetWallpaper(imgFullName);
                    btn.Foreground = Brushes.Red;
                    Growl.Success("壁纸设置成功。");
                    UserDataManage.AddRecord(RecordType.ManualWallpaper, imgInfo);
                }
            }
            break;

            case "btn_love":
            {
                if (btn.Foreground == Brushes.White)
                {
                    UserDataManage.SetLove(LoveType.Love, imgInfo);
                    btn.Foreground         = Brushes.Red;
                    btn_dislike.Foreground = Brushes.White;
                }
            }
            break;

            case "btn_dislike":
            {
                if (btn.Foreground == Brushes.White)
                {
                    UserDataManage.SetLove(LoveType.Dislike, imgInfo);
                    btn.Foreground      = Brushes.Red;
                    btn_love.Foreground = Brushes.White;
                    this.EffectPicture(null, null);
                }
            }
            break;
            }
        }