Exemplo n.º 1
0
        public virtual Size GetBorderOffset()
        {
            if (this.element.cachedBorderOffset == LayoutUtils.InvalidSize)
            {
                SizeF       borderSize = SizeF.Empty;
                IBoxElement parentBox  = this.Parent as IBoxElement;
                if ((parentBox != null) && (this.Parent.Visibility != ElementVisibility.Collapsed))
                {
                    borderSize = parentBox.Offset;
                }

                if (this.element is IBoxElement)
                {
                    return(borderSize.ToSize());
                }

                //Fix
                if (this.element is FillPrimitive)
                {
                    return(borderSize.ToSize());
                }

                SizeF childBorderSize = this.GetMaxChildBorderOffset();

                if (childBorderSize != SizeF.Empty)
                {
                    borderSize = SizeF.Add(borderSize, childBorderSize);
                }

                this.element.cachedBorderOffset = borderSize.ToSize();
            }

            return(this.element.cachedBorderOffset);
        }
Exemplo n.º 2
0
		/// <summary> Gets the index in the specified element to which this instance points. Throws if the specified element does not contain this index. Never returns InternalIndex.Last.  </summary>
		/// <param name="element"> The element to get the internal index in of this instance. </param>
		public InternalIndex GetIndexIn(IBoxElement element)
		{
#if DEBUG
			// ReSharper disable once UnusedVariable
			var DEBUGRESULT = element.Box.Elements.IndexOf(element);
#endif

			//there are four options:
			//firstly, the element is the one references by this.ElementIndex. In that case, the correct internal index is this.IndexInElement
			if (ElementIsAt(this.ElementIndex, element))
				return this.IndexInElement.MakeLastExplicit(element);

			//secondly, if this.IndexInElement == 0, then the element could be at ElementIndex - 1, in which case InternalIndex.Last is the correct solution
			if (this.IndexInElement == 0 && ElementIsAt(this.ElementIndex - 1, element))
				return InternalIndex.Last.MakeLastExplicit((IBoxElement)element.Box[ElementIndex - 1]);

			//thirdly, the specified element could be the one after the element references by ElementIndex. The answer is then InternalIndex.Zero, if the current IndexInElement is at the last position, 
			if (ElementIsAt(this.ElementIndex + 1, element))
			{
				//check whether the index in the currently references element is at the last position
				if (this.IndexInElement == InternalIndex.Last)
					return InternalIndex.First;
				if (this.ElementIndex != 0 && ((IBoxElement)element.Box[ElementIndex - 1]).CaretPositionCount == IndexInElement)
					return InternalIndex.First;
			}

			//lastly, the specified element cannot possibly contain this index
			throw new ContractException("The specified element does not contain this index. ");
		}
Exemplo n.º 3
0
        private SizeF GetMaxChildBorderNumber(RadElement parent, bool getAsSize)
        {
            if (parent == null)
            {
                return(SizeF.Empty);
            }

            SizeF maxBorderSize = SizeF.Empty;

            foreach (RadElement child in parent.GetChildren(ChildrenListOptions.Normal))
            {
                if ((parent == this.Parent) && (child == this.element))
                {
                    continue;
                }

                IBoxElement childBox = child as IBoxElement;

                if (childBox == null)
                {
                    continue;
                }

                if (child.LayoutableChildrenCount != 0)
                {
                    continue;
                }

                maxBorderSize.Width  = Math.Max(maxBorderSize.Width, (getAsSize ? childBox.HorizontalWidth : childBox.Offset.Width));
                maxBorderSize.Height = Math.Max(maxBorderSize.Height, (getAsSize ? childBox.VerticalWidth : childBox.Offset.Height));
            }

            return(maxBorderSize);
        }
Exemplo n.º 4
0
        public virtual Size GetBorderSize()
        {
            if (this.element.cachedBorderSize == LayoutUtils.InvalidSize)
            {
                SizeF borderSize = SizeF.Empty;

                IBoxElement elementBox = this.element as IBoxElement;
                if ((elementBox != null) && (this.element.Visibility != ElementVisibility.Collapsed))
                {
                    borderSize = elementBox.BorderSize;
                }

                SizeF childBorderSize = GetMaxChildBorder();

                if (childBorderSize != SizeF.Empty)
                {
                    borderSize = SizeF.Add(borderSize, childBorderSize);
                }

                this.element.cachedBorderSize = borderSize.ToSize();
            }

            return(this.element.cachedBorderSize);
        }
Exemplo n.º 5
0
		/// <summary> If this index is the special value "Last", then its explicit value is returned. Otherwise, its this instance is simply returned. </summary>
		/// <param name="element"> The element in which this index points. </param>
		internal InternalIndex MakeLastExplicit(IBoxElement element)
		{
			if (this == Last)
				return (InternalIndex)Math.Max(0, element.CaretPositionCount - 1);
			return this;
		}
Exemplo n.º 6
0
		public ExplicitIndex(IBoxElement element, InternalIndex indexInElement)
			: this()
		{
			Contract.Requires(element != null);
			this.ElementIndex = element.Box.Elements.IndexOf(element);
			Contract.Requires(this.ElementIndex != -1, "The specified element is not in the specified box. ");
			this.IndexInElement = indexInElement;
		}
Exemplo n.º 7
0
		/// <summary> Returns whether the specified element is at the specified index in that element's Box. Returns false if the index is out of range in the element.Box.Elements collection. </summary>
		/// <param name="element"> The element to check to be present at the specified index. </param>
		/// <param name="index"> The index to be checked for being in range and pointing to the specified element. </param>
		private static bool ElementIsAt(ElementIndex index, IBoxElement element)
		{
			return 0 <= index
				&& index < element.Box.Elements.ElementCount
				&& element.Box[index] == element;
		}
Exemplo n.º 8
0
		/// <summary> Gets the element index of the specified element. </summary>
		public ElementIndex(IBoxElement element) : this()
		{
			//this ctor is just syntactic sugar
			Contract.Requires(element != null);
			this = element.Box.Elements.IndexOf(element);
		}