Exemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (nullCheckOK())
            {
                string ext = System.IO.Path.GetExtension(fileUploadImage.FileName);

                string[] allowedExtenstions = new string[] { ".png", ".jpg", ".jpeg", ".PNG" };

                if (allowedExtenstions.Contains(ext))
                {
                    Bitmap bitmap = new Bitmap(fileUploadImage.PostedFile.InputStream);
                    Helpers.PanelHelper panelHelper = new Helpers.PanelHelper(bitmap, txtImageName.Text, txtImageDescription.Text, (Models.Password)Session["New"]);
                    Controllers.LedPanelController.addFace(panelHelper.getFace());
                    Response.Redirect("LedPanelPreview.aspx");
                }
                else
                {
                    lblWarning.Text = "Wrong Image format!";
                    lblWarning.ForeColor = Color.Red;
                }
            }
            else
            {
                lblWarning.Text = "Need at least an image and name to proceed.";
                lblWarning.ForeColor = Color.Red;
            }
        }
Exemplo n.º 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);
        }