示例#1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing && !m_IsInTray)
            {
                bool closeToTray = false;
                if (bool.Parse(m_Settings["UserWasAsked"]))
                {
                    closeToTray = bool.Parse(m_Settings["AlwaysCloseToTray"]);
                }
                else
                {
                    CloseToTrayDialog closeToTrayDialog = new CloseToTrayDialog();
                    switch (closeToTrayDialog.ShowDialog(this))
                    {
                    case DialogResult.Yes:
                        closeToTray = true;
                        if (closeToTrayDialog.SaveTheAnswer)
                        {
                            m_Settings["UserWasAsked"]      = "True";
                            m_Settings["AlwaysCloseToTray"] = "True";
                        }
                        break;

                    case DialogResult.No:
                        closeToTray = false;
                        if (closeToTrayDialog.SaveTheAnswer)
                        {
                            m_Settings["UserWasAsked"]      = "True";
                            m_Settings["AlwaysCloseToTray"] = "False";
                        }
                        break;

                    case DialogResult.Cancel:
                        e.Cancel = true;
                        break;
                    }
                    closeToTrayDialog.Dispose();
                }
                if (closeToTray)
                {
                    e.Cancel = true;
                    ShowInTray();
                }
                else if (e.Cancel == true || bool.Parse(m_Settings["ShowMessageBoxes"]) && MessageBox.Show(this, Properties.Resources.GoingToClose, String.Format(Constants.Software, Core.Version), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
                {
                    e.Cancel = true;
                }
            }
            else if (e.CloseReason == CloseReason.UserClosing && bool.Parse(m_Settings["ShowMessageBoxes"]) && MessageBox.Show(this, Properties.Resources.GoingToClose, String.Format(Constants.Software, Core.Version), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
            {
                e.Cancel = true;
            }
        }
示例#2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing && !m_IsInTray)
     {
         bool closeToTray = false;
         if (bool.Parse(m_Settings["UserWasAsked"]))
             closeToTray = bool.Parse(m_Settings["AlwaysCloseToTray"]);
         else
         {
             CloseToTrayDialog closeToTrayDialog = new CloseToTrayDialog();
             switch (closeToTrayDialog.ShowDialog(this))
             {
                 case DialogResult.Yes:
                     closeToTray = true;
                     if (closeToTrayDialog.SaveTheAnswer)
                     {
                         m_Settings["UserWasAsked"] = "True";
                         m_Settings["AlwaysCloseToTray"] = "True";
                     }
                     break;
                 case DialogResult.No:
                     closeToTray = false;
                     if (closeToTrayDialog.SaveTheAnswer)
                     {
                         m_Settings["UserWasAsked"] = "True";
                         m_Settings["AlwaysCloseToTray"] = "False";
                     }
                     break;
                 case DialogResult.Cancel:
                     e.Cancel = true;
                     break;
             }
             closeToTrayDialog.Dispose();
         }
         if (closeToTray)
         {
             e.Cancel = true;
             ShowInTray();
         }
         else if (e.Cancel == true || bool.Parse(m_Settings["ShowMessageBoxes"]) && MessageBox.Show(this, Properties.Resources.GoingToClose, String.Format(Constants.Software, Core.Version), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
             e.Cancel = true;
     }
     else if (e.CloseReason == CloseReason.UserClosing && bool.Parse(m_Settings["ShowMessageBoxes"]) && MessageBox.Show(this, Properties.Resources.GoingToClose, String.Format(Constants.Software, Core.Version), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
         e.Cancel = true;
 }