コード例 #1
0
        private void itemControlAddRelationshipRequest(ItemControl sender, ItemType itemType)
        {
            var    bottomControls = sender.Item.Relationships.Select(relationship => _allItemControls[relationship]).ToList();
            double mostBottom     = bottomControls.Count > 0
                                ? bottomControls.Max(itemControl => itemControl.Item.Top + itemControl.ActualHeight)
                                : sender.Item.Top + sender.ActualHeight;

            var command = new AddRelationshipCommand(_project, sender.Item, itemType, sender.Item.Left + sender.ActualWidth * 2 / 3, mostBottom + 15);

            _project.PerformCommand(command);

            var relationshipControl = _allItemControls[command.NewRelationship];

            displayRelationship(sender, relationshipControl);
        }
コード例 #2
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  An IHyperstore extension method that creates a relationship.
        /// </summary>
        /// <exception cref="SessionRequiredException">
        ///  Thrown when a Session Required error condition occurs.
        /// </exception>
        /// <param name="store">
        ///  The store to act on.
        /// </param>
        /// <param name="schema">
        ///  The schema.
        /// </param>
        /// <param name="start">
        ///  The start.
        /// </param>
        /// <param name="end">
        ///  The end.
        /// </param>
        /// <param name="id">
        ///  (Optional) the identifier.
        /// </param>
        /// <returns>
        ///  The new relationship.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static IModelRelationship CreateRelationship(this IHyperstore store, ISchemaRelationship schema, IModelElement start, IModelElement end, Identity id = null)
        {
            Contract.Requires(store != null, "store");
            Contract.Requires(schema != null, "schema");
            Contract.Requires(start != null, "start");
            Contract.Requires(end != null, "end");
            if (Session.Current == null)
            {
                throw new SessionRequiredException();
            }

            var domain = start.DomainModel;
            var cmd    = new AddRelationshipCommand(schema, start, end, id);

            Session.Current.Execute(cmd);
            return(cmd.Relationship);
        }
コード例 #3
0
            public override bool Equals(object o)
            {
                if (this == o)
                {
                    return(true);
                }
                if (o == null || this.GetType() != o.GetType())
                {
                    return(false);
                }
                if (!base.Equals(o))
                {
                    return(false);
                }
                AddRelationshipCommand that = ( AddRelationshipCommand )o;

                return(StartNodeConflict == that.StartNodeConflict && EndNodeConflict == that.EndNodeConflict);
            }
コード例 #4
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  An IDomainModel extension method that creates a relationship.
        /// </summary>
        /// <exception cref="SessionRequiredException">
        ///  Thrown when a Session Required error condition occurs.
        /// </exception>
        /// <param name="domain">
        ///  the domain model.
        /// </param>
        /// <param name="schema">
        ///  The schema.
        /// </param>
        /// <param name="startId">
        ///  The start identifier.
        /// </param>
        /// <param name="endId">
        ///  The end identifier.
        /// </param>
        /// <param name="id">
        ///  (Optional) the identifier.
        /// </param>
        /// <returns>
        ///  The new relationship.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static IModelRelationship CreateRelationship(this IDomainModel domain, ISchemaRelationship schema, Identity startId, Identity endId, Identity id = null)
        {
            Contract.Requires(domain != null, "domain");
            Contract.Requires(schema != null, "schema");
            Contract.Requires(startId != null, "startId");
            Contract.Requires(endId != null, "endId");

            if (Session.Current == null)
            {
                throw new SessionRequiredException();
            }

            var start = domain.GetElement(startId);

            if (start == null)
            {
                throw new InvalidElementException(startId);
            }

            var cmd = new AddRelationshipCommand(schema, start, endId, id);

            Session.Current.Execute(cmd);
            return(cmd.Relationship);
        }