Skip to content

Commit a75a63d

Browse files
committed
Add a button to resize the window
1 parent 42c82e0 commit a75a63d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

UI/MainWindow.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
<DockPanel Grid.Row="0" Background="WhiteSmoke" LastChildFill="True">
6565
<Separator DockPanel.Dock="Bottom" />
6666
<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Padding="10,0,0,0">Local Repo Path:</TextBlock>
67-
<Button x:Name="BtnOpenRepository" Click="BtnOpenRepository_OnClick" Width="15" Height="30" DockPanel.Dock="Right" VerticalAlignment="Bottom" Margin="0,10, 10, 10">...</Button>
67+
<Button x:Name="BtnResizeWindow" Click="BtnResizeWindow_OnClick" Height="30" DockPanel.Dock="Right" VerticalAlignment="Bottom" Margin="10" ToolTip="Resize automatically the window depending on graph size">Resize</Button>
68+
<Button x:Name="BtnOpenRepository" Click="BtnOpenRepository_OnClick" Width="15" Height="30" DockPanel.Dock="Right" VerticalAlignment="Bottom" Margin="0,10, 0, 10">...</Button>
6869
<TextBox x:Name="TxtRepositoryPath" Padding="5" Text="{Binding Path=RepositoryPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10, 10, 0, 10" />
6970
</DockPanel>
7071
<Image Source="readify.png" Grid.Row="1" Stretch="None" HorizontalAlignment="Right" VerticalAlignment="Bottom" Opacity="0.5" Margin="30"></Image>

UI/MainWindow.xaml.cs

+10
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ private void Graph_OnSizeChanged(object sender, SizeChangedEventArgs e)
3939
if (!viewModel.IsNewRepository)
4040
return;
4141
viewModel.IsNewRepository = false;
42+
ResizeWindowDependingOnGraphSize();
43+
}
44+
45+
private void ResizeWindowDependingOnGraphSize()
46+
{
4247
Width = Math.Min(Math.Max(graph.ActualWidth + 80, 400), SystemParameters.PrimaryScreenWidth - Left);
4348
Height = Math.Min(Math.Max(graph.ActualHeight + grid.RowDefinitions[0].ActualHeight + 80, 200), SystemParameters.PrimaryScreenHeight - Top);
4449
}
50+
51+
private void BtnResizeWindow_OnClick(object sender, RoutedEventArgs e)
52+
{
53+
ResizeWindowDependingOnGraphSize();
54+
}
4555
}
4656
}

0 commit comments

Comments
 (0)