Beispiel #1
0
        public void NewGame(int r, int t, bool h)
        {
            if (pnFild.Controls.Count > 0)
            {
                pnFild.Controls.Clear();
            }
            pnFild.AutoSize = true;

            Matrica     = new ButtonMatrix(r, t, h);
            i           = r;
            j           = t;
            Button[,] b = Matrica.ReturnMatrix();
            foreach (Button tmpButton in b)
            {
                pnFild.Controls.Add(tmpButton);
            }
        }
Beispiel #2
0
        public void NewGame()
        {
            #region add-to-panel
            if (pnFild.Controls.Count > 0)
            {
                pnFild.Controls.Clear();
            }
            pnFild.AutoSize = true;

            Matrica     = new ButtonMatrix(9, 9, 10);
            i           = j = 9;
            nmbOfMines  = 10;
            Button[,] b = Matrica.ReturnMatrix();
            foreach (Button tmpButton in b)
            {
                pnFild.Controls.Add(tmpButton);
            }


            #endregion
        }
Beispiel #3
0
        public void NewGame(int r, int t, int no)
        {
            #region add-to-panel
            if (pnFild.Controls.Count > 0)
            {
                pnFild.Controls.Clear();
            }
            pnFild.AutoSize = true;

            Matrica     = new ButtonMatrix(r, t, no);
            i           = r;
            j           = t;
            nmbOfMines  = no;
            Button[,] b = Matrica.ReturnMatrix();
            foreach (Button tmpButton in b)
            {
                pnFild.Controls.Add(tmpButton);
            }


            #endregion
        }
Beispiel #4
0
        public static void ListenToOtherStation(ButtonMatrix bt)
        {
            // Get local IP V4 address
            var addr = GetLocalIPv4();

            if (addr == null)
            {
                MessageLogger.Add("Unable to determine local IP address for inter-station comms", MessageLogger.MsgLevel.warning);
                return;
            }

            MessageLogger.Add(string.Format("Listening to address {0}, port {1} for inter-station comms",
                                            addr, CommonData.localSettings.ThisPackingStationPort),
                              MessageLogger.MsgLevel.info);

            var listener = new TcpListener(addr, CommonData.localSettings.ThisPackingStationPort);

            listener.Start();

            while (true)
            {
                Byte[] response = new Byte[80];
                var    client   = listener.AcceptTcpClient();
                var    stream   = client.GetStream();

                Int32  bytes    = stream.Read(response, 0, response.Length);
                bool   finished = false;
                bool   inRes    = true;
                string res      = "";

                for (int i = 0; i < bytes && !finished; i++)
                {
                    switch (response[i])
                    {
                    case startChar:
                        inRes = true;
                        break;

                    case endChar:
                        if (inRes)
                        {
                            finished = true;
                        }
                        break;

                    default:
                        if (inRes)
                        {
                            res += (char)response[i];
                        }
                        break;
                    }
                }
                var words = res.Split(',');
                if (words.Length == 3)
                {
                    string  orderNum    = words[0];
                    string  materialNum = words[1];
                    decimal qtyPacked   = decimal.Parse(words[2]);

                    var ord = CommonData.normalOrders.Find(o => o.materialNum.Equals(materialNum));
                    if (ord == null)
                    {
                        ord = CommonData.reworkOrders.Find(o => o.materialNum.Equals(materialNum));
                    }
                    if (ord != null)
                    {
                        var incOrd = ord.incOrders.Find(i => i.orderNum.Equals(orderNum));
                        if (incOrd != null)
                        {
                            ord.IncreaseDeliveredQty(qtyPacked, incOrd);
                            bt.UpdateButton(materialNum);
                        }
                    }
                }
            }
        }