private void DrawParentheses(DrawingContext dc) { if (Width < FontSize * 3) { firstSign.DrawTextTopLeftAligned(dc, Location); } else { firstSign.DrawTextTopLeftAligned(dc, Location); secondSign.DrawTextTopLeftAligned(dc, new Point(Right - secondSign.Width + secondSign.OverhangLeading, Top)); //dc.DrawLine(StandardPen, new Point(Left + secondSign.Width + secondSign.OverhangLeading, Top + FontSize * .03), new Point(Right - (secondSign.Width + secondSign.OverhangLeading), Top + FontSize * .03)); double left = Left + firstSign.GetFullWidth() * .85; double right = Right - secondSign.GetFullWidth() * .85; while (left < right) { bar.DrawTextTopLeftAligned(dc, new Point(left, Top)); left += bar.GetFullWidth() * .8; double shoot = (left + bar.GetFullWidth() * .8) - right; if (shoot > 0) { left -= shoot; bar.DrawTextTopLeftAligned(dc, new Point(left, Top)); break; } } } }
void DrawBottomCurly(DrawingContext dc) { if (Width < FontSize * 5) { sign.DrawTextTopLeftAligned(dc, Location); } else { var line = FontFactory.GetFormattedText("\uE14B", FontType.STIXNonUnicode, FontSize * .55); leftCurlyPart.DrawTextTopLeftAligned(dc, Location); sign.DrawTextTopLeftAligned(dc, new Point(MidX - sign.GetFullWidth() * .5, Top + leftCurlyPart.Extent - line.Extent)); rightCurlyPart.DrawTextTopLeftAligned(dc, new Point(Right - rightCurlyPart.GetFullWidth(), Top)); double left = Left + leftCurlyPart.GetFullWidth() * .85; double right = MidX - sign.GetFullWidth() * .4; while (left < right) { line.DrawTextTopLeftAligned(dc, new Point(left, Top + leftCurlyPart.Extent - line.Extent)); left += line.GetFullWidth() * .8; double shoot = (left + line.GetFullWidth() * .8) - right; if (shoot > 0) { left -= shoot; line.DrawTextTopLeftAligned(dc, new Point(left, Top + leftCurlyPart.Extent - line.Extent)); break; } } left = MidX + sign.GetFullWidth() * .4; right = Right - rightCurlyPart.GetFullWidth() * .8; while (left < right) { line.DrawTextTopLeftAligned(dc, new Point(left, Top + leftCurlyPart.Extent - line.Extent)); left += line.GetFullWidth() * .8; double shoot = (left + line.GetFullWidth() * .8) - right; if (shoot > 0) { left -= shoot; line.DrawTextTopLeftAligned(dc, new Point(left, Top + leftCurlyPart.Extent - line.Extent)); break; } } //dc.DrawLine(StandardPen, new Point(Left + leftCurlyPart.GetFullWidth() * .96, Top + leftCurlyPart.Extent - LineThickness * .5), // new Point(MidX - sign.GetFullWidth() * .48, Top + leftCurlyPart.Extent - LineThickness * .5)); //dc.DrawLine(StandardPen, new Point(MidX + sign.GetFullWidth() * .48, Top + rightCurlyPart.Extent - LineThickness * .5), // new Point(Right - rightCurlyPart.GetFullWidth() * .96, Top + rightCurlyPart.Extent - LineThickness * .5)); } }
private void DrawDoubleArrow(DrawingContext dc) { if (Width < FontSize * 0.8) { FormattedText text = FontFactory.GetFormattedText("\u2194", FontType.STIXGeneral, Width * 1.5); double factor = .1; do { text = FontFactory.GetFormattedText("\u2194", FontType.STIXGeneral, FontSize * factor); factor += .1; }while (Width > text.GetFullWidth()); text.DrawTextTopLeftAligned(dc, Location); } else { firstSign.DrawTextTopLeftAligned(dc, Location); secondSign.DrawTextTopRightAligned(dc, new Point(Right, Top)); dc.DrawLine(ThinPen, new Point(Left + FontSize * .06, MidY), new Point(Right - FontSize * .06, MidY)); } }
public override void DrawEquation(DrawingContext dc) { //dc.DrawText(formattedText, new Point(Left + LeftMarginFactor * FontSize, Top + TopOffestFactor * Height)); formattedText.DrawTextTopLeftAligned(dc, new Point(Left + LeftMarginFactor * FontSize, Top + TopOffestFactor * Height)); }
public override void DrawEquation(DrawingContext dc) { switch (decorationType) { case DecorationType.Bar: dc.DrawLine(ThinPen, Location, new Point(Right, Top)); break; case DecorationType.DoubleBar: dc.DrawLine(ThinPen, Location, new Point(Right, Top)); dc.DrawLine(ThinPen, new Point(Left, Bottom - ThinPen.Thickness), new Point(Right, Bottom - ThinPen.Thickness)); break; case DecorationType.Hat: dc.DrawPolyline(new Point(Left, Bottom - FontSize * .02), new PointCollection { new Point(MidX, Top + FontSize * .03), new Point(Right, Bottom - FontSize * .02) }, ThinPen); break; case DecorationType.LeftArrow: firstSign.DrawTextTopLeftAligned(dc, Location); dc.DrawLine(ThinPen, new Point(Left + FontSize * .06, MidY), new Point(Right, MidY)); break; case DecorationType.RightArrow: firstSign.DrawTextTopRightAligned(dc, new Point(Right, Top)); dc.DrawLine(ThinPen, new Point(Left, MidY), new Point(Right - FontSize * .06, MidY)); break; case DecorationType.DoubleArrow: DrawDoubleArrow(dc); break; case DecorationType.Parenthesis: DrawParentheses(dc); break; case DecorationType.RightHarpoonUpBarb: DrawRightHarpoonUpBarb(dc); break; case DecorationType.RightHarpoonDownBarb: DrawRightHarpoonDownBarb(dc); break; case DecorationType.LeftHarpoonUpBarb: DrawLeftHarpoonUpBarb(dc); break; case DecorationType.LeftHarpoonDownBarb: DrawLeftHarpoonDownBarb(dc); break; case DecorationType.Tilde: firstSign.DrawTextTopLeftAligned(dc, Location); break; case DecorationType.Tortoise: DrawTortoise(dc); break; case DecorationType.Cross: dc.DrawLine(ThinPen, ParentEquation.Location, new Point(Right, ParentEquation.Bottom)); dc.DrawLine(ThinPen, new Point(Left, ParentEquation.Bottom), new Point(Right, ParentEquation.Top)); break; case DecorationType.LeftCross: dc.DrawLine(ThinPen, ParentEquation.Location, new Point(Right, ParentEquation.Bottom)); break; case DecorationType.RightCross: dc.DrawLine(ThinPen, new Point(Left, ParentEquation.Bottom), new Point(Right, ParentEquation.Top)); break; case DecorationType.StrikeThrough: dc.DrawLine(ThinPen, new Point(Left, ParentEquation.MidY), new Point(Right, ParentEquation.MidY)); break; } }
void PaintCurly(DrawingContext dc) { if (Height < BracketBreakLimit) { signText.DrawTextTopLeftAligned(dc, new Point(SignLeft, Top)); } else { if (SignType == BracketSignType.LeftCurly) { double left = SignLeft + midText.GetFullWidth() - extension.GetFullWidth(); signText.DrawTextTopLeftAligned(dc, new Point(left, Top)); //dc.DrawLine(new Pen(Brushes.Red, 1), new Point(left, Top), new Point(left, Bottom)); midText.DrawTextTopLeftAligned(dc, new Point(SignLeft, MidY - midText.Extent / 2)); signText2.DrawTextBottomLeftAligned(dc, new Point(left, Bottom)); double top = Top + signText.Extent * .9; double bottom = MidY - midText.Extent * .4; double padding = extension.OverhangLeading; var geometry = extension.BuildGeometry(new Point(left - padding, 0)); PointCollection points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //dc.DrawLine(new Pen(Brushes.Red, 1), new Point(Left, top), new Point(Right, top)); //dc.DrawLine(new Pen(Brushes.Red, 1), new Point(Left, bottom), new Point(Right, bottom)); //double padding = extension.OverhangLeading; //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent; //var geometry = extension.BuildGeometry(new Point(SignLeft + midText.GetFullWidth(), top)); //double factor = ((bottom - top) / (extension.Extent)) * .95; //ScaleTransform transform = new ScaleTransform(1, factor); //transform.CenterY = extension.Extent / 2; //geometry.Transform = transform; //dc.DrawGeometry(Brushes.Red, null, geometry); //dc.PushTransform(transform); //Pen pen = new Pen(Brushes.Black, extension.GetFullWidth()); //dc.DrawText(extension, new Point(left - padding, (top/factor) - topExtra)); //dc.Pop(); //dc.DrawLine(pen, new Point(left + pen.Thickness * .65, top), new Point(left + pen.Thickness * .65, bottom)); //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68); //dc.DrawLine(pen, new Point(left + pen.Thickness * .68, top), // new Point(left + pen.Thickness * .68, bottom)); //while (top < bottom) //{ // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // top += extension.Extent * .75; // double shoot = (top + extension.Extent * .8) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // break; // } //} top = MidY + midText.Extent * .4; bottom = Bottom - signText2.Extent * .9; points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //dc.DrawLine(pen, new Point(left + pen.Thickness - padding * 1.2, top), // new Point(left + pen.Thickness - padding * 1.2, bottom)); //dc.DrawLine(pen, new Point(left + pen.Thickness * .68, top), // new Point(left + pen.Thickness * .68, bottom)); //while (top < bottom) //{ // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // top += extension.Extent * .75; // double shoot = (top + extension.Extent * .85) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // break; // } //} } else { double left = SignLeft + signText.GetFullWidth() - extension.GetFullWidth(); signText.DrawTextTopLeftAligned(dc, new Point(SignLeft, Top)); midText.DrawTextTopLeftAligned(dc, new Point(left, MidY - midText.Extent / 2)); signText2.DrawTextBottomLeftAligned(dc, new Point(SignLeft, Bottom)); double top = Top + signText.Extent * .9; double bottom = MidY - midText.Extent * .4; double padding = extension.OverhangLeading; var geometry = extension.BuildGeometry(new Point(left - padding, 0)); PointCollection points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //double padding = extension.OverhangLeading; //var geometry = extension.BuildGeometry(new Point(SignLeft, top)); //Pen pen = new Pen(Brushes.Black, geometry.Bounds.Width); //dc.DrawLine(pen, new Point(left + pen.Thickness - padding * 1.2, top), // new Point(left + pen.Thickness - padding * 1.2, bottom)); //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68); //dc.DrawLine(pen, new Point(left + pen.Thickness * .68, top), // new Point(left + pen.Thickness * .68, bottom)); //while (top < bottom) //{ // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // top += extension.Extent * .75; // double shoot = (top + extension.Extent * .85) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // break; // } //} top = MidY + midText.Extent * .4; bottom = Bottom - signText2.Extent * .9; points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //dc.DrawLine(pen, new Point(left + pen.Thickness - padding * 1.2, top), // new Point(left + pen.Thickness - padding * 1.2, bottom)); //dc.DrawLine(pen, new Point(left + pen.Thickness * .68, top), // new Point(left + pen.Thickness * .68, bottom)); //while (top < bottom) //{ // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // top += extension.Extent * .75; // double shoot = (top + extension.Extent * .85) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopLeftAligned(dc, new Point(left, top)); // break; // } //} } } }
void PaintRound(DrawingContext dc) { if (Height < BracketBreakLimit) { if (SignType == BracketSignType.LeftRound) { signText.DrawTextTopLeftAligned(dc, new Point(SignLeft, Top)); } else { signText.DrawTextTopRightAligned(dc, new Point(SignRight, Top)); } } else { if (SignType == BracketSignType.LeftRound) { double left = Math.Floor(SignLeft); signText.DrawTextTopLeftAligned(dc, new Point(left, Top)); signText2.DrawTextBottomLeftAligned(dc, new Point(left, Bottom)); double top = Top + signText.Extent * .9; double bottom = Bottom - signText2.Extent * .9; //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent; double padding = extension.OverhangLeading; var geometry = extension.BuildGeometry(new Point(left - padding, 0)); PointCollection points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68); //dc.DrawLine(pen, new Point(SignLeft + pen.Thickness * .68, top), // new Point(SignLeft + pen.Thickness * .68, bottom)); ////double topExtra = extension.Height + extension.OverhangAfter - extension.Extent; ////double padding = extension.OverhangLeading; ////var geometry = extension.BuildGeometry(new Point(SignLeft - padding, top - topExtra)); ////Pen pen = new Pen(Brushes.Black, geometry.Bounds.Width); ////dc.DrawLine(pen, new Point(SignLeft + pen.Thickness - padding * 1.2, top), //// new Point(SignLeft + LineThickness - padding * 1.2, bottom)); //var geometry2 = extension.BuildGeometry(new Point(SignLeft - 10, (top - topExtra)/2)); //var geometry3 = extension.BuildGeometry(new Point(SignLeft - 20, 10)); //double factor = (bottom - top) / (extension.Extent); //ScaleTransform scale = new ScaleTransform(1.0, factor); //scale.CenterY = extension.Extent / 2; //scale.CenterY = geometry2.Bounds.Height; //geometry2.Transform = scale; //ScaleTransform scale2 = new ScaleTransform(1.0, 3); //geometry3.Transform = scale2; //dc.DrawGeometry(Brushes.Red, null, geometry); //dc.DrawGeometry(Brushes.Blue, null, geometry2); //dc.DrawGeometry(Brushes.Green, null, geometry3); //var geo = Geometry.Combine(geometry, geometry, GeometryCombineMode.Intersect, scale); //dc.DrawGeometry(Brushes.HotPink, null, geo); //dc.PushTransform(scale); //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent; //double padding = extension.OverhangLeading; //dc.DrawText(extension, new Point(SignLeft - padding, top - (topExtra/factor))); //dc.Pop(); //while (top < bottom) //{ // extension.DrawTextTopLeftAligned(dc, new Point(SignLeft, top)); // top += extension.Extent *.85; // double shoot = (top + extension.Extent) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopLeftAligned(dc, new Point(SignLeft, top)); // break; // } //} } else { signText.DrawTextTopRightAligned(dc, new Point(SignRight, Top)); signText2.DrawTextBottomRightAligned(dc, new Point(SignRight, Bottom)); double top = Top + signText.Extent * .9; double bottom = Bottom - signText2.Extent * .9; var geometry = extension.BuildGeometry(new Point(SignRight - extension.GetFullWidth() - extension.OverhangLeading, 0)); PointCollection points = new PointCollection { new Point(geometry.Bounds.Right, top), new Point(geometry.Bounds.Right, bottom), new Point(geometry.Bounds.Left, bottom), }; dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points); //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent; ////double padding = extension.OverhangLeading; ////var geometry = extension.BuildGeometry(new Point(SignLeft, top)); ////Pen pen = new Pen(Brushes.Black, geometry.Bounds.Width); ////dc.DrawLine(pen, new Point(SignRight - pen.Thickness * .65, top), //// new Point(SignRight - pen.Thickness * .65, bottom)); //dc.DrawLine(new Pen(Brushes.Red, 1), new Point(SignLeft, Top), new Point(SignLeft, Bottom)); //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68); //dc.DrawLine(pen, new Point(SignRight - pen.Thickness * .68, top), // new Point(SignRight - pen.Thickness * .68, bottom)); //while (top < bottom) //{ // extension.DrawTextTopRightAligned(dc, new Point(left + signText.GetFullWidth(), top)); // top += extension.Extent * .85; // double shoot = (top + extension.Extent) - bottom; // if (shoot > 0) // { // top -= shoot; // extension.DrawTextTopRightAligned(dc, new Point(left + signText.GetFullWidth(), top)); // break; // } //} } } }