提交记录修改UI/Controls/Base/Img.cs+24 −10看文件
修改UI/Themes/Base/Img.xaml+1 −1看文件
| @@ -33,6 +33,17 @@ namespace UI.Controls.Base | ||
| 33 | 33 | typeof(CornerRadius), |
| 34 | 34 | typeof(Img)); |
| 35 | 35 | |
| 36 | 新增: public string Src | |
| 37 | 新增: { | |
| 38 | 新增: get { return (string)GetValue(SrcProperty); } | |
| 39 | 新增: set { SetValue(SrcProperty, value); } | |
| 40 | 新增: } | |
| 41 | 新增: public static readonly DependencyProperty SrcProperty = | |
| 42 | 新增: DependencyProperty.Register("Src", | |
| 43 | 新增: typeof(string), | |
| 44 | 新增: typeof(Img), new PropertyMetadata("pack://application:,,,/Tai;component/Resources/Icons/defaultIcon.png", new PropertyChangedCallback(OnPropertyChanged))); | |
| 45 | 新增: | |
| 46 | 新增: | |
| 36 | 47 | |
| 37 | 48 | /// <summary> |
| 38 | 49 | /// 图片链接 |
| @@ -50,29 +61,32 @@ namespace UI.Controls.Base | ||
| 50 | 61 | private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 51 | 62 | { |
| 52 | 63 | var control = (d as Img); |
| 53 | 删除: if (e.Property == URLProperty && e.OldValue != e.NewValue) | |
| 64 | 新增: if (e.Property == URLProperty && e.OldValue != e.NewValue && e.NewValue != null) | |
| 54 | 65 | { |
| 55 | 删除: control.Handle(); | |
| 66 | 新增: control.Handle(e.NewValue.ToString()); | |
| 56 | 67 | } |
| 57 | 68 | } |
| 58 | 删除: | |
| 69 | 新增: | |
| 59 | 70 | public Img() |
| 60 | 71 | { |
| 61 | 72 | DefaultStyleKey = typeof(Img); |
| 62 | 删除: | |
| 63 | 73 | } |
| 64 | 74 | |
| 65 | 删除: private void Handle() | |
| 75 | 新增: private void Handle(string path) | |
| 66 | 76 | { |
| 67 | 删除: if (URL != null && URL.Length > 8 && URL.Substring(0, 8) == "AppIcons") | |
| 77 | 新增: if (path != null && path.Length > 8 && path.Substring(0, 8) == "AppIcons") | |
| 68 | 78 | { |
| 69 | 删除: URL = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, URL); | |
| 79 | 新增: Src = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); | |
| 70 | 80 | } |
| 71 | 删除: if (URL == null || (URL.IndexOf("pack://") == -1 && !File.Exists(URL))) | |
| 81 | 新增: else if (path == null || (path.IndexOf("pack://") == -1 && !File.Exists(path))) | |
| 72 | 82 | { |
| 73 | 删除: URL = "pack://application:,,,/Tai;component/Resources/Icons/defaultIcon.png"; | |
| 83 | 新增: Src = "pack://application:,,,/Tai;component/Resources/Icons/defaultIcon.png"; | |
| 84 | 新增: } | |
| 85 | 新增: else | |
| 86 | 新增: { | |
| 87 | 新增: Src = path; | |
| 74 | 88 | } |
| 75 | 89 | } |
| 76 | 删除: | |
| 90 | 新增: | |
| 77 | 91 | } |
| 78 | 92 | } |
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | |
| 21 | 21 | <Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" CornerRadius="{TemplateBinding Radius}"> |
| 22 | 22 | <Border.Background> |
| 23 | 删除: <ImageBrush Stretch="Fill" x:Name="image" ImageSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Img}}, Path=URL}"/> | |
| 23 | 新增: <ImageBrush Stretch="Fill" x:Name="image" ImageSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Img}}, Path=Src}"/> | |
| 24 | 24 | </Border.Background> |
| 25 | 25 | </Border> |
| 26 | 26 | |

