Browse Source

Merge pull request #756 from Zvirja/ui-improve-pane-experience

Ui improve pane experience
pull/758/merge
Daniel Grunwald 9 years ago committed by GitHub
parent
commit
8f0b4b1928
  1. 35
      ILSpy/MainWindow.xaml.cs

35
ILSpy/MainWindow.xaml.cs

@ -849,7 +849,7 @@ namespace ICSharpCode.ILSpy
sessionSettings.WindowBounds = this.RestoreBounds; sessionSettings.WindowBounds = this.RestoreBounds;
sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value); sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value);
if (topPane.Visibility == Visibility.Visible) if (topPane.Visibility == Visibility.Visible)
sessionSettings.BottomPaneSplitterPosition = topPaneRow.Height.Value / (topPaneRow.Height.Value + textViewRow.Height.Value); sessionSettings.TopPaneSplitterPosition = topPaneRow.Height.Value / (topPaneRow.Height.Value + textViewRow.Height.Value);
if (bottomPane.Visibility == Visibility.Visible) if (bottomPane.Visibility == Visibility.Visible)
sessionSettings.BottomPaneSplitterPosition = bottomPaneRow.Height.Value / (bottomPaneRow.Height.Value + textViewRow.Height.Value); sessionSettings.BottomPaneSplitterPosition = bottomPaneRow.Height.Value / (bottomPaneRow.Height.Value + textViewRow.Height.Value);
sessionSettings.Save(); sessionSettings.Save();
@ -872,10 +872,40 @@ namespace ICSharpCode.ILSpy
} }
#region Top/Bottom Pane management #region Top/Bottom Pane management
/// <summary>
/// When grid is resized using splitter, row height value could become greater than 1.
/// As result, when a new pane is shown, both textView and pane could become very small.
/// This method normalizes two rows and ensures that height is less then 1.
/// </summary>
void NormalizePaneRowHeightValues(RowDefinition pane1Row, RowDefinition pane2Row)
{
var pane1Height = pane1Row.Height;
var pane2Height = pane2Row.Height;
//only star height values are normalized.
if (!pane1Height.IsStar || !pane2Height.IsStar)
{
return;
}
var totalHeight = pane1Height.Value + pane2Height.Value;
if (totalHeight == 0)
{
return;
}
pane1Row.Height = new GridLength(pane1Height.Value / totalHeight, GridUnitType.Star);
pane2Row.Height = new GridLength(pane2Height.Value / totalHeight, GridUnitType.Star);
}
public void ShowInTopPane(string title, object content) public void ShowInTopPane(string title, object content)
{ {
topPaneRow.MinHeight = 100; topPaneRow.MinHeight = 100;
if (sessionSettings.TopPaneSplitterPosition > 0 && sessionSettings.TopPaneSplitterPosition < 1) { if (sessionSettings.TopPaneSplitterPosition > 0 && sessionSettings.TopPaneSplitterPosition < 1) {
//Ensure all 3 blocks are in fair conditions
NormalizePaneRowHeightValues(bottomPaneRow, textViewRow);
textViewRow.Height = new GridLength(1 - sessionSettings.TopPaneSplitterPosition, GridUnitType.Star); textViewRow.Height = new GridLength(1 - sessionSettings.TopPaneSplitterPosition, GridUnitType.Star);
topPaneRow.Height = new GridLength(sessionSettings.TopPaneSplitterPosition, GridUnitType.Star); topPaneRow.Height = new GridLength(sessionSettings.TopPaneSplitterPosition, GridUnitType.Star);
} }
@ -906,6 +936,9 @@ namespace ICSharpCode.ILSpy
{ {
bottomPaneRow.MinHeight = 100; bottomPaneRow.MinHeight = 100;
if (sessionSettings.BottomPaneSplitterPosition > 0 && sessionSettings.BottomPaneSplitterPosition < 1) { if (sessionSettings.BottomPaneSplitterPosition > 0 && sessionSettings.BottomPaneSplitterPosition < 1) {
//Ensure all 3 blocks are in fair conditions
NormalizePaneRowHeightValues(topPaneRow, textViewRow);
textViewRow.Height = new GridLength(1 - sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star); textViewRow.Height = new GridLength(1 - sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star);
bottomPaneRow.Height = new GridLength(sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star); bottomPaneRow.Height = new GridLength(sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star);
} }

Loading…
Cancel
Save