public static void Register(FormWithWindowStateChangeEvent form, IWindowSettings settings, bool initiallyMaximized, ref IContainer?container) { Guard.NotNull(form, nameof(form)); Guard.NotNull(settings, nameof(settings)); if (!form.IsMdiChild) { throw new InvalidOperationException("Form must be an MDI child."); } // Justification for discard: Object registers itself to get disposed along with specified container on Form. _ = new DisposableComponent <TargetWindow>(new TargetWindow(form, settings, initiallyMaximized), ref container); }
public TargetWindow(FormWithWindowStateChangeEvent form, IWindowSettings settings, bool initiallyMaximized) { Guard.NotNull(form, nameof(form)); Guard.NotNull(settings, nameof(settings)); this.form = form; this.settings = settings; form.LocationChanged += FormOnLocationChanged; form.SizeChanged += FormOnSizeChanged; form.WindowStateChanged += FormOnWindowStateChanged; UpdateLayoutFromSettings(initiallyMaximized); }