コード例 #1
0
        XShape getNextSiblingByXShape()
        {
            if (Shape != null && Shape is XChild)
            {
                XShapes parent = getParentByXShape();
                if (parent != null && parent.hasElements())
                {
                    int childCount = ((XShapes)parent).getCount();
                    if (childCount > 0)
                    {
                        //string current_name = Name;

                        bool lastWasCurrent = false;
                        //find this child
                        for (int i = 0; i < childCount; i++)
                        {
                            var c = parent.getByIndex(i).Value;

                            if (lastWasCurrent && c != null && c is XShape)
                            {
                                return(c as XShape);
                            }
                            if (c == Shape)
                            {
                                lastWasCurrent = true;
                            }
                        }
                        // if no child was in front, return the las child at all
                        return(getChildByXShape(0, parent as XShapes));
                    }
                }
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Gets the previous sibling by X shape.
        /// </summary>
        XShape getPreviousSiblingByXShape()
        {
            if (Shape != null && Shape is XChild)
            {
                XShapes parent = getParentByXShape();
                if (parent != null && parent.hasElements())
                {
                    int childCount = parent.getCount();
                    if (childCount > 0)
                    {
                        //string current_name = Name;

                        XShape lastChild = null;
                        //find this child
                        for (int i = 0; i < childCount; i++)
                        {
                            var c = ((XShapes)parent).getByIndex(i).Value;

                            if (c == Shape)
                            {
                                if (lastChild != null)
                                {
                                    return(lastChild);
                                }
                            }
                            else if (c is XShape)
                            {
                                lastChild = c as XShape;
                            }
                        }

                        // if no child was in front, return the las child at all
                        return(getChildByXShape(-1, parent as XShapes));
                    }
                }
            }
            return(null);
        }