private void BindTracker(VisualElement element, PtInfo tracker, int modelIndex, List <PtInfo> trackerList) { element.style.backgroundColor = (modelIndex % 2) == 0 ? PtStyles.evenRowColor : PtStyles.oddRowColor; element.userData = new RowUserData { tracker = tracker, modelIndex = modelIndex }; var columnIndex = 0; var pinIcon = element.ElementAt(columnIndex++); if (pinIcon != null) { if (pinIcon.userData != null) { pinIcon.UnregisterCallback((EventCallback <MouseDownEvent>)pinIcon.userData); } EventCallback <MouseDownEvent> mouseDownCallback = evt => { TogglePinnedItem(modelIndex, trackerList); }; pinIcon.userData = mouseDownCallback; pinIcon.RegisterCallback(mouseDownCallback); if (IsPinnedTracker(tracker)) { pinIcon.EnableInClassList("perf-pin-off", false); pinIcon.EnableInClassList("perf-pin-on", true); } else { pinIcon.EnableInClassList("perf-pin-off", true); pinIcon.EnableInClassList("perf-pin-on", false); } } // Implement trackerName as a TextField to support text selection. var trackerName = element.ElementAt(columnIndex++) as TextField; if (trackerName.value != tracker.name) { trackerName.value = tracker.name; } if (IsColumnVisible(ColumnId.SampleCount)) { var sampleCount = element.ElementAt(columnIndex++) as Button; sampleCount.text = tracker.sampleCount.ToString(); } if (IsColumnVisible(ColumnId.Age)) { var age = element.ElementAt(columnIndex++) as Label; age.text = PtModel.FormatAge(tracker, EditorApplication.timeSinceStartup); age.style.color = tracker.updated ? PtStyles.warningColor : PtStyles.normalColor; } if (IsColumnVisible(ColumnId.PeakTime)) { var peakTime = element.ElementAt(columnIndex++) as Label; peakTime.text = PtModel.FormatTime(tracker.peakTime, tracker.dtPeakTime); peakTime.style.color = GetLabelTimeColor(tracker.peakTime, 0.5, 1.0); } if (IsColumnVisible(ColumnId.AvgTime)) { var avgTime = element.ElementAt(columnIndex++) as Label; avgTime.text = PtModel.FormatTime(tracker.avgTime, tracker.dtAvgTime); avgTime.style.color = GetLabelTimeColor(tracker.avgTime, 0.1, 0.5); } if (IsColumnVisible(ColumnId.LastTime)) { var lastTime = element.ElementAt(columnIndex++) as Label; lastTime.text = PtModel.FormatTimeChange(tracker.lastTime, tracker.dtLastTime); lastTime.style.color = GetLabelTimeChangeColor(tracker.dtLastTime); } if (IsColumnVisible(ColumnId.TotalTime)) { var totalTime = element.ElementAt(columnIndex++) as Label; totalTime.text = PtModel.FormatTimeRate(tracker.totalTime, tracker.usage); totalTime.style.color = GetLabelTimeColor(tracker.totalTime, 5, 10.0); } var actionBtn = element.ElementAt(columnIndex++) as Button; UpdateActionButton(actionBtn, tracker.name); }