Ejemplo n.º 1
0
        private void BTN_LaunchWC3_Click(object sender, EventArgs e)
        {
            string LastInstallPath = Settings.InstallPath;

            if (!File.Exists(Path.Combine(LastInstallPath, "Warcraft III.exe")) &&
                !File.Exists(Path.Combine(LastInstallPath, "war3.exe")))
            {
                OpenFileDialog FDialog = new OpenFileDialog
                {
                    Title  = "워크래프트 실행 파일을 선택하세요.",
                    Filter = "워크래프트 EXE파일|Warcraft III.exe;war3.exe"
                };
                if (FDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Settings.InstallPath = LastInstallPath = Path.GetDirectoryName(FDialog.FileName);
                string MixPath = $"{LastInstallPath}\\Cirnix";
                if (!File.Exists(MixPath + ".mix"))
                {
                    File.WriteAllBytes(MixPath + ".mix", Global.Properties.Resources.Cirnix);
                    NativeMethods.WritePrivateProfileString("Cirnix", "Mana Bar", "0", MixPath + ".ini");
                    NativeMethods.WritePrivateProfileString("Cirnix", "Show AS & MS in Number", "1", MixPath + ".ini");
                }
            }
            Process[] proc = Process.GetProcessesByName(TargetProcess);
            if (proc.Length > 0)
            {
                if (MetroDialog.YesNo("기존 프로세스 감지 됨", "Warcraft III 프로세스가 아직 실행 중입니다.\n종료하고 실행하시겠습니까?"))
                {
                    foreach (var item in proc)
                    {
                        try
                        {
                            item.Kill();
                        }
                        catch
                        {
                            proc = Process.GetProcessesByName(TargetProcess);
                            if (proc.Length > 0)
                            {
                                MetroDialog.OK("액세스 오류", "Warcraft III 프로세스를 종료할 수 없었습니다.\n작업 관리자에서 수동으로 프로세스를 종료하세요.");
                                return;
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            bool isDebug = false;

            if (File.Exists(Path.Combine(ResourcePath, "JNService", "DEBUG.txt")))
            {
                isDebug = true;
            }
            CLRHook.Injector.Init(LastInstallPath, MetroDialog.Select("화면 표기 설정", "창 모드", "전체 창", "전체화면"), true, isDebug);
        }
        protected override async Task <bool> OnApply(IGameState gameState)
        {
            var threeChoicesViewModel = MefContainer.GetExportedValue <IThreeChoicesViewModel>();

            threeChoicesViewModel.Option1          = Option1;
            threeChoicesViewModel.Option2          = Option2;
            threeChoicesViewModel.CanSelectOption1 = CanApplyOption1(gameState);
            threeChoicesViewModel.CanSelectOption2 = CanApplyOption2(gameState);

            var result = await MetroDialog.ShowDialog(threeChoicesViewModel);

            if (result == Selection.None)
            {
                return(false);
            }

            if (result == Selection.Option1)
            {
                return(await ApplyOption1(gameState));
            }
            if (result == Selection.Option2)
            {
                return(await ApplyOption2(gameState));
            }
            if (result == Selection.Option3)
            {
                return(await ApplyOption3(gameState));
            }
            return(false);
        }
Ejemplo n.º 3
0
        protected override async Task <bool> OnApply(IGameState gameState)
        {
            var success = await HarvestField.OnExecute();

            if (!success)
            {
                return(false);
            }

            if (!HarvestField.CanExecuteSpecial)
            {
                return(true);
            }
            success = await HarvestField.OnExecute();

            if (!success)
            {
                return(await MetroDialog.DoneOrCancelVisitor("harvesting"));
            }

            if (!HarvestField.CanExecuteSpecial)
            {
                return(true);
            }
            success = await HarvestField.OnExecute();

            if (!success)
            {
                return(await MetroDialog.DoneOrCancelVisitor("harvesting"));
            }

            gameState.VictoryPoints += 2;

            return(true);
        }
Ejemplo n.º 4
0
        private async void BtnRegister_Click(object sender, RoutedEventArgs e)
        {
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(UserEmailTextBox.Text);

            if (UserPasswordTextBox.Password != ConfirmUserPasswordTextBox.Password || ConfirmUserPasswordTextBox.Password != UserPasswordTextBox.Password)
            {
                await MetroDialog.MessageBoxAsync(this, "Info", "Password is not correct");
            }
            else
            {
                if (!match.Success)
                {
                    await MetroDialog.MessageBoxAsync(this, "Info", "Email is not correct");
                }
                else
                {
                    var request = new RestRequest("{id}", Method.GET);
                    request.AddParameter("username", UsernameTextBox.Text);
                    request.AddParameter("password", Encrypt(UserPasswordTextBox.Password));
                    request.AddParameter("email", UserEmailTextBox.Text);
                    request.AddUrlSegment("id", "createUser");
                    IRestResponse response = client.Execute(request);
                    var           content  = response.Content;

                    await MetroDialog.MessageBoxAsync(this, "Information", "Now you can login and watch your anime :)");
                }
            }
        }
Ejemplo n.º 5
0
        protected override async Task <bool> ApplyOption2(IGameState gameState)
        {
            var success = await MakeWine.MakeWine();

            if (!success)
            {
                return(false);
            }

            if (!MakeWine.CanExecuteSpecial)
            {
                return(true);
            }
            success = await MakeWine.MakeWine();

            if (!success)
            {
                return(await MetroDialog.DoneOrCancelVisitor("making wine"));
            }

            if (!MakeWine.CanExecuteSpecial)
            {
                return(true);
            }
            success = await MakeWine.MakeWine();

            if (!success)
            {
                return(await MetroDialog.DoneOrCancelVisitor("making wine"));
            }

            return(true);
        }
Ejemplo n.º 6
0
 private void VersionChecker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(infoURL))
     {
         return;
     }
     if (e.Error != null)
     {
         MetroDialog.OK("연결 오류", "업데이트 서버에 연결할 수 없습니다.");
         return;
     }
     isOnline = true;
     if (isUpdated)
     {
         InitHistoryForm();
     }
     if (version[0] > Latest[0])
     {
         return;
     }
     else if (version[0] == Latest[0])
     {
         if (version[1] > Latest[1])
         {
             return;
         }
         else if (version[1] == Latest[1])
         {
             if (version[2] > Latest[2])
             {
                 return;
             }
             else if (version[2] == Latest[2])
             {
                 if (version[3] >= Latest[3])
                 {
                     return;
                 }
             }
         }
     }
     if (MetroDialog.YesNo("업데이트 필요", $"최신 버전이 확인되었습니다.\n 현재: {version[0]}.{version[1]}.{version[2]}.{version[3]}\n 최신: {Latest[0]}.{Latest[1]}.{Latest[2]}.{Latest[3]}\n업데이트 하시겠습니까?"))
     {
         try
         {
             main.Dispose();
             option.Dispose();
             info.Dispose();
             channel.Dispose();
             sepro.Dispose();
             MainTrayIcon.Visible = false;
         }
         catch { }
         finally
         {
             new UpdateForm("Cirnix", LatestURL).ShowDialog();
         }
     }
 }
Ejemplo n.º 7
0
 private void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     LabelTitle.Text      = "업데이트 완료!";
     LabelMsg.Text        = "잠시 후, 자동으로 종료됩니다.\n프로그램을 다시 실행시켜주세요!";
     successfullyDownload = true;
     LabelMsg.Text        = "잠시 후, 자동으로 재시작됩니다.";
     MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 다시 시작됩니다.");
     ProceedRestartBat();
 }
        protected override async Task <bool> OnApply(IGameState gameState)
        {
            var playerWantsToDoBoth = false;

            if (CanDoBoth(gameState))
            {
                playerWantsToDoBoth =
                    await
                    MetroDialog.ShowMessage("Play visitor",
                                            $"Do you want to perform both actions (cost: {DoBothCost}",
                                            MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative;
            }

            var twoChoicesViewModel = MefContainer.GetExportedValue <ITwoChoicesViewModel>();

            twoChoicesViewModel.Option1          = Option1;
            twoChoicesViewModel.Option2          = Option2;
            twoChoicesViewModel.CanSelectOption1 = CanApplyOption1(gameState);
            twoChoicesViewModel.CanSelectOption2 = CanApplyOption2(gameState);

            var result = await MetroDialog.ShowDialog(twoChoicesViewModel);

            if (result == Selection.None)
            {
                return(false);
            }

            if (playerWantsToDoBoth)
            {
                if (result == Selection.Option1)
                {
                    await ApplyOption1(gameState);

                    if (CanApplyOption2(gameState))
                    {
                        await ApplyOption2(gameState);
                    }
                }
                else
                {
                    await ApplyOption2(gameState);

                    if (CanApplyOption1(gameState))
                    {
                        await ApplyOption1(gameState);
                    }
                }

                ApplyCostforDoingBoth(gameState);
                return(true);
            }

            return(result == Selection.Option1 ? await ApplyOption1(gameState) : await ApplyOption2(gameState));
        }
Ejemplo n.º 9
0
        private void DefaultSymbolButton_Click(object sender, RoutedEventArgs e)
        {
            var editor = new SymbolEditor();

            editor.Symbol = Renderer.DefaultSymbol?.Clone() ?? new SimpleMarkerSymbol();
            var result = MetroDialog.ShowDialog("Symbol Editor", editor, this);

            if (result == true)
            {
                Renderer.DefaultSymbol = editor.Symbol;
            }
        }
Ejemplo n.º 10
0
 private void UpdateForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (client.IsBusy)
     {
         if (MetroDialog.YesNo("업데이트 중단", "업데이트를 중단하시겠습니까?"))
         {
             client.CancelAsync();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Ejemplo n.º 11
0
        private void SymbolButton_Click(object sender, RoutedEventArgs e)
        {
            var value = ((Button)sender).DataContext as UniqueValue;

            if (value == null)
            {
                return;
            }
            var editor = new SymbolEditor();

            editor.Symbol = value.Symbol?.Clone() ?? new SimpleMarkerSymbol();
            var result = MetroDialog.ShowDialog("Symbol Editor", editor, this);

            if (result == true)
            {
                value.Symbol = editor.Symbol;
            }
        }
Ejemplo n.º 12
0
        protected override async Task <bool> OnApply(IGameState gameState)
        {
            var redWinesBefore       = gameState.RedWines.Count(p => p.IsBought);
            var whiteWinesBefore     = gameState.WhiteWines.Count(p => p.IsBought);
            var blushWinesBefore     = gameState.BlushWines.Count(p => p.IsBought);
            var sparklingWinesBefore = gameState.SparklingWines.Count(p => p.IsBought);

            var success = await MakeWine.MakeWine();

            if (!success)
            {
                return(false);
            }

            if (!MakeWine.CanExecuteSpecial)
            {
                return(true);
            }
            success = await MakeWine.MakeWine();

            if (!success)
            {
                AddVictoryPoints(gameState, redWinesBefore, whiteWinesBefore, blushWinesBefore, sparklingWinesBefore);
                return(await MetroDialog.DoneOrCancelVisitor("harvesting"));
            }

            if (!MakeWine.CanExecuteSpecial)
            {
                return(true);
            }
            success = await MakeWine.MakeWine();

            if (!success)
            {
                AddVictoryPoints(gameState, redWinesBefore, whiteWinesBefore, blushWinesBefore, sparklingWinesBefore);
                return(await MetroDialog.DoneOrCancelVisitor("harvesting"));
            }

            AddVictoryPoints(gameState, redWinesBefore, whiteWinesBefore, blushWinesBefore, sparklingWinesBefore);

            return(true);
        }
Ejemplo n.º 13
0
        private async void BTN_LaunchWC3_Click(object sender, EventArgs e)
        {
            string LastInstallPath = Settings.InstallPath;

            if (!File.Exists(Path.Combine(LastInstallPath, "JNLoader.exe")))
            {
                OpenFileDialog FDialog = new OpenFileDialog
                {
                    Title  = "실행 파일을 선택하세요.",
                    Filter = "워크래프트 EXE파일|JNLoader.exe;Warcraft III.exe;war3.exe"
                };
                if (FDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Settings.InstallPath = LastInstallPath = Path.GetDirectoryName(FDialog.FileName);
                string MixPath = $"{LastInstallPath}\\Cirnix";
                if (!File.Exists(MixPath + ".mix"))
                {
                    File.WriteAllBytes(MixPath + ".mix", Global.Properties.Resources.Cirnix);
                    NativeMethods.WritePrivateProfileString("Cirnix", "Mana Bar", "0", MixPath + ".ini");
                    NativeMethods.WritePrivateProfileString("Cirnix", "Show AS & MS in Number", "1", MixPath + ".ini");
                }
            }
            if (Memory.Component.Warcraft3Info.Process != null)
            {
                if (MetroDialog.YesNo("기존 프로세스 감지 됨", "Warcraft III 프로세스가 아직 실행 중입니다.\n종료하고 실행하시겠습니까?"))
                {
                    if (!Memory.Component.Warcraft3Info.Close())
                    {
                        MetroDialog.OK("액세스 오류", "Warcraft III 프로세스를 종료할 수 없었습니다.\n작업 관리자에서 수동으로 프로세스를 종료하세요.");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            GameModule.StartWarcraft3(LastInstallPath, MetroDialog.Select("화면 표기 설정", "창 모드", "전체 창", "전체화면"));
        }
Ejemplo n.º 14
0
        private void Select_Click(object sender, EventArgs e)
        {
            Process proc = ProcessList.FocusedItem.Tag as Process;

            switch (GameModule.InitWarcraft3Info(proc))
            {
            case WarcraftState.OK:
                MetroDialog.OK("지정 완료", $"{proc.ProcessName} ({proc.Id}) 가 지정되었습니다.");
                break;

            case WarcraftState.Closed:
                MetroDialog.OK("오류", $"{proc.ProcessName} ({proc.Id}) 는 이미 화면이 종료된 상태이므로 강제로 프로세스를 종료합니다.");
                break;

            case WarcraftState.Error:
                MetroDialog.OK("오류", "프로세스를 초기화 하는데에 실패했습니다.");
                break;
            }
            procs.Remove(proc);
            Close();
        }
Ejemplo n.º 15
0
        private async Task <bool> HarvestTwoFields()
        {
            var success = await HarvestField.OnExecute();

            if (!success)
            {
                return(false);
            }

            success = await HarvestField.OnExecute();

            if (!success)
            {
                return((await MetroDialog.ShowMessage("Done or cancel",
                                                      "Are you done harvesting or do you want to cancel the visitor card",
                                                      MessageDialogStyle.AffirmativeAndNegative,
                                                      new MetroDialogSettings {
                    AffirmativeButtonText = "Done", NegativeButtonText = "Cancel"
                })) ==
                       MessageDialogResult.Affirmative);
            }

            return(true);
        }
Ejemplo n.º 16
0
        private async void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                if (!IsSingle)
                {
                    File.Delete($"{name}.exe");
                    File.Move("update.tmp", Path.GetFileName(ProgramPath));
                }
                Close();
            }
            else if (e.Error != null)
            {
                LabelTitle.Text = "업데이트 실패!";
                MetroDialog.OK("오류 발생!", "업데이트 파일을 불러오는데 실패했습니다.");
                Close();
            }
            else
            {
                LabelTitle.Text = "업데이트 완료!";
                if (IsSingle)
                {
                    LabelMsg.Text = "잠시 후, 자동으로 창이 종료됩니다.";
                    MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 창이 종료됩니다.");
                    await Task.Delay(3000);

                    Close();
                }
                else
                {
                    LabelMsg.Text = "잠시 후, 자동으로 재시작됩니다.";
                    MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 다시 시작됩니다.");
                    ProceedRestartBat();
                }
            }
        }
Ejemplo n.º 17
0
        public static async Task <WarcraftState> StartWarcraft3(string path, int windowState = 0)
        {
            Global.Registry.Warcraft.SetFullQualityGraphics();
            string EXEPath     = $"{path}\\JNLoader.exe";
            string updaterPath = $"{path}\\JNUpdater.exe";

            if (!File.Exists(EXEPath) || !File.Exists(updaterPath))
            {
                try
                {
                    if (File.Exists(updaterPath))
                    {
                        File.Delete(updaterPath);
                    }
                    File.WriteAllBytes(updaterPath, Properties.Resources.JNUpdater);
                    ProcessStartInfo info = new ProcessStartInfo("JNUpdater.exe", "-updateonly -force");
                    info.WorkingDirectory = path;
                    using (Process proc = Process.Start(info))
                    {
                        proc.WaitForExit();
                        int ExitCode = proc.ExitCode;
                        if (ExitCode >> 16 < 0 || ExitCode << 16 >> 16 < 0)
                        {
                            MetroDialog.OK("오류", "JNLoader 설치에 실패했습니다.\n백신에 의해 차단됬을 수도 있습니다.");
                            return(0);
                        }
                    }
                }
                catch { return(0); }
            }

            string WindowsStateString;

            switch (windowState)
            {
            case 0: WindowsStateString = "-windows"; break;

            case 1: WindowsStateString = string.Empty; break;

            case 2: WindowsStateString = "-nativefullscr"; break;

            default: return(0);
            }
            try
            {
                using (Process proc = Process.Start(EXEPath, WindowsStateString))
                {
                    proc.WaitForExit();
                    int procId = proc.ExitCode;
                    if (procId <= 0)
                    {
                        return(WarcraftState.Error);
                    }
                    return(InitWarcraft3Info(procId));
                }
            }
            catch (ArgumentException ex)
            {
                MetroDialog.OK("오류", "Warcraft III를 실행하지 못했습니다.\nCirnix를 다시 실행시켜주세요.");
                ExceptionSender.ExceptionSendAsync(ex);
                return(0);
            }
        }
Ejemplo n.º 18
0
        internal static bool ProcessCheck()
        {
            if (GameModule.WarcraftDetect() != WarcraftState.OK ||
                !GameModule.WarcraftCheck())
            {
                InitializedWarcraft = ignoreDetect = false;

                // 프로그램을 찾지 못할 경우 검색 간격 증가
                Thread.Sleep(800);

                return(true);
            }
            if (!InitializedWarcraft)
            {
                InitializedWarcraft = true;
                Delay(2000);
                GameDll.GetOffset();
                GameDelay       = 50;
                RefreshCooldown = 0.01f;
                name            = string.Empty;
                StartDelay      = Settings.StartSpeed > 0 ? Settings.StartSpeed : 0.01f;
                CameraDistance  = Settings.CameraDistance;
                CameraAngleX    = Settings.CameraAngleX;
                CameraAngleY    = Settings.CameraAngleY;
            }
            if (Settings.IsAutoHp && !HPView)
            {
                HPView = true;
            }

            if (Settings.IsAntiZombieProcess)
            {
                if (ignoreDetect && ++ZombieCount > 9000)
                {
                    ignoreDetect = false;
                    ZombieCount  = 0;
                }
                else if (CurrentMusicState == MusicState.None)
                {
                    if (++ZombieCount > 22)
                    {
                        try
                        {
                            PerformanceCounter CPUCounter = new PerformanceCounter("Process", "% Processor Time", TargetProcess);
                            CPUCounter.NextValue();
                            for (int i = 0; i < 5; i++)
                            {
                                Delay(1100);
                                if (CPUCounter.NextValue() >= 0.01f)
                                {
                                    ZombieCount = 0;
                                    break;
                                }
                                if (i != 4)
                                {
                                    continue;
                                }
                                if (MetroDialog.YesNo("워크래프트가 정상적으로 종료되지 않은 것 같습니다.\n강제로 종료하시겠습니까?", "강제 종료 알림"))
                                {
                                    try
                                    {
                                        Warcraft3Info.Process.Kill();
                                    }
                                    catch
                                    {
                                        MetroDialog.OK("워크래프트를 강제로 종료할 수 없었습니다.\n이미 종료되었거나, 백신에 의해 차단된 것 같습니다.", "강제 종료 실패");
                                    }
                                }
                                else
                                {
                                    ignoreDetect = true;
                                }
                            }
                        }
                        catch
                        {
                            ZombieCount = 0;
                        }
                    }
                    return(true);
                }
                else
                {
                    ZombieCount = 0;
                }
            }
            if (Settings.IsMemoryOptimize)
            {
                if (MemoryOptimizeTimer.IsRunning)
                {
                    if (MemoryOptimizeTimer.Elapsed >= new TimeSpan(0, Settings.MemoryOptimizeCoolDown, 0))
                    {
                        CProcess.TrimProcessMemory(TargetProcess, true);
                        MemoryOptimizeTimer.Restart();
                    }
                    else
                    {
                        MemoryOptimizeTimer.Start();
                    }
                }
            }
            else if (MemoryOptimizeTimer.IsRunning)
            {
                MemoryOptimizeTimer.Stop();
            }

            StatusCheck();
            return(false);
        }