Esempio n. 1
0
        public async Task TestFileAndAdd()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);
            await control.LoadFromJsonFileAsync("Common/bind.json");

            control.AddBreakpointWithBindings(1500, AdaptiveContainer.Create().Set("TitleFontSize", "120").Set("TitleColor", "pink").Get())
            .AddBreakpointWithBindings(1800, AdaptiveContainer.Create().Set("TitleFontSize", "150").Set("TitleColor", "yellow").Get());

            Assert.AreEqual(5, control.BindingsByWidth.Count);

            var result = control.TryGetActive(100);

            Assert.AreEqual("20", result["TitleFontSize"]);
            Assert.AreEqual("red", result["TitleColor"]);

            result = control.TryGetActive(600);
            Assert.AreEqual("50", result["TitleFontSize"]);
            Assert.AreEqual("blue", result["TitleColor"]);

            result = control.TryGetActive(1200);
            Assert.AreEqual("100", result["TitleFontSize"]);
            Assert.AreEqual("green", result["TitleColor"]);

            result = control.TryGetActive(1600);
            Assert.AreEqual("120", result["TitleFontSize"]);
            Assert.AreEqual("pink", result["TitleColor"]);

            result = control.TryGetActive(1900);
            Assert.AreEqual("150", result["TitleFontSize"]);
            Assert.AreEqual("yellow", result["TitleColor"]);
        }
Esempio n. 2
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            var binder = new BreakpointBinder();

            // with dictionary string : object
            binder.AddBreakpointWithBindings(0, new Dictionary <string, object> {
                { "TitleFontSize", "14" }, { "TitleColor", "Green" }
            });

            // with Adaptive container helper
            binder.AddBreakpointWithBindings(640, AdaptiveContainer.Create().Set("TitleFontSize", "80").Set("TitleColor", "Red").Get());
            binder.AddBreakpointWithBindings(960, AdaptiveContainer.Create().Set("TitleFontSize", "160").Set("TitleColor", "Blue").Get());

            // DEFERRED
            //await Task.Delay(4000);

            binder.ActiveChanged += OnActiveChanged;
        }
Esempio n. 3
0
        public void TestIsNotified()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);

            control.AddBreakpointWithBindings(0, AdaptiveContainer.Create().Set("TitleFontSize", "20").Set("TitleColor", "red").Get())
            .AddBreakpointWithBindings(500, AdaptiveContainer.Create().Set("TitleFontSize", "50").Set("TitleColor", "blue").Get())
            .AddBreakpointWithBindings(1000, AdaptiveContainer.Create().Set("TitleFontSize", "100").Set("TitleColor", "green").Get());

            Assert.IsNull(control.Active);

            sizeStrategy.RaiseSizeChanged(600);

            Assert.AreEqual("50", control.Active["TitleFontSize"]);
            Assert.AreEqual("blue", control.Active["TitleColor"]);
        }
Esempio n. 4
0
        public void RaiseBreakpointBinderChanged_DeferredOnSubscribe()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);

            int count = 0;

            control.AddBreakpointWithBindings(0, AdaptiveContainer.Create().Set("TitleFontSize", "20").Set("TitleColor", "red").Get());

            sizeStrategy.RaiseSizeChanged(10);

            Task.Delay(3000);

            control.ActiveChanged += (s, e) =>
            {
                count++;
            };


            Assert.AreEqual(1, count);
        }
Esempio n. 5
0
        public void TestWithAdd()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);

            control.AddBreakpointWithBindings(0, AdaptiveContainer.Create().Set("TitleFontSize", "20").Set("TitleColor", "red").Get())
            .AddBreakpointWithBindings(500, AdaptiveContainer.Create().Set("TitleFontSize", "50").Set("TitleColor", "blue").Get())
            .AddBreakpointWithBindings(1000, AdaptiveContainer.Create().Set("TitleFontSize", "100").Set("TitleColor", "green").Get());

            Assert.AreEqual(3, control.BindingsByWidth.Count);

            var result = control.TryGetActive(100);

            Assert.AreEqual("20", result["TitleFontSize"]);
            Assert.AreEqual("red", result["TitleColor"]);

            result = control.TryGetActive(600);
            Assert.AreEqual("50", result["TitleFontSize"]);
            Assert.AreEqual("blue", result["TitleColor"]);

            result = control.TryGetActive(1200);
            Assert.AreEqual("100", result["TitleFontSize"]);
            Assert.AreEqual("green", result["TitleColor"]);
        }