Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 优化计时器体验 #49

Merged
merged 1 commit into from
Feb 12, 2023
Merged
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
22 changes: 17 additions & 5 deletions Ink Canvas/CountdownTimerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
Title="Ink Canvas 画板 - 计时器" Height="700" Width="1100">
<Border Background="#F0F3F9" CornerRadius="10" BorderThickness="1" BorderBrush="#0066BF" Margin="60">
<Grid>
<Viewbox Margin="20,20,20,20">
<TextBlock x:Name="TbCurrentTime" MouseDown="BtnMinimal_OnMouseUp" Visibility="Collapsed" FontSize="56" FontWeight="Black" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Border MouseMove="WindowDragMove" Visibility="{Binding ElementName=TbCurrentTime, Path=Visibility}" Width="64" Height="15" CornerRadius="8" Background="Gray" Margin="0,0,0,5" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
<Viewbox x:Name="BigViewController" Margin="20,20,20,20">
<Grid Height="180" Width="200">
<processbars:CycleProcessBar x:Name="ProcessBarTime" CurrentValue="0" Width="150" VerticalAlignment="Top"/>
<ui:SimpleStackPanel Orientation="Horizontal" Height="28.5" Margin="0,0,0,25"
<ui:SimpleStackPanel MouseMove="WindowDragMove" Orientation="Horizontal" Height="28.5" Margin="0,0,0,25"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Name="TextBlockHour" FontFamily="Segeo UI"
Expand Down Expand Up @@ -216,11 +218,21 @@
</ui:SimpleStackPanel>
</Grid>
</Viewbox>
<Viewbox Margin="20,20,20,20" HorizontalAlignment="Right">
<Viewbox Visibility="{Binding ElementName=BigViewController, Path=Visibility}" Margin="20,20,20,20" HorizontalAlignment="Right">
<ui:SimpleStackPanel Height="180" Orientation="Horizontal">
<Border x:Name="BtnMinimal" Visibility="{Binding ElementName=BorderStopTime, Path=Visibility}" MouseUp="BtnMinimal_OnMouseUp" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="5"
Background="#FBFBFD" Height="20" Width="20" CornerRadius="100">
<Border.Effect>
<DropShadowEffect Direction="0" ShadowDepth="0" Opacity="0.1" BlurRadius="3"/>
</Border.Effect>
<Viewbox Margin="5.5">
<ui:SymbolIcon Name="SymbolIconMinimal" Symbol="HideBcc" Foreground="Black"/>
</Viewbox>
</Border>
<Border x:Name="BtnFullscreen" MouseUp="BtnFullscreen_MouseUp" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="5"
Background="#FBFBFD" Height="20" Width="20" CornerRadius="100">
Margin="5"
Background="#FBFBFD" Height="20" Width="20" CornerRadius="100">
<Border.Effect>
<DropShadowEffect Direction="0" ShadowDepth="0" Opacity="0.1" BlurRadius="3"/>
</Border.Effect>
Expand Down
36 changes: 34 additions & 2 deletions Ink Canvas/CountdownTimerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
timer.Stop();
return;
}

TimeSpan timeSpan = DateTime.Now - startTime;
TimeSpan totalTimeSpan = new TimeSpan(hour, minute, second);
TimeSpan leftTimeSpan = totalTimeSpan - timeSpan;
Expand All @@ -47,6 +48,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
TextBlockHour.Text = leftTimeSpan.Hours.ToString("00");
TextBlockMinute.Text = leftTimeSpan.Minutes.ToString("00");
TextBlockSecond.Text = leftTimeSpan.Seconds.ToString("00");
TbCurrentTime.Text = leftTimeSpan.ToString(@"hh\:mm\:ss");
if (spentTimePercent >= 1)
{
ProcessBarTime.CurrentValue = 0;
Expand Down Expand Up @@ -269,7 +271,8 @@ private Color StringToColor(string colorStr)
Byte b2 = toByte(charArray[1]);
argb[i] = (Byte)(b2 | (b1 << 4));
}
return Color.FromArgb(argb[0], argb[1], argb[2], argb[3]);//#FFFFFFFF

return Color.FromArgb(argb[0], argb[1], argb[2], argb[3]); //#FFFFFFFF
}

private static byte toByte(char c)
Expand Down Expand Up @@ -347,5 +350,34 @@ private void BtnClose_MouseUp(object sender, MouseButtonEventArgs e)
{
Close();
}

private bool _isInCompact = false;

private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e)
{
if (_isInCompact)
{
Width = 1100;
Height = 700;
BigViewController.Visibility = Visibility.Visible;
TbCurrentTime.Visibility = Visibility.Collapsed;
}
else
{
if (WindowState == WindowState.Maximized) WindowState = WindowState.Normal;
Width = 400;
Height = 250;
BigViewController.Visibility = Visibility.Collapsed;
TbCurrentTime.Visibility = Visibility.Visible;
}

_isInCompact = !_isInCompact;
}

private void WindowDragMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
DragMove();
}
}
}
}
2 changes: 1 addition & 1 deletion Ink Canvas/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5738,7 +5738,7 @@ private void BtnTools_Click(object sender, RoutedEventArgs e)
private void BtnCountdownTimer_Click(object sender, RoutedEventArgs e)
{
StackPanelToolButtons.Visibility = Visibility.Collapsed;
new CountdownTimerWindow().ShowDialog();
new CountdownTimerWindow().Show();
}

private void BtnRand_Click(object sender, RoutedEventArgs e)
Expand Down