示例#1
0
        private IEnumerable <IInputInput> _GetInputs(SlimDX.DirectInput.Joystick device)
        {
            foreach (DeviceObjectInstance deviceObjectInstance in device.GetObjects())
            {
                JoystickInput input = null;

                if (_IsButton(deviceObjectInstance))
                {
                    input = new Button(deviceObjectInstance.Name, deviceObjectInstance.Usage);
                }
                else if (_IsAxis(deviceObjectInstance))
                {
                    input = _IsRotationAxis(deviceObjectInstance) ?
                            _CreateRotationAxis(deviceObjectInstance) :
                            _CreateAxis(deviceObjectInstance);
                }
                else if (_IsPov(deviceObjectInstance))
                {
                    input = new Pov(deviceObjectInstance.Name, deviceObjectInstance.DesignatorIndex);
                }

                if (input != null)
                {
                    yield return(input);
                }
            }
        }
示例#2
0
    public void Errors_if_target_does_not_exist_in_a_singleton_tree()
    {
        var tree = new Tree("x");
        var from = "nonexistent";

        Assert.Throws <ArgumentException>(() => Pov.FromPov(tree, from));
    }
示例#3
0
    public void Errors_if_target_does_not_exist_in_a_large_tree()
    {
        var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));
        var from = "nonexistent";

        Assert.Throws <ArgumentException>(() => Pov.FromPov(tree, from));
    }
示例#4
0
    public void Errors_if_source_does_not_exist()
    {
        var from = "nonexistent";
        var to   = "x";
        var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));

        Assert.Throws <ArgumentException>(() => Pov.PathTo(from, to, tree));
    }
示例#5
0
    public void Can_reroot_a_tree_with_a_parent_and_many_siblings()
    {
        var tree     = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
        var from     = "x";
        var expected = new Tree("x", new Tree("parent", new Tree("a"), new Tree("b"), new Tree("c")));

        Assert.Equal(expected, Pov.FromPov(tree, from));
    }
示例#6
0
    public void Can_reroot_a_tree_with_new_root_deeply_nested_in_tree()
    {
        var tree     = new Tree("level-0", new Tree("level-1", new Tree("level-2", new Tree("level-3", new Tree("x")))));
        var from     = "x";
        var expected = new Tree("x", new Tree("level-3", new Tree("level-2", new Tree("level-1", new Tree("level-0")))));

        Assert.Equal(expected, Pov.FromPov(tree, from));
    }
示例#7
0
    public void Moves_children_of_the_new_root_to_same_level_as_former_parent()
    {
        var tree     = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")));
        var from     = "x";
        var expected = new Tree("x", new Tree("kid-0"), new Tree("kid-1"), new Tree("parent"));

        Assert.Equal(expected, Pov.FromPov(tree, from));
    }
示例#8
0
    public void Can_reroot_a_complex_tree_with_cousins()
    {
        var tree     = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")));
        var from     = "x";
        var expected = new Tree("x", new Tree("kid-1"), new Tree("kid-0"), new Tree("parent", new Tree("sibling-0"), new Tree("sibling-1"), new Tree("grandparent", new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")))));

        Assert.Equal(expected, Pov.FromPov(tree, from));
    }
示例#9
0
    public void Results_in_the_same_tree_if_the_input_tree_is_a_singleton()
    {
        var tree     = new Tree("x");
        var from     = "x";
        var expected = new Tree("x");

        Assert.Equal(expected, Pov.FromPov(tree, from));
    }
示例#10
0
    public void Can_find_path_not_involving_root()
    {
        var from     = "x";
        var to       = "sibling-1";
        var tree     = new Tree("grandparent", new Tree("parent", new Tree("x"), new Tree("sibling-0"), new Tree("sibling-1")));
        var expected = new[] { "x", "parent", "sibling-1" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
示例#11
0
    public void Can_find_path_to_sibling()
    {
        var from     = "x";
        var to       = "b";
        var tree     = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
        var expected = new[] { "x", "parent", "b" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
示例#12
0
    public void Can_find_path_from_nodes_other_than_x()
    {
        var from     = "a";
        var to       = "c";
        var tree     = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
        var expected = new[] { "a", "parent", "c" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
示例#13
0
    public void Should_not_be_able_to_find_a_missing_node()
    {
        var nodes = new[] { singleton, flat, kids, nested, cousins }.Select(graph => Pov.FromPOV("NOT THERE", graph));

        Assert.All(nodes, node =>
        {
            Assert.Null(node);
        });
    }
示例#14
0
    public void Can_find_path_to_cousin()
    {
        var from     = "x";
        var to       = "cousin-1";
        var tree     = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")));
        var expected = new[] { "x", "parent", "grandparent", "uncle", "cousin-1" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
示例#15
0
        public override JsonCollection BuildParams()
        {
            JsonCollection options = new JsonCollection(false);

            options.Add("addressControl", AddressControl.Value, AddressControl.HasValue, typeof(bool));
            options.Add("addressControlOptions", AddressControlOptions.ToString(), AddressControlOptions != null);
            options.Add("disableDoubleClickZoom", DisableDoubleClickZoom.Value, DisableDoubleClickZoom.HasValue, typeof(bool));
            options.Add("enableCloseButton", EnableCloseButton.Value, EnableCloseButton.HasValue, typeof(bool));
            options.Add("imageDateControl", ImageDateControl.Value, ImageDateControl.HasValue, typeof(bool));
            options.Add("linksControl", LinksControl.Value, LinksControl.HasValue, typeof(bool));
            options.Add("panControl", PanControl.Value, PanControl.HasValue, typeof(bool));
            options.Add("panControlOptions", PanControlOptions.ToString(), PanControlOptions != null);
            options.Add("pano", Pano, !string.IsNullOrEmpty(Pano), typeof(string));
            options.Add("panoProvider", PanoProvider, !string.IsNullOrEmpty(PanoProvider));
            options.Add("position", Position.ToStringNew(), Position != null);
            options.Add("pov", Pov.ToString(), Pov != null);
            options.Add("scrollwheel", Scrollwheel.Value, Scrollwheel.HasValue, typeof(bool));
            options.Add("visible", Visible.Value, Visible.HasValue, typeof(bool));
            options.Add("zoomControl", ZoomControl.Value, ZoomControl.HasValue, typeof(bool));
            options.Add("zoomControlOptions", ZoomControlOptions.ToString(), ZoomControlOptions != null);

            return(options);
        }
示例#16
0
 public void Can_trace_from_a_leaf_to_a_leaf()
 {
     Assert.Equal(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" }, Pov.TracePathBetween("kid-a", "cousin-0", cousins));
 }
示例#17
0
 public void Reparent_singleton()
 {
     Assert.Equal(singleton_, Pov.FromPOV(x, singleton));
 }
示例#18
0
 public void Reparent_flat()
 {
     Assert.Equal(flat_, Pov.FromPOV(x, flat));
 }
示例#19
0
 public void Reparent_nested()
 {
     Assert.That(Pov.FromPOV(x, nested), Is.EqualTo(nested_));
 }
示例#20
0
 public void Cannot_trace_between_unconnected_nodes()
 {
     Assert.That(Pov.TracePathBetween(x, "NOT THERE", cousins), Is.Null);
 }
示例#21
0
 public void Reparent_kids()
 {
     Assert.That(Pov.FromPOV(x, kids), Is.EqualTo(kids_));
 }
示例#22
0
 public void Reparent_flat()
 {
     Assert.That(Pov.FromPOV(x, flat), Is.EqualTo(flat_));
 }
示例#23
0
 public void Reparent_singleton()
 {
     Assert.That(Pov.FromPOV(x, singleton), Is.EqualTo(singleton_));
 }
示例#24
0
 public void Reparent_cousins()
 {
     Assert.That(Pov.FromPOV(x, cousins), Is.EqualTo(cousins_));
 }
示例#25
0
 public void Can_trace_a_path_from_x_to_cousin()
 {
     Assert.That(Pov.TracePathBetween(x, "cousin-1", cousins), Is.EquivalentTo(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" }));
 }
示例#26
0
 public void Can_trace_a_path_from_x_to_cousin()
 {
     Assert.Equal(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" }, Pov.TracePathBetween(x, "cousin-1", cousins));
 }
示例#27
0
 public void Can_trace_from_a_leaf_to_a_leaf()
 {
     Assert.That(Pov.TracePathBetween("kid-a", "cousin-0", cousins), Is.EquivalentTo(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" }));
 }
示例#28
0
 public void Reparent_from_POV_of_non_existent_node()
 {
     Assert.That(Pov.FromPOV(x, leaf("foo")), Is.Null);
 }
示例#29
0
 private static Graph <T> leaf <T>(T v) => Pov.CreateGraph(v, new Graph <T> [0]);
示例#30
0
 public void Reparent_cousins()
 {
     Assert.Equal(cousins_, Pov.FromPOV(x, cousins));
 }