Ejemplo n.º 1
0
        /// <summary>
        /// Restores the size, position, and state of a window from another visible window of the same type, or from
        /// the app settings if there is no other visible window of the same type.
        /// </summary>
        /// <remarks>
        /// This method offsets the window position slightly so that the two windows do not overlap.
        /// </remarks>
        /// <typeparam name="T">The type of the window.</typeparam>
        /// <param name="window">A window.</param>
        /// <param name="options">Options for performing the restore. (Optional.)</param>
        public static void RestoreFromSibling <T>(this T window, RestoreOptions options = RestoreOptions.None)
            where T : Window, IRestorableWindow
        {
            WindowSize windowSize = WindowSize.FromSiblingOfWindow(window);

            if (windowSize != null)
            {
                WindowSize offsetWindowSize = windowSize.Offset();
                window.Restore(offsetWindowSize, options);
            }
            else
            {
                window.RestoreFromSettings(options);
            }
        }