This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tobiichiamane
committed
Apr 20, 2019
1 parent
e5582a4
commit db18d9e
Showing
6 changed files
with
132 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace PixivFSUWP.Controls | ||
{ | ||
public class ImageSelectorPanel : Panel | ||
{ | ||
//此属性决定项目间隔 | ||
public static readonly DependencyProperty ItemMarginProperty = | ||
DependencyProperty.Register("ItemMargin", typeof(double), | ||
typeof(ImageSelectorPanel), new PropertyMetadata((double)0, | ||
(DepObj, e) => | ||
{ | ||
(DepObj as ImageSelectorPanel).InvalidateMeasure(); | ||
(DepObj as ImageSelectorPanel).InvalidateArrange(); | ||
})); | ||
|
||
public double ItemMargin | ||
{ | ||
get => (double)GetValue(ItemMarginProperty); | ||
set => SetValue(ItemMarginProperty, value); | ||
} | ||
|
||
//此属性决定左端间距 | ||
public static readonly DependencyProperty LeftOffsetProperty = | ||
DependencyProperty.Register("LeftOffset", typeof(double), | ||
typeof(ImageSelectorPanel), new PropertyMetadata((double)0, | ||
(DepObj, e) => | ||
{ | ||
(DepObj as ImageSelectorPanel).InvalidateMeasure(); | ||
(DepObj as ImageSelectorPanel).InvalidateArrange(); | ||
})); | ||
|
||
public double LeftOffset | ||
{ | ||
get => (double)GetValue(LeftOffsetProperty); | ||
set => SetValue(LeftOffsetProperty, value); | ||
} | ||
|
||
//此属性决定右端间距 | ||
public static readonly DependencyProperty RightOffsetProperty = | ||
DependencyProperty.Register("RightOffset", typeof(double), | ||
typeof(ImageSelectorPanel), new PropertyMetadata((double)0, | ||
(DepObj, e) => | ||
{ | ||
(DepObj as ImageSelectorPanel).InvalidateMeasure(); | ||
(DepObj as ImageSelectorPanel).InvalidateArrange(); | ||
})); | ||
|
||
public double RightOffset | ||
{ | ||
get => (double)GetValue(RightOffsetProperty); | ||
set => SetValue(RightOffsetProperty, value); | ||
} | ||
|
||
protected override Size MeasureOverride(Size availableSize) | ||
{ | ||
Size toret = new Size(); | ||
toret.Height = availableSize.Height; | ||
toret.Width = LeftOffset + ItemMargin * (Children.Count - 1) + RightOffset; | ||
foreach (var i in Children) | ||
{ | ||
i.Measure(new Size(double.PositiveInfinity, toret.Height)); | ||
toret.Width += i.DesiredSize.Width; | ||
} | ||
return toret; | ||
} | ||
|
||
protected override Size ArrangeOverride(Size finalSize) | ||
{ | ||
double xOffset = LeftOffset; | ||
foreach (var i in Children) | ||
{ | ||
i.Arrange(new Rect(xOffset, 0, i.DesiredSize.Width, i.DesiredSize.Height)); | ||
xOffset += i.DesiredSize.Width + ItemMargin; | ||
} | ||
return finalSize; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters