public void do_not_create_a_link_if_the_filter_fails()
        {
            var link = new LinkSource <Site>((t, urls) => "http://site.com")
                       .IfSubjectMatches(s => false);

            link.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
            .Any().ShouldBeFalse();
        }
        public void do_not_create_a_link_if_the_filter_fails()
        {
            var link = new LinkSource<Site>((t, urls) => "http://site.com")
                .IfSubjectMatches(s => false);

            link.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Any().ShouldBeFalse();
        }
Exemple #3
0
        public void create_a_link_if_the_filter_passes()
        {
            var link = new LinkSource<Site>((t, urls) => "http://site.com")
                .IfSubjectMatches(s => true);

            link.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Single()
                .ShouldNotBeNull();
        }
Exemple #4
0
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);


            if (name == RO_ADJUST_BBOX)
            {
                ShapeLink src = GetVisibilityLinkSource();
                if (src == null || src.Links.Count == 0)
                {
                    return;
                }

                BoundingBox newbbox = new BoundingBox();
                foreach (LinkTarget tgt in src.Links)
                {
                    BoundingBox bbox = tgt.OwnerShape.AbsoluteBoundingBox;
                    if (bbox != null && bbox.Valid)
                    {
                        newbbox.AddBox(bbox);
                    }
                }
                if (newbbox.Valid)
                {
                    EditorManager.Actions.StartGroup(RO_ADJUST_BBOX);
                    Vector3F size = new Vector3F(newbbox.SizeX, newbbox.SizeY, newbbox.SizeZ);
                    EditorManager.Actions.Add(new MoveShapeAction(this, this.Position, newbbox.Center));
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSize", size));

                    EditorManager.Actions.EndGroup();
                }
            }

            if (name == RO_LINK_TO_TOUCHING_SHAPES || name == RO_LINK_TO_SHAPES_INSIDE)
            {
                EvaluateBBoxLinksVisitor visitor = new EvaluateBBoxLinksVisitor(this, name == RO_LINK_TO_TOUCHING_SHAPES);
                foreach (Layer layer in EditorManager.Scene.Layers)
                {
                    if (layer.Modifiable)
                    {
                        layer.Root.RunVisitor(visitor);
                    }
                }

                if (visitor.RelevantTargets.Count > 0)
                {
                    LinkSource linkSrc = GetVisibilityLinkSource();
                    EditorManager.Actions.StartGroup(name);
                    foreach (LinkTarget target in visitor.RelevantTargets)
                    {
                        EditorManager.Actions.Add(new LinkAction(linkSrc, target));
                    }

                    EditorManager.Actions.EndGroup();
                }
            }
        }
        public void create_a_link_if_the_filter_passes()
        {
            var link = new LinkSource <Site>((t, urls) => "http://site.com")
                       .IfSubjectMatches(s => true);

            link.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
            .Single()
            .ShouldNotBeNull();
        }
        public void do_create_a_link_if_the_filter_succeeds_by_IfEquals()
        {
            theSubject.Name = "Jeremy";

            var link = new LinkSource<Site>((t, urls) => "http://site.com")
                .IfEquals(x => x.Name, "Jeremy");

            link.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Any().ShouldBeTrue();
        }
        public void do_not_create_a_link_if_the_filter_fails_by_target_matches()
        {
            theSubject.IsObsolete = true;

            var link = new LinkSource<Site>((t, urls) => "http://site.com")
                .IfSubjectMatches(s => !s.IsObsolete);

            link.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Any().ShouldBeFalse();
        }
        public void do_create_a_link_if_the_filter_succeeds_by_IfNotEquals()
        {
            theSubject.Name = "Jeremy";

            var link = new LinkSource <Site>((t, urls) => "http://site.com")
                       .IfNotEquals(x => x.Name, "Jeremy");

            link.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
            .Any().ShouldBeFalse();
        }
        public void do_not_create_a_link_if_the_filter_fails_by_target_matches()
        {
            theSubject.IsObsolete = true;

            var link = new LinkSource <Site>((t, urls) => "http://site.com")
                       .IfSubjectMatches(s => !s.IsObsolete);

            link.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
            .Any().ShouldBeFalse();
        }
Exemple #10
0
        public void create_a_link_with_just_the_url_from_the_target()
        {
            var source = new LinkSource<Site>((t, urls) => "http://site.com");

            var link = source.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Single();

            link.Url.ShouldEqual("http://site.com");
            link.Rel.ShouldBeNull();
            link.Title.ShouldBeNull();
        }
        public void create_a_link_with_just_the_url_from_the_target()
        {
            var source = new LinkSource <Site>((t, urls) => "http://site.com");

            var link = source.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
                       .Single();

            link.Url.ShouldEqual("http://site.com");
            link.Rel.ShouldBeNull();
            link.Title.ShouldBeNull();
        }
Exemple #12
0
        public void create_a_link_with_just_the_url_from_the_target_with_a_title()
        {
            var token = StringToken.FromKeyString("the title");

            var source = new LinkSource<Site>((t, urls) => "http://site.com")
                .Rel("something")
                .Title(token);

            var link = source.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls)
                .Single();

            link.Url.ShouldEqual("http://site.com");
            link.Title.ShouldEqual(token.ToString());
        }
        public void create_a_link_with_just_the_url_from_the_target_with_a_title()
        {
            var token = StringToken.FromKeyString("the title");

            var source = new LinkSource <Site>((t, urls) => "http://site.com")
                         .Rel("something")
                         .Title(token);

            var link = source.As <ILinkSource <Site> >().LinksFor(theTarget, theUrls)
                       .Single();

            link.Url.ShouldEqual("http://site.com");
            link.Title.ShouldEqual(token.ToString());
        }
        public void TestRestoreLinks()
        {
            // load a different scene for this test
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"EntityShapeTest\RestoreLink.scene"));

            EntityShape entity = EditorManager.Scene.FindShapeByName("Entity") as EntityShape;

            Assert.IsNotNull(entity);

            // the map has an anim entity which is attached to a path
            Assert.AreEqual(entity.EntityClass, "AnimEntity_cl");
            Assert.AreEqual(entity.LinkSources.Count, 1);
            Assert.AreEqual(entity.LinkTargets.Count, 0);
            Assert.AreEqual(entity.LinkBidirections.Count, 0);

            // verify the link is there
            LinkSource linkSrc = (LinkSource)entity.LinkSources[0];

            Assert.AreEqual(linkSrc.Links.Count, 1);
            LinkTarget linkTgt   = (LinkTarget)linkSrc.Links[0];
            PathShape  pathShape = linkTgt.OwnerShape as PathShape;

            Assert.IsNotNull(pathShape);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1);

            // setting a new entity class removes the link
            IAction myAction = SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl");

            myAction.Do();
            Assert.AreEqual(entity.LinkSources.Count, 0);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 0); // not conected to entity anymore

            // now the link should be restored again
            myAction.Undo();
            Assert.AreEqual(entity.LinkSources.Count, 1);
            Assert.AreEqual(entity.LinkSources[0].Links.Count, 1);
            Assert.AreEqual(entity.LinkSources[0].Links[0].OwnerShape, pathShape);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1);
        }