public ThemesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; CreateThemeCommand = new RelayCommand(CreateTheme); var activeThemeId = _settingsService.GetCurrentThemeId(); foreach (var theme in _settingsService.GetThemes()) { var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService); viewModel.Activated += OnThemeActivated; viewModel.Deleted += OnThemeDeleted; if (theme.Id == activeThemeId) { viewModel.IsActive = true; } Themes.Add(viewModel); } SelectedTheme = Themes.First(t => t.IsActive); }
public JsonResult Post([FromBody] ThemeViewModel vm) { try { if (ModelState.IsValid) { var newTheme = Mapper.Map <Theme>(vm); _repository.AddTheme(newTheme); if (_repository.SaveAll()) { Response.StatusCode = (int)HttpStatusCode.Created; return(Json(Mapper.Map <ThemeViewModel>(newTheme))); } } } catch (Exception ex) { _logger.LogError(ex.Message); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { ex.Message })); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = "Validation Failed.", ModelState })); }
public ThemeWindow(SettingsViewModel settingsViewModel, Theme theme) { InitializeComponent(); _settingsViewModel = settingsViewModel; _themeViewModel = new ThemeViewModel(theme); DataContext = _themeViewModel; }
public ThemesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IThemeParserFactory themeParserFactory, IFileSystemService fileSystemService) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _themeParserFactory = themeParserFactory; _fileSystemService = fileSystemService; CreateThemeCommand = new RelayCommand(CreateTheme); ImportThemeCommand = new RelayCommand(ImportTheme); CloneCommand = new RelayCommand <ThemeViewModel>(CloneTheme); _settingsService.TerminalOptionsChanged += OnTerminalOptionsChanged; BackgroundOpacity = _settingsService.GetTerminalOptions().BackgroundOpacity; var activeThemeId = _settingsService.GetCurrentThemeId(); foreach (var theme in _settingsService.GetThemes()) { var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService, fileSystemService); viewModel.Activated += OnThemeActivated; viewModel.Deleted += OnThemeDeleted; if (theme.Id == activeThemeId) { viewModel.IsActive = true; } Themes.Add(viewModel); } SelectedTheme = Themes.First(t => t.IsActive); }
public ActionResult Edit(Guid id) { try { Theme item = _themeRepository.GetById(id); if (item == null) { Request.Flash("error", "Thema niet gevonden"); return(RedirectToAction("Index")); } ThemeViewModel model = new ThemeViewModel() { Id = item.Id, Title = item.Title, Description = item.Description }; return(View(model)); } catch (Exception e) { Request.Flash("error", "Er is iets mis gegaan: " + e.Message); return(RedirectToAction("Index")); } }
/// <summary> /// Builds a blank theme including a project file. /// </summary> /// <param name="themesFolder">The themes folder.</param> /// <param name="vm">The vm.</param> /// <param name="templates">The templates.</param> /// <param name="themeType">Type of theme.</param> private void BuildThemeWithProject(SolutionFolder themesFolder, ThemeViewModel vm, string templates, string themeType) { var solution = GetGlobalService(typeof(SVsSolution)) as IVsSolution; var envsol = dte.Solution; string solpath; string solfile; string soloptions; solution.GetSolutionInfo(out solpath, out solfile, out soloptions); var newDir = Path.Combine(solpath, "Orchard.Web", "Themes", vm.ThemeName); var newproj = themesFolder.AddFromTemplate(Path.Combine(templates, themeType, vm.Version, themeType + ".csproj"), newDir, vm.ThemeName); Insert(Path.Combine(newDir, vm.ThemeName + ".csproj"), new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("$$ModuleProjectGuid$$", Guid.NewGuid().ToString()), new KeyValuePair <string, string>("$$ModuleName$$", vm.ThemeName) }); // this does work... newproj.Properties.Item("AssemblyName").Value = vm.ThemeName; // need this as well because... I have no idea newproj.Properties.Item("RootNamespace").Value = vm.ThemeName; EditThemeFile(newDir, vm); // isn't added to tfs for some reason... if (vm.IncludeHelpFile) { newproj.ProjectItems.AddFromFile(templates + "\\ThemeHelp.md"); } newproj.Save(); }
private void LoadTheme_PostExecute(LoadThemeResults result) { if (result.Loaded) { ViewModel = new ThemeViewModel(result.Theme, result.Info); var path = result.Path; UpdateRecentsList(path); if (result.Info == null) { IconExtension icex = new IconExtension(@"/ThemeEditor.WPF;component/Resources/Icons/app_icn.ico", 48); var large = ((BitmapSource)icex.ProvideValue(null)).CreateResizedImage(48, 48); icex.Size = 24; var small = ((BitmapSource)icex.ProvideValue(null)).CreateResizedImage(24, 24); ViewModel.Info.LargeIcon.Bitmap = large; ViewModel.Info.SmallIcon.Bitmap = small; } ThemePath = result.Path; if (ReloadBGMCommand.CanExecute(null)) { ReloadBGMCommand.Execute(null); } } IsBusy = false; }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } if (!await _db.Themes.AnyAsync(t => t.Id == id)) { return(NotFound()); } Theme themeFromDB = await _db.Themes.Include(t => t.Faction).FirstAsync(t => t.Id == id); if (themeFromDB == null) { return(NotFound()); } ThemeViewModel viewModel = new ThemeViewModel() { Theme = themeFromDB }; return(View(viewModel)); }
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItemIndex < 0 || e.SelectedItem == null) { return; } ListView list = sender as ListView; if (scheduleOpening) { Debug.WriteLine("Ignoring theme selection since already opening"); list.SelectedItem = null; return; } scheduleOpening = true; // prevent double-click ThemeViewModel themeModel = e.SelectedItem as ThemeViewModel; // clear selection so it's not selected when navigating back list.SelectedItem = null; SendThemeSelectEvent(themeModel); await Navigation.PushAsync(new ScheduleStartPage(themeModel.FirstScheduleId)); scheduleOpening = false; }
public ActionResult SaveThemeChanges(ThemeViewModel vm) { if (!ModelState.IsValid) { return(SiteErrorHandler.GetBadRequestActionResult(ModelState)); } // Check if the theme exists. if (!_themeRepository.DoesThemeExist(vm.ThemeId)) { return(SiteErrorHandler.GetBadRequestActionResult("Could not find the theme.", "")); } // Check if the theme name is already in use. if (_themeRepository.IsThemeNameAlreadyInUse(vm.ThemeId, vm.Name)) { return(SiteErrorHandler.GetBadRequestActionResult($"The theme name {vm.Name} is already in use.", nameof(vm.Name))); } // Check if the theme is a system theme and has been modified. if (_themeRepository.IsThemeReadOnly(vm.ThemeId) && _themeRepository.HasNameBeenChanged(vm.ThemeId, vm.Name)) { return(SiteErrorHandler.GetBadRequestActionResult($"This is a system theme and cannot be modified.", "")); } var theme = _mapper.Map <ThemeModel>(vm); _themeRepository.SaveThemeChanges(theme); return(Json(new { message = "<strong>Success</strong>: The theme has been updated.", themeId = vm.ThemeId })); }
public async Task <IActionResult> DeleteConfirmed(int?id) { if (id == null) { return(NotFound()); } Theme themeFromDB = await _db.Themes.Include(t => t.Faction).FirstAsync(t => t.Id == id); if (themeFromDB == null) { return(NotFound()); } if (await _db.BattleReports.AnyAsync(br => br.WinningTheme == themeFromDB.Name || br.LosingTheme == themeFromDB.Name)) { ThemeViewModel viewModel = new ThemeViewModel() { Theme = themeFromDB, StatusMessage = "Error: You cannot delete a Theme for which there are already posted Battle Reports." }; return(View(nameof(Delete), viewModel)); } _db.Themes.Remove(themeFromDB); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
// GET: plans public async Task <IActionResult> Index(string planTheme, string searchString, string sortOrder) { //test sort ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; // Use LINQ to get list of themes. IQueryable <string> themeQuery = from m in _context.Plan orderby m.Theme select m.Theme; var plans = from m in _context.Plan select m; if (!string.IsNullOrEmpty(searchString)) { plans = plans.Where(s => s.Theme.Contains(searchString)); } if (!string.IsNullOrEmpty(planTheme)) { plans = plans.Where(x => x.Theme == planTheme); } var planThemeVM = new ThemeViewModel { Themes = new SelectList(await themeQuery.Distinct().ToListAsync()), Plans = await plans.ToListAsync() }; return(View(planThemeVM)); }
public void TestProperties() { var vm = new ThemeViewModel(DefaultTheme, DefaultName); Assert.Equal(DefaultName, vm.ThemeName); Assert.Equal(DefaultTheme, vm.Theme); }
/// <summary> /// Builds a blank theme including a project file. /// </summary> /// <param name="themesFolder">The themes folder.</param> /// <param name="vm">The vm.</param> /// <param name="templates">The templates.</param> /// <param name="themeType">Type of theme.</param> private void BuildThemeWithProject(SolutionFolder themesFolder, ThemeViewModel vm, string templates, string themeType) { var solution = GetGlobalService(typeof(SVsSolution)) as IVsSolution; var envsol = dte.Solution; string solpath; string solfile; string soloptions; solution.GetSolutionInfo(out solpath, out solfile, out soloptions); //TODO: fix this... var newDir = Path.Combine(solpath, "Orchard.Web", "Themes", vm.ThemeName); var newproj = themesFolder.AddFromTemplate(Path.Combine(templates, themeType, themeType + ".csproj"), newDir, vm.ThemeName); // this doesn't work EditCsProj(Path.Combine(newDir, vm.ThemeName + ".csproj"), vm.ThemeName); // this does work... newproj.Properties.Item("AssemblyName").Value = vm.ThemeName; // need this as well because... I have no idea newproj.Properties.Item("RootNamespace").Value = vm.ThemeName; EditThemeFile(newDir, vm); if (vm.IncludeHelpFile) { newproj.ProjectItems.AddFromFile(templates + "\\ThemeHelp.md"); } newproj.Save(); // for some reason this doesn't appear to work, references are manually added in the csproj file :( //var vsproj = newproj.Object as VSProject; //vsproj.References.Add("Orchard.Core"); //vsproj.References.Add("Orchard.Framework"); }
public ActionResult List() { var viewmodel = new ThemeViewModel(); var rootdir = GeneralConstants.APP_ROOT_DIR + Themepath; var dir = new DirectoryInfo(rootdir); foreach (var themedir in dir.GetDirectories()) { if (themedir.Attributes.HasFlag(FileAttributes.Hidden)) { continue; } var thumbnail = string.Format("{0}/thumb.jpg", themedir.FullName); if (!System.IO.File.Exists(thumbnail)) { #if !DEBUG Syslog.Write(string.Format("Theme thumbnail missing: {0}", thumbnail)); #endif continue; } var theme = new Theme { title = themedir.Name, thumbnail = string.Format("{0}/{1}/thumb.jpg", Themepath, themedir.Name) }; viewmodel.gallery.Add(theme); } // get current theme viewmodel.current = MASTERdomain.theme.ToModel(); return(View(viewmodel)); }
public ActionResult Details(int id) { itemManager = new ItemManager(); userManager = new UserManager(); subManager = new SubscriptionManager(); Item requestedItem = itemManager.GetThemeWithDetails(id); Theme theme = itemManager.GetThemeWithDetails(id); if (requestedItem == null) { return(HttpNotFound()); } Item subbedItem = subManager.GetSubscribedItemsForUser(User.Identity.GetUserId()) .FirstOrDefault(item => item.ItemId == id); ThemeViewModel themeViewModel = Mapper.Map(theme, new ThemeViewModel()); themeViewModel.PageTitle = theme.Name; themeViewModel.User = User.Identity.IsAuthenticated ? userManager.GetUser(User.Identity.GetUserId()) : null; themeViewModel.Theme = Mapper.Map(theme, new ItemDTO()); themeViewModel.Subscribed = subbedItem != null; themeViewModel.Keywords = theme.Keywords.ToList(); //Log visit activity new SubplatformManager().LogActivity(ActivityType.VisitActitiy); //Assembling the view return(View(themeViewModel)); }
public void AddTheme(ThemeViewModel theme) { if (Themes != null) { Themes.Add(theme); CurrentTheme = theme; } }
public void RemoveTheme(ThemeViewModel theme) { if (Themes != null) { Themes.Remove(theme); CurrentTheme = Themes.FirstOrDefault(); } }
private void FocusItem(ThemeViewModel themeViewModel) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { var container = ((UIElement) ThemeList.ItemContainerGenerator.ContainerFromItem(themeViewModel)); container?.Focus(); })); }
public void CurrentAccentNoUpdateTest() { var themeviewmodel = new ThemeViewModel(controller.Object); controller.Verify(c => c.SetAccent(accents[2].Name), Times.Once); themeviewmodel.CurrentAccent = accents[2]; controller.Verify(c => c.SetAccent(accents[2].Name), Times.Once); }
public void CurrentThemeUpdateTest() { var themeviewmodel = new ThemeViewModel(controller.Object); themeviewmodel.CurrentTheme = themes[0]; controller.Verify(c => c.SetTheme(themes[0].Name)); }
public void CurrentAccentUpdateTest() { var themeviewmodel = new ThemeViewModel(controller.Object); themeviewmodel.CurrentAccent = accents[0]; controller.Verify(c => c.SetAccent(accents[0].Name)); }
public ActionResult Themes(ThemeViewModel model) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } themeService.SetTheme(model.ThemeID); return(RedirectToAction("Index", "Home")); }
public void CurrentThemeNoUpdateTest() { var themeviewmodel = new ThemeViewModel(controller.Object); //set gets called once on construction, but not after set controller.Verify(c => c.SetTheme(themes[1].Name), Times.Once); themeviewmodel.CurrentTheme = themes[1]; controller.Verify(c => c.SetTheme(themes[1].Name), Times.Once); }
public ThemeView() { InitializeComponent(); var theme = DependencyService.Get <ITheme>(); var storage = DependencyService.Get <IStorage>(); BindingContext = new ThemeViewModel(theme, storage); }
public void ConstructionTest() { var themeviewmodel = new ThemeViewModel(controller.Object); Assert.AreEqual(themeviewmodel.Themes, themes); Assert.AreEqual(themeviewmodel.Accents, accents); Assert.AreEqual(themeviewmodel.CurrentTheme, themes[1]); Assert.AreEqual(themeviewmodel.CurrentAccent, accents[2]); }
public ActionResult Render() { var model = new ThemeViewModel { Theme = _themeService.GetDefault() }; return(View(model)); }
public ActionResult Render() { var model = new ThemeViewModel { Theme = AsyncHelpers.RunSync(() => _themeService.GetDefaultAsync()) }; return(View(model)); }
public ActionResult Index() { var model = new ThemeViewModel { Themes = _themeService.Get(), Fonts = _fontService.Get() }; return(View(model)); }
public async Task <IActionResult> Index() { ThemeViewModel viewModel = new ThemeViewModel() { Themes = await _db.Themes.ToListAsync(), Factions = await _db.Factions.OrderBy(f => f.Name).ToListAsync() }; return(View(viewModel)); }
public async Task <ActionResult> Index() { var model = new ThemeViewModel { Themes = await _themeService.GetAsync(), Fonts = await _fontService.GetAsync() }; return(View(model)); }
public MockThemeEditDialogViewModel() { Name = "Blue Skies"; Author = "Silent Bob"; Visibility = true; ThemeViewModel = new ThemeViewModel { //Model = new Theme("name", "author", "123") }; }
/// <summary> /// Initializes a new instance of the <see cref="T:ThemesWindowViewModel" /> class. /// </summary> public ThemesWindowViewModel(ThemeEditorViewModel themeEditorViewModel, ThemeManager themeManager, ThemeViewModel.Factory themeViewModelFactory, Func<ThemesWindowViewModel, ThemeEditDialogViewModel> themeEditDialogViewModelFactory, IDialogService dialogService) { ThemeEditorViewModel = themeEditorViewModel; ThemeManager = themeManager; EditDialogViewModel = themeEditDialogViewModelFactory(this); _dialogService = dialogService; Items = new ViewModelCollectionWrapper<ThemeViewModel, Theme>(ThemeManager.Themes, model => themeViewModelFactory(model, this)); OnLoadedCommand = () => { // select the current theme if (themeManager.ActiveTheme != null) { SelectItemByModel(themeManager.ActiveTheme); } }; CreateThemeCommand = new RelayCommand(o => ShowEditDialog()); }
/// <summary> /// Show the Rename dialog to edit the provided model ( /// </summary> /// <param name="model">The model.</param> public void Show(ThemeViewModel model = null) { ThemeViewModel = model; if (ThemeViewModel != null) { Name = ThemeViewModel.Name; Author = ThemeViewModel.Author; } else { Name = Author = ""; } OnPropertyChanged("Heading"); Visibility = true; IsNameInputFocused = false; IsNameInputFocused = true; }
/// <summary> /// Show a diaog which allows the user to provide a name and author for the theme. /// </summary> /// <param name="theme">The theme view model. If null is provided, the dialog will Create a new theme </param> public void ShowEditDialog(ThemeViewModel theme = null) { EditDialogViewModel.Show(theme); }