protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { MeasureSpec leftWidth = null; MeasureSpec rightWidth = null; if (widthSpec.Mode == MeasureSpecMode.Fixed || widthSpec.Mode == MeasureSpecMode.AtMost) { leftWidth = MeasureSpec.MakeFixed(widthSpec.Size * 0.8f); rightWidth = MeasureSpec.MakeFixed(widthSpec.Size * 0.2f); } else if (widthSpec.Mode == MeasureSpecMode.Unspecified) { leftWidth = widthSpec; rightWidth = widthSpec; } X.Measure(leftWidth, heightSpec, g, font, style); Pow.Measure(rightWidth, heightSpec, g, font, style); SetDesiredSize( X.DesiredWidth + Pow.DesiredWidth, Pow.DesiredHeight + X.FindMaxTop() + X.FindMaxBottom() - 10); }
private void OnMeasureDivide(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { MeasureSpec leftHeight = null; MeasureSpec rightHeight = null; if (heightSpec.Mode == MeasureSpecMode.Fixed) { leftHeight = MeasureSpec.MakeFixed((float)((heightSpec.Size - 2) / 2)); rightHeight = MeasureSpec.MakeFixed((float)((heightSpec.Size - 2) / 2)); } else if (heightSpec.Mode == MeasureSpecMode.AtMost) { leftHeight = MeasureSpec.MakeAtMost((float)((heightSpec.Size - 2) / 2)); rightHeight = MeasureSpec.MakeAtMost((float)((heightSpec.Size - 2) / 2)); } else if (heightSpec.Mode == MeasureSpecMode.Unspecified) { leftHeight = heightSpec; rightHeight = heightSpec; } Left.Measure(widthSpec, leftHeight, g, font, style); Right.Measure(widthSpec, rightHeight, g, font, style); Operator.Measure(MeasureSpec.MakeFixed(Math.Max(Left.DesiredWidth, Right.DesiredWidth) + 10), MeasureSpec.MakeFixed(2), g, font, style); SetDesiredSize(Math.Max(Left.DesiredWidth, Right.DesiredWidth) + 10, Left.DesiredHeight + Right.DesiredHeight + Operator.DesiredHeight); }
protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { size = g.MeasureString(")", style.BoldFont); MeasureSpec width = null; if (widthSpec.Mode == MeasureSpecMode.Fixed) { width = MeasureSpec.MakeFixed(widthSpec.Size - size.Width * 2); } else if (widthSpec.Mode == MeasureSpecMode.AtMost) { width = MeasureSpec.MakeFixed(widthSpec.Size - size.Width * 2); } else if (widthSpec.Mode == MeasureSpecMode.Unspecified) { width = widthSpec; } Body.Measure(width, heightSpec, g, font, style); SetDesiredSize( (float)(widthSpec.Mode == MeasureSpecMode.Fixed ? widthSpec.Size : Body.DesiredWidth + size.Width * 2), (float)(Math.Max(size.Height / 2, Body.FindMaxTop()) + Math.Max(size.Height / 2, Body.FindMaxBottom()))); }
protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { MeasureSpec leftWidth = null; MeasureSpec rightWidth = null; if (widthSpec.Mode == MeasureSpecMode.Fixed || widthSpec.Mode == MeasureSpecMode.AtMost) { leftWidth = MeasureSpec.MakeFixed((widthSpec.Size - SymbolWidth) * 0.2f); rightWidth = MeasureSpec.MakeFixed((widthSpec.Size - SymbolWidth) * 0.8f); } else if (widthSpec.Mode == MeasureSpecMode.Unspecified) { leftWidth = widthSpec; rightWidth = widthSpec; } if (Root != null) { Root.Measure(leftWidth, heightSpec, g, font, style); } X.Measure(rightWidth, heightSpec, g, font, style); SetDesiredSize( (Root == null ? 0 : Root.DesiredWidth) + X.DesiredWidth + SymbolWidth, 2 + (Root == null ? X.DesiredHeight + SymbolHeight : Root.DesiredHeight + X.DesiredHeight - RootOverlap)); }
private void OnMeasureHorizontal(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { Operator.Measure(MeasureSpec.MakeUnspecified(), MeasureSpec.MakeUnspecified(), g, font, style); ActualOperator.Measure(MeasureSpec.MakeUnspecified(), MeasureSpec.MakeUnspecified(), g, font, style); MeasureSpec leftWidth = null; MeasureSpec rightWidth = null; if (widthSpec.Mode == MeasureSpecMode.Fixed) { leftWidth = MeasureSpec.MakeFixed((float)((widthSpec.Size - Operator.DesiredWidth) / 2)); rightWidth = MeasureSpec.MakeFixed((float)((widthSpec.Size - Operator.DesiredWidth) / 2)); } else if (widthSpec.Mode == MeasureSpecMode.AtMost) { leftWidth = MeasureSpec.MakeAtMost((float)((widthSpec.Size - Operator.DesiredWidth) / 2)); rightWidth = MeasureSpec.MakeAtMost((float)((widthSpec.Size - Operator.DesiredWidth) / 2)); } else if (widthSpec.Mode == MeasureSpecMode.Unspecified) { leftWidth = widthSpec; rightWidth = widthSpec; } Left.Measure(leftWidth, heightSpec, g, font, style); Right.Measure(rightWidth, heightSpec, g, font, style); isTwoLines = Left.DesiredWidth > 450 || Right.DesiredWidth > 450; if (!isTwoLines) { SetDesiredSize( Left.DesiredWidth + Right.DesiredWidth + GetOperatorWidth(), Math.Max(Left.FindMaxTop(), Right.FindMaxTop()) + Math.Max(Left.FindMaxBottom(), Right.FindMaxBottom())); } else { Operator = ActualOperator; SetDesiredSize( Math.Max(Left.DesiredWidth, Right.DesiredWidth + GetOperatorWidth()), Left.DesiredHeight + Math.Max(Operator.DesiredHeight, Right.DesiredHeight)); } }
protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { MeasureSpec width = null; if (widthSpec.Mode == MeasureSpecMode.Fixed) { width = MeasureSpec.MakeFixed(widthSpec.Size - 10); } else if (widthSpec.Mode == MeasureSpecMode.AtMost) { width = MeasureSpec.MakeFixed(widthSpec.Size - 10); } else if (widthSpec.Mode == MeasureSpecMode.Unspecified) { width = widthSpec; } Operand.Measure(width, heightSpec, g, font, style); SetDesiredSize(widthSpec.Mode == MeasureSpecMode.Fixed ? widthSpec.Size : Operand.DesiredWidth + 10, Operand.DesiredHeight); }