Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Diary.Services;
- using System;
- using System.Diagnostics;
- using ReactiveUI;
- using System.Reactive;
- using Diary.Models;
- namespace Diary.ViewModels;
- public class UpdateAvailableViewModel : ViewModelBase
- {
- private string _title = "";
- private string _information = "";
- private string _subInformation = "";
- private string _background = "";
- private string _foreground = "";
- private string _border = "";
- private string _fontSize = "";
- private string _fontFamily = "";
- private string _fontStyle = "";
- private string _textAlign = "";
- private User _user;
- private StyleModel _userStyles;
- public UpdateAvailableViewModel()
- {
- _user = new();
- SetupUi();
- }
- public UpdateAvailableViewModel(GithubService.VersionData version, User user)
- {
- string latestVersion = version.LatestVersion.ToString();
- string releaseDate = version.ReleaseDate.ToString();
- Title = "A New Update Is Available";
- Information = $"""
- Version: {latestVersion}
- Release Date: {releaseDate}
- Author: mekasu0124
- """;
- SubInformation = "Would You Like To Update?";
- StartUpdate = ReactiveCommand.Create(LaunchUpdate);
- GoHome = ReactiveCommand.Create(() => { });
- SetupUi();
- }
- public void SetupUi()
- {
- _userStyles = User.UserSettings.StylesModel;
- Background = _userStyles.BackgroundColor;
- Foreground = _userStyles.FontColor;
- Border = _userStyles.BorderColor;
- FontSize = _userStyles.FontSize;
- FontFamily = _userStyles.FontName;
- FontStyle = _userStyles.FontStyle;
- TextAlign = _userStyles.TextAlign;
- }
- public static void LaunchUpdate()
- {
- Process pWin = new();
- pWin.StartInfo.FileName = "Updater.exe";
- pWin.Start();
- Environment.Exit(0);
- }
- public ReactiveCommand<Unit, Unit> StartUpdate { get; }
- public ReactiveCommand<Unit, Unit> GoHome { get; }
- #region Getters/Setters
- public string Title
- {
- get => _title;
- set => this.RaiseAndSetIfChanged(ref _title, value);
- }
- public string Information
- {
- get => _information;
- set => this.RaiseAndSetIfChanged(ref _information, value);
- }
- public string SubInformation
- {
- get => _subInformation;
- set => this.RaiseAndSetIfChanged(ref _subInformation, value);
- }
- public string Background
- {
- get => _background;
- set => this.RaiseAndSetIfChanged(ref _background, value);
- }
- public string Foreground
- {
- get => _foreground;
- set => this.RaiseAndSetIfChanged(ref _foreground, value);
- }
- public string Border
- {
- get => _border;
- set => this.RaiseAndSetIfChanged(ref _border, value);
- }
- public string FontSize
- {
- get => _fontSize;
- set => this.RaiseAndSetIfChanged(ref _fontSize, value);
- }
- public string FontFamily
- {
- get => _fontFamily;
- set => this.RaiseAndSetIfChanged(ref _fontFamily, value);
- }
- public string FontStyle
- {
- get => _fontStyle;
- set => this.RaiseAndSetIfChanged(ref _fontStyle, value);
- }
- public string TextAlign
- {
- get => _textAlign;
- set => this.RaiseAndSetIfChanged(ref _textAlign, value);
- }
- public User User
- {
- get => _user;
- set => this.RaiseAndSetIfChanged(ref _user, value);
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement