SPARK-1804
This commit is contained in:
1 parent
e67756d055
commit
8d9697d06d
4 files changed
+65
-6
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,50 @@
|
||||
using bts;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.controls.adorners;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
public class UniformTabGrid : UniformGrid {
|
||||
public UniformTabGrid () {
|
||||
this.IsItemsHost = true;
|
||||
this.Rows = 1;
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size constraint) {
|
||||
var child_tabs = this.Children.OfType<TabItem>();
|
||||
var child_tabs_max_width = child_tabs.Sum(t => t.MaxWidth);
|
||||
// I noticed when debugging that this can sometimes be infinty,
|
||||
// especially when a TabItem has not been set with a MaxWidth.
|
||||
if (!double.IsInfinity(child_tabs_max_width)) {
|
||||
// if the window width is greater than the total tab width, then
|
||||
// there is more than enough space for all the tabs. If this
|
||||
// is set to the default of Stretch and the window has only 1
|
||||
// tab or few tabs, the tab appears in the middle, which is not good.
|
||||
// i.e. we want tabs to added left to right, so align left
|
||||
//
|
||||
// When the window is less than the total tab width, then align
|
||||
// can be set to stretch b/c the UniformGrid will take care of
|
||||
// sizing each tab accordingly.
|
||||
this.HorizontalAlignment = (constraint.Width > child_tabs_max_width)
|
||||
? HorizontalAlignment.Left
|
||||
: HorizontalAlignment.Stretch;
|
||||
|
||||
// this bit here is necessary because when the window is expanded
|
||||
// beyond the maxwidth of all the tabs, we switch to Left and the
|
||||
// headers snap to some smaller than MaxWidth size, which is not
|
||||
// the behavior we want
|
||||
foreach (var child in child_tabs) {
|
||||
child.Width = this.HorizontalAlignment == HorizontalAlignment.Left
|
||||
? child.MaxWidth
|
||||
: double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
return base.MeasureOverride(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
|
||||
xmlns:ui="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
mc:Ignorable="d" AllowDrop="True"
|
||||
Style="{StaticResource BTSFloatingWindow}"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
@@ -25,18 +26,25 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<WrapPanel x:Name="HeaderPanel" Orientation="Horizontal" Margin="0,0,100,0"
|
||||
<!-- This stack panel serves as the area between the last tab and the widget control on right side of title bar (below).
|
||||
It allows the region in between (if such a region exists) to be grabbed to move the window.
|
||||
-->
|
||||
<StackPanel Grid.Row="0" Margin="0,0,100,0" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<c:UniformTabGrid x:Name="HeaderPanel"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="1"
|
||||
IsItemsHost="True"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
</WrapPanel>
|
||||
Background="Transparent"
|
||||
ui:WindowStyle.IsNonClientArea="True"
|
||||
>
|
||||
</c:UniformTabGrid>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="1" BorderThickness="0"
|
||||
Padding="{Binding Path=Padding, RelativeSource={RelativeSource AncestorType=Window}}" ui:WindowStyle.IsNonClientArea="False" >
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
|
||||
</Border>
|
||||
<Border Grid.Row="0" Width="100" HorizontalAlignment="Right" VerticalAlignment="Stretch" Panel.ZIndex="2" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<!-- Window widget control area-->
|
||||
<Border Grid.Row="0" MinWidth="100" HorizontalAlignment="Right" Panel.ZIndex="2" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Panel.ZIndex="2" Background="Transparent" Margin="5">
|
||||
<Button Style="{StaticResource RoundMinimizeButton}" HorizontalAlignment="Right" Command="{x:Static SystemCommands.MinimizeWindowCommand}" />
|
||||
<Button Style="{StaticResource RoundMaximizeButton}" HorizontalAlignment="Right" Command="{x:Static SystemCommands.MaximizeWindowCommand}" />
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</TabItem.RenderTransform>
|
||||
<TabItem.Template>
|
||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||
<Border x:Name="bd" BorderBrush="Black" BorderThickness="0,0,0.5,0" Background="#d6d6d6" Width="{DynamicResource TabWidth}" Height="{DynamicResource TabHeight}" MinWidth="40" Margin="0" SnapsToDevicePixels="True" DockPanel.Dock="Left">
|
||||
<Border x:Name="bd" BorderBrush="Black" BorderThickness="0,0,0.5,0" Background="#d6d6d6" Height="{DynamicResource TabHeight}" MinWidth="40" Margin="0" SnapsToDevicePixels="True" DockPanel.Dock="Left">
|
||||
<Border.ToolTip>
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
</Border.ToolTip>
|
||||
@@ -90,6 +90,7 @@
|
||||
</TabItem.Template>
|
||||
<TabItem.Style>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
|
||||
<Setter Property="MaxWidth" Value="{DynamicResource TabWidth}" />
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource _template}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding EditMode}" Value="True">
|
||||
|
||||
Reference in new issue
Block a user