/// <summary> /// Updates the cell to the display the given sensor. /// </summary> /// <param name="sensor">Sensor.</param> /// <param name="addClickedResponder">Add clicked responder.</param> public void UpdateTo(SensorRecord record, double cellWidth, Action addClickedResponder = null) { this.record = record; var cellHeight = 48; this.BackgroundColor = UIColor.Clear; viewBackground = new UIView(new CGRect(0, 0, cellWidth, cellHeight)); viewBackground.BackgroundColor = UIColor.Clear; buttonAdd = new UIButton(new CGRect(cellWidth - cellHeight, 0, cellHeight, cellHeight)); labelType = new UILabel(new CGRect(cellHeight, 0, cellWidth - cellHeight, .5 * cellHeight)); labelType.BackgroundColor = UIColor.White; labelMeasurement = new UILabel(new CGRect(cellHeight, .5 * cellHeight, cellWidth - cellHeight, .5 * cellHeight)); labelMeasurement.BackgroundColor = UIColor.White; buttonAdd.SetBackgroundImage(UIImage.FromBundle("ButtonGold").AsNinePatch(), UIControlState.Normal); buttonAdd.SetBackgroundImage(UIImage.FromBundle("ButtonBlack").AsNinePatch(), UIControlState.Selected); buttonAdd.SetImage(UIImage.FromBundle("ic_device_add"), UIControlState.Normal); buttonAdd.TouchUpInside += (object sender, EventArgs e) => { if (onAddClicked != null) { onAddClicked(); } }; onAddClicked = addClickedResponder; OnSensorUpdated(new SensorEvent(SensorEvent.EType.Invalidated, record.sensor)); viewBackground.Add(labelType); viewBackground.Add(labelMeasurement); viewBackground.Add(buttonAdd); this.AddSubview(viewBackground); }
// Overridden from IReleasable public void Release() { record = null; }