Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions UI/Controls/Select/DateSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChan
public Command ShowSelectCommand { get; set; }
public Command SetYearCommand { get; set; }
public Command SetMonthCommand { get; set; }
public Command SwitchDateCommand { get; set; }
public Command DoneCommand { get; set; }

private bool IsFirstClick = false;
Expand All @@ -164,6 +165,7 @@ public DateSelect()
ShowSelectCommand = new Command(new Action<object>(OnShowSelect));
SetYearCommand = new Command(new Action<object>(OnSetYear));
SetMonthCommand = new Command(new Action<object>(OnSetMonth));
SwitchDateCommand = new Command(new Action<object>(OnSwitchDate));
DoneCommand = new Command(new Action<object>(OnDone));


Expand Down Expand Up @@ -249,6 +251,30 @@ private void OnDone(object obj)
IsOpen = false;
}

private void OnSwitchDate(object obj)
{
var newDate = Day != null ? Day.Day : new DateTime(Year, Month, 1);
if (SelectType == DateSelectType.Day)
{
newDate = newDate.AddDays(int.Parse(obj.ToString()));
}
else if (SelectType == DateSelectType.Month)
{
newDate = newDate.AddMonths(int.Parse(obj.ToString()));
}
else if (SelectType == DateSelectType.Year)
{
newDate = newDate.AddYears(int.Parse(obj.ToString()));
}
Year = newDate.Year;
Month = newDate.Month;
Date = newDate;
SelectedDay = newDate;

UpdateDays();
UpdateDateStr();
}

private void OnSetMonth(object obj)
{
int newMonth = Month + int.Parse(obj.ToString());
Expand Down
24 changes: 14 additions & 10 deletions UI/Themes/Select/DateSelect.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
<DropShadowEffect Color="#d8d2d2" BlurRadius="1" Direction="300" ShadowDepth="4" Opacity="0.1" RenderingBias="Performance" ></DropShadowEffect>
</Border.Effect>
</Border>
<Border x:Name="Main" Margin="0,0,0,0" Background="{DynamicResource StandardBackgroundBrush}" HorizontalAlignment="Left" Padding="18,10" CornerRadius="5">
<Border.InputBindings>
<MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=ShowSelectCommand}"/>
</Border.InputBindings>

<StackPanel Orientation="Horizontal">
<base:Icon x:Name="Icon" IconType="Calendar" Foreground="{DynamicResource StandardTextBrush}"/>
<TextBlock Foreground="{DynamicResource StandardTextBrush}" Text="{TemplateBinding DateStr}" VerticalAlignment="Center" Margin="5,0,0,0"/>
</StackPanel>
</Border>
<StackPanel Orientation="Horizontal">
<button:IconButton Icon="ChevronLeft" FontSize="12" VerticalAlignment="Center" Margin="0,0,5,0" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SwitchDateCommand}" CommandParameter="-1"/>
<Border x:Name="Main" Margin="0,0,0,0" Background="{DynamicResource StandardBackgroundBrush}" HorizontalAlignment="Left" Padding="18,10" CornerRadius="5">
<Border.InputBindings>
<MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=ShowSelectCommand}"/>
</Border.InputBindings>

<StackPanel Orientation="Horizontal">
<base:Icon x:Name="Icon" IconType="Calendar" Foreground="{DynamicResource StandardTextBrush}"/>
<TextBlock Foreground="{DynamicResource StandardTextBrush}" Text="{TemplateBinding DateStr}" VerticalAlignment="Center" Margin="5,0,0,0"/>
</StackPanel>
</Border>
<button:IconButton Icon="ChevronRight" FontSize="12" VerticalAlignment="Center" Margin="5,0,0,0" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SwitchDateCommand}" CommandParameter="1"/>
</StackPanel>

<!--选择-->
<Popup
Expand Down