Skip to content

Commit ceefe7c

Browse files
committedJan 8, 2015
Support of multiscreens
1 parent a75a63d commit ceefe7c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎UI/MainWindow.xaml.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Windows;
3+
using System.Windows.Interop;
34
using GitViz.Logic;
45

56
namespace UI
@@ -42,10 +43,16 @@ private void Graph_OnSizeChanged(object sender, SizeChangedEventArgs e)
4243
ResizeWindowDependingOnGraphSize();
4344
}
4445

46+
public System.Windows.Forms.Screen GetCurrentScreen()
47+
{
48+
return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(this).Handle);
49+
}
50+
4551
private void ResizeWindowDependingOnGraphSize()
4652
{
47-
Width = Math.Min(Math.Max(graph.ActualWidth + 80, 400), SystemParameters.PrimaryScreenWidth - Left);
48-
Height = Math.Min(Math.Max(graph.ActualHeight + grid.RowDefinitions[0].ActualHeight + 80, 200), SystemParameters.PrimaryScreenHeight - Top);
53+
var currentScreen = GetCurrentScreen();
54+
Width = Math.Min(Math.Max(graph.ActualWidth + 80, 400), currentScreen.Bounds.Width - Left + currentScreen.Bounds.Left);
55+
Height = Math.Min(Math.Max(graph.ActualHeight + grid.RowDefinitions[0].ActualHeight + 80, 200), currentScreen.Bounds.Height - Top + currentScreen.Bounds.Top);
4956
}
5057

5158
private void BtnResizeWindow_OnClick(object sender, RoutedEventArgs e)

‎UI/UI.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
</Reference>
5858
<Reference Include="System" />
5959
<Reference Include="System.Data" />
60+
<Reference Include="System.Drawing" />
6061
<Reference Include="System.Windows.Forms" />
6162
<Reference Include="System.Xml" />
6263
<Reference Include="Microsoft.CSharp" />

0 commit comments

Comments
 (0)
Please sign in to comment.