/// <summary> /// Constructor for AppLayout. Uses window position and generates Layouts with default values. /// </summary> /// <param name="top">Top coordinate of window.</param> /// <param name="left">Left coordinate of window.</param> public AppLayout(double top, double left) : base(CurrentVersion) { Top = top; Left = left; Width = 870; Height = 720; WinState = WindowState.Normal; LayoutLive = MainWindowLayout.GetLayoutLive(); LayoutSnapshot = MainWindowLayout.GetLayoutSnapshot(); LayoutEvent = MainWindowLayout.GetLayoutSnapshot(); }
/// <summary> /// Updates app layout from previous version if necessary /// </summary> /// <param name="path">Location of settings file</param> /// <param name="top">Current top position of window</param> /// <param name="left">Current left position of window</param> /// <returns></returns> public void LoadLayoutIfPrevVersion(double top, double left) { if (this.Version == null || string.CompareOrdinal(this.Version, AppLayout.CurrentVersion) != 0) { // for now we enforce the layout to be always be default if the version mismatch. // it will reduce the unnecessary crashes or noize. but it may lose the previous layout info. // we may bear the lose of previous layout for now. this.Top = top; this.Left = left; this.Width = 870; this.Height = 720; WinState = WindowState.Normal; this.LayoutSnapshot = MainWindowLayout.GetLayoutSnapshot(); this.LayoutEvent = MainWindowLayout.GetLayoutSnapshot(); this.LayoutLive = MainWindowLayout.GetLayoutLive(); this.Version = CurrentVersion; } }