我尝试使用ctx.fillText
方法更改每个画布上的文本,但所有画布都显示给画布的最后一个文本。
var ctx = document.getElementById('myCanvas-' + i).getContext('2d');
image = new Image();
candidatePerformance = $('#performance'+i).val();
skillSet = $('#skillSet'+i).val();
verificationId = $('#verificationId'+i).val();
(function(ctx, image) {
image.onload = function() {
ctx.drawImage(image, 0, 0);
ctx.font = '15pt Arial '; ctx.fillStyle = "#fff"; ctx.textAlign = 'left'; ctx.fillText(skillSet,10,125);
ctx.font = '15pt Arial'; ctx.fillStyle = "#fff"; ctx.textAlign = 'left'; ctx.fillText(performance,160,155);
ctx.font = '15pt Arial'; ctx.fillStyle = "#fff"; ctx.textAlign = 'left'; ctx.fillText(verificationId,49,185);
};
image.src = $('#img'+i).val();
})(ctx, image);
答案 0 :(得分:0)
这是一个jsfiddle:https://jsfiddle.net/CanvasCode/z7xa757w/
private void PG_PropertyValueChanged(object sender, PropertyGrid.PropertyValueChangedEventArgs e)
{
var changedProperty = (PropertyItem)e.OriginalSource;
foreach (var x in SelectedObjects) {
//make sure that x supports this property
var ProperProperty = x.GetType().GetProperty(changedProperty.PropertyDescriptor.Name);
if (ProperProperty != null) {
//fetch property descriptor from the actual declaring type, otherwise setter
//will throw exception (happens when u have parent/child classes)
var DeclaredProperty = ProperProperty.DeclaringType.GetProperty(changedProperty.PropertyDescriptor.Name);
DeclaredProperty.SetValue(x, e.NewValue);
}
}
}