private void MainForm_Load(object sender, EventArgs e) { // SubMenu 비활성화 PanelKakaoSubMenu.Visible = false; PanelOptionSubMenu.Visible = false; // 타이머 설정 TimerAutoClick.Interval = 500; TimerAutoClick.Stop(); TimerFormRect.Interval = 50; TimerFormRect.Stop(); TimerClientInit.Interval = 500; TimerClientInit.Start(); // 프로세스(롤 클라이언트) 종료 이벤트 riotClientManager.LeagueClosed += () => { // 크로스 쓰레드 방지 this.Invoke((MethodInvoker) delegate { //Console.WriteLine("클라이언트 종료"); // 타이머 설정 TimerClientInit.Start(); TimerFormRect.Stop(); // 프로그램 옵션 변수 초기화 OptionDataInit(); // 클라이언트 변수 초기화 GlobalClientData.clientProcess = null; riotClientManager.isClientConnect = false; riotClientManager.currentSummonerName = null; // 마우스 폼 이동 이벤트 this.PanelStateLayer.MouseDown += new MouseEventHandler(this.PanelStateLayer_MouseDown); this.PanelStateLayer.MouseMove += new MouseEventHandler(this.PanelStateLayer_MouseMove); // UI 변경 LabelClientConnect.Text = "클라이언트 연결 끊김"; LabelClientConnect.ForeColor = Color.DarkRed; }); }; // 첫 실행시 오토클릭 활성화 BtnAutoClick_Click(sender, e); }
// 클라이언트 초기화 타이머 private async void TimerClientInit_Tick(object sender, EventArgs e) { //Console.WriteLine("클라이언트 찾는중..."); // 클라이언트 찾는 로직 try { // 클라이언트가 연결되지 않으면 클라이언트 연결 if (GlobalClientData.clientProcess == null) { if (initManager.SetProcessInit()) { //Console.WriteLine("클라이언트 찾는중.."); // 롤 클라이언트 핸들이 0이면 초기화 if (GlobalClientData.clientProcess.MainWindowHandle == IntPtr.Zero) { //Console.WriteLine("프로세스 요청 대기..."); GlobalClientData.clientProcess = null; return; } // 롤 클라이언트 연결 로직 if (initManager.SetClientPathInit()) { if (riotClientManager.Connect()) { // 클라이언트 UX활성화 await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Post, GlobalApiEndPoint.CLIENT_UXSHOW); // UI 변경 LabelClientConnect.Text = "클라이언트 연결됨"; LabelClientConnect.ForeColor = Color.DarkGreen; // 폼 마우스 이동 이벤트 this.PanelStateLayer.MouseDown -= new MouseEventHandler(this.PanelStateLayer_MouseDown); this.PanelStateLayer.MouseMove -= new MouseEventHandler(this.PanelStateLayer_MouseMove); // MainForm Size 조절 uiManager.InitClientPtr(); uiManager.InitClientRect(); // 클라이언트 연결 여부 riotClientManager.isClientConnect = true; // 프로그램 UI 사이즈 조절 Size = new Size(mainWidth, uiManager.GetClientHeight()); PanelStateLayer.Height = Convert.ToInt32(this.Size.Height * 0.11f); // 타이머 실행 TimerFormRect.Start(); TimerClientInit.Stop(); } } } } } catch { Console.WriteLine("클라이언트 찾기 실패"); } }