protected override SizeF OnMeasureContent(DevAge.Drawing.MeasureHelper measure, SizeF maxSize) { //TODO Here I must add some fixed pixels because seems that there are some little // difference from the measured content and the actual drawing surface (probably this is a little bug ... I must check) SizeF result = base.OnMeasureContent(measure, maxSize); return(new SizeF(result.Width + 1, result.Height + 1)); }
private void btMeasure_Click(object sender, EventArgs e) { using (DevAge.Drawing.MeasureHelper helper = new DevAge.Drawing.MeasureHelper(contentPanel)) { SizeF maxSize = new SizeF((Size)txtMaxSize.Value); SizeF measureSize = GetVisualElement().Measure(helper, SizeF.Empty, maxSize); txtSize.Value = DevAge.Drawing.Utilities.SizeFToSize(measureSize); } }
//Here I should also implement MeasureContent (think also for a solution to allow rotated text with any kind of allignment) protected override SizeF OnMeasureContent(DevAge.Drawing.MeasureHelper measure, SizeF maxSize) { SizeF size; SizeF boundSize = new SizeF(); //For a better drawing use the clear type rendering measure.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; StringFormat.Alignment = StringAlignment.Center; StringFormat.LineAlignment = StringAlignment.Center; size = measure.Graphics.MeasureString(Value, Font); float boundAngle = Math.Abs(Angle); boundSize.Width = (float)Math.Cos((boundAngle / 180) * Math.PI) * size.Width; boundSize.Height = (float)Math.Sin((boundAngle / 180) * Math.PI) * size.Width; return(boundSize); }
private void contentPanel_MouseMove(object sender, MouseEventArgs e) { using (DevAge.Drawing.MeasureHelper measure = new DevAge.Drawing.MeasureHelper(contentPanel)) { PointF mousePoint = contentPanel.PointToClient(Control.MousePosition); DevAge.Drawing.VisualElements.VisualElementList list; list = GetVisualElement().GetElementsAtPoint(measure, contentPanel.ClientRectangle, mousePoint); string text = ""; foreach (DevAge.Drawing.VisualElements.IVisualElement element in list) { text += element.ToString() + " ->"; } toolTip.SetToolTip(contentPanel, text); } }
protected override SizeF OnMeasureContent(DevAge.Drawing.MeasureHelper measure, SizeF maxSize) { return(SizeF.Empty); }
private void contentPanel_MouseMove(object sender, MouseEventArgs e) { using (DevAge.Drawing.MeasureHelper measure = new DevAge.Drawing.MeasureHelper(contentPanel)) { PointF mousePoint = contentPanel.PointToClient(Control.MousePosition); DevAge.Drawing.VisualElements.VisualElementList list; list = GetVisualElement().GetElementsAtPoint(measure, contentPanel.ClientRectangle, mousePoint); string text = ""; foreach (DevAge.Drawing.VisualElements.IVisualElement element in list) text += element.ToString() + " ->"; toolTip.SetToolTip(contentPanel, text); } }
private void btMeasure_Click(object sender, EventArgs e) { using (DevAge.Drawing.MeasureHelper helper = new DevAge.Drawing.MeasureHelper(contentPanel)) { SizeF maxSize = new SizeF((Size)txtMaxSize.Value); SizeF measureSize = GetVisualElement().Measure(helper, SizeF.Empty, maxSize); txtSize.Value = DevAge.Drawing.Utilities.SizeFToSize(measureSize); } }