コード例 #1
0
ファイル: Program.cs プロジェクト: jlovenpk1/LOJ
        static void Main(string[] Args)
        {
            //MessageBox.Show("Точка входа");

            {
                var S = System.Diagnostics.Process.GetProcessesByName(Application.ProductName);

                if (S.Length > 1)
                {
                    var CurrPID = System.Diagnostics.Process.GetCurrentProcess().Id;

                    if (MessageBox.Show("Программа уще запущена\nЗакрыть ту, что была запущена раньше?\nВ противном случае запуск этой копии будет прерван.", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        for (int i = 0; i < S.Length; i++)
                        {
                            if (S[i].Id != CurrPID)
                            {
                                S[i].Kill();
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < S.Length; i++)
                        {
                            if (S[i].Id != CurrPID)
                            {
                                SetForegroundWindow(S[i].MainWindowHandle);
                                break;
                            }
                        }
                        Application.ExitThread();
                        return;
                    }
                }
            }

            var m = new List <string>(3);

            if (!System.IO.File.Exists(Application.StartupPath + "\\MySql.Data.dll"))
            {
                m.Add("MySql.Data.dll");
            }

            if (!System.IO.File.Exists(Application.StartupPath + "\\NPOI.dll"))
            {
                m.Add("NPOI.dll");
            }

            if (!System.IO.File.Exists(Application.StartupPath + "\\AutoTable.dll"))
            {
                m.Add("AutoTable.dll");
            }

            if (m.Count > 0)
            {
                var message = "";
                for (int i = 0; i < m.Count; i++)
                {
                    if (m[i] != null)
                    {
                        message += '\n' + (i + 1).ToString() + ")" + m[i];
                    }
                    else
                    {
                        break;
                    }
                }

                MessageBox.Show("Похоже, что отсутсвуют некоторые компоненты программы:" + message + "\nЧтобы устранить проблему обратитесь в отдел ИТиТ");
                return;
            }

            Application.SetCompatibleTextRenderingDefault(false);

            SetArgs(Args);

            if (File.Exists(Application.StartupPath + "\\commands.txt"))
            {
                using (var sr = new StreamReader(Application.StartupPath + "\\commands.txt"))
                {
                    var FArgs = new List <string>();

                    while (!sr.EndOfStream)
                    {
                        FArgs.Add(sr.ReadLine());
                    }

                    SetArgs(FArgs.ToArray());
                }
            }

            if (data.DeleteConf && File.Exists(Application.StartupPath + "\\commands.txt"))
            {
                File.Delete(Application.StartupPath + "\\commands.txt");
            }

            AutoUpdate.UpdateAutoUpdate(data.StName, null);

            Misc.Prepare();  //гружу настройки

            var form = new Startup_Form();

            if (!form.IsDisposed)
            {
                Application.EnableVisualStyles();
                Application.Run(form);
            }
        }
コード例 #2
0
ファイル: AboutForm.cs プロジェクト: jlovenpk1/LOJ
 private void DocChanges_button_Click(object sender, EventArgs e)
 {
     Startup_Form.CheckDocChanges();
 }