ui: Animate AnalyticsShellModule window-section expand/collapse
This commit is contained in:
1 parent
9cd5d0890f
commit
bdbbcb05dc
3 files changed
+118
-22
No files matched your search
@@ -6,9 +6,16 @@ namespace mbts.spark {
|
||||
using Spark.ViewModel;
|
||||
|
||||
class AnalyticsShellModuleVM : ViewModelBase {
|
||||
string? _selected_window_type;
|
||||
|
||||
public EventCommand launch_exp_params_view_cmd { get; } = new();
|
||||
public KeyValueLauncherVM<int, string> vol_surface_launcher_vm { get; } = new();
|
||||
public KeyValueLauncherVM<int, string> slide_report_launcher_vm { get; } = new();
|
||||
public KeyValueLauncherVM<int, string> combo_report_launcher_vm { get; } = new();
|
||||
|
||||
public string? selected_window_type {
|
||||
get => _selected_window_type;
|
||||
set => Set(ref _selected_window_type, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:shell="clr-namespace:mbts.ui.shell"
|
||||
x:Name="me"
|
||||
Background="Transparent"
|
||||
MinWidth="250"
|
||||
@@ -17,11 +19,14 @@
|
||||
|
||||
<DataTemplate x:Key="LaunchItemTemplate">
|
||||
<Button
|
||||
Height="32" MinWidth="190" Padding="4"
|
||||
Height="32"
|
||||
MinWidth="190"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Padding="12,6,6,6"
|
||||
Command="{Binding DataContext.launch_cmd, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
|
||||
CommandParameter="{Binding key}"
|
||||
Style="{DynamicResource StartMenuButton}"
|
||||
Style="{StaticResource LargeMenuButton}"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -44,8 +49,8 @@
|
||||
<DataTemplate x:Key="ReportLauncherTemplate">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ItemsControl
|
||||
@@ -60,7 +65,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox
|
||||
c:TextBoxEx.EmptyTextPrompt="New Name"
|
||||
c:TextBoxEx.EmptyTextPrompt="Name"
|
||||
Template="{DynamicResource EmptyTextPromptTemplate}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="4"
|
||||
@@ -79,6 +84,15 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Name="WindowTypeToggle" TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
</Style>
|
||||
|
||||
<c:RadioButtonGroupManager
|
||||
x:Key="WindowTypeRadioButtonGroupManager"
|
||||
SelectedItem="{Binding DataContext.selected_window_type, Source={u:DirectReference me}, Mode=TwoWay}"
|
||||
/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="8">
|
||||
@@ -88,13 +102,15 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button
|
||||
Style="{DynamicResource StartMenuButton}"
|
||||
Content="Analytics Expiration Parameters"
|
||||
Command="{Binding launch_exp_params_view_cmd}"
|
||||
Padding="4"
|
||||
Style="{StaticResource LargeMenuButton}"
|
||||
/>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
@@ -117,28 +133,58 @@
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
<Expander
|
||||
<ToggleButton
|
||||
Grid.Row="2"
|
||||
Header="Vol Surfaces"
|
||||
Content="{Binding vol_surface_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
c:RadioButtonGroupManager.Manager="{StaticResource WindowTypeRadioButtonGroupManager}"
|
||||
Content="Vol Surfaces"
|
||||
DataContext="vol_surfaces"
|
||||
IsChecked="{Binding Path='(shell:AnalyticsShellModuleView.ShowWindowTypeContent)', ElementName=VolSurfacesContent, Mode=TwoWay}"
|
||||
Style="{StaticResource LargeMenuToggleButton}"
|
||||
/>
|
||||
|
||||
<Expander
|
||||
Grid.Row="3"
|
||||
Margin="0,6,0,0"
|
||||
Header="Slide Report"
|
||||
Content="{Binding slide_report_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
/>
|
||||
<ContentControl Grid.Row="3" Height="0">
|
||||
<ContentControl
|
||||
x:Name="VolSurfacesContent"
|
||||
Content="{Binding vol_surface_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
/>
|
||||
</ContentControl>
|
||||
|
||||
<Expander
|
||||
<ToggleButton
|
||||
Grid.Row="4"
|
||||
c:RadioButtonGroupManager.Manager="{StaticResource WindowTypeRadioButtonGroupManager}"
|
||||
Margin="0,6,0,0"
|
||||
Header="Combo Report"
|
||||
Content="{Binding combo_report_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
DataContext="slide_reports"
|
||||
Content="Slide Reports"
|
||||
IsChecked="{Binding Path='(shell:AnalyticsShellModuleView.ShowWindowTypeContent)', ElementName=SlideReportContent, Mode=TwoWay}"
|
||||
Style="{StaticResource LargeMenuToggleButton}"
|
||||
/>
|
||||
|
||||
<ContentControl Grid.Row="5" Height="0">
|
||||
<ContentControl
|
||||
x:Name="SlideReportContent"
|
||||
Content="{Binding slide_report_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
/>
|
||||
</ContentControl>
|
||||
|
||||
<ToggleButton
|
||||
Grid.Row="6"
|
||||
c:RadioButtonGroupManager.Manager="{StaticResource WindowTypeRadioButtonGroupManager}"
|
||||
Margin="0,6,0,0"
|
||||
DataContext="combo_reports"
|
||||
Content="Combo Report"
|
||||
IsChecked="{Binding Path='(shell:AnalyticsShellModuleView.ShowWindowTypeContent)', ElementName=ComboReportContent, Mode=TwoWay}"
|
||||
Style="{StaticResource LargeMenuToggleButton}"
|
||||
/>
|
||||
|
||||
<ContentControl Grid.Row="7" Height="0">
|
||||
<ContentControl
|
||||
x:Name="ComboReportContent"
|
||||
Content="{Binding combo_report_launcher_vm}"
|
||||
ContentTemplate="{StaticResource ReportLauncherTemplate}"
|
||||
/>
|
||||
</ContentControl>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,5 +1,10 @@
|
||||
namespace mbts.ui.shell {
|
||||
using bts.utils;
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for VolSurfaceShellModuleContent.xaml
|
||||
@@ -7,5 +12,43 @@
|
||||
partial class AnalyticsShellModuleView : UserControl {
|
||||
public AnalyticsShellModuleView() =>
|
||||
InitializeComponent();
|
||||
|
||||
#region ShowWindowTypeContent
|
||||
public static readonly DependencyProperty ShowWindowTypeContentProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"ShowWindowTypeContent", typeof(bool), typeof(AnalyticsShellModuleView),
|
||||
new PropertyMetadata(false, _on_show_window_type_content_changed));
|
||||
|
||||
static void _on_show_window_type_content_changed(
|
||||
DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
if (d is not FrameworkElement content) {
|
||||
return;
|
||||
}
|
||||
|
||||
var collapsible_container = content.find_ancestor_of_type<ContentControl>();
|
||||
content.Measure(new(double.PositiveInfinity, double.PositiveInfinity));
|
||||
|
||||
var (from, to) = (bool)e.NewValue ?
|
||||
(0D, content.DesiredSize.Height) : (content.DesiredSize.Height, 0D);
|
||||
var anim = new DoubleAnimation {
|
||||
From = from,
|
||||
To = to,
|
||||
EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseOut },
|
||||
Duration = TimeSpan.FromSeconds(0.23)
|
||||
};
|
||||
Storyboard.SetTarget(anim, collapsible_container);
|
||||
Storyboard.SetTargetProperty(anim, new(HeightProperty));
|
||||
|
||||
var sb = new Storyboard();
|
||||
sb.Children.Add(anim);
|
||||
sb.Begin();
|
||||
}
|
||||
|
||||
public static bool GetShowWindowTypeContent(DependencyObject d) =>
|
||||
(bool)d.GetValue(ShowWindowTypeContentProperty);
|
||||
|
||||
public static void SetShowWindowTypeContent(DependencyObject d, bool value) =>
|
||||
d.SetValue(ShowWindowTypeContentProperty, value);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user