Exemplo n.º 1
0
        public static void GetClient(GameModel GameM, LoginModel LoginM)
        {
            while (LoginM.Login)
            {
                try
                {
                    bool found = false;
                    WindowsFind.FindWindows(Mill.ProcessesByName);
                    foreach (NameProcess p in WindowsFind.Get)
                    {
                        if (ProcessExists(p.Name.Id))
                        {
                            found = true;
                            if (GameM.ListAccount.Count <= 0 || GameM.ListAccount == null)
                            {
                                GameM.ListAccount = new System.Collections.ObjectModel.ObservableCollection <AccountModel>();
                            }
                            foreach (AccountModel A in GameM.ListAccount)
                            {
                                if (p.Name.Id == A.Pid)
                                {
                                    found = false;
                                    break;
                                }
                            }
                            if (found)
                            {
                                AccountModel AM = new AccountModel
                                {
                                    Pid = p.Name.Id
                                };
                                if (AM.Func == null)
                                {
                                    AM.Func = new Memory.Function();
                                }
                                AM.Func.Login    = LoginM.Login;
                                AM.Func.KeyStart = LoginM.KeyStart;
                                AM.Func.SetFunction(p.Name.Id);
                                MAPN.SetWindowText(p.Name.MainWindowHandle, "Khan Online1");
                                AM.AddClassChar();
                                App.Current.Dispatcher.Invoke((Action) delegate
                                {
                                    GameM.ListAccount.Add(AM);
                                });

                                break;
                            }
                        }
                    }
                    // xoa danh sach
                    foreach (AccountModel A in GameM.ListAccount)
                    {
                        if (!ProcessExists(A.Pid))
                        {
                            App.Current.Dispatcher.Invoke((Action) delegate
                            {
                                GameM.ListAccount.Remove(A);
                            });
                            if (GameM.ListAccount.Count == 0)
                            {
                                GameVM.InfoVi.IsEnabled = false;
                            }
                            break;
                        }
                    }
                    GetName(GameM);
                }
                catch (ThreadAbortException) { break; }
                catch { }
                Thread.Sleep(600);
            }
        }