/// <summary> /// Handles the MouseUp event of the imgCurrent control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param> private void imgCurrent_MouseUp(object sender, MouseButtonEventArgs e) { var scale = ((1 / imgCurrent.Source.Width) * imgCurrent.ActualWidth); var face = new Models.Face { Height = (int)(SelectRectangle.Height / scale), Width = (int)(SelectRectangle.Width / scale), Left = (int)(_selectRectangleStartPoint.X / scale), Top = (int)(_selectRectangleStartPoint.Y / scale), ImageFile = SelectedFile }; DetectedFaces.Add(face); _isDragging = false; canvDrag.Children.Clear(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["New"] != null) { var user = (Models.Password)Session["New"]; this.face = Controllers.LedPanelController.getLastFace(user); makePanel(); } else { Response.Redirect("Unauthorized.aspx"); } }
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); }
public Models.Face getFace() { Models.Face face = new Models.Face { Name = name, Description = description, Panels = getPanels(), Approved = this.approved, UserAccount = user, TimeAdded = DateTime.UtcNow }; return face; }