/// <summary> /// Find an open area in the inflight interface /// </summary> /// <returns>An empty point in space</returns> public Point getOpenSpace() { List <Rectangle> recs = new List <Rectangle>(); OverViewResponse items = (OverViewResponse)com.sendCall(FunctionCallFactory.CALLS.GETINTERFACEWINDOWS, Response.RESPONSES.OVERVIEWRESPONSE); if (items == null) { Console.WriteLine("cargolist is null"); return(new Point(-1, -1)); } InterfaceResponse inflight = (InterfaceResponse)com.sendCall(FunctionCallFactory.CALLS.GETINFLIGHTINTERFACE, Response.RESPONSES.INTERFACERESPONSE); if (inflight == null) { Console.WriteLine("inflight is null"); return(new Point(-1, -1)); } Point pt = new Point(ran.Next(inflight.X, inflight.X + inflight.Width), ran.Next(inflight.Y, inflight.Y + inflight.Height)); foreach (OverViewEntry it in (List <OverViewEntry>)items.Data) { recs.Add(new Rectangle(it.X, it.Y, it.Width, it.Height)); } while (!isEmpty(recs, pt)) { pt = new Point(ran.Next(inflight.X, inflight.X + inflight.Width), ran.Next(inflight.Y, inflight.Y + inflight.Height)); } return(pt); }
/// <summary> /// Populate this overview wrapper with the client's current overview /// </summary> /// <returns>True if success, false otherwise</returns> public bool readOverView() { entries.Clear(); OverViewResponse resp = (OverViewResponse)comm.sendCall(FunctionCallFactory.CALLS.GETOVERVIEWITEMS, Response.RESPONSES.OVERVIEWRESPONSE); if (resp == null) { return(false); } foreach (OverViewEntry entry in (List <OverViewEntry>)resp.Data) { entries.Add(entry); } entries.Sort(new SortIntDescending()); return(true); }