123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using MediaViewerLib.Utilities;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace HistoryDLL
- {
- /// <summary>
- /// ThumbnailContainer.xaml 的互動邏輯
- /// </summary>
- public partial class ThumbnailContainer : UserControl
- {
- private Storyboard sbShowStart;
- private Storyboard sbShowStop;
- private List<string> imgPath;
- private int imgWidth = 211;
- private int imgHeight = 158;
- private int topBottomDiff = 10;
- public List<string> ImgPath
- {
- get { return imgPath; }
- set
- {
- imgPath = value;
- LoadThumbImage();
- }
- }
- public ThumbnailContainer()
- {
- InitializeComponent();
- if (GlobalFunction.isSolutionUsing4K)
- {
- imgWidth *= 2;
- imgHeight *= 2;
- //topBottomDiff *= 2;
- }
- sbShowStart = FindResource("sbShowStart") as Storyboard;
- sbShowStart.Completed += new EventHandler(sbShowStart_Completed);
- sbShowStop = FindResource("sbShowStop") as Storyboard;
- sbShowStop.Completed += new EventHandler(sbShowStop_Completed);
- }
- private void sbShowStop_Completed(object sender, EventArgs e)
- {
- uxStackPanel.Opacity = 0.0;
- }
- private void sbShowStart_Completed(object sender, EventArgs e)
- {
- uxStackPanel.Opacity = 1.0;
- }
- public void StartOpacityAnimation()
- {
- if (sbShowStart != null)
- {
- sbShowStart.Begin();
- }
- }
- public void StopOpacityAnimation()
- {
- if (sbShowStop != null)
- {
- sbShowStop.Begin();
- }
- }
- private void LoadThumbImage()
- {
- uxStackPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
- SolidColorBrush brush = new SolidColorBrush(ConfigSettingClass.EventCollect.BackgroundColor);
- if (imgPath.Count == 0)
- {
- Image img = new Image();
- if (File.Exists(GlobalFunction.thumbPath + ConfigSettingClass.MainBackCollect.ImgLogo))
- {
- Grid gd = new Grid();
- Rectangle rectange = new Rectangle();
- //ImageBrush imagebrush = new ImageBrush(new BitmapImage(new Uri(@"pack://application:,,,/" + GlobalFunction.projectname + @";component/Data/Thumb/shadow_big.png", UriKind.RelativeOrAbsolute)));
- ImageBrush imagebrush = null;
- gd.Width = imgWidth + (GlobalFunction.isSolutionUsing4K ? 8 : 5);
- gd.Height = imgHeight + (GlobalFunction.isSolutionUsing4K ? 8 : 5);
- //imagebrush.Stretch = Stretch.Fill;
- //gd.Background = imagebrush;
- gd.Background =Brushes.Gray;
- gd.VerticalAlignment = System.Windows.VerticalAlignment.Center;
- gd.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
- rectange.VerticalAlignment = System.Windows.VerticalAlignment.Top;
- rectange.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
- img.Width = rectange.Width = imgWidth;
- img.Height = rectange.Height = imgHeight;
- //img.Margin = new Thickness(-(GlobalFunction.isSolutionUsing4K ? 10 : 5), -(GlobalFunction.isSolutionUsing4K ? 10 : 5), 0, 0);
- img.Margin = rectange.Margin = new Thickness(3, 2, 0, 0);
- img.Source = new BitmapImage(new Uri(GlobalFunction.thumbPath + ConfigSettingClass.MainBackCollect.ImgLogo));
- rectange.Fill = brush;
- gd.Children.Add(rectange);
- gd.Children.Add(img);
- gd.Margin = GlobalFunction.isSolutionUsing4K ? new Thickness(0, 0, 0, topBottomDiff) : new Thickness(0, 0, 0, 0);
- uxStackPanel.Children.Add(gd);
- }
- }
- else
- {
- for (int i = 0; i < imgPath.Count; i++)
- {
- BitmapSource src = MediaUtilties.LoadThumbnailImage(imgPath[i], ThumbnailSize.Large);
- Grid gd = new Grid();
- //ImageBrush imagebrush = new ImageBrush(new BitmapImage(new Uri(@"pack://application:,,,/" + GlobalFunction.projectname + @";component/Data/Thumb/shadow_big.png", UriKind.RelativeOrAbsolute)));
- ImageBrush imagebrush = new ImageBrush(new BitmapImage(new Uri(System.IO.Path.Combine(GlobalFunction.thumbPath,"shadow_big.png"), UriKind.RelativeOrAbsolute)));
- Image img = new Image();
- Rectangle rectange = new Rectangle();
- gd.Width = imgWidth + (GlobalFunction.isSolutionUsing4K ? 8 : 5);
- gd.Height = imgHeight + (GlobalFunction.isSolutionUsing4K ? 8 : 5);
- //gd.Background = new SolidColorBrush(Colors.Red);
- imagebrush.Stretch = Stretch.Fill;
- gd.Background = imagebrush;
- gd.VerticalAlignment = System.Windows.VerticalAlignment.Center;
- gd.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
- img.VerticalAlignment = rectange.VerticalAlignment = System.Windows.VerticalAlignment.Top;
- img.HorizontalAlignment = rectange.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
- img.Width = rectange.Width = imgWidth;
- img.Height = rectange.Height = imgHeight;
- img.Stretch = Stretch.UniformToFill;
- img.Source = src;
- rectange.Fill = brush;
- img.Margin = rectange.Margin = new Thickness(3, 2, 0, 0);
- //gd.Margin = new Thickness(0, topBottomDiff, 0, 0);
- gd.Children.Add(rectange);
- gd.Children.Add(img);
- gd.Margin = GlobalFunction.isSolutionUsing4K ? new Thickness(0, 0, 0, topBottomDiff) : new Thickness(0, 0, 0, 0);
- uxStackPanel.Children.Add(gd);
- }
- }
- }
- }
- }
|