public ControlWithMenu(EntityManager MathMLEntityManager, FontCollection FontCollection) : base(MathMLEntityManager, FontCollection) { this.designMode = false; this.InitializeComponent(); this.CreateMenu(); }
public IdentifierDictionaryDialog(EntityManager EntityManager, FontCollection FontCollection, bool bIdentifier) { this.container = null; this.curEntityIndex_ = 0; this.numEntities_ = 0; this.success_ = false; this.ready_ = false; this.fonts_ = null; this.InitializeComponent(); this.fonts_ = FontCollection; this.entManager_ = EntityManager; this.entities_.DoubleClick += new EventHandler(this.OnEntitiesDoubleClick); this.uniCats_ .ItemCheck += new ItemCheckEventHandler(this.OnUniItemCheck); if (bIdentifier) { this.isitalic_.Visible = true; this.isbold_.Visible = true; this.isitalic_.Checked = true; this.isbold_.Checked = false; this.Text = "Insert Identifier"; this.items_ = this.entManager_.ids_; this.isID_.Checked = true; this.mo_.Checked = false; } else { this.isitalic_.Visible = false; this.isbold_.Visible = false; this.Text = "Insert Operator"; this.items_ = this.entManager_.ops_; this.isID_.Checked = false; this.mo_.Checked = true; } this.cheader.Width = this.uniCats_.Size.Width - 20; this.FillEntities(); this.FillCats(); this.ready_ = true; }
public void SetEntityManager(EntityManager MathMLEntityManager) { this.entityManager = MathMLEntityManager; }
// public void SetEntityManager (EntityManager eman) { this.entityManager = eman; }
private void Init (EntityManager MathMLEntityManager, FontCollection FontCollection) { try { SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler (UserPrefChanged); } catch { } fonts_ = FontCollection; selectionBrush_ = new SolidBrush (Color.Gray); operators_ = new OperatorDictionary (); builder_ = new NodesBuilder (base.ClientRectangle.Width - 20, operators_); builder_.setFonts (fonts_); builder_.SetOrigin (lMargin - OffsetX, tMargin - OffsetY); if (MathMLEntityManager == null) { entityManager = new EntityManager (fonts_); } else { entityManager = MathMLEntityManager; } builder_.SetEntityManager (entityManager); builder_.UndoRedo += new EventHandler (UndoRedoHandler); builder_.InvalidXML += new InvalidXMLFile (OnInvalidXML); builder_.InsertHappened += new InsertionHappenned (OnInsert); base.SetStyle (ControlStyles.UserPaint, true); base.SetStyle (ControlStyles.AllPaintingInWmPaint, true); base.SetStyle (ControlStyles.DoubleBuffer, true); caretBlackPen = new Pen (Color.Black); caretBluePen = new Pen (Color.Blue); caretThread = new Thread (new ThreadStart (CaretThreadProc)); caretThread.Start (); canvasWidth = 0; canvasHeight = 0; ResizeScrollbars (); horScroller_.Visible = false; vertScroller_.Visible = false; vertScroller_.TabStop = false; horScroller_.TabStop = false; vertScroller_.GotFocus += new EventHandler (VertGotFocusHandler); horScroller_.GotFocus += new EventHandler (HorzGotFocusHandler); builder_.PropogateEntityManager (); types = new Types (); builder_.SetTypes (types); SetAntialias (true); try { UpdateMargins (); } catch { } DoResize (base.ClientRectangle.Width, base.ClientRectangle.Height, true, false); if (base.ClientRectangle.Width > 50) { SetWidth ((base.ClientRectangle.Width - vertScroller_.Width) - 2); } else { SetWidth (50); } }
public CoreControl (EntityManager MathMLEntityManager, FontCollection FontCollection) { needUpdate = false; needCheckIsPaletted = true; isPaletted = false; selectionInfo = null; fonts_ = null; panel_ = null; operators_ = null; autoCloseBrackets_ = true; isInitialized_ = false; types = null; canvasWidth = 0; canvasHeight = 0; lMargin = 0; rMargin = 0; tMargin = 0; bMargin = 0; bbox = new BBox (); markX = 0; markY = 0; caretHeight = 0; showCaret = false; offsetY = 0; offsetX = 0; isAntiAlias = true; haveScrollbars_ = false; try { InitializeComponent (); Init (MathMLEntityManager, FontCollection); isInitialized_ = true; } catch { } }
public Node ParseMstyle(XmlNode XMLNode, Types mTypes, EntityManager mEntities, bool bAll, StyleAttributes styleAttributes) { StyleAttributes s = null; if ((XMLNode.Attributes == null) || (XMLNode.Attributes.Count <= 0)) { return Parse(XMLNode, mTypes, mEntities, bAll, styleAttributes, true); } Node node = new Node(); node.type_ = mTypes["mstyle"]; node.attrs = new AttributeList(); for (int i = 0; i < XMLNode.Attributes.Count; i++) { node.attrs.Add(new Attribute(XMLNode.Attributes[i].Name, XMLNode.Attributes[i].Value, "")); } StyleAttributes fromNode = new StyleAttributes(); s = new StyleAttributes(); fromNode = AttributeBuilder.StyleAttrsFromNode(node, true); if (fromNode != null) { if (styleAttributes != null) { node.style_ = new StyleAttributes(); fromNode.CopyTo(node.style_); node.style_.canOverride = true; s = node.CascadeOverride(styleAttributes); } else { fromNode.CopyTo(s); } } else { if (styleAttributes != null) styleAttributes.CopyTo(s); } s.canOverride = true; XMLNode.Attributes.RemoveAll(); return Parse(XMLNode, mTypes, mEntities, bAll, s, true); }
public Node Parse(XmlNode XMLNode, Types mTypes, EntityManager mEntities, bool recurse, StyleAttributes styleAttributes, bool bParentShift) { bool hasSelect = false; bool hasSelectRight = false; Node result = null; if (!bParentShift) { xmlTagName = XMLNode.LocalName; namespaceURI = XMLNode.NamespaceURI; } int numAttrs = 0; if ((recurse && (XMLNode.Attributes != null)) && !bParentShift) { StyleAttributes attributes = ParseMStyle(XMLNode, style_); if (attributes != null) { if (style_ == null) { style_ = new StyleAttributes(); } attributes.CopyTo(style_); } numAttrs = XMLNode.Attributes.Count; if (numAttrs > 0) { if (attrs == null) { attrs = new AttributeList(); } for (int i = 0; i < numAttrs; i++) { if (XMLNode.Attributes[i].Name == "nugenCursor") { result = this; hasSelect = true; } else if (XMLNode.Attributes[i].Name == "nugenCursorEnd") { result = this; result.IsAppend = true; hasSelectRight = true; } else { attrs.Add(new Attribute(XMLNode.Attributes[i].Name, XMLNode.Attributes[i].Value, XMLNode.Attributes[i].NamespaceURI)); } } if (hasSelect) { XMLNode.Attributes.RemoveNamedItem("nugenCursor"); } if (hasSelectRight) { XMLNode.Attributes.RemoveNamedItem("nugenCursorEnd"); } } } if ((XMLNode.NodeType == XmlNodeType.Element) && !bParentShift) { if (type_ == null) { type_ = mTypes[xmlTagName]; } if ((hasSelect && (type_.type == ElementType.Mi)) && (literalText != null)) { InternalMark = literalText.Length; } } if (recurse && XMLNode.HasChildNodes) { XmlNodeList list = XMLNode.ChildNodes; for (int i = 0; i < list.Count; i++) { if (list[i].NodeType == XmlNodeType.Text) { if ((type_.type == ElementType.Mtext) || (type_.type == ElementType.Ms)) { literalText += list[i].Value; continue; } if (type_.type == ElementType.Mn) { literalText += list[i].Value.Trim(); continue; } if (type_.type == ElementType.Mi) { literalText += list[i].Value.Trim(); continue; } if (type_.type != ElementType.Mo) { continue; } string entityChar = list[i].Value.Trim(); bool isGlyph = false; try { Glyph glyph; if (! (((((entityChar != "(") && (entityChar != ")")) && ((entityChar != "[") && (entityChar != "]"))) && (((entityChar != "{") && (entityChar != "}")) && ((entityChar != "|") && (entityChar != "||")))) && (((entityChar != "+") && (entityChar != "-")) && ((entityChar != "=") && (entityChar != "/"))))) { string entityName = ""; switch (entityChar) { case "(": { entityName = "lpar"; break; } case ")": { entityName = "rpar"; break; } case "[": { entityName = "lbrack"; break; } case "]": { entityName = "rbrack"; break; } case "{": { entityName = "lbrace"; break; } case "}": { entityName = "rbrace"; break; } case "|": { entityName = "verbar"; break; } case "||": { entityName = "Verbar"; break; } case "+": { entityName = "plus"; break; } case "-": { entityName = "minus"; break; } case "=": { entityName = "equals"; break; } case "/": { entityName = "sol"; break; } } glyph = mEntities.ByName(entityName); if (glyph != null) { Node glyphNode = new Node(); glyphNode.type_ = mTypes["entity"]; glyphNode.literalText = "" + glyph.CharValue; glyphNode.fontFamily = glyph.FontFamily; glyphNode.glyph = glyph; glyphNode.xmlTagName = glyph.Name; AdoptChild(glyphNode); isGlyph = true; } } } catch { } if (!isGlyph) { literalText += entityChar; } continue; } if (list[i].NodeType == XmlNodeType.SignificantWhitespace) { continue; } if (list[i].NodeType == XmlNodeType.Whitespace) { if ((type_.type == ElementType.Mtext) || (type_.type == ElementType.Ms)) { literalText += " "; } continue; } if (list[i].NodeType == XmlNodeType.Element) { if ((list[i].NamespaceURI == "http://www.w3.org/1998/Math/MathML") && (list[i].LocalName == "mstyle")) { Node mstyl = ParseMstyle(list[i], mTypes, mEntities, recurse, styleAttributes); if (mstyl != null) { result = mstyl; } } else { Node n = new Node(XMLNode.Name, styleAttributes); n.type_ = mTypes[list[i].LocalName]; if (AdoptChild(n)) { Node sn = n.Parse(list[i], mTypes, mEntities, recurse, styleAttributes, false); if (sn != null) { result = sn; } } } continue; } if (list[i].NodeType == XmlNodeType.EntityReference) { Node n = new Node(); n.type_ = mTypes["entity"]; if ((type_.type == ElementType.Mtext) || (type_.type == ElementType.Ms)) { Glyph glyph = mEntities.ByName(list[i].LocalName); if (glyph != null) { char c = Convert.ToChar(Convert.ToUInt32(glyph.Code, 0x10)); if (char.IsWhiteSpace(c) || char.IsControl(c)) { literalText = literalText + " "; } else { literalText = literalText + c; } } } else { try { Glyph glyph = mEntities.ByName(list[i].LocalName); if (glyph != null) { n.literalText = ""; n.literalText = n.literalText + glyph.CharValue; n.fontFamily = glyph.FontFamily; n.glyph = glyph; n.xmlTagName = list[i].LocalName; } else { n.literalText = "?"; n.xmlTagName = list[i].LocalName; } AdoptChild(n); } catch { n.literalText = "?"; n.xmlTagName = list[i].LocalName; AdoptChild(n); } } } } } return result; }
public Node Parse(XmlNode XMLNode, Types mTypes, EntityManager mEntities, bool bAll, StyleAttributes styleAttributes) { return Parse(XMLNode, mTypes, mEntities, bAll, styleAttributes, false); }