private void AddCustomLabelText(CustomLabelVM customLabel) { var label = new FormattedTextLabel(customLabel.FormatString, customLabel.Color, customLabel.FontSize, customLabel.FontFamily, customLabel.TextAlignment); var labelBindingSource = new BindingSource(components); var trackBindingSource = new BindingSource(components); label.DataBindings.Add(new Binding(nameof(label.Format), labelBindingSource, nameof(customLabel.FormatString), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.DefaultColor), labelBindingSource, nameof(customLabel.Color), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.FontSize), labelBindingSource, nameof(customLabel.FontSize), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.FontFamily), labelBindingSource, nameof(customLabel.FontFamily), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Alignment), labelBindingSource, nameof(customLabel.TextAlignment), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Visible), labelBindingSource, nameof(customLabel.IsVisible), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Width), labelBindingSource, nameof(customLabel.Width), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Height), labelBindingSource, nameof(customLabel.Height), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Location), labelBindingSource, nameof(customLabel.Location), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.ScrollSpeed), labelBindingSource, nameof(customLabel.ScrollSpeed), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.AlbumName), trackBindingSource, nameof(_trackModel.AlbumName), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.Artist), trackBindingSource, nameof(_trackModel.Artist), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.SongName), trackBindingSource, nameof(_trackModel.TrackName), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.SongLength), trackBindingSource, nameof(_trackModel.TrackLength), true, DataSourceUpdateMode.OnPropertyChanged)); label.DataBindings.Add(new Binding(nameof(label.SongProgress), trackBindingSource, nameof(_trackModel.TrackProgress), true, DataSourceUpdateMode.OnPropertyChanged)); labelBindingSource.DataSource = customLabel; trackBindingSource.DataSource = _trackModel; label.Tag = customLabel; label.Name = CustomLabelControlsKey; Controls.Add(label); }
private void CreateTextLabel(TextAppearance appearance) { var label = new FormattedTextLabel(appearance.FormatString, appearance.Color, appearance.FontSize, appearance.FontFamily, appearance.TextAlignment); label.DataBindings.Add(nameof(label.Format), appearance, nameof(appearance.FormatString)); label.DataBindings.Add(nameof(label.DefaultColor), appearance, nameof(appearance.Color)); label.DataBindings.Add(nameof(label.FontSize), appearance, nameof(appearance.FontSize)); label.DataBindings.Add(nameof(label.FontFamily), appearance, nameof(appearance.FontFamily)); label.DataBindings.Add(nameof(label.Alignment), appearance, nameof(appearance.TextAlignment)); label.DataBindings.Add(nameof(label.Visible), appearance, nameof(appearance.IsVisible)); label.DataBindings.Add(nameof(label.Width), appearance, nameof(appearance.Width)); label.DataBindings.Add(nameof(label.Height), appearance, nameof(appearance.Height)); label.DataBindings.Add(nameof(label.Location), appearance, nameof(appearance.Location)); label.DataBindings.Add(nameof(label.ScrollSpeed), appearance, nameof(appearance.ScrollSpeed)); label.AlbumName = _audioSourceStatus.AlbumName; label.Artist = _audioSourceStatus.Artist; label.SongName = _audioSourceStatus.SongName; label.SongLength = _audioSourceStatus.SongLength; label.SongProgress = _audioSourceStatus.SongProgress; label.DataBindings.Add(nameof(label.AlbumName), _audioSourceStatus, nameof(_audioSourceStatus.AlbumName)); label.DataBindings.Add(nameof(label.Artist), _audioSourceStatus, nameof(_audioSourceStatus.Artist)); label.DataBindings.Add(nameof(label.SongName), _audioSourceStatus, nameof(_audioSourceStatus.SongName)); label.DataBindings.Add(nameof(label.SongLength), _audioSourceStatus, nameof(_audioSourceStatus.SongLength)); label.DataBindings.Add(nameof(label.SongProgress), _audioSourceStatus, nameof(_audioSourceStatus.SongProgress)); appearance.Tag = _nextTag++; label.TagId = appearance.Tag; label.Name = "formatted label"; Controls.Add(label); }