개정판 09b40aad
decodeImage 수정
Change-Id: Iea9964f77b6759bf4a7b9befce60dafe4a4f7732
KCOM/Controls/DecodeImage.cs | ||
---|---|---|
11 | 11 |
|
12 | 12 |
namespace KCOM.Controls |
13 | 13 |
{ |
14 |
[TemplatePart(Name = PART_IMAGE, Type = typeof(Image))] |
|
14 |
// [TemplatePart(Name = PART_IMAGE, Type = typeof(Image))]
|
|
15 | 15 |
public class ScaleDecodeImage : System.Windows.Controls.Control |
16 | 16 |
{ |
17 |
private const string PART_IMAGE = "PART_IMAGE"; |
|
18 |
|
|
19 |
private Image ImageControl; |
|
17 |
// private const string PART_IMAGE = "PART_IMAGE"; |
|
18 |
//private Image ImageControl; |
|
20 | 19 |
|
21 | 20 |
public override void OnApplyTemplate() |
22 | 21 |
{ |
23 | 22 |
base.OnApplyTemplate(); |
24 | 23 |
|
25 |
ImageControl = GetTemplateChild(PART_IMAGE) as Image; |
|
24 |
//ImageControl = GetTemplateChild(PART_IMAGE) as Image;
|
|
26 | 25 |
} |
27 | 26 |
|
28 | 27 |
|
28 |
public static readonly DependencyProperty ViewSourceProperty = DependencyProperty.Register( |
|
29 |
"ViewSource", typeof(BitmapImage), typeof(ScaleDecodeImage)); |
|
30 |
|
|
31 |
|
|
32 |
public BitmapImage ViewSource |
|
33 |
{ |
|
34 |
get => (BitmapImage)GetValue(ViewSourceProperty); |
|
35 |
set => SetValue(ViewSourceProperty, value); |
|
36 |
} |
|
37 |
|
|
29 | 38 |
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( |
30 |
"Source", typeof(BitmapImage), typeof(ScaleDecodeImage),new PropertyMetadata(new PropertyChangedCallback(SourcePropertyChaged))); |
|
39 |
"Source", typeof(BitmapImage), typeof(ScaleDecodeImage), new PropertyMetadata(new PropertyChangedCallback(SourcePropertyChaged)));
|
|
31 | 40 |
|
32 | 41 |
|
33 | 42 |
public BitmapImage Source |
... | ... | |
40 | 49 |
{ |
41 | 50 |
var owner = d as ScaleDecodeImage; |
42 | 51 |
|
43 |
if(owner != null) |
|
52 |
if (owner != null)
|
|
44 | 53 |
{ |
45 |
owner.Scale = 1.0; |
|
54 |
if (e.NewValue != null) |
|
55 |
{ |
|
56 |
owner.ViewSource = (BitmapImage)e.NewValue; |
|
57 |
owner.Scale = 1.0; |
|
58 |
} |
|
46 | 59 |
} |
47 | 60 |
} |
48 | 61 |
|
49 | 62 |
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register( |
50 |
"Scale", typeof(double), typeof(ScaleDecodeImage), new PropertyMetadata(0.0,new PropertyChangedCallback(ScalePropertyChaged))); |
|
63 |
"Scale", typeof(double), typeof(ScaleDecodeImage), new PropertyMetadata(0.0, new PropertyChangedCallback(ScalePropertyChaged)));
|
|
51 | 64 |
|
52 | 65 |
|
53 | 66 |
public double Scale |
... | ... | |
56 | 69 |
set => SetValue(ScaleProperty, value); |
57 | 70 |
} |
58 | 71 |
|
59 |
private static async void ScalePropertyChaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
72 |
private static void ScalePropertyChaged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|
60 | 73 |
{ |
61 | 74 |
var owner = d as ScaleDecodeImage; |
62 | 75 |
|
63 | 76 |
if (owner != null) |
64 | 77 |
{ |
65 |
if(owner.ImageControl != null) |
|
66 |
{ |
|
67 |
var value = owner.Scale; |
|
68 |
System.Windows.Media.Imaging.BitmapImage image = owner.Source.Clone(); |
|
78 |
var value = owner.Scale; |
|
79 |
System.Windows.Media.Imaging.BitmapImage image = owner.Source.Clone(); |
|
69 | 80 |
|
70 |
image.DecodePixelWidth = (int)(image.PixelWidth * value);
|
|
71 |
image.DecodePixelHeight = (int)(image.PixelHeight * value);
|
|
81 |
image.DecodePixelWidth = (int)(image.PixelWidth * value); |
|
82 |
image.DecodePixelHeight = (int)(image.PixelHeight * value); |
|
72 | 83 |
|
73 |
await owner.Dispatcher.InvokeAsync(() => { owner.ImageControl.Source = image; }); |
|
74 |
|
|
75 |
} |
|
84 |
owner.ViewSource = image; |
|
76 | 85 |
} |
77 | 86 |
} |
78 | 87 |
} |
내보내기 Unified diff