public async Task CloseModal(ModalDialog modalForm, FormBase oldForm) { DeviceSession ds = this.Device; if (ds == null) { return; } if (modalForm == null) { throw new Exception("No modal form"); } ds.FormSwitched = true; ds.PreviousForm = ds.ActiveForm; ds.ActiveForm = oldForm; }
/// <summary> /// Opens this form modal, but don't closes the original ones /// </summary> /// <param name="newForm"></param> /// <returns></returns> public virtual async Task OpenModal(ModalDialog newForm, params object[] args) { DeviceSession ds = this.Device; if (ds == null) { return; } var parentForm = this; ds.FormSwitched = true; ds.PreviousForm = ds.ActiveForm; ds.ActiveForm = newForm; newForm.Client = parentForm.Client; newForm.Device = ds; newForm.ParentForm = parentForm; newForm.Closed += async(s, en) => { await CloseModal(newForm, parentForm); }; foreach (var b in this.Controls) { if (!b.Enabled) { continue; } await b.Hidden(false); } await newForm.OnInit(new InitEventArgs(args)); await newForm.OnOpened(new EventArgs()); }
/// <summary> /// Get invoked when a modal child from has been closed. /// </summary> /// <param name="message"></param> /// <returns></returns> public virtual async Task ReturnFromModal(ModalDialog modal) { }