我正在为System.Windows.Forms.DataVisualization.Charting.Chart
制作扩展方法扩展方法将事件添加到MouseDown,MouseUp,MouseMove,MouseWheel。我还将ContextMenuStrip附加到图表中。
在ContextMenuStrip中,我有一些选择。是否可以将这些状态保存在我以某种方式附加到Chart对象的对象中?
或者我应该遍历ContextMenuStrip以在需要时获取选择的状态?
例如,MouseWheel需要检查是否选中了“Zoom X”和“Zoom Y”。
MouseDown必须检查是否选中了“Scroll”。
将一个对象附加到Chart以处理这些状态会很好。
例如:
function runReplaceInSheet(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("StudentTimetableEntry");
// get the current data range values as an array
// Fewer calls to access the sheet -> lower overhead
var values = sheet.getDataRange().getValues();
// Replace Subject Names
replaceInSheet(values, /\d\dART\d\d/g, "Art");
replaceInSheet(values, /\d\dCCL\d\d/g, "Communication & Culture");
replaceInSheet(values, /\d\dDLT\d\d/g, "Digital Technology");
replaceInSheet(values, /\d\dDRA\d\d/g, "Drama");
// Replace Staff Names
replaceInSheet(values, 'TED', 'Tahlee Edward');
replaceInSheet(values, 'TLL', 'Tyrone LLoyd');
replaceInSheet(values, 'TMA', 'Timothy Mahone');
replaceInSheet(values, 'TQU', 'Tom Quebec');
// Write all updated values to the sheet, at once
sheet.getDataRange().setValues(values);
}
function replaceInSheet(values, to_replace, replace_with) {
//loop over the rows in the array
for(var row in values){
//use Array.map to execute a replace call on each of the cells in the row.
var replaced_values = values[row].map(function(original_value) {
return original_value.toString().replace(to_replace,replace_with);
});
//replace the original row values with the replaced values
values[row] = replaced_values;
}
}
答案 0 :(得分:1)
使用标签如下:
在Form1_Load中首次实例化:
chart1.Tag = new ChartAddonState();
您可以使用以下任何地方:
(chart1.Tag as ChartAddonState).scroll = true;
或:
if ((chart1.Tag as ChartAddonState).scroll == true)
{
}