コード例 #1
0
        // Cálculo del evento producido tras la selección de una casilla de la plantilla
        public int selectedBox(int row, int column)
        {
            int tableID = findTable(row, column);

            if ((Mode == 3 || Mode == 4) && tableID != -1)  // Modo "Cliente llega"
            {
                TableInf table = Room.Tables[Room.Tables.IndexOf(new TableInf(tableID))];
                if (Mode == 3 && table.Status == -1 &&
                    table.Capacity >= JourneyManager.Instance.ClientManager.Guests)
                {
                    if (selectedTable > 0)
                    {
                        TableInf prevTable = Room.Tables[Room.Tables.IndexOf(new TableInf(selectedTable))];
                        paintTable(prevTable, -1);
                    }
                    paintTable(table, 6);
                    selectedTable = table.Id;
                    return(table.Id);
                }
                else if (Mode == 4 && (table.Status == 3 || table.Status == 0)) // Modo "Cliente se va"
                {
                    if (selectedTable > 0)
                    {
                        TableInf prevTable = Room.Tables[Room.Tables.IndexOf(new TableInf(selectedTable))];
                        paintTable(prevTable, prevTable.Status);
                    }
                    paintTable(table, 6);
                    selectedTable = table.Id;
                    return(table.Id);
                }
                return(-1);
            }
            return(-1);
        }
コード例 #2
0
 // Cambia de color las casillas de una mesa
 private void paintTable(TableInf table, int colour)
 {
     foreach (int[] coordinates in table.Place)
     {
         RowSelected    = coordinates[0];
         ColumnSelected = coordinates[1];
         BoxStatus      = colour;
         boxStatusHasChanged();
     }
 }
コード例 #3
0
        // Dos mesas son iguales si tienen el mismo identificador
        public override bool Equals(Object o)
        {
            if (o == null)
            {
                return(false);
            }
            if (o.GetType() != typeof(TableInf))
            {
                return(false);
            }
            TableInf t = (TableInf)o;

            return(id.Equals(t.Id));
        }
コード例 #4
0
 // Decodifica el XML del estado de las mesas del restaurante
 private void xmlTablesStatus(string sXml)
 {
     if (sXml != "")
     {
         XmlDocument xml = new XmlDocument();
         xml.LoadXml(sXml);
         XmlNodeList tables = xml.GetElementsByTagName("Tables");
         XmlNodeList tList  = ((XmlElement)tables[0]).GetElementsByTagName("Table");
         foreach (XmlElement table in tList)
         {
             int         id     = Convert.ToInt16(table.GetAttribute("id"));
             TableInf    taux   = new TableInf(id);
             XmlNodeList status = ((XmlElement)table).GetElementsByTagName("Status");
             Room.Tables[Room.Tables.IndexOf(taux)].Status = Convert.ToInt16(status[0].InnerText);
             XmlNodeList client = ((XmlElement)table).GetElementsByTagName("Client");
             Room.Tables[Room.Tables.IndexOf(taux)].Client = Convert.ToString(client[0].InnerText).Trim();
             XmlNodeList guests = ((XmlElement)table).GetElementsByTagName("Guests");
             Room.Tables[Room.Tables.IndexOf(taux)].Guests = Convert.ToInt16(guests[0].InnerText);
         }
     }
 }
コード例 #5
0
        // Confirmar la ubicación de un objeto en la plantilla
        public void acceptOperation(int id, int capacity)
        {
            switch (Mode)
            {
            case 1: confirmBox(Room.Receiver); break;

            case 2: confirmBox(Room.Bar); break;

            case 3:
                TableInf table = new TableInf(id, capacity);
                confirmBox(table.Place);
                if (table.Place.Count > 0)
                {
                    Room.Tables.Add(table);
                    NTable = Room.Tables.Count() + 1;
                }
                break;

            default: break;
            }
            Mode = 0;
        }
コード例 #6
0
 // Decodifica el XML con la información de la plantilla del restaurante
 private void xmlDistributionOfRoom(string sXml)
 {
     if (sXml != "" && sXml != null)
     {
         Room = new RoomDef();
         XmlDocument xml = new XmlDocument();
         xml.LoadXml(sXml);
         XmlNodeList _room = xml.GetElementsByTagName("Room");
         Room.Name = Convert.ToString(((XmlElement)_room[0]).GetAttribute("name")).Trim();
         XmlNodeList dimension = ((XmlElement)_room[0]).GetElementsByTagName("Dimension");
         XmlNodeList width     = ((XmlElement)dimension[0]).GetElementsByTagName("Width");
         Room.Width = Convert.ToInt16(width[0].InnerText);
         XmlNodeList height = ((XmlElement)dimension[0]).GetElementsByTagName("Height");
         Room.Height = Convert.ToInt16(height[0].InnerText);
         XmlNodeList receiver   = ((XmlElement)_room[0]).GetElementsByTagName("Receiver");
         XmlNodeList rBoxes     = ((XmlElement)receiver[0]).GetElementsByTagName("Boxes");
         XmlNodeList rBoxesList = ((XmlElement)rBoxes[0]).GetElementsByTagName("Box");
         Room.Receiver = new List <int[]>();
         readBoxes(rBoxesList, room.Receiver);
         XmlNodeList bar        = ((XmlElement)_room[0]).GetElementsByTagName("Bar");
         XmlNodeList bBoxes     = ((XmlElement)bar[0]).GetElementsByTagName("Boxes");
         XmlNodeList bBoxesList = ((XmlElement)bBoxes[0]).GetElementsByTagName("Box");
         Room.Bar = new List <int[]>();
         readBoxes(bBoxesList, room.Bar);
         XmlNodeList tables = ((XmlElement)_room[0]).GetElementsByTagName("Tables");
         XmlNodeList tList  = ((XmlElement)tables[0]).GetElementsByTagName("Table");
         Room.Tables = new List <TableInf>();
         foreach (XmlElement table in tList)
         {
             TableInf td = new TableInf();
             td.Id       = Convert.ToInt16(table.GetAttribute("id"));
             td.Capacity = Convert.ToInt16(table.GetAttribute("capacity"));
             XmlNodeList tBoxes     = ((XmlElement)table).GetElementsByTagName("Boxes");
             XmlNodeList tBoxesList = ((XmlElement)tBoxes[0]).GetElementsByTagName("Box");
             readBoxes(tBoxesList, td.Place);
             Room.Tables.Add(td);
         }
     }
 }