Beispiel #1
0
        public IBlock FindNodeById(string id)
        {
            if (id == ID)
            {
                return(this);
            }
            else
            {
                if (null != RootIndex)
                {
                    var node = RootIndex.FindNodeById(id);
                    if (null != node)
                    {
                        return(node);
                    }
                }

                if (null != Radicand)
                {
                    var deNode = Radicand.FindNodeById(id);
                    if (null != deNode)
                    {
                        return(deNode);
                    }
                }

                return(null);
            }
        }
Beispiel #2
0
 private Size GetRootIndexSize()
 {
     if (null == RootIndex)
     {
         return(new Size(FontManager.Instance.FontSize / 2, FontManager.Instance.FontSize));
     }
     else
     {
         return(RootIndex.GetSize());
     }
 }
Beispiel #3
0
        public void RemoveChild(IBlock block)
        {
            if (null != RootIndex)
            {
                RootIndex.RemoveChild(block);;
            }

            if (null != Radicand)
            {
                Radicand.RemoveChild(block);
            }
        }
Beispiel #4
0
        public void GetElementBeforeCaret(Point caretLocation)
        {
            if (null != RootIndex)
            {
                RootIndex.GetElementBeforeCaret(caretLocation);
            }

            if (null != Radicand)
            {
                Radicand.GetElementBeforeCaret(caretLocation);
            }
        }
Beispiel #5
0
 public void AddChildrenAfterBlock(IBlock block, IEnumerable <IBlock> inputCharactors)
 {
     if (RootIndex != null && RootIndex.Children.Contains(block))
     {
         RootIndex.AddChildrenAfterBlock(block, inputCharactors);
     }
     if (Radicand != null)
     {
         if (Radicand.Children.Contains(block))
         {
             Radicand.AddChildrenAfterBlock(block, inputCharactors);
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PaletteBailout.GetHashCode();
         hashCode = (hashCode * 397) ^ MaxIterationColor.GetHashCode();
         hashCode = (hashCode * 397) ^ PaletteScale.GetHashCode();
         hashCode = (hashCode * 397) ^ Shift.GetHashCode();
         hashCode = (hashCode * 397) ^ LogIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ RootIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ Root.GetHashCode();
         hashCode = (hashCode * 397) ^ MinIterations;
         hashCode = (hashCode * 397) ^ IndexScale.GetHashCode();
         hashCode = (hashCode * 397) ^ Weight.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #7
0
        public XElement Serialize()
        {
            var      typeFraction = (new Radical()).GetType();
            XElement fraction     = new XElement("Radical");
            XElement molecule     = new XElement("RootIndex");
            XElement denominator  = new XElement("Radicand");

            XElement rootIndexBlockNode = RootIndex.Serialize();

            molecule.Add(rootIndexBlockNode);

            XElement radicandBlockNode = Radicand.Serialize();

            denominator.Add(radicandBlockNode);

            fraction.Add(molecule);
            fraction.Add(denominator);
            return(fraction);
        }
Beispiel #8
0
        public void SetBlockLocation(double locationX, double alignmentCenterY, double rowY)
        {
            var    rootindexSize = GetRootIndexSize();
            double rootIndexY    = alignmentCenterY - GetVerticalAlignmentCenter();

            this.Location = new Point(locationX, rootIndexY);
            if (null != RootIndex)
            {
                RootIndex.Location = new Point(locationX, rootIndexY);
                var rootIndexVerticalCenter = RootIndex.GetVerticalAlignmentCenter();
                RootIndex.SetBlockLocation(locationX, RootIndex.Location.Y + rootIndexVerticalCenter, rowY);
            }

            if (null != Radicand)
            {
                Radicand.Location = new Point(locationX + rootindexSize.Width + 10, this.Location.Y + rootindexSize.Height / 3);
                double radicandVerticalCenter = Radicand.GetVerticalAlignmentCenter();
                Radicand.SetBlockLocation(Radicand.Location.X, Radicand.Location.Y + radicandVerticalCenter, rowY);
            }
        }
Beispiel #9
0
        public IBlock GetCaretBrotherElement(bool before, Point caretPoint)
        {
            if (null != RootIndex)
            {
                var block = RootIndex.GetCaretBrotherElement(before, caretPoint);
                if (null != block)
                {
                    return(block);
                }
            }

            if (null != Radicand)
            {
                var block = Radicand.GetCaretBrotherElement(before, caretPoint);
                if (null != block)
                {
                    return(block);
                }
            }

            return(null);
        }
Beispiel #10
0
        public void AddChildren(IEnumerable <IBlock> inputCharactors, Point caretPoint, string parentId)
        {
            if (IsRootIndexContains(caretPoint))
            {
                if (null == RootIndex)
                {
                    RootIndex          = new BlockNode();
                    RootIndex.ParentId = ID;
                }
                RootIndex.AddChildren(inputCharactors, caretPoint, parentId);
            }

            if (IsRadicandContains(caretPoint))
            {
                if (null == Radicand)
                {
                    Radicand          = new BlockNode();
                    Radicand.ParentId = ID;
                }
                Radicand.AddChildren(inputCharactors, caretPoint, parentId);
            }
        }
Beispiel #11
0
        public void DrawBlock(Canvas canvas)
        {
            Polyline radicalPolyline = CreateRadicalPolyline();

            var rootIndexRect      = GetRootIndexRect();
            var rootIndexRectangle = CreateRangeRect(rootIndexRect);

            var radicandRect      = GetRadicandRect();
            var radicandRectangle = CreateRangeRect(radicandRect);

            canvas.Children.Add(rootIndexRectangle);
            canvas.Children.Add(radicandRectangle);

            canvas.Children.Add(radicalPolyline);
            if (null != RootIndex)
            {
                RootIndex.DrawBlock(canvas);
            }

            if (null != Radicand)
            {
                Radicand.DrawBlock(canvas);
            }
        }
Beispiel #12
0
        public double GetVerticalAlignmentCenter()
        {
            Size rootIndexSize;

            if (null == RootIndex)
            {
                rootIndexSize = new Size(12, FontManager.Instance.FontSize);
            }
            else
            {
                rootIndexSize = RootIndex.GetSize();
            }


            if (null == Radicand)
            {
                return(FontManager.Instance.FontSize / 2 + rootIndexSize.Height / 3);
            }
            else
            {
                double verticalCenter = Radicand.GetVerticalAlignmentCenter();
                return(verticalCenter + rootIndexSize.Height / 3);
            }
        }