-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTileItem.xaml.cs
1033 lines (889 loc) · 34.8 KB
/
TileItem.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Microsoft.UI.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using Trivial.Data;
using Trivial.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Text;
namespace Trivial.UI;
using DependencyObjectProxy = DependencyObjectProxy<TileItem>;
/// <summary>
/// The tile item control.
/// </summary>
public sealed partial class TileItem : UserControl
{
/// <summary>
/// The dependency property of click mode.
/// </summary>
public static readonly DependencyProperty ClickModeProperty = DependencyObjectProxy.RegisterProperty<ClickMode>(nameof(ClickMode), (c, e, p) => c.ClickMode = e.NewValue);
/// <summary>
/// The dependency property of hover foreground.
/// </summary>
public static readonly DependencyProperty HoverForegroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(HoverForeground));
/// <summary>
/// The dependency property of pressed foreground.
/// </summary>
public static readonly DependencyProperty PressedForegroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(PressedForeground));
/// <summary>
/// The dependency property of hover background.
/// </summary>
public static readonly DependencyProperty HoverBackgroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(HoverBackground));
/// <summary>
/// The dependency property of pressed background.
/// </summary>
public static readonly DependencyProperty PressedBackgroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(PressedBackground));
/// <summary>
/// The dependency property of orientation.
/// </summary>
public static readonly DependencyProperty OrientationProperty = DependencyObjectProxy.RegisterProperty(nameof(Orientation), Orientation.Vertical);
/// <summary>
/// The dependency property of text width.
/// </summary>
public static readonly DependencyProperty TextWidthProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(TextWidth));
/// <summary>
/// The dependency property of text height.
/// </summary>
public static readonly DependencyProperty TextHeightProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(TextHeight));
/// <summary>
/// The dependency property of horiontal text alignment.
/// </summary>
public static readonly DependencyProperty HorizontalTextAlignmentProperty = DependencyObjectProxy.RegisterProperty(nameof(HorizontalTextAlignment), TextAlignment.Left);
/// <summary>
/// The dependency property of text background.
/// </summary>
public static readonly DependencyProperty TextBackgroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(TextBackground));
/// <summary>
/// The dependency property of text background sizing.
/// </summary>
public static readonly DependencyProperty TextBackgroundSizingProperty = DependencyObjectProxy.RegisterProperty<BackgroundSizing>(nameof(TextBackgroundSizing));
/// <summary>
/// The dependency property of text padding.
/// </summary>
public static readonly DependencyProperty TextPaddingProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(TextPadding));
/// <summary>
/// The dependency property of text margin.
/// </summary>
public static readonly DependencyProperty TextMarginProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(TextMargin));
/// <summary>
/// The dependency property of text border brush.
/// </summary>
public static readonly DependencyProperty TextBorderBrushProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(TextBorderBrush));
/// <summary>
/// The dependency property of text thickness brush.
/// </summary>
public static readonly DependencyProperty TextBorderThicknessProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(TextBorderThickness));
/// <summary>
/// The dependency property of text corner radius.
/// </summary>
public static readonly DependencyProperty TextCornerRadiusProperty = DependencyObjectProxy.RegisterProperty<CornerRadius>(nameof(TextCornerRadius));
/// <summary>
/// The dependency property of title property.
/// </summary>
public static readonly DependencyProperty TitleProperty = DependencyObjectProxy.RegisterProperty<string>(nameof(Title), OnTextChanged);
/// <summary>
/// The dependency property of title font size.
/// </summary>
public static readonly DependencyProperty TitleFontSizeProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleFontSize), 14d);
/// <summary>
/// The dependency property of title font weight.
/// </summary>
public static readonly DependencyProperty TitleFontWeightProperty = DependencyObjectProxy.RegisterFontWeightProperty(nameof(TitleFontWeight));
/// <summary>
/// The dependency property of title font style.
/// </summary>
public static readonly DependencyProperty TitleFontStyleProperty = DependencyObjectProxy.RegisterProperty<FontStyle>(nameof(TitleFontStyle));
/// <summary>
/// The dependency property of title line height.
/// </summary>
public static readonly DependencyProperty TitleLineHeightProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleLineHeight), 0d);
/// <summary>
/// The dependency property of title foreground.
/// </summary>
public static readonly DependencyProperty TitleForegroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(TitleForeground), new SolidColorBrush(Microsoft.UI.Colors.Gray));
/// <summary>
/// The dependency property of title width.
/// </summary>
public static readonly DependencyProperty TitleWidthProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(TitleWidth));
/// <summary>
/// The dependency property of title height.
/// </summary>
public static readonly DependencyProperty TitleHeightProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(TitleHeight));
/// <summary>
/// The dependency property of title max height.
/// </summary>
public static readonly DependencyProperty TitleMaxHeightProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleMaxHeight), double.PositiveInfinity);
/// <summary>
/// The dependency property of title horizontal alignment property.
/// </summary>
public static readonly DependencyProperty TitleHorizontalAlignmentProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleHorizontalAlignment), HorizontalAlignment.Stretch);
/// <summary>
/// The dependency property of title wrapping.
/// </summary>
public static readonly DependencyProperty TitleWrappingProperty = DependencyObjectProxy.RegisterProperty<TextWrapping>(nameof(TitleWrapping));
/// <summary>
/// The dependency property of title trimming.
/// </summary>
public static readonly DependencyProperty TitleTrimmingProperty = DependencyObjectProxy.RegisterProperty<TextTrimming>(nameof(TitleTrimming));
/// <summary>
/// The dependency property of title connected animation key property.
/// </summary>
public static readonly DependencyProperty TitleConnectedAnimationKeyProperty = DependencyObjectProxy.RegisterProperty<string>(nameof(TitleConnectedAnimationKey));
/// <summary>
/// The dependency property of description.
/// </summary>
public static readonly DependencyProperty DescriptionProperty = DependencyObjectProxy.RegisterProperty<string>(nameof(Description), OnTextChanged);
/// <summary>
/// The dependency property of description font size.
/// </summary>
public static readonly DependencyProperty DescriptionFontSizeProperty = DependencyObjectProxy.RegisterProperty(nameof(DescriptionFontSize), 12d);
/// <summary>
/// The dependency property of description font weight.
/// </summary>
public static readonly DependencyProperty DescriptionFontWeightProperty = DependencyObjectProxy.RegisterFontWeightProperty(nameof(DescriptionFontWeight));
/// <summary>
/// The dependency property of description font style.
/// </summary>
public static readonly DependencyProperty DescriptionFontStyleProperty = DependencyObjectProxy.RegisterProperty<FontStyle>(nameof(DescriptionFontStyle));
/// <summary>
/// The dependency property of description line height.
/// </summary>
public static readonly DependencyProperty DescriptionLineHeightProperty = DependencyObjectProxy.RegisterProperty(nameof(DescriptionLineHeight), 0d);
/// <summary>
/// The dependency property of description foreground.
/// </summary>
public static readonly DependencyProperty DescriptionForegroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(DescriptionForeground), new SolidColorBrush(Microsoft.UI.Colors.Gray));
/// <summary>
/// The dependency property of description width.
/// </summary>
public static readonly DependencyProperty DescriptionWidthProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(DescriptionWidth));
/// <summary>
/// The dependency property of description height.
/// </summary>
public static readonly DependencyProperty DescriptionHeightProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(DescriptionHeight));
/// <summary>
/// The dependency property of description horizontal alignment property.
/// </summary>
public static readonly DependencyProperty DescriptionHorizontalAlignmentProperty = DependencyObjectProxy.RegisterProperty(nameof(DescriptionHorizontalAlignment), HorizontalAlignment.Stretch);
/// <summary>
/// The dependency property of description wrapping.
/// </summary>
public static readonly DependencyProperty DescriptionWrappingProperty = DependencyObjectProxy.RegisterProperty<TextWrapping>(nameof(DescriptionWrapping));
/// <summary>
/// The dependency property of description trimming.
/// </summary>
public static readonly DependencyProperty DescriptionTrimmingProperty = DependencyObjectProxy.RegisterProperty<TextTrimming>(nameof(DescriptionTrimming));
/// <summary>
/// The dependency property of image URI.
/// </summary>
public static readonly DependencyProperty ImageUriProperty = DependencyObjectProxy.RegisterProperty<Uri>(nameof(ImageUri), OnImageUriChanged);
/// <summary>
/// The dependency property of image width.
/// </summary>
public static readonly DependencyProperty ImageWidthProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(ImageWidth));
/// <summary>
/// The dependency property of image height.
/// </summary>
public static readonly DependencyProperty ImageHeightProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(ImageHeight));
/// <summary>
/// The dependency property of image background.
/// </summary>
public static readonly DependencyProperty ImageBackgroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(ImageBackground));
/// <summary>
/// The dependency property of image background sizing.
/// </summary>
public static readonly DependencyProperty ImageBackgroundSizingProperty = DependencyObjectProxy.RegisterProperty<BackgroundSizing>(nameof(ImageBackgroundSizing));
/// <summary>
/// The dependency property of image padding.
/// </summary>
public static readonly DependencyProperty ImagePaddingProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(ImagePadding));
/// <summary>
/// The dependency property of image margin.
/// </summary>
public static readonly DependencyProperty ImageMarginProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(ImageMargin));
/// <summary>
/// The dependency property of image border brush.
/// </summary>
public static readonly DependencyProperty ImageBorderBrushProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(ImageBorderBrush));
/// <summary>
/// The dependency property of image thickness brush.
/// </summary>
public static readonly DependencyProperty ImageBorderThicknessProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(ImageBorderThickness));
/// <summary>
/// The dependency property of image corner radius.
/// </summary>
public static readonly DependencyProperty ImageCornerRadiusProperty = DependencyObjectProxy.RegisterProperty<CornerRadius>(nameof(ImageCornerRadius));
/// <summary>
/// The dependency property of image horizontal alignment property.
/// </summary>
public static readonly DependencyProperty ImageHorizontalAlignmentProperty = DependencyObjectProxy.RegisterProperty(nameof(ImageHorizontalAlignment), HorizontalAlignment.Stretch);
/// <summary>
/// The dependency property of image connected animation key property.
/// </summary>
public static readonly DependencyProperty ImageConnectedAnimationKeyProperty = DependencyObjectProxy.RegisterProperty<string>(nameof(ImageConnectedAnimationKey));
private Uri imageUri;
/// <summary>
/// Initializes a new instance of the TileItem class.
/// </summary>
public TileItem()
{
InitializeComponent();
}
/// <summary>
/// Occurs when this control is clicked.
/// </summary>
public event RoutedEventHandler Click;
/// <summary>
/// Occurs when the title trimmed property value has changed.
/// </summary>
public event TypedEventHandler<TileItem, IsTextTrimmedChangedEventArgs> IsTitleTrimmedChanged;
/// <summary>
/// Occurs when the description trimmed property value has changed.
/// </summary>
public event TypedEventHandler<TileItem, IsTextTrimmedChangedEventArgs> IsDescriptionTrimmedChanged;
/// <summary>
/// Occurs when there is an error associated with image retrieval or format.
/// </summary>
public event ExceptionRoutedEventHandler ImageFailed;
/// <summary>
/// Occurs when the image source is downloaded and decoded with no failure.
/// </summary>
public event RoutedEventHandler ImageOpened;
/// <summary>
/// Gets or sets the button style.
/// </summary>
public Style ButtonStyle
{
get => OwnerButton.Style;
set => OwnerButton.Style = value;
}
/// <summary>
/// Gets or sets the button template.
/// </summary>
public ControlTemplate ButtonTemplate
{
get => OwnerButton.Template;
set => OwnerButton.Template = value;
}
/// <summary>
/// Gets or sets the hover foreground.
/// </summary>
public Brush HoverForeground
{
get => (Brush)GetValue(HoverForegroundProperty);
set => SetValue(HoverForegroundProperty, value);
}
/// <summary>
/// Gets or sets the pressed foreground.
/// </summary>
public Brush PressedForeground
{
get => (Brush)GetValue(PressedForegroundProperty);
set => SetValue(PressedForegroundProperty, value);
}
/// <summary>
/// Gets or sets the hover background.
/// </summary>
public Brush HoverBackground
{
get => (Brush)GetValue(HoverBackgroundProperty);
set => SetValue(HoverBackgroundProperty, value);
}
/// <summary>
/// Gets or sets the pressed background.
/// </summary>
public Brush PressedBackground
{
get => (Brush)GetValue(PressedBackgroundProperty);
set => SetValue(PressedBackgroundProperty, value);
}
/// <summary>
/// Gets or sets the orientation of the image and text.
/// </summary>
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
/// <summary>
/// Gets or sets a value that indicates when the click event occurs, in terms of device behavior.
/// </summary>
public ClickMode ClickMode
{
get => OwnerButton.ClickMode;
set => OwnerButton.ClickMode = value;
}
/// <summary>
/// Gets or sets the background of text zone.
/// </summary>
public Brush TextBackground
{
get => (Brush)GetValue(TextBackgroundProperty);
set => SetValue(TextBackgroundProperty, value);
}
/// <summary>
/// Gets or sets the background sizing of text zone.
/// </summary>
public BackgroundSizing TextBackgroundSizing
{
get => (BackgroundSizing)GetValue(TextBackgroundSizingProperty);
set => SetValue(TextBackgroundSizingProperty, value);
}
/// <summary>
/// Gets or sets the width of text zone.
/// </summary>
public double TextWidth
{
get => (double)GetValue(TextWidthProperty);
set => SetValue(TextWidthProperty, value);
}
/// <summary>
/// Gets or sets the height of text zone.
/// </summary>
public double TextHeight
{
get => (double)GetValue(TextHeightProperty);
set => SetValue(TextHeightProperty, value);
}
/// <summary>
/// Gets or sets the alignment of text zone.
/// </summary>
public TextAlignment HorizontalTextAlignment
{
get => (TextAlignment)GetValue(HorizontalTextAlignmentProperty);
set => SetValue(HorizontalTextAlignmentProperty, value);
}
/// <summary>
/// Gets or sets the padding of text zone.
/// </summary>
public Thickness TextPadding
{
get => (Thickness)GetValue(TextPaddingProperty);
set => SetValue(TextPaddingProperty, value);
}
/// <summary>
/// Gets or sets the margin of text zone.
/// </summary>
public Thickness TextMargin
{
get => (Thickness)GetValue(TextMarginProperty);
set => SetValue(TextMarginProperty, value);
}
/// <summary>
/// Gets or sets the border brush of text zone.
/// </summary>
public Brush TextBorderBrush
{
get => (Brush)GetValue(TextBorderBrushProperty);
set => SetValue(TextBorderBrushProperty, value);
}
/// <summary>
/// Gets or sets the border thickness of text zone.
/// </summary>
public Thickness TextBorderThickness
{
get => (Thickness)GetValue(TextBorderThicknessProperty);
set => SetValue(TextBorderThicknessProperty, value);
}
/// <summary>
/// Gets or sets the corner radius of text zone.
/// </summary>
public CornerRadius TextCornerRadius
{
get => (CornerRadius)GetValue(TextCornerRadiusProperty);
set => SetValue(TextCornerRadiusProperty, value);
}
/// <summary>
/// Gets or sets the title.
/// </summary>
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
/// <summary>
/// Gets or sets the font size of title.
/// </summary>
public double TitleFontSize
{
get => (double)GetValue(TitleFontSizeProperty);
set => SetValue(TitleFontSizeProperty, value);
}
/// <summary>
/// Gets or sets the font weight of title.
/// </summary>
public FontWeight TitleFontWeight
{
get => (FontWeight)GetValue(TitleFontWeightProperty);
set => SetValue(TitleFontWeightProperty, value);
}
/// <summary>
/// Gets or sets the font style of title.
/// </summary>
public FontStyle TitleFontStyle
{
get => (FontStyle)GetValue(TitleFontStyleProperty);
set => SetValue(TitleFontStyleProperty, value);
}
/// <summary>
/// Gets or sets the line height of title.
/// </summary>
public double TitleLineHeight
{
get => (double)GetValue(TitleLineHeightProperty);
set => SetValue(TitleLineHeightProperty, value);
}
/// <summary>
/// Gets or sets the foreground of title.
/// </summary>
public Brush TitleForeground
{
get => (Brush)GetValue(TitleForegroundProperty);
set => SetValue(TitleForegroundProperty, value);
}
/// <summary>
/// Gets or sets the width of title.
/// </summary>
public double TitleWidth
{
get => (double)GetValue(TitleWidthProperty);
set => SetValue(TitleWidthProperty, value);
}
/// <summary>
/// Gets or sets the height of title.
/// </summary>
public double TitleHeight
{
get => (double)GetValue(TitleHeightProperty);
set => SetValue(TitleHeightProperty, value);
}
/// <summary>
/// Gets or sets the max height of title.
/// </summary>
public double TitleMaxHeight
{
get => (double)GetValue(TitleMaxHeightProperty);
set => SetValue(TitleMaxHeightProperty, value);
}
/// <summary>
/// Gets or sets the horizontal alignment of title.
/// </summary>
public HorizontalAlignment TitleHorizontalAlignment
{
get => (HorizontalAlignment)GetValue(TitleHorizontalAlignmentProperty);
set => SetValue(TitleHorizontalAlignmentProperty, value);
}
/// <summary>
/// Gets or sets the wrapping mode of title.
/// </summary>
public TextWrapping TitleWrapping
{
get => (TextWrapping)GetValue(TitleWrappingProperty);
set => SetValue(TitleWrappingProperty, value);
}
/// <summary>
/// Gets or sets the trimming mode of title.
/// </summary>
public TextTrimming TitleTrimming
{
get => (TextTrimming)GetValue(TitleTrimmingProperty);
set => SetValue(TitleTrimmingProperty, value);
}
/// <summary>
/// Gets or sets the title connected animation key.
/// </summary>
public string TitleConnectedAnimationKey
{
get => (string)GetValue(TitleConnectedAnimationKeyProperty);
set => SetValue(TitleConnectedAnimationKeyProperty, value);
}
/// <summary>
/// Gets or sets the description.
/// </summary>
public string Description
{
get => (string)GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
/// <summary>
/// Gets or sets the font size of description.
/// </summary>
public double DescriptionFontSize
{
get => (double)GetValue(DescriptionFontSizeProperty);
set => SetValue(DescriptionFontSizeProperty, value);
}
/// <summary>
/// Gets or sets the font weight of description.
/// </summary>
public FontWeight DescriptionFontWeight
{
get => (FontWeight)GetValue(DescriptionFontWeightProperty);
set => SetValue(DescriptionFontWeightProperty, value);
}
/// <summary>
/// Gets or sets the font style of description.
/// </summary>
public FontStyle DescriptionFontStyle
{
get => (FontStyle)GetValue(DescriptionFontStyleProperty);
set => SetValue(DescriptionFontStyleProperty, value);
}
/// <summary>
/// Gets or sets the line height of description.
/// </summary>
public double DescriptionLineHeight
{
get => (double)GetValue(DescriptionLineHeightProperty);
set => SetValue(DescriptionLineHeightProperty, value);
}
/// <summary>
/// Gets or sets the foreground of description.
/// </summary>
public Brush DescriptionForeground
{
get => (Brush)GetValue(DescriptionForegroundProperty);
set => SetValue(DescriptionForegroundProperty, value);
}
/// <summary>
/// Gets or sets the width of description.
/// </summary>
public double DescriptionWidth
{
get => (double)GetValue(DescriptionWidthProperty);
set => SetValue(DescriptionWidthProperty, value);
}
/// <summary>
/// Gets or sets the height of description.
/// </summary>
public double DescriptionHeight
{
get => (double)GetValue(DescriptionHeightProperty);
set => SetValue(DescriptionHeightProperty, value);
}
/// <summary>
/// Gets or sets the horizontal alignment of description.
/// </summary>
public HorizontalAlignment DescriptionHorizontalAlignment
{
get => (HorizontalAlignment)GetValue(DescriptionHorizontalAlignmentProperty);
set => SetValue(DescriptionHorizontalAlignmentProperty, value);
}
/// <summary>
/// Gets or sets the wrapping mode of description.
/// </summary>
public TextWrapping DescriptionWrapping
{
get => (TextWrapping)GetValue(DescriptionWrappingProperty);
set => SetValue(DescriptionWrappingProperty, value);
}
/// <summary>
/// Gets or sets the trimming mode of description.
/// </summary>
public TextTrimming DescriptionTrimming
{
get => (TextTrimming)GetValue(DescriptionTrimmingProperty);
set => SetValue(DescriptionTrimmingProperty, value);
}
/// <summary>
/// Gets or sets the image URI.
/// </summary>
public Uri ImageUri
{
get => (Uri)GetValue(ImageUriProperty);
set => SetValue(ImageUriProperty, value);
}
/// <summary>
/// Gets or sets the width of image.
/// </summary>
public double ImageWidth
{
get => (double)GetValue(ImageWidthProperty);
set => SetValue(ImageWidthProperty, value);
}
/// <summary>
/// Gets or sets the height of image.
/// </summary>
public double ImageHeight
{
get => (double)GetValue(ImageHeightProperty);
set => SetValue(ImageHeightProperty, value);
}
/// <summary>
/// Gets or sets the background of image.
/// </summary>
public Brush ImageBackground
{
get => (Brush)GetValue(ImageBackgroundProperty);
set => SetValue(ImageBackgroundProperty, value);
}
/// <summary>
/// Gets or sets the background sizing of image.
/// </summary>
public BackgroundSizing ImageBackgroundSizing
{
get => (BackgroundSizing)GetValue(ImageBackgroundSizingProperty);
set => SetValue(ImageBackgroundSizingProperty, value);
}
/// <summary>
/// Gets or sets the padding of image.
/// </summary>
public Thickness ImagePadding
{
get => (Thickness)GetValue(ImagePaddingProperty);
set => SetValue(ImagePaddingProperty, value);
}
/// <summary>
/// Gets or sets the margin of image.
/// </summary>
public Thickness ImageMargin
{
get => (Thickness)GetValue(ImageMarginProperty);
set => SetValue(ImageMarginProperty, value);
}
/// <summary>
/// Gets or sets the border brush of image.
/// </summary>
public Brush ImageBorderBrush
{
get => (Brush)GetValue(ImageBorderBrushProperty);
set => SetValue(ImageBorderBrushProperty, value);
}
/// <summary>
/// Gets or sets the border thickness of image.
/// </summary>
public Thickness ImageBorderThickness
{
get => (Thickness)GetValue(ImageBorderThicknessProperty);
set => SetValue(ImageBorderThicknessProperty, value);
}
/// <summary>
/// Gets or sets the corner radius of image.
/// </summary>
public CornerRadius ImageCornerRadius
{
get => (CornerRadius)GetValue(ImageCornerRadiusProperty);
set => SetValue(ImageCornerRadiusProperty, value);
}
/// <summary>
/// Gets or sets the image connected animation key.
/// </summary>
public string ImageConnectedAnimationKey
{
get => (string)GetValue(ImageConnectedAnimationKeyProperty);
set => SetValue(ImageConnectedAnimationKeyProperty, value);
}
/// <summary>
/// Gets or sets the horizontal alignment of image.
/// </summary>
public HorizontalAlignment ImageHorizontalAlignment
{
get => (HorizontalAlignment)GetValue(ImageHorizontalAlignmentProperty);
set => SetValue(ImageHorizontalAlignmentProperty, value);
}
/// <summary>
/// Gets or sets the content of top customized zone.
/// </summary>
public UIElement TopContent
{
get => Top.Child;
set => Top.Child = value;
}
/// <summary>
/// Gets or sets the content of bottom customized zone.
/// </summary>
public UIElement BottomContent
{
get => Bottom.Child;
set => Bottom.Child = value;
}
/// <summary>
/// Gets or sets the content of image cover zone.
/// </summary>
public UIElement ImageCoverContent
{
get => ImageCover.Child;
set => ImageCover.Child = value;
}
/// <summary>
/// Gets or sets the content of text cover zone.
/// </summary>
public UIElement TextCoverContent
{
get => TextCover.Child;
set => TextCover.Child = value;
}
/// <summary>
/// Gets or sets the content of image cover zone.
/// </summary>
public UIElement ImageBackgroundContent
{
get => ImageBack.Child;
set => ImageBack.Child = value;
}
/// <summary>
/// Gets or sets the content of text cover zone.
/// </summary>
public UIElement TextBackgroundContent
{
get => TextBack.Child;
set => TextBack.Child = value;
}
/// <summary>
/// Gets or sets the content of customized zone before text.
/// </summary>
public UIElement BeforeTextContent
{
get => BeforeText.Child;
set => BeforeText.Child = value;
}
/// <summary>
/// Gets or sets the content of customized zone after text.
/// </summary>
public UIElement AfterTextContent
{
get => AfterText.Child;
set => AfterText.Child = value;
}
/// <summary>
/// Gets the collection of title highlights.
/// </summary>
public IList<Microsoft.UI.Xaml.Documents.TextHighlighter> TitleHighlighters => TitleText.TextHighlighters;
/// <summary>
/// Gets the collection of description highlights.
/// </summary>
public IList<Microsoft.UI.Xaml.Documents.TextHighlighter> DescriptionHighlighters => DescriptionText.TextHighlighters;
/// <summary>
/// Gets a value by which each line of title text content is offset from a baseline.
/// </summary>
public double TitleBaselineOffset => TitleText.BaselineOffset;
/// <summary>
/// Gets a value by which each line of description text content is offset from a baseline.
/// </summary>
public double DescriptionBaselineOffset => DescriptionText.BaselineOffset;
/// <summary>
/// Gets a value that indicates whether a device pointer is located over this.
/// </summary>
public bool IsPointerOver => OwnerButton.IsPointerOver;
/// <summary>
/// Gets a value that indicates whether this is currently in a pressed state.
/// </summary>
public bool IsPressed => OwnerButton.IsPressed;
/// <summary>
/// Sets image URI.
/// </summary>
/// <param name="uri">The image URI.</param>
/// <param name="prepareOnly">true if it is used to prepare to set, that means it will not take effect in fact; otherwise, false.</param>
public void SetImage(Uri uri, bool prepareOnly = false)
{
if (prepareOnly) imageUri = uri;
else ImageUri = uri;
}
/// <summary>
/// Uses prepare image URI if available.
/// </summary>
public void UseImageUriPrepared()
{
if (imageUri == null) return;
ImageUri = imageUri;
}
/// <summary>
/// Sets the value of the ToolTipService.ToolTip XAML attached property.
/// </summary>
/// <param name="value">The value to set for tooltip content.</param>
public void SetTitleToolTip(object value)
=> ToolTipService.SetToolTip(TitleText, value);
/// <summary>
/// Sets the value of the ToolTipService.ToolTip XAML attached property.
/// </summary>
/// <param name="value">The value to set for tooltip content.</param>
public void SetDescriptionToolTip(object value)
=> ToolTipService.SetToolTip(DescriptionText, value);
/// <summary>
/// Sets the value of the ToolTipService.ToolTip XAML attached property.
/// </summary>
/// <param name="value">The value to set for tooltip content.</param>
public void SetImageToolTip(object value)
=> ToolTipService.SetToolTip(ImageControl, value);
/// <inheritdoc />
public override string ToString()
=> Title ?? string.Empty;
private void TitleText_IsTextTrimmedChanged(TextBlock sender, IsTextTrimmedChangedEventArgs args)
=> IsTitleTrimmedChanged?.Invoke(this, args);
private void DescriptionText_IsTextTrimmedChanged(TextBlock sender, IsTextTrimmedChangedEventArgs args)
=> IsDescriptionTrimmedChanged?.Invoke(this, args);
private void ImageControl_ImageFailed(object sender, ExceptionRoutedEventArgs e)
=> ImageFailed?.Invoke(this, e);
private void ImageControl_ImageOpened(object sender, RoutedEventArgs e)
=> ImageOpened?.Invoke(this, e);
private void Button_Click(object sender, RoutedEventArgs e)
{
try
{
if (!string.IsNullOrWhiteSpace(TitleConnectedAnimationKey)) ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(TitleConnectedAnimationKey, TitleText);
if (!string.IsNullOrWhiteSpace(ImageConnectedAnimationKey)) ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(ImageConnectedAnimationKey, ImageControl);
}
catch (NullReferenceException)
{
}
catch (InvalidOperationException)
{
}
Click?.Invoke(this, e);
}
private static void OnTextChanged(TileItem c, ChangeEventArgs<string> e, DependencyProperty p)
{
c.TitleText.Visibility = string.IsNullOrWhiteSpace(c.Title) ? Visibility.Collapsed : Visibility.Visible;
c.DescriptionText.Visibility = string.IsNullOrWhiteSpace(c.Description) ? Visibility.Collapsed : Visibility.Visible;
}
private static void OnImageUriChanged(TileItem c, ChangeEventArgs<Uri> e, DependencyProperty p)
{
c.imageUri = null;
}
/// <summary>