Esempio n. 1
0
        private void FormFireManager_OnResize(object sender, EventArgs e)
        {
            var findedFireForm =
                InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.Form <T>().Equals(sender));

            if (findedFireForm == null)
            {
                return;
            }
            if (((T)sender).WindowState == FormWindowState.Minimized)
            {
                findedFireForm.IsMinimized = true;
                findedFireForm.IsMaximized = false;
            }
            else if (((T)sender).WindowState != FormWindowState.Minimized)
            {
                findedFireForm.IsMaximized = false;
                findedFireForm.IsMinimized = false;
            }
            else if (((T)sender).WindowState == FormWindowState.Maximized)
            {
                findedFireForm.IsMinimized = false;
                findedFireForm.IsMaximized = false;
            }
        }
Esempio n. 2
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>());
        }
Esempio n. 3
0
        private void FormFireManager_OnShown(object sender, EventArgs e)
        {
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.Equals(sender));

            if (findedFireForm != null)
            {
                findedFireForm.IsShowed = false;
            }
        }
Esempio n. 4
0
        private void FormFireManager_OnFormClosing(object sender, FormClosingEventArgs e)
        {
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.Equals(sender));

            if (findedFireForm == null || !findedFireForm.IsHasPrompt)
            {
                return;
            }
            if (MessageBox.Show(findedFireForm.PromptMessage, findedFireForm.PromptTitle,
                                MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                e.Cancel = true;
            }
        }
Esempio n. 5
0
        private void FormFireManager_OnFormClosed(object sender, FormClosedEventArgs e)
        {
            var findedFireForm = InstanceForms.FirstOrDefault(r => r.IsDisposed == false && r.MainForm.Equals(sender));

            if (findedFireForm == null)
            {
                return;
            }
            findedFireForm.IsDisposed = true;
            if (findedFireForm.IsMain)
            {
                Application.Exit();
            }
        }
Esempio n. 6
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>());
        }
Esempio n. 7
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>());
        }