コード例 #1
0
        private void invertLEDs()
        {
            List<bool> tempList = new List<bool>();
            List<byte> byteList = new List<byte>();

            foreach (TableRow row in Table1.Rows)
            {
                foreach (TableCell cell in row.Cells)
                {
                    ImageButton[] iBArray = new ImageButton[1];
                    cell.Controls.CopyTo(iBArray, 0);
                    int rowIndex = int.Parse(((ImageButton)iBArray.GetValue(0)).CommandArgument.Split(',')[0]);
                    int columnIndex = int.Parse(((ImageButton)iBArray.GetValue(0)).CommandArgument.Split(',')[1]);
                    if (((ImageButton)iBArray.GetValue(0)).ImageUrl.Equals(imgTagOff))
                    {
                        ((ImageButton)iBArray.GetValue(0)).ImageUrl = imgTagOn;
                    }
                    else
                    {
                        ((ImageButton)iBArray.GetValue(0)).ImageUrl = imgTagOff;
                    }
                }
            }
        }
コード例 #2
0
        private void loopThroughLEDs()
        {
            List<bool> tempList = new List<bool>();
            List<byte> byteList = new List<byte>();

            foreach(TableRow row in Table1.Rows)
            {
                foreach(TableCell cell in row.Cells)
                {
                    ImageButton[] iBArray = new ImageButton[1];
                    cell.Controls.CopyTo(iBArray,0);
                    int rowIndex = int.Parse(((ImageButton)iBArray.GetValue(0)).CommandArgument.Split(',')[0]);
                    int columnIndex = int.Parse(((ImageButton)iBArray.GetValue(0)).CommandArgument.Split(',')[1]);
                    if (((ImageButton)iBArray.GetValue(0)).ImageUrl.Equals(imgTagOff))
                    {
                        tempList.Add(false);
                    }
                    else
                    {
                        tempList.Add(true);
                    }
                    if(tempList.Count == 8)
                    {
                        byteList.Add(Helpers.PanelHelper.convertToByte(tempList.ToArray()));
                        tempList = new List<bool>();
                    }
                }
            }
            Helpers.PanelHelper pHelper = new Helpers.PanelHelper(byteList, face.Name, face.Description, face.UserAccount);
            Models.Face tempFace = pHelper.getFace();

            //I'm making this object here because otherwise a duplicate is added to the db due to the ID from the other face
            Models.Face faceToInsert = new Models.Face
            {
                Name = face.Name,
                Description = tempFace.Description,
                TimeAdded = tempFace.TimeAdded,
                Approved = tempFace.Approved,
                Panels = tempFace.Panels,
                UserAccount = tempFace.UserAccount
            };
            Controllers.LedPanelController.addFace(faceToInsert);
        }