Пример #1
0
        static void Main()
        {
            using (var mutex = new Mutex(true, "TestProject", out bool Success))
            {
                if (!Success)
                {
                    MessageBox.Show("TestProject 프로그램이 실행 중 입니다.", "중복실행", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                LoginForm    loginForm    = new LoginForm();
                DialogResult dialogResult = loginForm.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    Application.Run(new MainForm());
                }
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
Start:
            #region LoginRegion
            using (var autoForm = new LoginForm())
            {
                if (autoForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            #endregion

startChoice:
            #region CoustomMessageBox
            using (var question = new CustomMessageBox())
            {
                var dialogResult = question.ShowDialog();

                if (dialogResult == DialogResult.Yes)
                {
                    result = dialogResult.ToString();
                    question.Close();
                    goto end;
                }
                else if (dialogResult == DialogResult.No)
                {
                    result = dialogResult.ToString();
                    question.Close();
                    goto end;
                }
                else if (dialogResult == DialogResult.OK)
                {
                    result = dialogResult.ToString();
                    question.Close();
                    goto end;
                }
                else if (dialogResult == DialogResult.Abort)
                {
                    question.Close();
                    goto Start;
                }
            }
            #endregion

end:
            #region EndRegion
            switch (result)
            {
            case "Yes":
                using (var habrPars = new HabrParserForm())
                {
                    if (habrPars.ShowDialog() == DialogResult.Cancel)
                    {
                        habrPars.Close();
                        goto startChoice;
                    }
                }
                break;

            case "No":
                using (var agilityPars = new AgilityParserForm())
                {
                    if (agilityPars.ShowDialog() == DialogResult.Cancel)
                    {
                        agilityPars.Close();
                        goto startChoice;
                    }
                }
                break;

            case "OK":
                using (var saveData = new SaveForm())
                {
                    if (saveData.ShowDialog() == DialogResult.Cancel)
                    {
                        saveData.Close();
                        goto startChoice;
                    }
                }
                break;
            }
            #endregion
        }