public async Task SetThemeAsync(ThemeInfoBase info)
        {
            await _themeService.SetThemeAsync(info, !_darkOnly && NightMode == NightMode.Disabled);

            RaisePropertyChanged(nameof(IsNightModeAvailable));

            await RefreshThemesAsync();
        }
        public async Task SetThemeAsync(ThemeInfoBase info)
        {
            await _themeService.SetThemeAsync(info);

            RaisePropertyChanged(() => IsNightModeAvailable);

            await RefreshThemesAsync();
        }
Пример #3
0
        private async void ThemeCreateExecute(ThemeInfoBase theme)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.CreateNewThemeAlert, Strings.Resources.NewTheme, Strings.Resources.CreateTheme, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var input = new InputDialog();

            input.Title  = Strings.Resources.NewTheme;
            input.Header = Strings.Resources.EnterThemeName;
            input.Text   = $"{theme.Name} #2";
            input.IsPrimaryButtonEnabled   = true;
            input.IsSecondaryButtonEnabled = true;
            input.PrimaryButtonText        = Strings.Resources.OK;
            input.SecondaryButtonText      = Strings.Resources.Cancel;

            confirm = await input.ShowQueuedAsync();

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var preparing = new ThemeCustomInfo {
                Name = input.Text, Parent = theme.Parent
            };
            var fileName = Client.Execute(new CleanFileName(theme.Name)) as Text;

            if (theme is ThemeCustomInfo custom)
            {
                foreach (var item in custom.Values)
                {
                    preparing.Values[item.Key] = item.Value;
                }
            }
            else if (theme is ThemeAccentInfo accent)
            {
                foreach (var item in accent.Values)
                {
                    preparing.Values[item.Key] = item.Value;
                }
            }

            var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("themes\\" + fileName.TextValue + ".unigram-theme", CreationCollisionOption.GenerateUniqueName);

            await _themeService.SerializeAsync(file, preparing);

            preparing.Path = file.Path;

            ThemeEditExecute(preparing);
        }
Пример #4
0
 public void Update(ThemeInfoBase info)
 {
     if (info is ThemeCustomInfo custom)
     {
         Update(custom.Values);
     }
     else if (info is ThemeAccentInfo colorized)
     {
         Update(colorized.Values);
     }
     else
     {
         Update();
     }
 }
Пример #5
0
 public void Update(ThemeInfoBase info)
 {
     if (info is ThemeCustomInfo custom)
     {
         Update(info.Parent, custom);
     }
     else if (info is ThemeAccentInfo colorized)
     {
         Update(info.Parent, colorized);
     }
     else
     {
         Update(info.Parent);
     }
 }
Пример #6
0
 public async Task SetThemeAsync(ThemeInfoBase info)
 {
     _themeService.SetTheme(info, !_darkOnly && NightMode == NightMode.Disabled);
     await RefreshThemesAsync();
 }