private void FontComboBox_SelectedIndexChanged(object sender, System.Windows.RoutedEventArgs e) { ViewModels.FontViewModel oViewModel = FontComboBox.SelectedItem as ViewModels.FontViewModel; App.Current.Resources[Infrastructure.Text.PersianFontResources] = oViewModel.FontFamily; IsThemeChanged = true; }
private void SaveTheme(bool doByMessageBox) { DAL.UnitOfWork oUnitOfWork = null; try { oUnitOfWork = new DAL.UnitOfWork(); Models.User oUser = oUnitOfWork.UserRepository .GetById(Utility.CurrentUser.Id); ViewModels.FontViewModel oFViewModel = FontComboBox.SelectedItem as ViewModels.FontViewModel; ViewModels.ThemeViewModel oTViewModel = ThemeComboBox.SelectedItem as ViewModels.ThemeViewModel; oUser.UserSetting.Theme.ApplicationTheme = oTViewModel.ApplicationThemeName; DevExpress.Xpf.Core.ApplicationThemeHelper.ApplicationThemeName = oUser.UserSetting.Theme.ApplicationTheme; Utility.SetThemeBackground(DevExpress.Xpf.Core.ApplicationThemeHelper.ApplicationThemeName); oUser.UserSetting.Theme.FontFamily = oFViewModel.FontFamily.Source; App.Current.Resources[Infrastructure.Text.PersianFontResources] = oFViewModel.FontFamily; oUnitOfWork.UserRepository.Update(oUser); Utility.CurrentUser = oUser; oUnitOfWork.Save(); Infrastructure.MessageBox.Show ( caption: Infrastructure.MessageBox.Caption.Information, text: "تنظیمات شخصی سازی با موفقیت ذخیره گردید." ); ignoreMessageBox = true; if (doByMessageBox == false) { this.Close(); } } catch (System.Exception ex) { Infrastructure.MessageBox.Show(ex.Message);; } finally { if (oUnitOfWork != null) { oUnitOfWork.Dispose(); oUnitOfWork = null; } } }
static Font() { FontsList = new System.Collections.Generic.List <ViewModels.FontViewModel>(); if (FontsList.Count == 0) { ViewModels.FontViewModel oViewModel = new ViewModels.FontViewModel(); oViewModel.FontName = "یاقوت"; oViewModel.FontFamily = new System.Windows.Media.FontFamily(Infrastructure.FontFamily.BYagut); FontsList.Add(oViewModel); oViewModel = new ViewModels.FontViewModel(); oViewModel.FontName = "ترافیک"; oViewModel.FontFamily = new System.Windows.Media.FontFamily(Infrastructure.FontFamily.BTraffic); FontsList.Add(oViewModel); oViewModel = new ViewModels.FontViewModel(); oViewModel.FontName = "نازنین"; oViewModel.FontFamily = new System.Windows.Media.FontFamily(Infrastructure.FontFamily.BNazanin); FontsList.Add(oViewModel); oViewModel = new ViewModels.FontViewModel(); oViewModel.FontName = "یکان"; oViewModel.FontFamily = new System.Windows.Media.FontFamily(Infrastructure.FontFamily.BYekan); FontsList.Add(oViewModel); oViewModel = new ViewModels.FontViewModel(); oViewModel.FontName = "آریـال"; oViewModel.FontFamily = new System.Windows.Media.FontFamily(Infrastructure.FontFamily.Arial); FontsList.Add(oViewModel); } FontsList = FontsList .OrderBy(current => current.FontName) .ToList(); }