void TryRestoreLayout( ) { try { var uc_main = GetActiveUCMain( ); if (uc_main != null) { if (Properties.Settings.Default.McsRightWidth > 20 && Properties.Settings.Default.McsTopHeight > 20 && Properties.Settings.Default.McsBottomHeight > 20) { TabMetrics metrics = new TabMetrics { RightColumnWidth = Properties.Settings.Default.McsRightWidth, TopRowHeight = Properties.Settings.Default.McsTopHeight, BottomRowHeight = Properties.Settings.Default.McsBottomHeight }; uc_main.ApplyMetrics(metrics); } } } catch (Exception exc) { _ = exc; if (Debugger.IsAttached) { Debugger.Break( ); } // ignore } }
public TabMetrics GetMetrics( ) { var metrics = new TabMetrics { RightColumnWidth = RightColumn.ActualWidth, TopRowHeight = TopRow.ActualHeight, BottomRowHeight = BottomRow.ActualHeight }; return(metrics); }
public void ApplyMetrics(TabMetrics metrics) { if (metrics.RightColumnWidth > 0) { RightColumn.Width = new GridLength(metrics.RightColumnWidth); } if (metrics.TopRowHeight > 0) { TopRow.Height = new GridLength(metrics.TopRowHeight); } if (metrics.BottomRowHeight > 0) { BottomRow.Height = new GridLength(metrics.BottomRowHeight); } }
void SaveWindowPlacement( ) { try { Properties.Settings.Default.IsMaximised = WindowState == WindowState.Maximized; if (Properties.Settings.Default.IsMaximised) { Properties.Settings.Default.RestoreBounds = RestoreBounds; } else { Properties.Settings.Default.RestoreBounds = new Rect(Left, Top, ActualWidth, ActualHeight); } var uc_main = GetActiveUCMain( ); if (uc_main != null) { TabMetrics metrics = uc_main.GetMetrics( ); Properties.Settings.Default.McsRightWidth = metrics.RightColumnWidth; Properties.Settings.Default.McsTopHeight = metrics.TopRowHeight; Properties.Settings.Default.McsBottomHeight = metrics.BottomRowHeight; } Properties.Settings.Default.Save( ); } catch (Exception exc) { if (Debugger.IsAttached) { Debugger.Break( ); } else { Debug.Fail(exc.Message, exc.ToString( )); } // ignore } }