public void AddViewWorkItem(PictureInfo pi)
 {
     lock (ViewWorkQueue)
     {
         ViewWorkQueue.Enqueue(pi);
     }
 }
        }//从path处创建图片的Bitmap对象

        public static void EnsureThumb(PictureInfo pictureInfo)
        {
            if (pictureInfo.ThumbImage == null)
            {
                if (File.Exists(pictureInfo.ThumbPath))
                {
                    pictureInfo.ThumbImage = CreatePicture(pictureInfo.ThumbPath);
                }
                else
                {
                    if (CreateThumb(pictureInfo))
                    {
                        pictureInfo.ThumbImage = CreatePicture(pictureInfo.ThumbPath);
                    }
                    else
                    {
                        pictureInfo.ThumbImage = null;
                    }
                }
            }
            if (pictureInfo.ThumbImage != null && pictureInfo.ThumbImage.CanFreeze && !pictureInfo.ThumbImage.IsFrozen)
            {
                pictureInfo.ThumbImage.Freeze();
            }
        }//创建pictureInfo对象的缩略图并提取到内存
        }//点击上下按钮执行的操作

        private void HorizontalScrollPanel_ImageButtonClicked(object sender, PictureInfo pictureInfo, List <PictureInfo> pictureList)
        {
            if (ImageButtonClicked != null)
            {
                ImageButtonClicked(sender, pictureInfo, pictureList);
            }
        }
 Queue <PictureInfo> ViewWorkQueue = new Queue <PictureInfo>();   //任务队列,包含所有没大缩略图的PictureInfo对象
 public void AddWorkingItem(PictureInfo vi)
 {
     lock (DetaiQueue)
     {
         DetaiQueue.Enqueue(vi);
     }
 }
 void UC_CoverFlow_ImageButtonClicked(object sender, PictureInfo p, List <PictureInfo> list)
 {
     if (ImageButtonClicked != null)
     {
         ImageButtonClicked(sender, p, list);
     }
 }
Example #6
0
 private void GetImageAsync(PictureInfo pi1, PictureInfo pi2, PictureInfo pi3)
 {
     if (pi1.Image == null)
     {
         App.ViewModel.AddViewWorkItem(pi1);
         waitFlag[0] = true;
     }
     else
     {
         (LastShow.Fill as ImageBrush).ImageSource = null;
         (LastShow.Fill as ImageBrush).ImageSource = PictureInfoList[(CurrentIndex - 1 + PictureInfoList.Count) % PictureInfoList.Count].Image;
     }
     if (pi2.Image == null)
     {
         App.ViewModel.AddViewWorkItem(pi2);
         waitFlag[1] = true;
     }
     else
     {
         (MainShow.Fill as ImageBrush).ImageSource = null;
         (MainShow.Fill as ImageBrush).ImageSource = PictureInfoList[CurrentIndex].Image;
     }
     if (pi3.Image == null)
     {
         App.ViewModel.AddViewWorkItem(pi3);
         waitFlag[2] = true;
     }
     else
     {
         (NextShow.Fill as ImageBrush).ImageSource = null;
         (NextShow.Fill as ImageBrush).ImageSource = PictureInfoList[(CurrentIndex + 1) % PictureInfoList.Count].Image;
     }
     App.ViewModel.RunViewWorker();
 }
 private void UC_ImageButtonClicked(object sender, PictureInfo pictrueInfo, List <PictureInfo> pictureList)
 {
     if (isInAnime)
     {
         return;
     }
     CreateExpanderShow(pictrueInfo, pictureList);
 }
 public void RefreshButtonBackground(PictureInfo pictureInfo)
 {
     for (int i = 0; i < STK_Main.Children.Count; i++)
     {
         Control b = STK_Main.Children[i] as Control;
         if ((b.Tag as PictureInfo).AbsolutePath == pictureInfo.AbsolutePath)
         {
             (b.Foreground as ImageBrush).ImageSource = pictureInfo.ThumbImage;
         }
     }
 }
 private void DisposeImage(PictureInfo pictureInfo)
 {
     if (pictureInfo.ThumbImage != null)
     {
         if (pictureInfo.ThumbImage.StreamSource != null)
         {
             pictureInfo.ThumbImage.StreamSource.Dispose();
         }
         pictureInfo.ThumbImage = null;
     }
 }
Example #10
0
        }//创建pictureInfo对象的缩略图并提取到内存

        public static void CreateSmallVersion(PictureInfo pictureInfo)
        {
            if (!Directory.Exists(System.IO.Path.GetDirectoryName(pictureInfo.SmallVersionPath)))
            {
                try
                {
                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(pictureInfo.SmallVersionPath));
                    File.SetAttributes(Path.GetDirectoryName(pictureInfo.SmallVersionPath), FileAttributes.Hidden);
                }
                catch { }
            }
            ThumbNailMaker.GetReducedImageFitSize((App.Current as App).SmallWidth, (App.Current as App).SmallHeight, pictureInfo.AbsolutePath, pictureInfo.SmallVersionPath);
        }//创建pictureInfo对象的大缩略图
Example #11
0
 private void MergeDirectoris(string path, ref List <string> alldirectories, ref List <List <PictureInfo> > allMatrix)
 {
     #region merge this dir
     List <PictureInfo> topfiles    = new List <PictureInfo>();
     string[]           alltopfiles = Directory.GetFiles(path, "*");
     for (int j = 0; j < alltopfiles.Length; j++)
     {
         if (PictureInfo.IsImageFileExtension(System.IO.Path.GetExtension(alltopfiles[j])))
         {
             PictureInfo vi = new PictureInfo(alltopfiles[j]);
             topfiles.Add(vi);
         }
     }
     if (topfiles.Count != 0)
     {
         alldirectories.Add(path);
         allMatrix.Add(topfiles);
     }
     #endregion
     #region merge child dirs
     string[] allDirs = Directory.GetDirectories(path, "*", SearchOption.AllDirectories);
     for (int i = 0; i < allDirs.Length; i++)
     {
         if (allDirs[i].Contains(PictureInfo.ThumbDirectoryName) || allDirs[i].Contains(PictureInfo.SmallVersionDirectoryName))
         {
             continue;
         }
         List <PictureInfo> list  = new List <PictureInfo>();
         string[]           files = System.IO.Directory.GetFiles(allDirs[i], "*", System.IO.SearchOption.TopDirectoryOnly);
         for (int j = 0; j < files.Length; j++)
         {
             if (PictureInfo.IsImageFileExtension(System.IO.Path.GetExtension(files[j])))
             {
                 PictureInfo vi = new PictureInfo(files[j]);
                 list.Add(vi);
             }
         }
         if (list.Count != 0)
         {
             alldirectories.Add(allDirs[i]);
             allMatrix.Add(list);
         }
     }
     #endregion
 }
Example #12
0
 private void RefreshControlBackground(PictureInfo pictureInfo)
 {
     try
     {
         for (int i = 0; i < controlList.Count; i++)
         {
             PictureInfo v = controlList[i].Tag as PictureInfo;
             if (v == null)
             {
                 return;
             }
             if (v.AbsolutePath == pictureInfo.AbsolutePath)
             {
                 (controlList[i].Background as ImageBrush).ImageSource = pictureInfo.ThumbImage;
             }
         }
     }
     catch { return; }
 }
Example #13
0
        }//创建pictureInfo对象的大缩略图

        internal static bool CreateThumb(PictureInfo pictureInfo)
        {
            if (System.IO.File.Exists(pictureInfo.ThumbPath))
            {
                return(true);
            }
            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(pictureInfo.ThumbPath)))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(pictureInfo.ThumbPath));
                    File.SetAttributes(System.IO.Path.GetDirectoryName(pictureInfo.ThumbPath), System.IO.FileAttributes.Hidden);
                }
                catch { return(false); }
            }
            if (ThumbNailMaker.GetReducedImage((App.Current as App).ThumbWidth, (App.Current as App).ThumbHeight, pictureInfo.AbsolutePath, pictureInfo.ThumbPath))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }//创建缩略图并提取到内存
        private void CreateExpanderShow(PictureInfo pictrueInfo, List <PictureInfo> pictureList)
        {
            ExpandShow eps = null;

            if (this.CC_MainHolder.Content == null || CC_MainHolder.Content as ExpandShow == null)
            {
                eps         = new ExpandShow();
                eps.Closed += () =>
                {
                    isInAnime = true;
                    STB_ExpOut.Begin();
                    //CC_MainHolder.Visibility = Visibility.Collapsed;
                };
                CC_MainHolder.Content = eps;
            }
            else
            {
                eps = CC_MainHolder.Content as ExpandShow;
            }
            eps.PictureInfoList = pictureList;
            eps.CurrentIndex    = pictureList.IndexOf(pictrueInfo);
            eps.ShowImage();
            GoToExpanderState();
        }
Example #15
0
 private void InitBackgroundWorker()
 {
     #region 文件系统线程
     fileSystemWorker = new BackgroundWorker()
     {
         WorkerReportsProgress = true, WorkerSupportsCancellation = true
     };
     fileSystemWorker.DoWork += (sender, e) =>
     {
         GetAllPictureInfoMatrix();
     };
     //fileSystemWorker.ProgressChanged += (sender, e) => { };
     fileSystemWorker.RunWorkerCompleted += (sender, e) =>
     {
         if (FileSystemWorkCompleted != null)
         {
             FileSystemWorkCompleted();
         }
     };
     #endregion
     #region 信息加载线程
     loadDetailWorker = new BackgroundWorker()
     {
         WorkerReportsProgress = true, WorkerSupportsCancellation = true
     };
     loadDetailWorker.DoWork += (sender, e) =>
     {
         while (DetaiQueue.Count != 0)
         {
             PictureInfo pi;
             lock (DetaiQueue)
             {
                 pi = DetaiQueue.Dequeue();
             }
             PictureInfo.EnsureThumb(pi);
             loadDetailWorker.ReportProgress(0, pi);
         }
     };
     loadDetailWorker.ProgressChanged += (sender, e) =>
     {
         if (LoadDetailsProgressChanged != null)
         {
             LoadDetailsProgressChanged((e.UserState as PictureInfo));
         }
     };
     loadDetailWorker.RunWorkerCompleted += (sender, e) =>
     {
         if (DetailWorkCompleted != null)
         {
             DetailWorkCompleted();
         }
     };
     //loadDetailWorker.RunWorkerCompleted += (sender, e) => { };
     #endregion
     #region 守护线程
     guardWorker = new BackgroundWorker()
     {
         WorkerReportsProgress = false, WorkerSupportsCancellation = true
     };
     guardWorker.DoWork += (sender, e) =>
     {
         #region ClearPicture
         if (!isCleaned)
         {
             for (int i = 0; i < allDirectoryList.Count; i++)
             {
                 try
                 {
                     string thumbpath = allDirectoryList[i] + "\\" + PictureInfo.ThumbDirectoryName;
                     ClearRedundancy(thumbpath, PictureInfo.ThumbSuffix);
                     string smallversionpath = allDirectoryList[i] + "\\" + PictureInfo.SmallVersionDirectoryName;
                     ClearRedundancy(smallversionpath, PictureInfo.SmallVersionSuffix);
                 }
                 catch { continue; }
             }
             isCleaned = true;
         }
         #endregion
     };
     #endregion
     #region 全屏图片加载线程
     viewWorker         = new BackgroundWorker();
     viewWorker.DoWork += (sender, e) =>
     {
         while (ViewWorkQueue.Count != 0)
         {
             PictureInfo pi;
             lock (ViewWorkQueue)
             {
                 pi = ViewWorkQueue.Dequeue();
             }
             if (pi != null)
             {
                 if (File.Exists(pi.SmallVersionPath))
                 {
                     pi.Image = PictureInfo.CreatePicture(pi.SmallVersionPath);
                     if (pi.Image != null && pi.Image.CanFreeze)
                     {
                         pi.Image.Freeze();
                     }
                 }
                 else
                 {
                     PictureInfo.CreateSmallVersion(pi);
                     pi.Image = PictureInfo.CreatePicture(pi.SmallVersionPath);
                     if (pi.Image != null && pi.Image.CanFreeze)
                     {
                         pi.Image.Freeze();
                     }
                 }
             }
         }
     };
     viewWorker.RunWorkerCompleted += (sender, e) =>
     {
         if (ViewWorkCompleted != null)
         {
             ViewWorkCompleted();
         }
     };
     #endregion
 }
 private void ViewModel_LoadDetailsProgressChanged(PictureInfo pictureInfo)
 {
     RefreshButtonBackground(pictureInfo);
 }