Esempio n. 1
0
        public static void SetBitmapImage(Image image, string fileName, bool isFullImagePath = false)
        {
            BitmapImage bitmapImage = CustomPictureBox.GetBitmapImage(fileName, "", isFullImagePath);

            if (bitmapImage != null)
            {
                bitmapImage.Freeze();
                BlueStacksUIBinding.Bind(image, Image.SourceProperty, fileName);
                if (image is CustomPictureBox)
                {
                    CustomPictureBox customPictureBox = image as CustomPictureBox;
                    customPictureBox.BitmapImage = bitmapImage;
                    if (customPictureBox.IsAlwaysHalfSize)
                    {
                        customPictureBox.maxSize   = new Point(customPictureBox.MaxWidth, customPictureBox.MaxHeight);
                        customPictureBox.MaxWidth  = bitmapImage.Width / 2.0;
                        customPictureBox.MaxHeight = bitmapImage.Height / 2.0;
                    }
                    else if (customPictureBox.maxSize != new Point())
                    {
                        customPictureBox.MaxWidth  = customPictureBox.maxSize.X;
                        customPictureBox.MaxHeight = customPictureBox.maxSize.Y;
                    }
                }
            }
        }
Esempio n. 2
0
 public static void UpdateImagesFromNewDirectory(string path = "")
 {
     foreach (Tuple <string, bool> tuple in CustomPictureBox.sImageAssetsDict.Select <KeyValuePair <string, Tuple <BitmapImage, bool> >, Tuple <string, bool> >((Func <KeyValuePair <string, Tuple <BitmapImage, bool> >, Tuple <string, bool> >)(_ => new Tuple <string, bool>(_.Key, _.Value.Item2))).ToList <Tuple <string, bool> >())
     {
         if (tuple.Item1.IndexOfAny(new char[2]
         {
             Path.AltDirectorySeparatorChar,
             Path.DirectorySeparatorChar
         }) == -1)
         {
             CustomPictureBox.sImageAssetsDict.Remove(tuple.Item1);
             CustomPictureBox.GetBitmapImage(tuple.Item1, path, tuple.Item2);
         }
     }
     CustomPictureBox.NotifyUIElements();
 }