Esempio n. 1
0
        public override void FillCopy(ViewHelper copy, IDictionary <Element, Element> modelMap)
        {
            base.FillCopy(copy, modelMap);

            AssociationEndViewHelper copyAssociationEndViewHelper = (AssociationEndViewHelper)copy;

            this.MultiplicityLabelViewHelper.FillCopy(copyAssociationEndViewHelper.MultiplicityLabelViewHelper, modelMap);
            this.RoleLabelViewHelper.FillCopy(copyAssociationEndViewHelper.RoleLabelViewHelper, modelMap);
            copyAssociationEndViewHelper.Points.AppendRangeAsCopy(this.Points);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates <see cref="AssociationEndViewHelper"/> for each <paramref name="association"/>'s end.
        /// </summary>
        /// <param name="association">model association</param>
        public void CreateEndsViewHelpers(Association association)
        {
            #region validate operation
            foreach (AssociationEnd associationEnd in association.Ends)
            {
                if (!Diagram.IsElementPresent(associationEnd.Class))
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "Association cannot be visualized on the diagram, association end {0} is not included in the diagram.",
                                  associationEnd));
                }
            }
            #endregion

            //associationEndsViewHelpers.Clear();

            List <AssociationEndViewHelper> used = new List <AssociationEndViewHelper>();

            // add new ends
            foreach (AssociationEnd associationEnd in association.Ends)
            {
                AssociationEndViewHelper endViewHelper = associationEndsViewHelpers.Where(helper => helper.AssociationEnd == associationEnd).SingleOrDefault();

                if (endViewHelper == null)
                {
                    endViewHelper = new AssociationEndViewHelper(Diagram, this, associationEnd);
                    associationEndsViewHelpers.Add(endViewHelper);
                }

                used.Add(endViewHelper);
            }

            if (used.Count == 2 && associationEndsViewHelpers.Count > 2 && UseDiamond)
            {
                associationEndsViewHelpers[0].Points.Clear();
            }

            associationEndsViewHelpers.RemoveAll(helper => !used.Contains(helper));

            if (association.Ends.Count > 2 || ForceUseDiamond)
            {
                UseDiamond = true;
            }
            else
            {
                UseDiamond = false;
            }
        }
Esempio n. 3
0
        public override void FillCopy(ViewHelper copy, IDictionary <Element, Element> modelMap)
        {
            AssociationViewHelper copyAssociationViewHelper = (AssociationViewHelper)copy;

            copyAssociationViewHelper.UseDiamond = UseDiamond;

            MainLabelViewHelper.FillCopy(copyAssociationViewHelper.MainLabelViewHelper, modelMap);

            for (int i = 0; i < AssociationEndsViewHelpers.Count; i++)
            {
                AssociationEndViewHelper associationEndViewHelper = AssociationEndsViewHelpers[i];
                AssociationEnd           copyEnd = ((Association)Map(associationEndViewHelper.AssociationEnd.Association, modelMap)).Ends[i];
                System.Diagnostics.Debug.Assert(copyEnd.Class == Map(associationEndViewHelper.AssociationEnd.Class, modelMap));
                AssociationEndViewHelper endViewHelperCopy = new AssociationEndViewHelper(copy.Diagram, copyAssociationViewHelper, copyEnd);
                associationEndViewHelper.FillCopy(endViewHelperCopy, modelMap);
                copyAssociationViewHelper.AssociationEndsViewHelpers.Add(endViewHelperCopy);
            }

            base.FillCopy(copy, modelMap);
        }