コード例 #1
0
ファイル: ImageBoxViewModel.cs プロジェクト: yy121212/FModel
        public static void Set(this ImageBoxViewModel vm, BitmapImage image, string name)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                vm.Image = image;
                vm.Name  = name;
            });

            if (Properties.Settings.Default.AutoSaveImage)
            {
                vm.Save(true);
            }
        }
コード例 #2
0
ファイル: ImageBoxViewModel.cs プロジェクト: yy121212/FModel
        public static void Set(this ImageBoxViewModel vm, SKImage image, string name)
        {
            using var encoded = image.Encode();
            using var stream  = encoded.AsStream();
            BitmapImage photo = new BitmapImage();

            photo.BeginInit();
            photo.CacheOption  = BitmapCacheOption.OnLoad;
            photo.StreamSource = stream;
            photo.EndInit();
            photo.Freeze();

            Application.Current.Dispatcher.Invoke(delegate
            {
                vm.Image = photo;
                vm.Name  = name;
            });

            if (Properties.Settings.Default.AutoSaveImage)
            {
                vm.Save(true);
            }
        }