Permalink
Browse files

GridSplitter snaps to changeset history grid.

  • Loading branch information...
kaisellgren committed Jul 5, 2012
1 parent 23793f3 commit 22337bda150423033969410377b860b42729be32
Showing with 61 additions and 23 deletions.
  1. +1 −23 Templates/RepoTabContentTemplate.xaml
  2. +32 −0 UserControls/CenterArea.xaml
  3. +28 −0 UserControls/CenterArea.xaml.cs
@@ -9,29 +9,7 @@
<controls:TopToolbar DockPanel.Dock="Top" />
<controls:LeftToolbar DockPanel.Dock="Left" VerticalAlignment="Stretch" />
- <Grid DockPanel.Dock="Right">
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition Height="6" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
- <controls:ChangesetHistory Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
-
- <GridSplitter Grid.Row="1" Style="{StaticResource GridSplitterVerticalStyle}" />
-
- <Grid Grid.Row="2">
- <Grid.ColumnDefinitions>
- <ColumnDefinition />
- <ColumnDefinition Width="6" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
-
- <controls:StatusGrid Grid.Column="0" HorizontalAlignment="Stretch" />
- <GridSplitter Grid.Column="1" Style="{StaticResource GridSplitterHorizontalStyle}" />
- <controls:CommitPanel Grid.Column="2" HorizontalAlignment="Stretch" />
- </Grid>
- </Grid>
+ <controls:CenterArea DockPanel.Dock="Right" />
</DockPanel>
</DataTemplate>
@@ -0,0 +1,32 @@
+<UserControl x:Class="GG.UserControls.CenterArea"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:controls="clr-namespace:GG.UserControls"
+ mc:Ignorable="d"
+ d:DesignHeight="412" d:DesignWidth="859">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Name="ChangesetHistoryRowDefinition" />
+ <RowDefinition Height="6" />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+
+ <controls:ChangesetHistory Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="ChangesetHistoryElement" />
+
+ <GridSplitter Grid.Row="1" Style="{StaticResource GridSplitterVerticalStyle}" DragCompleted="GridSplitterDragCompleted" />
+
+ <Grid Grid.Row="2">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition />
+ <ColumnDefinition Width="6" />
+ <ColumnDefinition />
+ </Grid.ColumnDefinitions>
+
+ <controls:StatusGrid Grid.Column="0" HorizontalAlignment="Stretch" />
+ <GridSplitter Grid.Column="1" Style="{StaticResource GridSplitterHorizontalStyle}" />
+ <controls:CommitPanel Grid.Column="2" HorizontalAlignment="Stretch" />
+ </Grid>
+ </Grid>
+</UserControl>
@@ -0,0 +1,28 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+
+namespace GG.UserControls
+{
+ /// <summary>
+ /// Interaction logic for CenterArea.xaml
+ /// </summary>
+ public partial class CenterArea : UserControl
+ {
+ public CenterArea()
+ {
+ InitializeComponent();
+ }
+
+ private void GridSplitterDragCompleted(object sender, DragCompletedEventArgs e)
+ {
+ // We want the grid splitter to snap in grid of 24 units.
+ var excess = (int) ChangesetHistoryRowDefinition.Height.Value % 24;
+
+ if (excess == 0)
+ return;
+
+ ChangesetHistoryRowDefinition.Height = new GridLength(ChangesetHistoryRowDefinition.Height.Value - excess);
+ }
+ }
+}

0 comments on commit 22337bd

Please sign in to comment.