Esempio n. 1
0
        internal PresentationLocator CreateCopyForMerging()
        {
            PresentationLocator copy = new PresentationLocator();

            copy.CopyLocatorBaseInformation(this);
            if (this.childDisplayOrder != null)
            {
                copy.childDisplayOrder = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childDisplayOrder)
                {
                    copy.childDisplayOrder[de1.Key] = de1.Value;
                }
            }

            if (this.childLocatorsByHRef != null)
            {
                copy.childLocatorsByHRef = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childLocatorsByHRef)
                {
                    ChildPresentationLocator cpl = de1.Value as ChildPresentationLocator;
                    copy.childLocatorsByHRef[de1.Key] = cpl.CreateCopyForMerging();
                }
            }


            //parent info udjused later
            copy.parents = this.parents;


            return(copy);
        }
Esempio n. 2
0
        /// <summary>
        /// UPDATE PRESENTATION LINK TO CHANGE AN ARC TO PROHIBITED
        /// </summary>
        /// <param name="elementToProhibit"></param>
        /// <param name="ParentNode"></param>
        /// <param name="isPresentation"></param>
        /// <returns></returns>
        public bool ProhibitArc(Node elementToProhibit,
                                Node ParentNode, bool isPresentation)
        {
            PresentationLocator parentLocator = locators[ParentNode.Id] as PresentationLocator;

            if (parentLocator == null)
            {
                return(false);
            }

            ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementToProhibit.Id] as ChildPresentationLocator;

            foreach (LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
            {
                if (((double)(lri.Order)).ToString("####0.####", new CultureInfo("en-US")).Equals(
                        elementToProhibit.order.ToString("####0.####", new CultureInfo("en-US"))) &&
                    (!isPresentation || lri.PrefLabel == elementToProhibit.PreferredLabel) &&
                    (isPresentation || lri.CalculationWeight == elementToProhibit.CalculationWeight) &&
                    lri.IsProhibited == false)
                {
                    //simply prohibit the link...
                    //when we reload the prohibited link would anyway superseed the optional one
                    lri.IsProhibited = true;
                    break;
                }
            }

            return(true);
        }
Esempio n. 3
0
        internal string GetLocatorLabel(Node childNode, ref int priority)
        {
            if (childLocatorsByHRef != null)
            {
                ChildPresentationLocator cpl = childLocatorsByHRef[childNode.Id] as ChildPresentationLocator;

                if (cpl != null)
                {
                    for (int i = cpl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                    {
                        LocatorRelationshipInfo lri = cpl.LocatorRelationshipInfos[i] as LocatorRelationshipInfo;

                        if (lri.Order == (float)childNode.order &&
                            lri.PrefLabel == childNode.PreferredLabel &&
                            lri.CalculationWeight == childNode.Weight)
                        {
                            priority = lri.Priority;
                            return(lri.Label);
                        }
                    }
                    LocatorRelationshipInfo netRel = cpl.NetRelationShipInfo;
                    priority = netRel.Priority;
                    return(netRel.Label);
                }
            }

            return(null);
        }
Esempio n. 4
0
        public void AddChild(PresentationLocator childPl, string label, string priority,
                             float orderArg, string prefLabel, string weight, bool isProhibited)
        {
            childPl.AddParent(this);

            if (this.childLocatorsByHRef == null)
            {
                this.childLocatorsByHRef = new HybridDictionary();
                this.childDisplayOrder   = new HybridDictionary();
            }


            LocatorRelationshipInfo newRelation = LocatorRelationshipInfo.CreateObj(label,
                                                                                    priority, orderArg, orderArg, prefLabel, weight, isProhibited);
            ChildPresentationLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildPresentationLocator;

            if (cpl == null)
            {
                // doesn't exist in either the href table or the order table
                cpl = new ChildPresentationLocator(childPl.HRef, newRelation);

                childLocatorsByHRef.Add(childPl.HRef, cpl);

                // keep these separate so they don't impact each other
                ChildPresentationLocator cplOrder = new ChildPresentationLocator(cpl);
            }
            else
            {
                // the cpl already exists, append the existing relation info
                cpl.AddRelationship(newRelation);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new instance of <see cref="ChildPresentationLocator"/>, copying properties
        /// from a parameter-supplied <see cref="ChildPresentationLocator"/>.
        /// </summary>
        /// <param name="cpl">A <see cref="ChildPresentationLocator"/> from which the properties
        /// of the new <see cref="ChildPresentationLocator"/> are to be copied.</param>
        public ChildPresentationLocator(ChildPresentationLocator cpl)
        {
            hRef = cpl.hRef;

            foreach (LocatorRelationshipInfo lri in cpl.locatorRelationshipInfos)
            {
                locatorRelationshipInfos.Add(lri);
            }
        }
Esempio n. 6
0
        public void Append(PresentationLocator arg)
        {
            if (arg.childLocatorsByHRef != null)
            {
                if (this.childLocatorsByHRef == null)
                {
                    this.childLocatorsByHRef = new HybridDictionary();
                    this.childDisplayOrder   = new HybridDictionary();
                }

                foreach (ChildPresentationLocator cpl in arg.childLocatorsByHRef.Values)
                {
                    ChildPresentationLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildPresentationLocator;

                    if (orig == null)
                    {
                        childLocatorsByHRef[cpl.HRef] = cpl;
                    }
                    else
                    {
                        foreach (LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
                        {
                            if (orig.CanAddRelationship(lri))
                            {
                                orig.AddRelationship(lri);
                            }
                        }
                    }
                }
            }


            if (arg.parents != null && arg.parents.Count > 0)
            {
                if (parents == null)
                {
                    parents = arg.parents;
                }
                else
                {
                    // unique parents only please
                    foreach (PresentationLocator parent in arg.Parents)
                    {
                        if (!parents.Contains(parent))
                        {
                            parents.Add(parent);
                        }
                    }
                }
            }

            foreach (string label in arg.labelArray)
            {
                AddLabel(label);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Add a new relationship between two locators...
        /// </summary>
        /// <param name="elementId"></param>
        /// <param name="parentElementId"></param>
        /// <param name="newLocatorRelationshipInfo"></param>
        /// <param name="taxonomy"></param>
        /// <returns></returns>
        public bool UpdateArc(string elementId, string parentElementId,
                              LocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy)
        {
            PresentationLocator parentLocator = locators[parentElementId] as PresentationLocator;


            if (parentLocator == null && !string.IsNullOrEmpty(parentElementId))
            {
                parentLocator           = new PresentationLocator();
                parentLocator.href      = parentElementId;
                parentLocator.MyElement = taxonomy.allElements[parentElementId] as Element;

                locators[parentElementId] = parentLocator;
            }

            PresentationLocator childLocator = locators[elementId] as PresentationLocator;

            if (childLocator == null)
            {
                childLocator           = new PresentationLocator();
                childLocator.href      = elementId;
                childLocator.MyElement = taxonomy.allElements[elementId] as Element;

                if (parentLocator != null)
                {
                    childLocator.AddParent(parentLocator);
                }
                locators[elementId] = childLocator;
            }

            if (parentLocator != null)
            {
                if (parentLocator.childLocatorsByHRef == null)
                {
                    parentLocator.childLocatorsByHRef = new HybridDictionary();
                }
                ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementId] as ChildPresentationLocator;
                if (cpl != null)
                {
                    cpl.AddRelationship(newLocatorRelationshipInfo);
                }
                else
                {
                    cpl = new ChildPresentationLocator(elementId, newLocatorRelationshipInfo);
                    parentLocator.childLocatorsByHRef[elementId] = cpl;
                }
            }



            return(true);
        }
Esempio n. 8
0
//		#region IComparable Members
//
//		public int CompareTo(object obj)
//		{
//			ChildPresentationLocator other  = (ChildPresentationLocator)obj;
//
//			return this.NetRelationShipInfo.Order.CompareTo( other.NetRelationShipInfo.Order );
//		}
//
//		#endregion


        internal ChildPresentationLocator CreateCopyForMerging()
        {
            ChildPresentationLocator ret = new ChildPresentationLocator();

            ret.hRef = this.hRef;
            ret.locatorRelationshipInfos = new ArrayList(this.locatorRelationshipInfos.Count);
            for (int i = 0; i < locatorRelationshipInfos.Count; i++)
            {
                ret.locatorRelationshipInfos.Add(new LocatorRelationshipInfo(locatorRelationshipInfos[i] as LocatorRelationshipInfo));
            }


            return(ret);
        }
Esempio n. 9
0
        /// <summary>
        /// Determines the next available priority within the locator relationship
        /// of a given child locator.
        /// </summary>
        /// <param name="childId">The id of the child for whom the next available locator
        /// relationship priority is to be returned.</param>
        /// <returns>The calculated next available priority.</returns>
        public int GetNextPriority(string childId)
        {
            if (childLocatorsByHRef != null)
            {
                ChildPresentationLocator cpl = childLocatorsByHRef[childId] as ChildPresentationLocator;

                if (cpl != null)
                {
                    int maxPriority = 0;
                    foreach (LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
                    {
                        maxPriority = Math.Max(lri.Priority, maxPriority);
                    }

                    return(maxPriority + 1);
                }
            }

            return(1);
        }
Esempio n. 10
0
        internal bool IsChildProhibited(string id, double order)
        {
            ChildPresentationLocator cpl = childLocatorsByHRef[id] as ChildPresentationLocator;

            if (cpl != null)
            {
                for (int i = cpl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                {
                    LocatorRelationshipInfo lri = cpl.LocatorRelationshipInfos[i] as LocatorRelationshipInfo;

                    if (lri.Order == order)
                    {
                        return(lri.IsProhibited);
                    }
                }

                return(cpl.NetRelationShipInfo.IsProhibited);
            }

            return(false);
        }