private void load(ApplicationConfigManager config, BackgroundImageStore images, BackgroundVideoStore videos) { type = config.GetBindable <BackgroundType>(ApplicationSetting.Background); ox = config.GetBindable <float>(ApplicationSetting.BackgroundOffsetX); oy = config.GetBindable <float>(ApplicationSetting.BackgroundOffsetY); sx = config.GetBindable <float>(ApplicationSetting.BackgroundScaleXY); colorConfig = config.GetBindable <string>(ApplicationSetting.BackgroundColor); imageConfig = config.GetBindable <string>(ApplicationSetting.BackgroundImageFile); videoConfig = config.GetBindable <string>(ApplicationSetting.BackgroundVideoFile); Children = new Drawable[] { new ThemedSpriteText { Font = SegoeUI.Bold.With(size: 18), Text = "Preview" }, new Container { RelativeSizeAxes = Axes.X, CornerRadius = 5.0f, Masking = true, Margin = new MarginPadding { Bottom = 10 }, Height = 250, Width = 0.95f, Children = new Drawable[] { new Box { Colour = Colour4.Black, RelativeSizeAxes = Axes.Both, }, new Background(false) { RelativeSizeAxes = Axes.Both, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, }, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Colour4.Black.Opacity(0.2f), Radius = 10.0f, Hollow = true, }, }, new ThemedSpriteText { Font = SegoeUI.Bold.With(size: 18), Text = "Display" }, new LabelledEnumDropdown <BackgroundType> { Label = "Type", Current = type, }, imagesDropdown = new LabelledFileDropdown <Texture> { Label = "Image", ItemSource = images.Loaded, }, videosDropdown = new LabelledFileDropdown <Stream> { Label = "Video", ItemSource = videos.Loaded, }, colourPicker = new ColourPicker { Current = new Bindable <Colour4>(), }, new ThemedTextButton { Text = "Open Folder", Width = 200, Action = () => images.OpenInNativeExplorer(), }, offsetConfigContainer = new FillFlowContainer { Spacing = new Vector2(0, 10), AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Children = new Drawable[] { new ThemedSpriteText { Font = SegoeUI.Bold.With(size: 18), Text = "Offset" }, new FillFlowContainer { Alpha = type.Value != BackgroundType.Color ? 1 : 0, Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Spacing = new Vector2(10, 0), Children = new Drawable[] { new LabelledNumberBox { Label = "X", Width = 50, Current = inputOffsetX, }, new LabelledNumberBox { Label = "Y", Width = 50, Current = inputOffsetY, }, new LabelledNumberBox { Label = "Scale", Width = 50, Current = inputScaleXY, }, new ThemedIconButton { Icon = FluentSystemIcons.Filled.Drag24, Size = new Vector2(25), Style = ButtonStyle.Override, Action = enableBackgroundAdjustments, IconSize = new Vector2(15), LabelColour = ThemeColour.NeutralPrimary, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }, new ThemedIconButton { Icon = FluentSystemIcons.Filled.ArrowUndo24, Size = new Vector2(25), Style = ButtonStyle.Override, Action = resetBackgroundOffsets, IconSize = new Vector2(15), LabelColour = ThemeColour.NeutralPrimary, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }, } }, } }, }; type.BindValueChanged(handleTypeChange, true); imagesDropdown.Current.ValueChanged += e => imageConfig.Value = e.NewValue?.Name ?? string.Empty; imagesDropdown.Current.Value = images.GetReference(imageConfig.Value); videosDropdown.Current.ValueChanged += e => videoConfig.Value = e.NewValue?.Name ?? string.Empty; videosDropdown.Current.Value = videos.GetReference(videoConfig.Value); colourPicker.Current.ValueChanged += e => colorConfig.Value = e.NewValue.ToHex(); colourPicker.Current.Value = Colour4.FromHex(colorConfig.Value); inputOffsetX.ValueChanged += e => { if (float.TryParse(e.NewValue, out float x)) { ox.Value = x; } }; inputOffsetY.ValueChanged += e => { if (float.TryParse(e.NewValue, out float y)) { oy.Value = y; } }; inputScaleXY.ValueChanged += e => { if (float.TryParse(e.NewValue, out float s)) { sx.Value = s; } }; ox.ValueChanged += e => inputOffsetX.Value = e.NewValue.ToString(); oy.ValueChanged += e => inputOffsetY.Value = e.NewValue.ToString(); sx.ValueChanged += e => inputScaleXY.Value = e.NewValue.ToString(); }
private void load(ApplicationConfigManager config, BackgroundImageStore images, BackgroundVideoStore videos) { ox = config.GetBindable <float>(ApplicationSetting.BackgroundOffsetX); ox.ValueChanged += _ => updatePosition(); oy = config.GetBindable <float>(ApplicationSetting.BackgroundOffsetY); oy.ValueChanged += _ => updatePosition(); sx = config.GetBindable <float>(ApplicationSetting.BackgroundScaleXY); sx.ValueChanged += _ => updatePosition(); switch (Type) { case BackgroundType.Color: AddInternal(new Box()); break; case BackgroundType.Image: if (string.IsNullOrEmpty(asset)) { return; } AddInternal(new Sprite { Texture = images.Get(asset), Size = Vector2.One, FillMode = FillMode.Fill }); break; case BackgroundType.Video: if (string.IsNullOrEmpty(asset)) { return; } AddInternal(new Video(videos.Get(asset))); break; } InternalChild.RelativeSizeAxes = Axes.Both; colour = config.GetBindable <string>(ApplicationSetting.BackgroundColor); colour.BindValueChanged((e) => updateColour(), true); }