Пример #1
0
        /// <summary>
        ///     This method must be first call on each form manager. When this form is closed, FormManager will capture and close
        ///     the application.
        /// </summary>
        /// <exception cref="FormFireExceptions.CreateFormInstanceException"></exception>
        /// <exception cref="FormFireExceptions.ShowFormInstanceException"></exception>
        /// <exception cref="FormFireExceptions.FireFormEventException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <typeparam name="TU">Your specificied form derrived from System.Windows.Forms.Form class</typeparam>
        /// <returns>Returns initalized form object</returns>
        public TU OpenMainForm <TU>() where TU : T, new()
        {
            if (InstanceForms == null)
            {
                throw new FormFireExceptions.FireFormListException("Instance Forms property is not initalized, Probably wrong call FormFireManager");
            }
            if (InstanceForms.Any())
            {
                throw new FormFireExceptions.CreateFormInstanceException("Main forms must be called on first for them FormFireManager");
            }
            try
            {
                var fireForm = FireFormHelper <T> .Create <TU>();

                fireForm.IsMain = true;
                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            catch (Exception exception)
            {
                throw new FormFireExceptions.CreateFormInstanceException(exception.Message, exception);
            }
        }
Пример #2
0
        /// <summary>
        ///     This method must be first call on each form manager. When this form is closed, FormManager will capture and close
        ///     the application.
        /// </summary>
        /// <exception cref="FormFireExceptions.CreateFormInstanceException"></exception>
        /// <exception cref="FormFireExceptions.ShowFormInstanceException"></exception>
        /// <exception cref="FormFireExceptions.FireFormEventException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <typeparam name="TU">Your specificied form derrived from System.Windows.Forms.Form class</typeparam>
        /// <returns>Returns initalized form object</returns>
        public TU OpenMainFormWithClosePrompt <TU>(string promptMessage, string promptTitle) where TU : T, new()
        {
            if (InstanceForms == null)
            {
                throw new FormFireExceptions.FireFormListException("Instance Forms property is not initalized, Probably wrong call FormFireManager");
            }
            if (InstanceForms.Any())
            {
                throw new FormFireExceptions.CreateFormInstanceException("Main forms must be called on first for them FormFireManager");
            }
            if (string.IsNullOrEmpty(promptMessage))
            {
                throw new ArgumentNullException(nameof(promptTitle));
            }
            if (string.IsNullOrEmpty(promptTitle))
            {
                throw new ArgumentNullException(nameof(promptTitle));
            }
            try
            {
                var fireForm = FireFormHelper <T> .Create <TU>();

                fireForm.IsMain        = true;
                fireForm.IsHasPrompt   = true;
                fireForm.PromptTitle   = promptTitle;
                fireForm.PromptMessage = promptMessage;
                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            catch (Exception exception)
            {
                throw new FormFireExceptions.CreateFormInstanceException(exception.Message, exception);
            }
        }