public Size GetSize() { if (null == Molecule && null == Denominator) { //返回默认分数大小 return(new Size(FontManager.Instance.FontSize, FontManager.Instance.FontSize * 2.4)); } else { double maxWidth = 0; double maxHeight = 0; if (null == Molecule && null != Denominator) { maxWidth = FontManager.Instance.FontSize > Denominator.GetSize().Width ? FontManager.Instance.FontSize : Denominator.GetSize().Width; maxHeight = FontManager.Instance.FontSize * 1.4 + Denominator.GetSize().Height; return(new Size(maxWidth, maxHeight)); } if (null != Molecule && null == Denominator) { maxWidth = FontManager.Instance.FontSize > Molecule.GetSize().Width ? FontManager.Instance.FontSize : Molecule.GetSize().Width; maxHeight = FontManager.Instance.FontSize * 1.4 + Molecule.GetSize().Height; return(new Size(maxWidth, maxHeight)); } var topSize = Molecule.GetSize(); var bottomSize = Denominator.GetSize(); maxWidth = topSize.Width > bottomSize.Width ? topSize.Width : bottomSize.Width; return(new Size(maxWidth, topSize.Height + bottomSize.Height + FontManager.Instance.FontSize * 0.4)); } }
public Point GotoNextPart(Point caretLocation) { /*1.当前输入分子;2.当前输入分母*/ bool isInputMolecule = IsContainCaretLocation(Molecule, caretLocation); if (isInputMolecule) { if (null == Denominator) { if (null == Molecule) { return(new Point(this.Location.X, this.Location.Y + FontManager.Instance.FontSize * 1.4)); } else { return(new Point(this.Location.X, this.Location.Y + Molecule.GetSize().Height + FontManager.Instance.FontSize * 0.4)); } } else { var denominatorSize = Denominator.GetSize(); return(new Point(Denominator.Location.X + denominatorSize.Width, Denominator.Location.Y)); } } else { var fractionSize = GetSize(); MessageManager.Instance.OnInputParentChanged(ParentId); return(new Point(Location.X + fractionSize.Width, Location.Y + Molecule.GetSize().Height - FontManager.Instance.FontSize * 0.3)); } }
private Line CreateFractionLine() { Line separateLine = new Line(); separateLine.Uid = ID; separateLine.Stroke = Brushes.Black; separateLine.X1 = Location.X; double maxLineWidth = 0; if (null != Molecule) { separateLine.Y1 = Location.Y + Molecule.GetSize().Height + FontManager.Instance.FontSize * 0.2; maxLineWidth = Molecule.GetSize().Width; separateLine.X2 = Location.X + maxLineWidth; } else { separateLine.Y1 = Location.Y + FontManager.Instance.FontSize * 1.2; separateLine.X2 = Location.X + FontManager.Instance.FontSize; } if (null != Denominator) { var denominatorMaxLineWidth = Denominator.GetSize().Width; if (denominatorMaxLineWidth > maxLineWidth) { separateLine.X2 = Location.X + denominatorMaxLineWidth; } } separateLine.Y2 = separateLine.Y1; _separateLineY = separateLine.Y1; return(separateLine); }
public void AddChildren(IEnumerable <IBlock> inputCharactors, Point caretPoint, string parentId) { Rect moleculeRect; Rect denominatorRect; if (null == Molecule) { moleculeRect = new Rect(Location.X - 2, Location.Y - 4, FontManager.Instance.FontSize + 4, FontManager.Instance.FontSize + 4); } else { moleculeRect = new Rect(Location.X - 2, Location.Y - 4, Molecule.GetSize().Width + 4, Molecule.GetSize().Height + 4); } if (null == Denominator) { denominatorRect = new Rect(Location.X - 2, Location.Y + FontManager.Instance.FontSize * 1.2 - 2, FontManager.Instance.FontSize + 4, FontManager.Instance.FontSize + 4); } else { denominatorRect = new Rect(Location.X - 2, Location.Y + moleculeRect.Height + FontManager.Instance.FontSize * 0.2 - 2, Denominator.GetSize().Width + 4, Denominator.GetSize().Height + 4); } if (moleculeRect.Contains(caretPoint)) { if (null == Molecule) { Molecule = new BlockNode(); Molecule.ParentId = ID; } Molecule.AddChildren(inputCharactors, caretPoint, parentId); } else { if (null == Denominator) { Denominator = new BlockNode(); Denominator.ParentId = ID; } Denominator.AddChildren(inputCharactors, caretPoint, parentId); } }