Inheritance: ObservableObject
コード例 #1
0
        public ClientProcess PeekNewClient()
        {
            ClientProcess process = null;

            newClients.TryPeek(out process);

            return(process);
        }
コード例 #2
0
        public ClientProcess DequeueDeadClient()
        {
            ClientProcess process = null;

            deadClients.TryDequeue(out process);

            return(process);
        }
コード例 #3
0
        public ClientProcess DequeueNewClient()
        {
            ClientProcess process = null;

            newClients.TryDequeue(out process);

            return(process);
        }
コード例 #4
0
        public ClientProcess PeekDeadClient()
        {
            ClientProcess process = null;

            deadClients.TryPeek(out process);

            return(process);
        }
コード例 #5
0
        void OnProcessTerminated(ClientProcess process)
        {
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }

            ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process));
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: ewrogers/SleepHunter4
 public Player(ClientProcess process)
 {
     this.process = process;
       accessor = new ProcessMemoryAccessor(process.ProcessId, ProcessAccess.Read);
       inventory = new Inventory(this);
       equipment = new EquipmentSet(this);
       skillbook = new Skillbook(this);
       spellbook = new Spellbook(this);
       stats = new PlayerStats(this);
       modifiers = new PlayerModifiers(this);
       location = new MapLocation(this);
       gameClient = new ClientState(this);
 }
コード例 #7
0
        public void AddNewClient(ClientProcess process, ClientVersion version = null)
        {
            var player = new Player(process) { Version = version };
              player.PropertyChanged += Player_PropertyChanged;

              if (player.Version == null)
              {
            player.Version = ClientVersionManager.Instance.Versions.First(v => v.Key != "Auto-Detect");
              }

              AddPlayer(player);
              player.Update();
        }
コード例 #8
0
 public ClientProcessEventArgs(ClientProcess process)
 {
     this.process = process;
 }
コード例 #9
0
        void OnProcessTerminated(ClientProcess process)
        {
            if (process == null)
            throw new ArgumentNullException("process");

              ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process));
        }
コード例 #10
0
        public void ScanForProcesses(Action<ClientProcess> enumProcessCallback = null)
        {
            var foundClients = new Dictionary<int, ClientProcess>();
              var deadClients = new Dictionary<int, ClientProcess>();
              var newClients = new Dictionary<int, ClientProcess>();

              NativeMethods.EnumWindows((windowHandle, lParam) =>
              {
               // Get Process & Thread Id
               var processId = 0;
            var threadId = NativeMethods.GetWindowThreadProcessId(windowHandle, out processId);

               // Get Window Class Name
               var classNameBuffer = new StringBuilder(256);
            var classNameLength = NativeMethods.GetClassName(windowHandle, classNameBuffer, classNameBuffer.Capacity);
            var className = classNameBuffer.ToString();

               // Check Class Name (DA)
               if (!string.Equals("DarkAges", className, StringComparison.OrdinalIgnoreCase))
              return true;

               // Get Window Title
               var windowTextLength = NativeMethods.GetWindowTextLength(windowHandle);
            var windowTextBuffer = new StringBuilder(windowTextLength + 1);
            windowTextLength = NativeMethods.GetWindowText(windowHandle, windowTextBuffer, windowTextBuffer.Capacity);
            var windowText = windowTextBuffer.ToString();

               // Get Window Rectangle
               Rect windowRect;
            NativeMethods.GetWindowRect(windowHandle, out windowRect);

            var process = new ClientProcess
            {
              ProcessId = processId,
              WindowHandle = windowHandle,
              WindowClassName = className,
              WindowTitle = windowText,
              WindowWidth = windowRect.Width,
              WindowHeight = windowRect.Height
            };

               // Add to found clients
               foundClients[processId] = process;

               // Callback
               enumProcessCallback?.Invoke(process);

            return true;

              }, IntPtr.Zero);

              // Find Dead Clients
              foreach (var client in clientProcesses.Values.ToArray())
              {
            ClientProcess process;

            if (!foundClients.ContainsKey(client.ProcessId))
            {
              clientProcesses.TryRemove(client.ProcessId, out process);
              EnqueueDeadClient(client);
            }
              }

              // Find New Clients
              foreach (var client in foundClients.Values)
              {
            if (!clientProcesses.ContainsKey(client.ProcessId))
            {
              clientProcesses[client.ProcessId] = client;
              EnqueueNewClient(client);
            }
              }
        }
コード例 #11
0
 public void EnqueueNewClient(ClientProcess process)
 {
     newClients.Enqueue(process);
       OnProcessCreated(process);
 }
コード例 #12
0
 public void EnqueueDeadClient(ClientProcess process)
 {
     deadClients.Enqueue(process);
       OnProcessTerminated(process);
 }
コード例 #13
0
 public ClientProcessEventArgs(ClientProcess process)
 {
     this.process = process;
 }
コード例 #14
0
 public void EnqueueNewClient(ClientProcess process)
 {
     newClients.Enqueue(process);
     OnProcessCreated(process);
 }
コード例 #15
0
 public void EnqueueDeadClient(ClientProcess process)
 {
     deadClients.Enqueue(process);
     OnProcessTerminated(process);
 }
コード例 #16
0
        public void ScanForProcesses(Action <ClientProcess> enumProcessCallback = null)
        {
            var foundClients = new Dictionary <int, ClientProcess>();
            var deadClients  = new Dictionary <int, ClientProcess>();
            var newClients   = new Dictionary <int, ClientProcess>();

            NativeMethods.EnumWindows((windowHandle, lParam) =>
            {
                // Get Process & Thread Id
                var processId = 0;
                var threadId  = NativeMethods.GetWindowThreadProcessId(windowHandle, out processId);

                // Get Window Class Name
                var classNameBuffer = new StringBuilder(256);
                var classNameLength = NativeMethods.GetClassName(windowHandle, classNameBuffer, classNameBuffer.Capacity);
                var className       = classNameBuffer.ToString();

                // Check Class Name (DA)
                if (!string.Equals("DarkAges", className, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }

                // Get Window Title
                var windowTextLength = NativeMethods.GetWindowTextLength(windowHandle);
                var windowTextBuffer = new StringBuilder(windowTextLength + 1);
                windowTextLength     = NativeMethods.GetWindowText(windowHandle, windowTextBuffer, windowTextBuffer.Capacity);
                var windowText       = windowTextBuffer.ToString();

                // Get Window Rectangle
                Rect windowRect;
                NativeMethods.GetWindowRect(windowHandle, out windowRect);

                var process = new ClientProcess
                {
                    ProcessId       = processId,
                    WindowHandle    = windowHandle,
                    WindowClassName = className,
                    WindowTitle     = windowText,
                    WindowWidth     = windowRect.Width,
                    WindowHeight    = windowRect.Height
                };

                // Add to found clients
                foundClients[processId] = process;

                // Callback
                enumProcessCallback?.Invoke(process);

                return(true);
            }, IntPtr.Zero);

            // Find Dead Clients
            foreach (var client in clientProcesses.Values.ToArray())
            {
                ClientProcess process;

                if (!foundClients.ContainsKey(client.ProcessId))
                {
                    clientProcesses.TryRemove(client.ProcessId, out process);
                    EnqueueDeadClient(client);
                }
            }

            // Find New Clients
            foreach (var client in foundClients.Values)
            {
                if (!clientProcesses.ContainsKey(client.ProcessId))
                {
                    clientProcesses[client.ProcessId] = client;
                    EnqueueNewClient(client);
                }
            }
        }