예제 #1
0
        /// <summary>
        /// Update the drag state when the payload is a <see cref="ParameterGroup"/>
        /// </summary>
        /// <param name="dropInfo">The <see cref="IDropInfo"/> to update</param>
        /// <param name="group">The <see cref="ParameterGroup"/> payload</param>
        private void DragOver(IDropInfo dropInfo, ParameterGroup group)
        {
            if (group.Container == this.Thing.Container)
            {
                if (this.Thing.Group == null)
                {
                    dropInfo.Effects = DragDropEffects.Move;
                    return;
                }

                var containedGroups = group.ContainedGroup(true).ToList();
                if (group != this.Thing.Group && !containedGroups.Contains(this.Thing.Group))
                {
                    if (!this.PermissionService.CanWrite(group))
                    {
                        dropInfo.Effects = DragDropEffects.None;
                        return;
                    }

                    dropInfo.Effects = DragDropEffects.Move;
                    return;
                }
            }

            dropInfo.Effects = DragDropEffects.None;
        }
예제 #2
0
        public void VerifyThatContainedGroupsDeepReturnsGroupsThatAreContained()
        {
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null);

            var parameterGroup_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1);
            var parameterGroup_2 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_2);

            var parameterGroup_1_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_1);
            parameterGroup_1_1.ContainingGroup = parameterGroup_1;

            var parameterGroup_1_2 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_2);
            parameterGroup_1_2.ContainingGroup = parameterGroup_1;

            var parameterGroup_1_1_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_1_1);
            parameterGroup_1_1_1.ContainingGroup = parameterGroup_1_1;

            Assert.IsEmpty(parameterGroup_2.ContainedGroup(true));

            Assert.IsFalse(parameterGroup_1.ContainedGroup(true).Contains(parameterGroup_1));
            Assert.IsTrue(parameterGroup_1.ContainedGroup(true).Contains(parameterGroup_1_1));
            Assert.IsTrue(parameterGroup_1.ContainedGroup(true).Contains(parameterGroup_1_2));
            Assert.IsTrue(parameterGroup_1.ContainedGroup(true).Contains(parameterGroup_1_1_1));
            Assert.AreEqual(3, parameterGroup_1.ContainedGroup(true).Count());

            Assert.IsTrue(parameterGroup_1_1.ContainedGroup(true).Contains(parameterGroup_1_1_1));
            Assert.AreEqual(1, parameterGroup_1_1.ContainedGroup(true).Count());

            Assert.IsEmpty(parameterGroup_1_2.ContainedGroup(true));
        }
예제 #3
0
        /// <summary>
        /// Update the drag state when the payload is a <see cref="ParameterGroup"/>
        /// </summary>
        /// <param name="dropInfo">The <see cref="IDropInfo"/> to update</param>
        /// <param name="group">The <see cref="ParameterGroup"/> payload</param>
        private void DragOver(IDropInfo dropInfo, ParameterGroup group)
        {
            if (group.Container == this.Thing.Container && !group.ContainedGroup(true).Contains(this.Thing) && group != this.Thing)
            {
                if (!this.PermissionService.CanWrite(group))
                {
                    dropInfo.Effects = DragDropEffects.None;
                    return;
                }

                dropInfo.Effects = DragDropEffects.Move;
                return;
            }

            dropInfo.Effects = DragDropEffects.None;
        }
예제 #4
0
        public void VerifyThatContainedGroupsReturnsGroupsThatAreContained()
        {
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null);

            var parameterGroup_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1);
            var parameterGroup_2 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_2);

            var parameterGroup_1_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_1);
            parameterGroup_1_1.ContainingGroup = parameterGroup_1;

            var parameterGroup_1_2 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_2);
            parameterGroup_1_2.ContainingGroup = parameterGroup_1;

            var parameterGroup_1_1_1 = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup_1_1_1);
            parameterGroup_1_1_1.ContainingGroup = parameterGroup_1_1;

            Assert.IsEmpty(parameterGroup_2.ContainedGroup(elementDefinition.ParameterGroup));

            CollectionAssert.Contains(parameterGroup_1.ContainedGroup(elementDefinition.ParameterGroup), parameterGroup_1_1);
            CollectionAssert.Contains(parameterGroup_1.ContainedGroup(), parameterGroup_1_1);

            CollectionAssert.Contains(parameterGroup_1.ContainedGroup(elementDefinition.ParameterGroup), parameterGroup_1_2);
            CollectionAssert.Contains(parameterGroup_1.ContainedGroup(), parameterGroup_1_2);

            CollectionAssert.DoesNotContain(parameterGroup_1.ContainedGroup(elementDefinition.ParameterGroup), parameterGroup_1_1_1);
            CollectionAssert.DoesNotContain(parameterGroup_1.ContainedGroup(), parameterGroup_1_1_1);
        }
예제 #5
0
        public void VerifyThatIfContainerIsNullReturnsEmptyGroupIEnumerable()
        {
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), null, null);

            Assert.IsEmpty(parameterGroup.ContainedGroup());
        }