コード例 #1
0
ファイル: Node_setprops.cs プロジェクト: philipxyc/NuGenEQML
 public void ClearStyle()
 {
     style_ = null;
     try
     {
         if (!HasChildren())
         {
             return;
         }
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             try
             {
                 if (node.type_.type != ElementType.Entity)
                 {
                     node.ClearStyle();
                 }
             }
             catch
             {
             }
         }
     }
     catch
     {
     }
 }
コード例 #2
0
ファイル: Node_setprops.cs プロジェクト: philipxyc/NuGenEQML
 public void SetScale(double scaling)
 {
     if (style_ == null)
     {
         style_ = new StyleAttributes();
     }
     if (scaling == 1)
     {
         style_.hasSize     = false;
         style_.size        = "";
         style_.scale       = 1;
         style_.canOverride = true;
     }
     else
     {
         style_.hasSize = true;
         style_.scale   = scaling;
         string size = (scaling * 100).ToString();
         size               = size.Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".");
         size               = size + "%";
         style_.size        = size;
         style_.canOverride = true;
     }
     if (HasChildren())
     {
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             if (node.type_.type != ElementType.Entity)
             {
                 node.SetScale(scaling);
             }
         }
     }
 }
コード例 #3
0
ファイル: Node_tree.cs プロジェクト: philipxyc/NuGenEQML
        public void UpdateChildrenIndices()
        {
            NodesList list  = GetChildrenNodes();
            Node      node  = list.Next();
            int       index = 0;

            while (node != null)
            {
                node.childIndex = index;
                node            = list.Next();
                index++;
            }
            numChildren = index;
        }
コード例 #4
0
ファイル: Node_tree.cs プロジェクト: philipxyc/NuGenEQML
 public void UpdateLevel()
 {
     if (firstChild != null)
     {
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             node.level = level + 1;
             if (node.firstChild != null)
             {
                 node.UpdateLevel();
             }
         }
     }
 }
コード例 #5
0
ファイル: Node_tree.cs プロジェクト: philipxyc/NuGenEQML
 public void EmbraceParent()
 {
     if (firstChild != null)
     {
         NodesList list = GetChildrenNodes();
         for (Node n = list.Next(); n != null; n = list.Next())
         {
             n.parent_ = this;
             if (n.firstChild != null)
             {
                 n.EmbraceParent();
             }
         }
     }
 }
コード例 #6
0
        public void PositionPass()
        {
            if (((box != null)))
            {
                box.SetPosition(this);

                NodesList list = GetChildrenNodes();
                for (Node node = list.Next(); node != null; node = list.Next())
                {
                    box.UpdateChildPosition(node);


                    node.PositionPass();
                }
            }
        }
コード例 #7
0
        public void print(Rectangle rect, PaintMode printMode, Color MathColor)
        {
            try
            {
                if (box == null)
                {
                    return;
                }

                box.Draw(this, printMode, MathColor);

                NodesList nodesList  = GetChildrenNodes();
                Node      node       = nodesList.Next();
                bool      notOnWhite = false;

                while (node != null)
                {
                    if (!notOnWhite &&
                        (((type_.type == ElementType.Math) ||
                          (type_.type == ElementType.Mtd)) ||
                         (type_.type == ElementType.Mrow)))
                    {
                        notOnWhite = node.NotOnWhite();
                    }
                    if (node.isVisible && (node.type_.type != ElementType.Mphantom))
                    {
                        node.print(rect, printMode, MathColor);
                    }
                    node = nodesList.Next();
                }

                if ((printMode == PaintMode.BACKGROUND))
                {
                    if (!notOnWhite ||
                        (((type_.type != ElementType.Math) &&
                          (type_.type != ElementType.Mtd)) &&
                         (type_.type != ElementType.Mrow)))
                    {
                        return;
                    }
                    ((BaseBox)box).painter_.FillBackground(this);
                }
            }
            catch
            {
            }
        }
コード例 #8
0
ファイル: Node_setprops.cs プロジェクト: philipxyc/NuGenEQML
 public void SetColor(Color _color)
 {
     if (style_ == null)
     {
         style_ = new StyleAttributes();
     }
     style_.canOverride = true;
     style_.color       = _color;
     style_.hasColor    = true;
     if (HasChildren())
     {
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             node.SetColor(_color);
         }
     }
 }
コード例 #9
0
        public Node NodeAtPoint(Point p, CaretLocation result)
        {
            NodesList list = GetChildrenNodes();

            for (Node n = list.Next(); n != null; n = list.Next())
            {
                if (n.GetCaretPos(p) != CaretPosition.None)
                {
                    return(n.NodeAtPoint(p, result));
                }
            }

            result.pos = GetCaretPos(p);
            if (result.pos == CaretPosition.None)
            {
                return(null);
            }
            return(this);
        }
コード例 #10
0
 public void PropogateYOffset()
 {
     if (yOffset != 0)
     {
         box.Y = box.Y + yOffset;
     }
     if ((yOffset != 0))
     {
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             if (yOffset != 0)
             {
                 node.yOffset = yOffset;
             }
             node.PropogateYOffset();
         }
     }
     yOffset = 0;
 }
コード例 #11
0
ファイル: Node_setprops.cs プロジェクト: philipxyc/NuGenEQML
 public void SetStyle(StyleAttributes styleAttributes)
 {
     if (style_ == null)
     {
         style_ = new StyleAttributes();
     }
     styleAttributes.CopyTo(style_);
     style_.canOverride = true;
     if (HasChildren())
     {
         NodesList list = GetChildrenNodes();
         for (Node child = list.Next(); child != null; child = list.Next())
         {
             if (child.type_.type != ElementType.Entity)
             {
                 child.SetStyle(styleAttributes);
             }
         }
     }
 }
コード例 #12
0
        public NodesList GetChildrenNodes()
        {
            NodesList list = new NodesList();

            if (HasChildren())
            {
                Node node    = firstChild;
                Node sibling = null;
                if (node != null)
                {
                    sibling = node.nextSibling;
                    list.Add(node);
                }
                while (sibling != null)
                {
                    list.Add(sibling);
                    sibling = sibling.nextSibling;
                }
            }
            return(list);
        }
コード例 #13
0
ファイル: Node_setprops.cs プロジェクト: philipxyc/NuGenEQML
 public void SetBackground(Color _color)
 {
     if (style_ == null)
     {
         style_ = new StyleAttributes();
     }
     style_.canOverride   = true;
     style_.background    = _color;
     style_.hasBackground = true;
     if (HasChildren())
     {
         NodesList list = GetChildrenNodes();
         for (Node node = list.Next(); node != null; node = list.Next())
         {
             if (node.type_.type != ElementType.Entity)
             {
                 node.SetBackground(_color);
             }
         }
     }
 }
コード例 #14
0
ファイル: Node.cs プロジェクト: xuchuansheng/GenXSource
 public NodesList GetChildrenNodes()
 {
     NodesList list = new NodesList();
     if (HasChildren())
     {
         Node node = firstChild;
         Node sibling = null;
         if (node != null)
         {
             sibling = node.nextSibling;
             list.Add(node);
         }
         while (sibling != null)
         {
             list.Add(sibling);
             sibling = sibling.nextSibling;
         }
     }
     return list;
 }
コード例 #15
0
        public void MeasurePass(Painter g)
        {
            if (parent_ != null)
            {
                level = parent_.level + 1;
            }
            int  x      = 0;
            int  y      = 0;
            bool hasBox = false;

            if ((box != null))
            {
                hasBox = true;
                x      = box.X;
                y      = box.Y;
            }

            if ((((box == null) || ((level < 2))) || ((level == 2))) || ((level > 2)))
            {
                BoxBuilder.MakeBox(this, g);
            }
            if ((type_ != null) && (type_.type == ElementType.Math))
            {
                PushdownStyleScript();
            }

            if (hasBox)
            {
                box.X = x;
                box.Y = y;
            }


            NodesList list = GetChildrenNodes();
            Node      n    = list.Next();

            if ((style_ != null) && (style_.size.Length > 0))
            {
                try
                {
                    style_.scale = StyleAttributes.FontScale(style_.size, (double)g.GetSuitableFont(this, style_).SizeInPoints);
                    style_.size  = "";
                }
                catch
                {
                }
            }
            if ((style_ != null))
            {
                if (type_.type == ElementType.Math)
                {
                    style_.isTop = true;
                }
                else if (style_.canOverride)
                {
                    style_.isTop = false;
                }
            }
            while (n != null)
            {
                if (style_ != null)
                {
                    if (((n.style_ != null) && n.style_.canOverride) && n.IsSameStyleParent())
                    {
                        n.CombineStyles(n.style_, style_);
                    }
                    else if (n.type_.type == ElementType.Entity)
                    {
                        n.style_ = null;
                    }
                    else
                    {
                        try
                        {
                            StyleAttributes style = n.CascadeOverride(style_);
                            if (style != null)
                            {
                                if (type_.type == ElementType.Math)
                                {
                                    style.fontFamily  = "";
                                    style.isUnderline = false;
                                }
                                n.style_ = new StyleAttributes();
                                style.CopyTo(n.style_);
                                if ((style_ != null) && style_.isTop)
                                {
                                    n.style_.canOverride = false;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                n.MeasurePass(g);
                box.setChildSize(n);
                n = list.Next();
            }

            if (((((level < 2)) || ((level == 2))) || ((level > 2))))
            {
                box.getSize(this);
            }
        }
コード例 #16
0
        private void PushdownStyleScript()
        {
            if ((type_ != null))
            {
                bool overrodeParentDispStyle = false;
                bool overrodeScriptLevel     = false;
                bool overrodePlus            = false;
                bool overrodeMinus           = false;
                int  plusValue  = 0;
                int  minusValue = 0;

                if (type_.type == ElementType.Math)
                {
                    scriptLevel_ = 0;
                }
                else if (style_ != null)
                {
                    DisplayStyle ownDispStyle       = style_.displayStyle;
                    DisplayStyle parentDisplayStyle = DisplayStyle.AUTOMATIC;

                    if ((parent_ != null) && (parent_.style_ != null))
                    {
                        parentDisplayStyle = parent_.style_.displayStyle;
                    }

                    if ((ownDispStyle != DisplayStyle.AUTOMATIC) && (ownDispStyle != parentDisplayStyle))
                    {
                        if (style_.displayStyle == DisplayStyle.TRUE)
                        {
                            displayStyle            = true;
                            overrodeParentDispStyle = true;
                        }
                        else if (style_.displayStyle == DisplayStyle.FALSE)
                        {
                            displayStyle            = false;
                            overrodeParentDispStyle = true;
                        }
                    }
                    else
                    {
                        displayStyle = parent_.displayStyle;
                    }

                    ScriptLevel ownscriptLevel    = style_.scriptLevel;
                    ScriptLevel parentScriptLevel = ScriptLevel.NONE;

                    if ((parent_ != null) && (parent_.style_ != null))
                    {
                        parentScriptLevel = parent_.style_.scriptLevel;
                    }
                    if ((ownscriptLevel != ScriptLevel.NONE) && (ownscriptLevel != parentScriptLevel))
                    {
                        if (style_.scriptLevel == ScriptLevel.ZERO)
                        {
                            scriptLevel_        = 0;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.ONE)
                        {
                            scriptLevel_        = 1;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.TWO)
                        {
                            scriptLevel_        = 2;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.PLUS_ONE)
                        {
                            overrodePlus = true;
                            minusValue   = 1;
                        }
                        else if (style_.scriptLevel == ScriptLevel.PLUS_TWO)
                        {
                            overrodePlus = true;
                            minusValue   = 2;
                        }
                        else if (style_.scriptLevel == ScriptLevel.MINUS_ONE)
                        {
                            overrodeMinus = true;
                            plusValue     = 1;
                        }
                        else if (style_.scriptLevel == ScriptLevel.MINUS_TWO)
                        {
                            overrodeMinus = true;
                            plusValue     = 2;
                        }
                    }
                    else
                    {
                        scriptLevel_ = parent_.scriptLevel_;
                    }
                }

                if (((type_.type != ElementType.Math) && (parent_ != null)) && (parent_.type_ != null))
                {
                    if (!overrodeParentDispStyle)
                    {
                        displayStyle = parent_.displayStyle;
                    }
                    if (!overrodeScriptLevel)
                    {
                        scriptLevel_ = parent_.scriptLevel_;
                    }

                    if ((((parent_.type_.type == ElementType.Mover) ||
                          (parent_.type_.type == ElementType.Munder)) ||
                         ((parent_.type_.type == ElementType.Munderover) ||
                          (parent_.type_.type == ElementType.Msub))) ||
                        (((parent_.type_.type == ElementType.Msup) ||
                          (parent_.type_.type == ElementType.Mmultiscripts)) ||
                         (parent_.type_.type == ElementType.Msubsup)))
                    {
                        if (childIndex > 0)
                        {
                            if (!overrodeScriptLevel)
                            {
                                scriptLevel_ = parent_.scriptLevel_ + 1;
                            }
                            if (!overrodeParentDispStyle)
                            {
                                displayStyle = false;
                            }
                        }
                    }
                    else if (parent_.type_.type == ElementType.Mroot)
                    {
                        if ((childIndex > 0) && !overrodeScriptLevel)
                        {
                            scriptLevel_ = parent_.scriptLevel_ + 2;
                        }
                    }
                    else if (parent_.type_.type == ElementType.Mfrac)
                    {
                        if (parent_.displayStyle)
                        {
                            if (!overrodeScriptLevel)
                            {
                                scriptLevel_ = parent_.scriptLevel_;
                            }
                        }
                        else if (!overrodeScriptLevel)
                        {
                            scriptLevel_ = parent_.scriptLevel_ + 1;
                        }
                        if (!overrodeParentDispStyle)
                        {
                            displayStyle = false;
                        }
                    }
                }
                if (overrodePlus)
                {
                    scriptLevel_ += plusValue;
                    scriptLevel_  = Math.Min(scriptLevel_, 2);
                }
                if (overrodeMinus)
                {
                    scriptLevel_ -= minusValue;
                    scriptLevel_  = Math.Max(scriptLevel_, 0);
                }
            }

            NodesList list = GetChildrenNodes();

            for (Node child = list.Next(); child != null; child = list.Next())
            {
                child.PushdownStyleScript();
            }

            scriptLevel_ = Math.Min(scriptLevel_, 2);
            scriptLevel_ = Math.Max(scriptLevel_, 0);
        }