コード例 #1
0
        protected void PaintArguments(IGraphics g, PointF point, List <string> Signs)
        {
            BoundaryInfo boundary = GetArgumentsBoundary(g, Signs);

            g.PaintBoundary(boundary, point);

            float ix = point.X;

            for (int i = 0; i < Arguments.Count; ++i)
            {
                Element      argument  = Arguments[i];
                BoundaryInfo iBoundary = argument.GetBoundary(g);

                float  y0     = point.Y + (boundary.BaseLine - iBoundary.BaseLine);
                PointF iPoint = new PointF(ix, y0);

                argument.Paint(g, iPoint);

                ix += iBoundary.Width;

                if (i < Arguments.Count - 1)
                {
                    string sign   = Signs[i + 1];
                    SizeF  size   = g.MeasureString(sign);
                    PointF sPoint = new PointF(ix, point.Y + boundary.BaseLine - size.Height);

                    g.DrawString(sign, sPoint);

                    ix += size.Width;
                }
            }
        }
コード例 #2
0
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            SizeF functionSize = g.MeasureString(FunctionName);

            List <string> signs = new List <string>();

            foreach (var Arg in Arguments)
            {
                signs.Add(";");
            }

            BoundaryInfo argsSize = GetArgumentsBoundary(g, signs);



            float width  = functionSize.Width + BRACKET_WIDTH + argsSize.Width + BRACKET_WIDTH;
            float height = BRACKET_WIDTH + argsSize.Height + BRACKET_WIDTH;

            float baseLine = argsSize.BaseLine;

            return(new BoundaryInfo
            {
                Size = new SizeF(width, height),
                BaseLine = baseLine
            });
        }
コード例 #3
0
ファイル: ValueElement.cs プロジェクト: macieja79/formulas
		public override BoundaryInfo GetBoundary(IGraphics g)
		{
			SizeF valueSize = g.MeasureString(Value);
			if (!HasArguments) {
				return new BoundaryInfo
				{
					Size = valueSize,
					BaseLine = valueSize.Height
				};
			}

			// TODO: poprawic, po zrobione 

			UnitElement unit = (UnitElement)Arguments[0];

			BoundaryInfo unitBounds = unit.GetBoundary(g);

			float totalWidth = valueSize.Width + unitBounds.Width;
			float totalHeight = Math.Max(valueSize.Height, unitBounds.Height);

			return new BoundaryInfo
			{
				Size = new SizeF(totalWidth, totalHeight),
				BaseLine = valueSize.Height
			};
			




		}
コード例 #4
0
        public override void Paint(IGraphics g, PointF point)
        {
            SizeF functionSize = g.MeasureString(FunctionName);

            List <string> signs = new List <string>();

            foreach (var Arg in Arguments)
            {
                signs.Add(";");
            }

            BoundaryInfo argsSize = GetArgumentsBoundary(g, signs);

            g.DrawString(FunctionName, point);

            PointF argPoint = new PointF(point.X + functionSize.Width + BRACKET_WIDTH, point.Y);

            PaintArguments(g, argPoint, signs);

            float x1 = point.X + functionSize.Width;
            float x2 = point.X + functionSize.Width + BRACKET_WIDTH;
            float x3 = point.X + functionSize.Width + BRACKET_WIDTH + argsSize.Width;
            float x4 = point.X + functionSize.Width + BRACKET_WIDTH + argsSize.Width + BRACKET_WIDTH;

            float y1  = point.Y;
            float y12 = point.Y + argsSize.Height * 0.5f;
            float y2  = point.Y + argsSize.Height;


            if (TypeOfBracket == BracketShapeType.Squared)
            {
                g.DrawLine(x2, y2, x1, y2);
                g.DrawLine(x1, y2, x1, y1);
                g.DrawLine(x1, y1, x2, y1);

                g.DrawLine(x3, y1, x4, y1);
                g.DrawLine(x4, y1, x4, y2);
                g.DrawLine(x4, y2, x3, y2);
            }

            if (TypeOfBracket == BracketShapeType.Round)
            {
                PointF p1 = new PointF(x2, y1);
                PointF p2 = new PointF(x1, y12);
                PointF p3 = new PointF(x2, y2);

                PointF p4 = new PointF(x3, y1);
                PointF p5 = new PointF(x4, y12);
                PointF p6 = new PointF(x3, y2);

                PointF[] pointsLeft = new PointF[] { p1, p2, p3 };
                g.DrawCurve(pointsLeft);

                PointF[] pointsRight = new PointF[] { p4, p5, p6 };
                g.DrawCurve(pointsRight);
            }
        }
コード例 #5
0
        public override void Paint(IGraphics g, PointF point)
        {
            float dY = point.Y;

            foreach (EquationElement element in Arguments)
            {
                PointF iPoint = new PointF(point.X, dY);
                element.Paint(g, iPoint);
                BoundaryInfo iBounds = element.GetBoundary(g);
                dY += iBounds.Height;
            }
        }
コード例 #6
0
        public override void Paint(IGraphics g, PointF point)
        {
            List <Element> elements = new List <Element>();

            for (int i = 0; i < Arguments.Count - 1; i++)
            {
                elements.Add(Arguments[i]);
                elements.Add(Element.Eq);
            }
            elements.Add(Arguments.Last());

            BoundaryInfo.PaintElements(g, point, elements);
        }
コード例 #7
0
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            Element      elem = Arguments.First();
            BoundaryInfo info = elem.GetBoundary(g);

            SizeF rect     = new SizeF(info.Width + 3 * DIST, info.Height + 2 * DIST);
            float baseLine = info.BaseLine + DIST;

            return(new BoundaryInfo
            {
                Size = rect,
                BaseLine = baseLine
            });
        }
コード例 #8
0
ファイル: MtGraphics.cs プロジェクト: macieja79/formulas
        public void PaintBoundary(BoundaryInfo boundary, PointF point)
        {
            if (!IsBoundary)
            {
                return;
            }

            Rectangle rect = new Rectangle((int)point.X, (int)point.Y, (int)boundary.Size.Width, (int)boundary.Size.Height);
            PointF    p1   = new PointF(point.X, point.Y + boundary.BaseLine);
            PointF    p2   = new PointF(point.X + boundary.Width, point.Y + boundary.BaseLine);

            _g.DrawRectangle(_bp, rect);
            _g.DrawLine(_bbaseline, p1, p2);
        }
コード例 #9
0
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            List <Element> elements = new List <Element>();

            for (int i = 0; i < Arguments.Count - 1; i++)
            {
                elements.Add(Arguments[i]);
                elements.Add(Element.Eq);
            }
            elements.Add(Arguments.Last());

            BoundaryInfo info = BoundaryInfo.GetElementsBoundary(g, elements);

            return(info);
        }
コード例 #10
0
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            BoundaryInfo[] boundaries = Arguments.Select(e => e.GetBoundary(g)).ToArray();

            float height = BoundaryInfo.GetHeightSummed(boundaries);
            float width  = BoundaryInfo.GetWidthMax(boundaries);

            return(new BoundaryInfo()
            {
                Size = new System.Drawing.SizeF {
                    Height = height, Width = width
                },
                BaseLine = height
            });
        }
コード例 #11
0
ファイル: PowElement.cs プロジェクト: macieja79/formulas
        public override void Paint(IGraphics g, PointF point)
        {
            Element powBase  = Arguments[0];
            Element exponent = Arguments[1];

            BoundaryInfo allInfo = GetBoundary(g);

            g.PaintBoundary(allInfo, point);

            BoundaryInfo baseInfo     = powBase.GetBoundary(g);
            BoundaryInfo exponentInfo = exponent.GetBoundary(g);

            float height = allInfo.Height - baseInfo.Height;

            powBase.Paint(g, new PointF(point.X, point.Y + height));

            exponent.Paint(g, new PointF(point.X + baseInfo.Width, point.Y));
        }
コード例 #12
0
ファイル: SymbolElement.cs プロジェクト: macieja79/formulas
        public override void Paint(IGraphics g, PointF p)
        {
            BoundaryInfo boundary = GetBoundary(g);

            g.PaintBoundary(boundary, p);

            SizeF symbolSize = g.MeasureString(Symbol);
            SizeF suffixSize = g.MeasureString(Suffix);


            g.DrawString(Symbol, p);

            PointF indexPoint = new PointF(
                p.X + symbolSize.Width,
                p.Y + symbolSize.Height - suffixSize.Height * 0.5f);

            g.DrawString(Suffix, indexPoint);
        }
コード例 #13
0
        public static void PaintElements(IGraphics g, PointF point, List <Element> elements)
        {
            BoundaryInfo boundary = GetElementsBoundary(g, elements);

            g.PaintBoundary(boundary, point);

            float ix = point.X;

            for (int i = 0; i < elements.Count; ++i)
            {
                Element      iElement  = elements[i];
                BoundaryInfo iBoundary = iElement.GetBoundary(g);

                float  y0     = point.Y + (boundary.BaseLine - iBoundary.BaseLine);
                PointF iPoint = new PointF(ix, y0);

                iElement.Paint(g, iPoint);
                ix += iBoundary.Width;
            }
        }
コード例 #14
0
ファイル: PowElement.cs プロジェクト: macieja79/formulas
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            Element powBase  = Arguments[0];
            Element exponent = Arguments[1];

            BoundaryInfo baseInfo     = powBase.GetBoundary(g);
            BoundaryInfo exponentInfo = exponent.GetBoundary(g);

            float width  = baseInfo.Width + exponentInfo.Width;
            float height = (baseInfo.Height * 0.5f + exponentInfo.Height);

            SizeF rectangle = new SizeF(width, height);
            float baseLine  = height;

            return(new BoundaryInfo
            {
                Size = rectangle,
                BaseLine = baseLine
            });
        }
コード例 #15
0
ファイル: FractionElement.cs プロジェクト: macieja79/formulas
        public override BoundaryInfo GetBoundary(IGraphics g)
        {
            Element numerator   = Arguments[0];
            Element denominator = Arguments[1];

            BoundaryInfo numeratorInfo   = numerator.GetBoundary(g);
            BoundaryInfo denominatorInfo = denominator.GetBoundary(g);

            SizeF sigleCharSize = g.MeasureString("+");

            float width    = Math.Max(numeratorInfo.Width, denominatorInfo.Width);
            float height   = numeratorInfo.Height + denominatorInfo.Height;
            float baseLine = numeratorInfo.Height + sigleCharSize.Height * 0.5f;

            return(new BoundaryInfo
            {
                Size = new System.Drawing.SizeF(width, height),
                BaseLine = baseLine
            });
        }
コード例 #16
0
ファイル: ValueElement.cs プロジェクト: macieja79/formulas
		public override void Paint(IGraphics g, PointF point)
		{

					g.DrawString(Value, point);

			if (!HasArguments) {
		
				return;
			}

			SizeF valueSize = g.MeasureString(Value);

			UnitElement unit = (UnitElement)Arguments.First();
			BoundaryInfo unitBounds = unit.GetBoundary(g);

			PointF unitPoint = new PointF(point.X + valueSize.Width, point.Y);
			unit.Paint(g, unitPoint);


		}
コード例 #17
0
        public override void Paint(IGraphics g, PointF point)
        {
            Element elem = Arguments.First();


            BoundaryInfo info = elem.GetBoundary(g);

            g.PaintBoundary(info, point);

            PointF p1 = new PointF(point.X, point.Y + info.Height - DIST);
            PointF p2 = new PointF(point.X + DIST, point.Y + info.Height);
            PointF p3 = new PointF(point.X + 2 * DIST, point.Y);
            PointF p4 = new PointF(point.X + 3 * DIST + info.Width, point.Y);

            g.DrawLine(p1, p2);
            g.DrawLine(p2, p3);
            g.DrawLine(p3, p4);

            PointF argPoint = new PointF(point.X + 3 * DIST, point.Y + DIST);

            elem.Paint(g, argPoint);
        }
コード例 #18
0
ファイル: FractionElement.cs プロジェクト: macieja79/formulas
        public override void Paint(IGraphics g, System.Drawing.PointF point)
        {
            Element numerator   = Arguments[0];
            Element denominator = Arguments[1];

            BoundaryInfo numeratorInfo   = numerator.GetBoundary(g);
            BoundaryInfo denominatorInfo = denominator.GetBoundary(g);
            BoundaryInfo total           = GetBoundary(g);

            float numeratorOffset   = (total.Width - numeratorInfo.Width) * 0.5f;
            float denominatorOffset = (total.Width - denominatorInfo.Width) * 0.5f;

            PointF nPoint = new PointF(point.X + numeratorOffset, point.Y);

            numerator.Paint(g, nPoint);

            PointF dPoint = new PointF(point.X + denominatorOffset, point.Y + numeratorInfo.Height);

            denominator.Paint(g, dPoint);

            g.DrawLine(point.X, point.Y + numeratorInfo.Height, point.X + total.Width, point.Y + numeratorInfo.Height);
        }