mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-22 10:31:26 -07:00
i dont know what the issue id for this is because im on a plane like 999999 feet in the air 😭
130 lines
4.6 KiB
C#
130 lines
4.6 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
using Bloxstrap.Dialogs;
|
|
using Bloxstrap.Enums;
|
|
using Bloxstrap.Helpers.Extensions;
|
|
using Bloxstrap.Views;
|
|
|
|
namespace Bloxstrap.ViewModels
|
|
{
|
|
public class AppearanceViewModel : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
private readonly Page _page;
|
|
|
|
public ICommand PreviewBootstrapperCommand => new RelayCommand(PreviewBootstrapper);
|
|
public ICommand BrowseCustomIconLocationCommand => new RelayCommand(BrowseCustomIconLocation);
|
|
|
|
private void PreviewBootstrapper()
|
|
{
|
|
IBootstrapperDialog dialog = App.Settings.Prop.BootstrapperStyle.GetNew();
|
|
dialog.Message = "Style preview - Click Cancel to close";
|
|
dialog.CancelEnabled = true;
|
|
dialog.ShowBootstrapper();
|
|
}
|
|
|
|
private void BrowseCustomIconLocation()
|
|
{
|
|
using var dialog = new OpenFileDialog();
|
|
dialog.Filter = "Icon files (*.ico)|*.ico|All files (*.*)|*.*";
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
CustomIconLocation = dialog.FileName;
|
|
OnPropertyChanged(nameof(CustomIconLocation));
|
|
}
|
|
}
|
|
|
|
public AppearanceViewModel(Page page)
|
|
{
|
|
_page = page;
|
|
}
|
|
|
|
public IReadOnlyDictionary<string, Theme> Themes { get; set; } = new Dictionary<string, Theme>()
|
|
{
|
|
{ "System Default", Enums.Theme.Default },
|
|
{ "Light", Enums.Theme.Light },
|
|
{ "Dark", Enums.Theme.Dark },
|
|
};
|
|
|
|
public string Theme
|
|
{
|
|
get => Themes.FirstOrDefault(x => x.Value == App.Settings.Prop.Theme).Key;
|
|
set
|
|
{
|
|
App.Settings.Prop.Theme = Themes[value];
|
|
((MainWindow)Window.GetWindow(_page)!).SetTheme();
|
|
}
|
|
}
|
|
|
|
public IReadOnlyDictionary<string, BootstrapperStyle> Dialogs { get; set; } = new Dictionary<string, BootstrapperStyle>()
|
|
{
|
|
{ "Fluent", BootstrapperStyle.FluentDialog },
|
|
{ "Progress (~2014)", BootstrapperStyle.ProgressDialog },
|
|
{ "Legacy (2011 - 2014)", BootstrapperStyle.LegacyDialog2011 },
|
|
{ "Legacy (2009 - 2011)", BootstrapperStyle.LegacyDialog2009 },
|
|
{ "Vista (2009 - 2011)", BootstrapperStyle.VistaDialog },
|
|
};
|
|
|
|
public string Dialog
|
|
{
|
|
get => Dialogs.FirstOrDefault(x => x.Value == App.Settings.Prop.BootstrapperStyle).Key;
|
|
set => App.Settings.Prop.BootstrapperStyle = Dialogs[value];
|
|
}
|
|
|
|
public IReadOnlyDictionary<string, BootstrapperIcon> Icons { get; set; } = new Dictionary<string, BootstrapperIcon>()
|
|
{
|
|
{ "Bloxstrap", BootstrapperIcon.IconBloxstrap },
|
|
{ "2022", BootstrapperIcon.Icon2022 },
|
|
{ "2019", BootstrapperIcon.Icon2019 },
|
|
{ "2017", BootstrapperIcon.Icon2017 },
|
|
{ "Late 2015", BootstrapperIcon.IconLate2015 },
|
|
{ "Early 2015", BootstrapperIcon.IconEarly2015 },
|
|
{ "2011", BootstrapperIcon.Icon2011 },
|
|
{ "2009", BootstrapperIcon.Icon2009 },
|
|
{ "Custom", BootstrapperIcon.IconCustom },
|
|
};
|
|
|
|
public string Icon
|
|
{
|
|
get => Icons.FirstOrDefault(x => x.Value == App.Settings.Prop.BootstrapperIcon).Key;
|
|
set
|
|
{
|
|
App.Settings.Prop.BootstrapperIcon = Icons[value];
|
|
OnPropertyChanged(nameof(IconPreviewSource));
|
|
}
|
|
}
|
|
|
|
public ImageSource IconPreviewSource => App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
|
|
|
|
public string Title
|
|
{
|
|
get => App.Settings.Prop.BootstrapperTitle;
|
|
set => App.Settings.Prop.BootstrapperTitle = value;
|
|
}
|
|
|
|
public string CustomIconLocation
|
|
{
|
|
get => App.Settings.Prop.BootstrapperIconCustomLocation;
|
|
set
|
|
{
|
|
App.Settings.Prop.BootstrapperIcon = BootstrapperIcon.IconCustom;
|
|
App.Settings.Prop.BootstrapperIconCustomLocation = value;
|
|
|
|
OnPropertyChanged(nameof(Icon));
|
|
OnPropertyChanged(nameof(IconPreviewSource));
|
|
}
|
|
}
|
|
}
|
|
}
|