Beispiel #1
0
        public TU CreateFormOnlyWithClosePrompt <TU>(object[] args, string promptMessage, string promptTitle)
        {
            if (InstanceForms == null)
            {
                throw new FormFireExceptions.FireFormListException("Instance Forms property is not initalized, Probably wrong call FormFireManager");
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            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>(args);

                fireForm.IsHasPrompt   = true;
                fireForm.PromptTitle   = promptTitle;
                fireForm.PromptMessage = promptMessage;
                InstanceForms.Add(fireForm);
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            catch (Exception exception)
            {
                throw new FormFireExceptions.CreateFormInstanceException(exception.Message, exception);
            }
        }
Beispiel #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 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);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Will initialize the specificied form. Doesnt support for multiple instances, if you call this method for already
        ///     pre opened form or hidden form, The method will reopen the pre form again.
        /// </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 / finded form object</returns>
        public TU OpenSingleFormWithClosePrompt <TU>(object[] args, string promptMessage, string promptTitle) where TU : T, new()
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            if (string.IsNullOrEmpty(promptMessage))
            {
                throw new ArgumentNullException(nameof(promptTitle));
            }
            if (string.IsNullOrEmpty(promptTitle))
            {
                throw new ArgumentNullException(nameof(promptTitle));
            }
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.GetType() == typeof(TU));

            if (findedFireForm == null)
            {
                var fireForm = FireFormHelper <T> .Create <TU>(args);

                fireForm.IsHasPrompt   = true;
                fireForm.PromptTitle   = promptTitle;
                fireForm.PromptMessage = promptMessage;
                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            findedFireForm.Show();
            AttachFireFormEvents(findedFireForm);
            return(findedFireForm.Form <TU>());
        }
Beispiel #4
0
        /// <summary>
        ///     Will initialize the specificied form. Doesnt support for multiple instances, if you call this method for already
        ///     pre opened form or hidden form, The method will reopen the pre form again.
        /// </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 / finded form object</returns>
        public TU OpenSingleForm <TU>() where TU : T, new()
        {
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.GetType() == typeof(TU));

            if (findedFireForm == null)
            {
                var fireForm = FireFormHelper <T> .Create <TU>();

                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            findedFireForm.Show();
            AttachFireFormEvents(findedFireForm);
            return(findedFireForm.Form <TU>());
        }
Beispiel #5
0
        public TU CreateFormOnly <TU>()
        {
            if (InstanceForms == null)
            {
                throw new FormFireExceptions.FireFormListException("Instance Forms property is not initalized, Probably wrong call FormFireManager");
            }
            try
            {
                var fireForm = FireFormHelper <T> .Create <TU>();

                InstanceForms.Add(fireForm);
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            catch (Exception exception)
            {
                throw new FormFireExceptions.CreateFormInstanceException(exception.Message, exception);
            }
        }
Beispiel #6
0
        /// <summary>
        ///     Will initialize the specificied form with parameters to ctor and show it. Doesnt support for multiple instances, if
        ///     you call this method for already pre opened form or hidden form, The method will reopen the pre form again.
        /// </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 / finded form object</returns>
        public TU OpenSingleForm <TU>(object[] args) where TU : T, new()
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.GetType() == typeof(TU));

            if (findedFireForm == null)
            {
                var fireForm = FireFormHelper <T> .Create <TU>(args);

                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            findedFireForm.Show();
            AttachFireFormEvents(findedFireForm);
            return(findedFireForm.Form <TU>());
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
        /// <summary>
        ///     Will initialize the specificied form with parameters to ctor and show it. Supports for multiple instances at the
        ///     same time.
        /// </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 OpenForm <TU>(object[] args) where TU : T, new()
        {
            if (InstanceForms == null)
            {
                throw new FormFireExceptions.FireFormListException("Instance Forms property is not initalized, Probably wrong call FormFireManager");
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            try
            {
                var fireForm = FireFormHelper <T> .Create <TU>(args);

                InstanceForms.Add(fireForm);
                fireForm.Show();
                AttachFireFormEvents(fireForm);
                return(fireForm.Form <TU>());
            }
            catch (Exception exception)
            {
                throw new FormFireExceptions.CreateFormInstanceException(exception.Message, exception);
            }
        }