Esempio n. 1
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        ///     Merges the two anchors into one, if possible.
        /// </summary>
        /// <param name="anchor1">anchor to merge </param>
        /// <param name="anchor2">other anchor to merge </param>
        /// <param name="newAnchor">new anchor that contains the data from both
        /// anchor1 and anchor2</param>
        /// <returns>true if the anchors were merged, false otherwise
        /// </returns>
        /// <exception cref="ArgumentNullException">anchor1 or anchor2 are null</exception>
        public static bool MergeSelections(Object anchor1, Object anchor2, out Object newAnchor)
        {
            TextAnchor firstAnchor  = anchor1 as TextAnchor;
            TextAnchor secondAnchor = anchor2 as TextAnchor;

            if ((anchor1 != null) && (firstAnchor == null))
            {
                throw new ArgumentException(SR.Get(SRID.WrongSelectionType), "anchor1: type = " + anchor1.GetType().ToString());
            }

            if ((anchor2 != null) && (secondAnchor == null))
            {
                throw new ArgumentException(SR.Get(SRID.WrongSelectionType), "Anchor2: type = " + anchor2.GetType().ToString());
            }

            if (firstAnchor == null)
            {
                newAnchor = secondAnchor;
                return(newAnchor != null);
            }

            if (secondAnchor == null)
            {
                newAnchor = firstAnchor;
                return(newAnchor != null);
            }

            newAnchor = TextAnchor.ExclusiveUnion(firstAnchor, secondAnchor);

            return(true);
        }
Esempio n. 2
0
        // Token: 0x06007C32 RID: 31794 RVA: 0x0022EA90 File Offset: 0x0022CC90
        public static bool MergeSelections(object anchor1, object anchor2, out object newAnchor)
        {
            TextAnchor textAnchor  = anchor1 as TextAnchor;
            TextAnchor textAnchor2 = anchor2 as TextAnchor;

            if (anchor1 != null && textAnchor == null)
            {
                throw new ArgumentException(SR.Get("WrongSelectionType"), "anchor1: type = " + anchor1.GetType().ToString());
            }
            if (anchor2 != null && textAnchor2 == null)
            {
                throw new ArgumentException(SR.Get("WrongSelectionType"), "Anchor2: type = " + anchor2.GetType().ToString());
            }
            if (textAnchor == null)
            {
                newAnchor = textAnchor2;
                return(newAnchor != null);
            }
            if (textAnchor2 == null)
            {
                newAnchor = textAnchor;
                return(newAnchor != null);
            }
            newAnchor = TextAnchor.ExclusiveUnion(textAnchor, textAnchor2);
            return(true);
        }