public void setValueLabel(xLabel l) { mValueLabel = l; if (mValueLabel != null) { // update label if (mValueZoom == 1) { mValueLabel.setText("" + ((int)mValue.Value)); } else { StringBuilder sb = utils.Utils.sb; sb.Length = 0; if (mValueZoom == 10) { sb.AppendFormat("{0:F1}", mValue.Value); } else if (mValueZoom == 100) { sb.AppendFormat("{0:F2}", mValue.Value); } else { sb.AppendFormat("{0:F3}", mValue.Value); } mValueLabel.setText(sb.ToString()); } } }
static public xLabel createMultiLineLabel(string text, Font f, int w) { xLabel l = new xLabel(); Label _l = new Label(); // calc height of text int tw = utils.Utils.getStringW(text, f) + 10; int lines = tw / w; if (lines < 1) { lines = 1; } if (tw - lines * w > 0) { lines++; } _l.Font = f; _l.Size = new Size(w, lines * f.Height); _l.Text = text; l.setControl(_l); return(l); }
static public xLabel createSingleLabel(string text) { xLabel l = new xLabel(text); l.setSize(utils.Utils.getStringW(text, l.getControl().Font), l.getFont().Height); return(l); }
static public xLabel createSingleLabel(string text, int w) { xLabel l = new xLabel(text); l.setSize(w, l.getFont().Height); return(l); }
static public xLabel createMultiLineLabel(string text, int w) { xLabel l = new xLabel(); Label _l = new Label(); _l.Size = new Size(w, _l.Size.Height); _l.Text = text; l.setControl(_l); return(l); }
static public xLabel createSingleLabel(string text, Font f, int w) { xLabel l = new xLabel(text); if (f != null) { l.setFont(f); } if (w == -1) { w = utils.Utils.getStringW(text, f) + 40; // 40??? don't know why } l.setSize(w, f.Height); return(l); }
// zoomValue: 1, 10, 100 static public xSlider createSlider(float min, float max, float step, xFloat o, int zooomValue, xLabel valueLabel) { xSlider slider = new xSlider(o, null); slider.setSliderRange(min, max, o.Value, step, zooomValue); slider.setValueLabel(valueLabel); return(slider); }