Beispiel #1
0
        private void UnpatchButton_Click(object sender, EventArgs e)
        {
            this.patchButton.Enabled   = false;
            this.unpatchButton.Enabled = false;

            HostFileManager
            .UnpatchAsync()
            .ContinueWith(task =>
            {
                string errMsg;
                if (task.IsCompleted)
                {
                    errMsg = task.Result ?? "패치를 제거했습니다";
                }
                else
                {
                    errMsg = "알 수 없는 오류가 발생하였습니다.";
                }

                this.Invoke(new Action(() =>
                {
                    MessageBox.Show(errMsg, "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.patchButton.Enabled   = true;
                    this.unpatchButton.Enabled = true;
                }));
            });
        }
Beispiel #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            WindowsPrincipal principal          = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            bool             administrativeMode = principal.IsInRole(WindowsBuiltInRole.Administrator);

            if (!administrativeMode)
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.Verb     = "runas";
                startInfo.FileName = Application.ExecutablePath;
                try
                {
                    Process.Start(startInfo);
                }
                catch
                {
                    MessageBox.Show("Hosts 파일 수정을 위해 관리자 권한이 필요합니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                return;
            }

            HostFileManager.Init();
            Application.Run(new Form1());
        }
Beispiel #3
0
        private void PatchButton_Click(object sender, EventArgs e)
        {
            Process pps = HostFileManager.Patch();

            pps.BeginOutputReadLine();
            pps.BeginErrorReadLine();
            pps.OutputDataReceived += (object send, DataReceivedEventArgs ee) => status.AppendText(ee.Data + Environment.NewLine);
            pps.ErrorDataReceived  += (object send, DataReceivedEventArgs ee) => status.AppendText(ee.Data + Environment.NewLine);
            pps.WaitForExit();
        }
Beispiel #4
0
        private void PatchButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("최적의 패치를 위하여 시간이 소요될 수 있습니다.\n계속할까요?", "알림", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }

            this.patchButton.Enabled   = false;
            this.unpatchButton.Enabled = false;

            HostFileManager
            .PatchAsync()
            .ContinueWith(task =>
            {
                string errMsg;
                if (task.IsCompleted)
                {
                    if (task.Result == null)
                    {
                        errMsg = "오류가 발생하였습니다!\n\n" + task.Result;
                    }
                    else
                    {
                        errMsg = "패치되었습니다.\n브라우저 혹은 클라이언트를 재실행 해주세요!";
                    }
                }
                else
                {
                    errMsg = "알 수 없는 오류가 발생하였습니다.";
                }

                this.Invoke(new Action(() =>
                {
                    MessageBox.Show(errMsg, "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.patchButton.Enabled   = true;
                    this.unpatchButton.Enabled = true;
                    this.progress.Visible      = false;
                }));
            });
        }
Beispiel #5
0
 private void OpenHostFile_Click(object sender, EventArgs e)
 {
     HostFileManager.OpenHostFile();
 }
Beispiel #6
0
 private void UnpatchButton_Click(object sender, EventArgs e)
 {
     HostFileManager.UnPatch();
 }