C#: Convertire string array in int array
A futura memoria:
string[] stringArray = { "1", "2", "3"};
int[] intArray = Array.ConvertAll<string, int>(stringArray, delegate(string s) { return int.Parse(s); });
A futura memoria:
string[] stringArray = { "1", "2", "3"};
int[] intArray = Array.ConvertAll<string, int>(stringArray, delegate(string s) { return int.Parse(s); });
Da parecchio tempo sono impegnato nella realizzazione di un importante progetto con l’ ausilio del framework javascript Extjs. Tra le tante funzionalità richieste dal cliente, c’è quella di modificare le dimensioni del font dei testi e lo Slider mi è venuto in aiuto. Vi posto un pò di codice che ho scritto per l’ occasione sperando che possa esservi utile come spunto. Se avete qualche suggerimento sono tutto orecchi…
Dichiaro lo slider e l’ evento
var slider = new Ext.Slider({ width: 100 changeFontSize: function(startValue, endValue) { }, onChangecomplete: function(slider, newValue) {
, value: 12
, increment: 1
, minValue: 9
, maxValue: 15
, animate: false
, plugins: new Ext.ux.SliderTip()
});
slider.on('changecomplete', this.onChangecomplete, this);
this.sliderValue = 12;
this.removeClass(String.format('doc-font-{0}', this.sliderValue));
this.addClass(String.format('doc-font-{0}', endValue));
this.changeFontSize(this.sliderValue, newValue);
this.sliderValue = newValue;
}
Nella dichiarazione ho utilizzato il seguente plugin:
/** onSlide: function(slider) { getText: function(slider) {
* @class Ext.ux.SliderTip
* @extends Ext.Tip
* Simple plugin for using an Ext.Tip with a slider to show the slider value
*/
Ext.ux.SliderTip = Ext.extend(Ext.Tip, {
minWidth: 10,
offsets: [0, -10],
init: function(slider) {
slider.on('dragstart', this.onSlide, this);
slider.on('drag', this.onSlide, this);
slider.on('dragend', this.hide, this);
slider.on('destroy', this.destroy, this);
},
this.show();
this.body.update(this.getText(slider));
this.doAutoWidth();
this.el.alignTo(slider.thumb, 'b-t?', this.offsets);
},
return slider.getValue();
}
});