提交记录修改UI/Controls/Base/Img.cs+5 −85看文件
修改UI/Themes/Base/Img.xaml+2 −0看文件
修改UI/Themes/Charts/Charts.xaml+1 −1看文件
修改UI/Views/DetailPage.xaml+1 −1看文件
| @@ -2,9 +2,11 @@ | ||
| 2 | 2 | using System; |
| 3 | 3 | using System.Collections.Generic; |
| 4 | 4 | using System.Diagnostics; |
| 5 | 新增:using System.Drawing; | |
| 5 | 6 | using System.IO; |
| 6 | 7 | using System.Linq; |
| 7 | 8 | using System.Text; |
| 9 | 新增:using System.Threading; | |
| 8 | 10 | using System.Threading.Tasks; |
| 9 | 11 | using System.Windows; |
| 10 | 12 | using System.Windows.Controls; |
| @@ -15,22 +17,12 @@ using System.Windows.Media; | ||
| 15 | 17 | using System.Windows.Media.Imaging; |
| 16 | 18 | using System.Windows.Navigation; |
| 17 | 19 | using System.Windows.Shapes; |
| 20 | 新增:using System.Windows.Threading; | |
| 18 | 21 | |
| 19 | 22 | namespace UI.Controls.Base |
| 20 | 23 | { |
| 21 | 24 | public class Img : Control |
| 22 | 25 | { |
| 23 | 删除: public bool IsAutoDispose | |
| 24 | 删除: { | |
| 25 | 删除: get { return (bool)GetValue(IsAutoDisposeProperty); } | |
| 26 | 删除: set { SetValue(IsAutoDisposeProperty, value); } | |
| 27 | 删除: } | |
| 28 | 删除: public static readonly DependencyProperty IsAutoDisposeProperty = | |
| 29 | 删除: DependencyProperty.Register("IsAutoDispose", | |
| 30 | 删除: typeof(bool), | |
| 31 | 删除: typeof(Img), new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged))); | |
| 32 | 删除: | |
| 33 | 删除: | |
| 34 | 26 | public CornerRadius Radius |
| 35 | 27 | { |
| 36 | 28 | get { return (CornerRadius)GetValue(RadiusProperty); } |
| @@ -63,23 +55,11 @@ namespace UI.Controls.Base | ||
| 63 | 55 | control.Handle(); |
| 64 | 56 | } |
| 65 | 57 | } |
| 66 | 删除: //private bool isRendered = false; | |
| 67 | 删除: //private Image _image; | |
| 68 | 删除: //Page page; | |
| 69 | 删除: private ImageBrush _image; | |
| 58 | 新增: | |
| 70 | 59 | public Img() |
| 71 | 60 | { |
| 72 | 61 | DefaultStyleKey = typeof(Img); |
| 73 | 删除: } | |
| 74 | 删除: | |
| 75 | 删除: public override void OnApplyTemplate() | |
| 76 | 删除: { | |
| 77 | 删除: base.OnApplyTemplate(); | |
| 78 | 删除: | |
| 79 | 删除: _image = GetTemplateChild("image") as ImageBrush; | |
| 80 | 62 | |
| 81 | 删除: Render(); | |
| 82 | 删除: //_image = GetTemplateChild("image") as Image; | |
| 83 | 63 | } |
| 84 | 64 | |
| 85 | 65 | private void Handle() |
| @@ -92,67 +72,7 @@ namespace UI.Controls.Base | ||
| 92 | 72 | { |
| 93 | 73 | URL = "pack://application:,,,/Tai;component/Resources/Icons/defaultIcon.png"; |
| 94 | 74 | } |
| 95 | 删除: | |
| 96 | 删除: Render(); | |
| 97 | 删除: } | |
| 98 | 删除: | |
| 99 | 删除: | |
| 100 | 删除: | |
| 101 | 删除: //private void Page_LayoutUpdated(object sender, EventArgs e) | |
| 102 | 删除: //{ | |
| 103 | 删除: // if (!isRendered) | |
| 104 | 删除: // { | |
| 105 | 删除: // Rect bounds = this.TransformToAncestor(page).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); | |
| 106 | 删除: // Rect rect = new Rect(0.0, 0.0, page.ActualWidth, page.ActualHeight); | |
| 107 | 删除: | |
| 108 | 删除: // if (rect.Contains(bounds)) | |
| 109 | 删除: // { | |
| 110 | 删除: // Debug.WriteLine("渲染!"); | |
| 111 | 删除: | |
| 112 | 删除: // isRendered = true; | |
| 113 | 删除: | |
| 114 | 删除: // Render(); | |
| 115 | 删除: // } | |
| 116 | 删除: // } | |
| 117 | 删除: //} | |
| 118 | 删除: | |
| 119 | 删除: //private void Img_Loaded(object sender, RoutedEventArgs e) | |
| 120 | 删除: //{ | |
| 121 | 删除: // var parent = VisualTreeHelper.GetParent(this); | |
| 122 | 删除: // while (!(parent is Page)) | |
| 123 | 删除: // { | |
| 124 | 删除: // parent = VisualTreeHelper.GetParent(parent); | |
| 125 | 删除: // } | |
| 126 | 删除: // page = (parent as Page); | |
| 127 | 删除: | |
| 128 | 删除: // page.LayoutUpdated += Page_LayoutUpdated; | |
| 129 | 删除: //} | |
| 130 | 删除: | |
| 131 | 删除: private async void Render() | |
| 132 | 删除: { | |
| 133 | 删除: if (_image == null || !IsAutoDispose) | |
| 134 | 删除: { | |
| 135 | 删除: return; | |
| 136 | 删除: } | |
| 137 | 删除: | |
| 138 | 删除: _image.ImageSource = null; | |
| 139 | 删除: //_image.Source = Imager.Load(URL); | |
| 140 | 删除: | |
| 141 | 删除: | |
| 142 | 删除: | |
| 143 | 删除: //_image.ImageSource = Imager.Load(URL); | |
| 144 | 删除: //BitmapImage bitimg = null; | |
| 145 | 删除: | |
| 146 | 删除: string img = URL != null ? URL.ToString() : ""; | |
| 147 | 删除: | |
| 148 | 删除: var res = Task.Run(() => | |
| 149 | 删除: { | |
| 150 | 删除: | |
| 151 | 删除: Debug.WriteLine("load:" + img); | |
| 152 | 删除: return Imager.Load(img); | |
| 153 | 删除: }); | |
| 154 | 删除: | |
| 155 | 删除: _image.ImageSource = await res; | |
| 156 | 75 | } |
| 76 | 新增: | |
| 157 | 77 | } |
| 158 | 78 | } |
| @@ -18,11 +18,13 @@ | ||
| 18 | 18 | <!--<Border Background="{TemplateBinding Background}" CornerRadius="5"> |
| 19 | 19 | <Image x:Name="image" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/> |
| 20 | 20 | </Border>--> |
| 21 | 新增: | |
| 21 | 22 | <Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" CornerRadius="{TemplateBinding Radius}"> |
| 22 | 23 | <Border.Background> |
| 23 | 24 | <ImageBrush Stretch="Fill" x:Name="image" ImageSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Img}}, Path=URL}"/> |
| 24 | 25 | </Border.Background> |
| 25 | 26 | </Border> |
| 27 | 新增: | |
| 26 | 28 | </ControlTemplate> |
| 27 | 29 | </Setter.Value> |
| 28 | 30 | </Setter> |
| @@ -126,7 +126,7 @@ | ||
| 126 | 126 | </Border> |
| 127 | 127 | <Border Grid.Column="1"> |
| 128 | 128 | <!--图标--> |
| 129 | 删除: <base:Img IsAutoDispose="True" Width="20" Height="20" URL="{Binding Icon}"/> | |
| 129 | 新增: <base:Img Width="20" Height="20" URL="{Binding Icon}"/> | |
| 130 | 130 | </Border> |
| 131 | 131 | <Border Grid.Column="2" Margin="5,0,0,0"> |
| 132 | 132 | <!--名称--> |
| @@ -38,7 +38,7 @@ | ||
| 38 | 38 | <ColumnDefinition Width="3*"/> |
| 39 | 39 | |
| 40 | 40 | </Grid.ColumnDefinitions> |
| 41 | 删除: <base:Img IsAutoDispose="True" URL="{Binding App.IconFile}" Width="25" Height="25" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |
| 41 | 新增: <base:Img URL="{Binding App.IconFile}" Width="25" Height="25" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |
| 42 | 42 | <!--<Image Source="{Binding Process.Icon}" Width="25" HorizontalAlignment="Center" VerticalAlignment="Center"/>--> |
| 43 | 43 | |
| 44 | 44 | <StackPanel Grid.Column="1" VerticalAlignment="Center"> |

