Exemple #1
0
        void Bind()
        {
            ctx = this.GetBindingContext();
            ctx.Add(addcategorybutton.BindWithIcon(
                        App.Current.ResourcesLocator.LoadIcon("lm-tag-category", StyleConf.TemplatesIconSize),
                        vm => ((DashboardsManagerVM)vm).AddButton, "Category"));
            ctx.Add(scorebutton.BindWithIcon(
                        App.Current.ResourcesLocator.LoadIcon("lm-tag-score", StyleConf.TemplatesIconSize),
                        vm => ((DashboardsManagerVM)vm).AddButton, "Score"));
            ctx.Add(timerbutton.BindWithIcon(
                        App.Current.ResourcesLocator.LoadIcon("lm-tag-timer", StyleConf.TemplatesIconSize),
                        vm => ((DashboardsManagerVM)vm).AddButton, "Timer"));
            ctx.Add(addtagbutton1.BindWithIcon(
                        App.Current.ResourcesLocator.LoadIcon("lm-tag-tag", StyleConf.TemplatesIconSize),
                        vm => ((DashboardsManagerVM)vm).AddButton, "Tag"));
            ctx.Add(cardbutton.BindWithIcon(
                        App.Current.ResourcesLocator.LoadIcon("lm-tag-tag", StyleConf.TemplatesIconSize),
                        vm => ((DashboardsManagerVM)vm).AddButton, "Card"));

            ctx.Add(deletetemplatebutton.Bind(vm => ((DashboardsManagerVM)vm).DeleteCommand));
            ctx.Add(newtemplatebutton.Bind(vm => ((DashboardsManagerVM)vm).NewCommand));
            ctx.Add(importtemplatebutton.Bind(vm => ((DashboardsManagerVM)vm).ImportCommand));
            ctx.Add(exporttemplatebutton.Bind(vm => ((DashboardsManagerVM)vm).ExportCommand));
            ctx.Add(savetemplatebutton.Bind(vm => ((DashboardsManagerVM)vm).SaveCommand, true));
        }
Exemple #2
0
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(nameentry.Bind(vm => ((EditPlaylistElementVM)vm).Title));
     ctx.Add(durationspinbutton.Bind(vm => ((EditPlaylistElementVM)vm).Duration.TotalSeconds,
                                     new VASInt32Converter()));
 }
        public void BindingContext_Remove_Invoke_Success()
        {
            var context     = new BindingContext();
            var source1     = new BindingSource();
            var dataSource1 = new DataSource();
            var source2     = new BindingSource();
            var dataSource2 = new DataSource();

            context.Add(dataSource1, source1.CurrencyManager);
            context.Add(dataSource2, source2.CurrencyManager);

            context.Remove(dataSource1);
            Assert.Single(context);

            // Remove again.
            context.Remove(dataSource1);
            Assert.Single(context);

            context.Remove(dataSource2);
            Assert.Empty(context);

            // Remove again.
            context.Remove(dataSource2);
            Assert.Empty(context);
        }
Exemple #4
0
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(clearbutton.Bind(vm => ((JobsManagerVM)vm).ClearFinishedCommand));
     ctx.Add(cancelbutton.Bind(vm => ((JobsManagerVM)vm).CancelSelectedCommand));
     ctx.Add(retrybutton.Bind(vm => ((JobsManagerVM)vm).RetryCommand));
 }
Exemple #5
0
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(licenseTextLabel.Bind(lbl => lbl.LabelProp, vm => ((LicenseBannerVM)vm).Text));
     ctx.Add(upgradeButton.Bind(vm => ((LicenseBannerVM)vm).UpgradeCommand));
     ctx.Add(this.Bind((banner) => banner.Visible, vm => ((LicenseBannerVM)vm).Visible));
 }
Exemple #6
0
 /// <summary>
 /// Bind the view elements with the viewmodel properties.
 /// </summary>
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(header.Bind(vm => ((UpgradeLimitationVM)vm).Header));
     ctx.Add(featuresHeader.Bind(vm => ((UpgradeLimitationVM)vm).FeaturesHeader));
     ctx.Add(featuresCaption.Bind(vm => ((UpgradeLimitationVM)vm).FeaturesCaption));
     ctx.Add(upgradeButton2.Bind(vm => ((UpgradeLimitationVM)vm).UpgradeCommand));
     ctx.Add(undecidedlbl.Bind(vm => ((UpgradeLimitationVM)vm).Undecided));
 }
Exemple #7
0
 public LimitationWidget()
 {
     this.Build();
     count_label.SetPadding(5, 0);
     limit_label.SetPadding(5, 0);
     limit_label.Name = StyleConf.LabelLimit;
     limit_box.Name   = StyleConf.BoxLimit;
     NoShowAll        = true;
     upgradeButton.ApplyStyleLimit();
     ctx = this.GetBindingContext();
     ctx.Add(upgradeButton.Bind(vm => ((CountLimitationVM)vm).UpgradeCommand));
     ctx.Add(limit_label.Bind(vm => ((CountLimitationVM)vm).Maximum, new Int32Converter()));
     ctx.Add(count_label.Bind(vm => ((CountLimitationVM)vm).Count, new Int32Converter()));
 }
Exemple #8
0
        /// <summary>
        /// Binds the behavior to the simulation.
        /// </summary>
        /// <param name="behavior">The behavior that needs to be bound to the simulation.</param>
        /// <param name="simulation">The simulation to be bound to.</param>
        protected virtual void BindBehavior(IBehavior behavior, Simulation simulation)
        {
            simulation.ThrowIfNull(nameof(simulation));

            // Build the setup behavior
            var context = new BindingContext();

            // Add existing entity behaviors that have already been created
            context.Add("entity", simulation.EntityBehaviors[Name]);
            context.Add("entity", simulation.EntityParameters[Name]);

            // Finally bind the behavior to the simulation
            behavior.Bind(simulation, context);
        }
 void Bind()
 {
     ctx       = this.GetBindingContext();
     detailCtx = new BindingContext();
     ctx.Add(deletebutton.Bind(vm => ((SportsProjectsManagerVM)vm).DeleteCommand));
     ctx.Add(openbutton.Bind(vm => ((SportsProjectsManagerVM)vm).OpenCommand));
     ctx.Add(exportbutton.Bind(vm => ((SportsProjectsManagerVM)vm).ExportCommand));
     ctx.Add(savebutton.Bind(vm => ((SportsProjectsManagerVM)vm).SaveCommand));
     ctx.Add(resyncbutton.Bind(vm => ((SportsProjectsManagerVM)vm).ResyncCommand));
     detailCtx.Add(seasonentry.Bind(vm => ((LMProjectVM)vm).Season));
     detailCtx.Add(competitionentry.Bind(vm => ((LMProjectVM)vm).Competition));
     detailCtx.Add(datepicker.Bind(vm => ((LMProjectVM)vm).MatchDate));
     detailCtx.Add(templatelabel.Bind(vm => ((LMProjectVM)vm).DashboardText));
     detailCtx.Add(desctextview.Bind(vm => ((LMProjectVM)vm).Description));
 }
        public void BindingContext_Add_InvokeMultiple_Success()
        {
            var context     = new BindingContext();
            var source1     = new BindingSource();
            var source2     = new BindingSource();
            var dataSource1 = new DataSource();
            var dataSource2 = new DataSource();

            context.Add(dataSource1, source1.CurrencyManager);
            context.Add(dataSource2, source2.CurrencyManager);
            Assert.Equal(2, ((ICollection)context).Count);

            Assert.Same(source1.CurrencyManager, context[dataSource1]);
            Assert.Same(source2.CurrencyManager, context[dataSource2]);
        }
Exemple #11
0
        public static IEnumerable <object[]> Equals_TestData()
        {
            var context1    = new BindingContext();
            var context2    = new BindingContext();
            var context3    = new BindingContext();
            var context4    = new BindingContext();
            var source1     = new BindingSource();
            var source2     = new BindingSource();
            var dataSource1 = new DataSource();
            var dataSource2 = new DataSource();

            context1.Add(dataSource1, source1.CurrencyManager);
            context2.Add(dataSource1, source1.CurrencyManager);
            context3.Add(dataSource2, source1.CurrencyManager);
            context4.Add(dataSource2, source2.CurrencyManager);

            yield return(new object[] { Assert.Single(context1), Assert.Single(context1), true });

            yield return(new object[] { Assert.Single(context1), Assert.Single(context2), true });

            yield return(new object[] { Assert.Single(context1), Assert.Single(context3), false });

            yield return(new object[] { Assert.Single(context1), Assert.Single(context4), false });

            yield return(new object[] { Assert.Single(context1), new object(), false });

            yield return(new object[] { Assert.Single(context1), null, false });
        }
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(newbutton.BindWithIcon(
                 App.Current.ResourcesLocator.LoadIcon("lm-playlist-new", Sizes.PlayerCapturerIconSize),
                 vm => ((PlaylistCollectionVM)vm).NewCommand));
 }
        public void BindingContext_Add_NullDataSource_ThrowsArgumentNullException()
        {
            var context = new BindingContext();
            var source  = new BindingSource();

            Assert.Throws <ArgumentNullException>("dataSource", () => context.Add(null, source.CurrencyManager));
        }
        public void BindingContext_KeyEquals_Invoke_ReturnsExpected()
        {
            var context1    = new BindingContext();
            var context2    = new BindingContext();
            var context3    = new BindingContext();
            var context4    = new BindingContext();
            var source1     = new BindingSource();
            var source2     = new BindingSource();
            var dataSource1 = new DataSource();
            var dataSource2 = new DataSource();

            context1.Add(dataSource1, source1.CurrencyManager);
            context2.Add(dataSource1, source1.CurrencyManager);
            context3.Add(dataSource2, source1.CurrencyManager);
            context4.Add(dataSource2, source2.CurrencyManager);

            DictionaryEntry entry1 = Assert.IsType <DictionaryEntry>(Assert.Single(context1));
            DictionaryEntry entry2 = Assert.IsType <DictionaryEntry>(Assert.Single(context2));
            DictionaryEntry entry3 = Assert.IsType <DictionaryEntry>(Assert.Single(context3));
            DictionaryEntry entry4 = Assert.IsType <DictionaryEntry>(Assert.Single(context3));

            Assert.True(entry1.Key.Equals(entry1.Key));
            Assert.True(entry1.Key.Equals(entry2.Key));
            Assert.False(entry1.Key.Equals(entry3.Key));
            Assert.False(entry1.Key.Equals(entry4.Key));

            Assert.False(entry1.Key.Equals(new object()));
            Assert.False(entry1.Key.Equals(null));
        }
        public static IEnumerable <object[]> Contains_DataSourceDataMember_TestData()
        {
            var context     = new BindingContext();
            var source      = new BindingSource();
            var dataSource1 = new DataSource();
            var dataSource2 = new DataSource();

            context.Add(dataSource1, source.CurrencyManager);
            Assert.NotNull(context[dataSource2, "Property"]);

            yield return(new object[] { context, dataSource1, string.Empty, true });

            yield return(new object[] { context, dataSource1, null, true });

            yield return(new object[] { context, dataSource1, "Property", false });

            yield return(new object[] { context, dataSource2, "Property", true });

            yield return(new object[] { context, dataSource2, "property", true });

            yield return(new object[] { context, dataSource2, "NoSuchProperty", false });

            yield return(new object[] { context, dataSource2, string.Empty, true });

            yield return(new object[] { context, dataSource2, null, true });

            yield return(new object[] { context, 1, "Property", false });
        }
        public void BindingContext_Item_GetWithAddedDataSourceWithDataMember_ThrowsArgumentException()
        {
            var context    = new BindingContext();
            var source     = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source.CurrencyManager);
            Assert.Throws <ArgumentException>(null, () => context[dataSource, "Property"]);
        }
Exemple #17
0
        public static IEnumerable <object[]> Contains_DataSource_TestData()
        {
            var context    = new BindingContext();
            var source     = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source.CurrencyManager);
            yield return(new object[] { context, dataSource, true });

            yield return(new object[] { context, 1, false });
        }
        public void BindingContext_Add_Invoke_GetReturnsExpected()
        {
            var context    = new BindingContext();
            var source1    = new BindingSource();
            var source2    = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source1.CurrencyManager);
            Assert.Single(context);

            Assert.Same(source1.CurrencyManager, context[dataSource]);
            Assert.Same(source1.CurrencyManager, context[dataSource, null]);
            Assert.Same(source1.CurrencyManager, context[dataSource, string.Empty]);

            // Set new value.
            context.Add(dataSource, source2.CurrencyManager);
            Assert.Single(context);
            Assert.Same(source2.CurrencyManager, context[dataSource]);
            Assert.Same(source2.CurrencyManager, context[dataSource, null]);
            Assert.Same(source2.CurrencyManager, context[dataSource, string.Empty]);
        }
Exemple #19
0
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(deleteteambutton.Bind(vm => ((TeamsManagerVM)vm).DeleteCommand));
     ctx.Add(newteambutton.Bind(vm => ((TeamsManagerVM)vm).NewCommand));
     ctx.Add(importteambutton.Bind(vm => ((TeamsManagerVM)vm).ImportCommand));
     ctx.Add(exportteambutton.Bind(vm => ((TeamsManagerVM)vm).ExportCommand));
     ctx.Add(saveteambutton.Bind(vm => ((TeamsManagerVM)vm).SaveCommand, true));
     ctx.Add(newplayerbutton1.Bind(vm => ((TeamsManagerVM)vm).TeamEditor.NewPlayerCommand));
     ctx.Add(deleteplayerbutton.Bind(vm => ((TeamsManagerVM)vm).TeamEditor.DeletePlayersCommand));
 }
Exemple #20
0
        void SetBindings()
        {
            bindingContext = this.GetBindingContext();

            bindingContext.Add(this.Bind(v => v.ProgramName, vm => ((AboutVM)vm).ProgramName));
            bindingContext.Add(this.Bind(v => v.Version, vm => ((AboutVM)vm).Version));
            bindingContext.Add(this.Bind(v => v.Copyright, vm => ((AboutVM)vm).Copyright));
            bindingContext.Add(this.Bind(v => v.Website, vm => ((AboutVM)vm).Website));
            bindingContext.Add(this.Bind(v => v.License, vm => ((AboutVM)vm).License));
            bindingContext.Add(this.Bind(v => v.Authors, vm => ((AboutVM)vm).Authors));
            bindingContext.Add(this.Bind(v => v.TranslatorCredits, vm => ((AboutVM)vm).TranslatorCredits));
        }
        public void BindingContext_Contains_DataSource_ReturnsExpected()
        {
            var context    = new BindingContext();
            var source     = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source.CurrencyManager);
            Assert.True(context.Contains(dataSource));
            Assert.True(context.Contains(dataSource, null));
            Assert.True(context.Contains(dataSource, string.Empty));
            Assert.False(context.Contains(1));
            Assert.False(context.Contains(1, null));
            Assert.False(context.Contains(1, string.Empty));
        }
        public void BindingContext_Clear_NotEmpty_Success()
        {
            var context = new BindingContext();
            var source  = new BindingSource();

            context.Add(new DataSource(), source.CurrencyManager);

            // Clear again.
            context.Clear();
            Assert.Empty(context);

            context.Clear();
            Assert.Empty(context);
        }
 /// <summary>
 /// Recursively registers  all <see cref="ILogical"/>s in <paramref name="logicals"/> to the <paramref name="bindingContext"/>.
 /// </summary>
 /// <param name="logicals">A <see cref="Queue{T}"/> containing the root controls that will be recursively registered.</param>
 /// <param name="bindingContext">The <see cref="BindingContext"/> the <see cref="ScalableObject"/>s will be registered to.</param>
 public static void RegisterControls(Queue <IEnumerable <ILogical> > logicals, BindingContext bindingContext)
 {
     while (logicals.Count > 0)
     {
         IEnumerable <ILogical> children = logicals.Dequeue();
         foreach (ILogical child in children)
         {
             logicals.Enqueue(child.GetLogicalChildren());
             if (child is AvaloniaObject avaloniaObject)
             {
                 ScalableObject scalableObject = new ScalableObject(avaloniaObject);
                 bindingContext.Add(scalableObject);
             }
         }
     }
 }
        public void BindingContext_CopyTo_Invoke_Success()
        {
            var context    = new BindingContext();
            var source     = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source.CurrencyManager);

            var array = new object[] { 1, 2, 3 };

            ((ICollection)context).CopyTo(array, 1);
            Assert.Equal(1, array[0]);
            Assert.NotNull(Assert.IsType <DictionaryEntry>(array[1]).Key);
            Assert.Equal(source.CurrencyManager, Assert.IsType <WeakReference>(Assert.IsType <DictionaryEntry>(array[1]).Value).Target);
            Assert.Equal(3, array[2]);
        }
Exemple #25
0
 void Bind()
 {
     ctx = this.GetBindingContext();
     ctx.Add(upgradeButton.Bind(vm => ((CountLimitationBarChartVM)vm).Limitation.UpgradeCommand));
 }
Exemple #26
0
 /// <summary>
 /// Bind the series in the BarChart to the limitation properties, so that the chart updates automatically.
 /// </summary>
 public void Bind()
 {
     ctx.Add(BarChart.LeftSerie.Bind(s => s.Elements, vm => ((CountLimitationVM)vm).Remaining));
     ctx.Add(BarChart.RightSerie.Bind(s => s.Elements, vm => ((CountLimitationVM)vm).Count));
     ctx.UpdateViewModel(Limitation);
 }
Exemple #27
0
 void Bind()
 {
     ctx = new BindingContext();
     ctx.Add(logoImage.Bind(vm => ((HomeViewModel)vm).LogoIcon));
 }
        void Bind()
        {
            ctx = this.GetBindingContext();

            ctx.Add(fieldimage.Bind(vm => ((DashboardVM)vm).FieldBackground, 50, 50));
            ctx.Add(hfieldimage.Bind(vm => ((DashboardVM)vm).HalfFieldBackground, 50, 50));
            ctx.Add(goalimage.Bind(vm => ((DashboardVM)vm).GoalBackground, 50, 50));

            ctx.Add(addcatbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-tag-category", StyleConf.NotebookTabSize),
                                              vm => ((DashboardVM)vm).AddButton, "Category"));
            ctx.Add(addscorebutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-tag-score", StyleConf.NotebookTabSize),
                                                vm => ((DashboardVM)vm).AddButton, "Score"));
            ctx.Add(addtimerbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-tag-timer", StyleConf.NotebookTabSize),
                                                vm => ((DashboardVM)vm).AddButton, "Timer"));
            ctx.Add(addtagbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-tag-tag", StyleConf.NotebookTabSize),
                                              vm => ((DashboardVM)vm).AddButton, "Tag"));
            ctx.Add(addcardbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-tag-tag", StyleConf.NotebookTabSize),
                                               vm => ((DashboardVM)vm).AddButton, "Card"));

            ctx.Add(resetfieldbutton.Bind(vm => ((DashboardVM)vm).ResetField, FieldPositionType.Field));
            ctx.Add(resethfieldbutton.Bind(vm => ((DashboardVM)vm).ResetField, FieldPositionType.HalfField));
            ctx.Add(resetgoalbutton.Bind(vm => ((DashboardVM)vm).ResetField, FieldPositionType.Goal));

            ctx.Add(editbutton.Bind(vm => ((DashboardVM)vm).ChangeDashboardMode, DashboardMode.Edit, DashboardMode.Code));
            ctx.Add(linksbutton.Bind(vm => ((DashboardVM)vm).ToggleActionLinks, true, false));
            ctx.Add(popupbutton.Bind(vm => ((DashboardVM)vm).TogglePopupWindow, true, false));
            ctx.Add(fitbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-dash-fit", 22),
                                           vm => ((DashboardVM)vm).ChangeFitMode, FitMode.Fit));
            ctx.Add(fillbutton.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-dash-fill", 22),
                                            vm => ((DashboardVM)vm).ChangeFitMode, FitMode.Fill));
            ctx.Add(d11button.BindWithIcon(App.Current.ResourcesLocator.LoadIcon("lm-dash-11", 22),
                                           vm => ((DashboardVM)vm).ChangeFitMode, FitMode.Original));
        }
Exemple #29
0
 void Bind()
 {
     ctx = new BindingContext();
     ctx.Add(zoomLevelButton.Bind((vm) => ((VideoPlayerVM)vm).ShowZoomCommand));
     ctx.Add(editDurationButton.Bind((vm) => ((VideoPlayerVM)vm).EditEventDurationCommand, true, false, true));
     ctx.Add(volumeWindow.Bind(volumebutton, vm => ((VideoPlayerVM)vm).ChangeVolumeCommand, vm => ((VideoPlayerVM)vm).Volume, HandleVolumeChanged));
     ctx.Add(jumpsWindow.Bind(jumpsButton, vm => ((VideoPlayerVM)vm).ChangeStepCommand));
     ctx.Add(rateWindow.Bind(rateLevelButton, vm => ((VideoPlayerVM)vm).ChangeRateCommand));
     ctx.Add(closebutton.Bind((vm) => ((VideoPlayerVM)vm).CloseCommand));
     ctx.Add(prevbutton.Bind((vm) => ((VideoPlayerVM)vm).PreviousCommand));
     ctx.Add(nextbutton.Bind((vm) => ((VideoPlayerVM)vm).NextCommand));
     ctx.Add(playbutton.Bind((vm) => ((VideoPlayerVM)vm).PlayCommand));
     ctx.Add(pausebutton.Bind((vm) => ((VideoPlayerVM)vm).PauseCommand, false));
     ctx.Add(drawbutton.Bind((vm) => ((VideoPlayerVM)vm).DrawCommand));
     ctx.Add(detachbutton.Bind((vm) => ((VideoPlayerVM)vm).DetachCommand));
     ctx.Add(viewportsSwitchButton.Bind((vm) => ((VideoPlayerVM)vm).ViewPortsSwitchToggleCommand));
     ctx.Add(currentTime.Bind(t => t.Text, vm => ((VideoPlayerVM)vm).CurrentTime, new TimeToStringConverter(true, true)));
     ctx.Add(totalTime.Bind(t => t.Text, vm => ((VideoPlayerVM)vm).Duration, new TimeToStringConverter()));
 }
        public void BindingContext_Add_NullListManager_ThrowsArgumentNullException()
        {
            var context = new BindingContext();

            Assert.Throws <ArgumentNullException>("listManager", () => context.Add(1, null));
        }