Example #1
0
        public async Task <PartialViewResult> CreateComment(int themeId, string text)
        {
            ThemeModel theme = _context.ThemeModel.FirstOrDefault(t => t.Id == themeId);
            var        user  = await _userManager.GetUserAsync(User);

            List <Comment> comments = _context.Comment
                                      .OrderBy(a => a.DateTime)
                                      .Where(a => a.ThemeId == themeId).ToList();
            CommentViewModel viewModel = new CommentViewModel()
            {
                Comments = comments
            };

            theme.CommentCount += 1;
            if (ModelState.IsValid)
            {
                Comment model = new Comment()
                {
                    UserId     = user.Id,
                    Text       = text,
                    DateTime   = DateTime.Now,
                    ThemeId    = theme.Id,
                    ThemeModel = theme,
                    User       = user
                };
                _context.Update(theme);
                _context.Add(model);
                await _context.SaveChangesAsync();
            }

            return(PartialView("Comments", viewModel));
        }
Example #2
0
        public async Task AddThemeToArticleAsync(ArticleModel article, string theme)
        {
            await Initialize();

            await ExecuteSafe(async() =>
            {
                var normalizedTheme = NormalizeThemeName(theme);
                var themeModel      = ThemeManager.TryGetSimilarTheme(normalizedTheme);
                if (themeModel == null)
                {
                    themeModel = new ThemeModel()
                    {
                        NormalizedName = normalizedTheme,
                        Name           = theme
                    };
                    //concurrency: soem other thread may have added the same theme
                    var tm = ThemeManager.TryAddTheme(themeModel);
                    if (tm == themeModel)
                    {
                        await _themeGenericRepository.AddAsync(themeModel);
                    }
                }
                if (article.Themes.Contains(themeModel))
                {
                    return;
                }

                article.Themes.Add(themeModel);
                await _sqliteService.Add(new ThemeArticleRelations()
                {
                    ArticleId = article.GetId(),
                    ThemeId   = themeModel.GetId()
                });
            });
        }
Example #3
0
        public async Task <ActionResult> Index(ThemeModel model, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                ViewData[Constant.CustomSuccessMessage] = Constant.CustomValidationErrorMessage;
                ViewData[Constant.QuerySuccess]         = false;
                model = (ThemeModel)await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

                return(View(model));
            }
            ModelState.Clear();
            model = (ThemeModel)await _service.SaveAsync(HttpContext.ApplicationInstance.Context, model, GetCanellationToken(cancellationToken));

            ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
            ViewData[Constant.FormTitle]    = HttpContext.Items[Constant.FormTitle];

            if (!Convert.ToBoolean(ViewData[Constant.QuerySuccess]))
            {
                ViewData[Constant.CustomSuccessMessage] = "Error : Record cannot be Saved. Make sure the 'Name' isn't being duplicated.";
                if (model.ThemeId == 0)
                {
                    model.ThemeId = null;
                }
            }
            else
            {
                ViewData[Constant.FormTitle] = "EDIT Theme";
            }
            return(View(model));
        }
Example #4
0
        public List <ThemeModel> getThemes()
        {
            List <ThemeModel> list = new List <ThemeModel>();

            using (var db = base.getDatabase())
            {
                Sql thsql     = new Sql("SELECT *  FROM `theme`  ");
                var themelist = db.Fetch <theme>(thsql);
                for (int i = 0; i < themelist.Count; i++)
                {
                    ThemeModel tmodel = new ThemeModel();
                    tmodel.id           = themelist[i].id;
                    tmodel.head_img_id  = themelist[i].head_img_id;
                    tmodel.name         = themelist[i].name;
                    tmodel.topic_img_id = themelist[i].topic_img_id;
                    thsql = new Sql("SELECT *  FROM  image where id = @0", themelist[i].topic_img_id);
                    image      imagelist = db.FirstOrDefault <image>(thsql);
                    ImageModel imodel    = new ImageModel();
                    imodel.id       = imagelist.id;
                    imodel.url      = imagelist.url;
                    tmodel.banImage = imodel;
                    tmodel.tempUrl  = "https://localhost:44390/images" + imagelist.url;

                    list.Add(tmodel);
                }
            }

            return(list);
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Body,DateTime,UserId")] ThemeModel themeModel)
        {
            if (id != themeModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(themeModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ThemeModelExists(themeModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", themeModel.UserId);
            return(View(themeModel));
        }
 public ThemeLoaderViewModel()
 {
     movieThemeManager = new MovieThemeManager();
     ThemeModels       = new ObservableCollection <ThemeModel>()
     {
         new ThemeModel
         {
             ThemeName = "Black Skin",
             ThemePath = "/Movies.Themes;component/Themes/BlackSkin.xaml",
             IsActive  = false
         },
         new ThemeModel
         {
             ThemeName = "White Skin",
             ThemePath = "/Movies.Themes;component/Themes/WhiteSkin.xaml",
             IsActive  = false
         },
         new ThemeModel
         {
             ThemeName = "Hybrid Skin",
             ThemePath = "/Movies.Themes;component/Themes/Hybrid.xaml",
             IsActive  = false
         }
     };
     CurrentSkin = ThemeModels[0];
 }
Example #7
0
        public ThemeSettingsViewModel LoadTheme(ThemeModel theme)
        {
            ThemeSettingsViewModel result = null;

            try
            {
                if (theme == null)
                {
                    theme = DefaultTheme;
                }
                if (theme.Path.StartsWith("/Cleverdock;component/"))
                {
                    LoadComponentTheme(theme.Path);
                }
                else
                {
                    var xamlPath = Path.Combine(theme.Path, "style.xaml");
                    var xaml     = XamlHelper.LoadXaml(xamlPath);
                    LoadResourceDictionary(xaml);
                    var settingsPath = Path.Combine(theme.Path, "theme.json");
                    result = GetSettings(settingsPath);
                }
                VMLocator.Main.Theme = theme;
                if (ThemeChanged != null)
                {
                    ThemeChanged(this, new ThemeEventArgs(theme));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Theme \"" + theme.Name + "\" failed to load. \n" + ex.Message);
                LoadTheme(DefaultTheme);
            }
            return(result);
        }
Example #8
0
        public ActionResult Theme()
        {
            UserService users = GetService <UserService>();
            var         user  = users.GetByName(User.Identity.Name);

            var model = new ThemeModel();

            // here's brown-ish low-contrast theme, as used on wikipedia. Looks good, but doens't go with the blue.
            // ffce9e / e8ad73 / d18b47
            // ff4535 / f73a26 / f02e18

            model.BoardLight = /*user.ThemeColorLight ??*/ "e0e0e0";
            model.BoardMid   = /*user.ThemeColorMid ??*/ "909090";
            model.BoardDark  = /*user.ThemeColorDark ??*/ "606060";

            model.BoardLightSelected = /*user.ThemeColorLightSelected ??*/ "ffa0a0";
            model.BoardMidSelected   = /*user.ThemeColorMidSelected ??*/ "ff9090";
            model.BoardDarkSelected  = /*user.ThemeColorDarkSelected ??*/ "ff7070";

            model.BoardLightHighlight = /*user.ThemeColorLightHighlight ??*/ "ffffa0";
            model.BoardMidHighlight   = /*user.ThemeColorMidHighlight ??*/ "ffff90";
            model.BoardDarkHighlight  = /*user.ThemeColorDarkHighlight ??*/ "ffff70";

            model.PieceLight = /*user.ThemeColorPieceLight ??*/ "ffffff";
            model.PieceDark  = /*user.ThemeColorPieceDark ??*/ "000000";

            Response.ContentType = "text/css";
            return(View(model));
        }
Example #9
0
 public IList <TopicModel> GetActiveTopics(ThemeModel tema)
 {
     using (AppTourEntities data = new AppTourEntities())
     {
         return(this.GetTopic(data).Where(x => x.Theme.Id == tema.Id && x.IsActive).ToList());
     }
 }
Example #10
0
        public static ExerciceJeu GetExerciceJeu(ThemeModel themeJeu, string niveau)
        {
            ExerciceJeu exo = new ExerciceJeu(ExerciceConfig.GetBaseConfigPourExercice("MvtsComplexes"), ExerciceConfig.GetBigBorne(), themeJeu);

            exo.Niveau = GetNiveauByte(niveau);
            return(exo);
        }
Example #11
0
        private FormsContext()
        {
            var provider = new XmlDataProvider <SettingsModel>("settings.xml", null);

            Settings     = provider.Load() ?? new SettingsModel();
            CurrentTheme = ThemeFactory.GetCurrent();
        }
Example #12
0
        public static List <ThemeModel> LoadAllReeducationTheme()
        {
            XDocument fileTheme = XDocument.Load(@"../../Theme/listeThemesReeducation.xml");
            var       th        = from theme in fileTheme.Descendants("Theme") orderby theme.Attribute("Nom") select theme;

            List <ThemeModel> listeTheme = new List <ThemeModel>();

            foreach (var theme in th)
            {
                string        nom                = (string)theme.Element("Nom");
                string        cheminCible        = "../../Theme/Reeducation/" + nom + "/Cible/cible.png";
                string        cheminCibleDynamic = "../../Theme/Reeducation/" + nom + "/Cible/cibleDynamic.png";
                string        nomCible           = (string)theme.Element("NomCible");
                string        cheminChasseur     = "../../Theme/Reeducation/" + nom + "/Chasseur/shape.png";
                string        cheminChasseurHit  = "../../Theme/Reeducation/" + nom + "/Chasseur/shapeHit.png";
                string        nomChasseur        = (string)theme.Element("NomChasseur");
                string        sonChasseur        = "../../Theme/Reeducation/" + nom + "/son/sound.wav";
                string        fond               = "../../Theme/Reeducation/" + nom + "/Fond/background.jpg";
                string        fondDynamic        = "../../Theme/Reeducation/" + nom + "/Fond/backgroundDynamic.jpg";
                string        genre              = (string)theme.Element("Genre");
                CibleModel    cible              = new CibleModel(cheminCible, cheminCible, nomCible);
                CibleModel    cibleDynamic       = new CibleModel(cheminCibleDynamic, cheminCibleDynamic, nomCible);
                ChasseurModel chasseur           = new ChasseurModel(cheminChasseur, cheminChasseurHit, nomChasseur, sonChasseur);
                ThemeModel    themeMod           = new ThemeModel(nom, cible, cibleDynamic, chasseur, fond, fondDynamic, genre);
                listeTheme.Add(themeMod);
            }
            return(listeTheme);
        }
Example #13
0
        public void DeleteTheme(ThemeModel theme)
        {
            if (theme == null)
            {
                throw new ArgumentNullException();
            }
            using (AppTourEntities data = new AppTourEntities())
            {
                THEME current = data.THEME.Where(p => p.ID == theme.Id).SingleOrDefault();
                if (current != null)
                {
                    try
                    {
                        current.IS_ACTIVE = false;

                        data.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        if (e.InnerException != null)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                        throw;
                    }
                }
            }
        }
Example #14
0
        // Save any changes to a theme.
        public void SaveThemeChanges(ThemeModel theme)
        {
            bool isActiveTheme = false;
            var  originalTheme = _context.Themes.FirstOrDefault(x => x.ThemeId == theme.ThemeId);

            originalTheme.Active = theme.Active;
            originalTheme.Name   = theme.Name;
            _context.Entry(originalTheme).State = EntityState.Modified;

            // If the current theme is not the active theme and
            // has been marked as the active, then toggle the current
            // active theme.
            if (!IsActiveTheme(originalTheme.ThemeId) && originalTheme.Active)
            {
                ToggleActiveTheme();
                isActiveTheme = true;
            }

            SaveChanges();

            // Clear the active theme cache.
            if (isActiveTheme)
            {
                ClearActiveThemeCache();
            }
        }
Example #15
0
        public void UpdateTheme(ThemeModel theme)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                THEME current = data.THEME.Where(x => theme.Id == x.ID).SingleOrDefault();
                if (current != null)
                {
                    try
                    {
                        current.NAME          = theme.Name;
                        current.DESCRIPTION   = theme.Description;
                        current.IMAGE         = theme.Image;
                        current.IS_ACTIVE     = theme.IsActive;
                        current.CREATION_DATE = theme.CreationDate;
                        current.UPDATE_DATE   = DateTime.Now;

                        data.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        if (e.InnerException != null)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                        throw;
                    }
                }
            }
        }
Example #16
0
 private static void LoadTheme(ThemeModel theme)
 {
     if (!themes.ContainsKey(theme.Key))
     {
         themes.Add(theme.Key, theme);
     }
 }
        public void AddMissingProperties()
        {
            if (this._defaultTheme == null)
            {
                string themeFileName = Path.Combine(Directory.GetCurrentDirectory(), MainViewModel.ThemeFileSchema);
                _dataService.GetData(themeFileName,
                                     (item, error) =>
                {
                    if (error != null)
                    {
                        //TODO: Report error here
                        return;
                    }

                    this._defaultTheme = item;
                });
            }
            foreach (Style style in this._defaultTheme.styles)
            {
                Style themeStyle = this.StyleModel.styles.FirstOrDefault(s => s.name == style.name);
                if (themeStyle != null)
                {
                    foreach (Propertyvaluesmap property in style.propertyValuesMap)
                    {
                        if (!themeStyle.propertyValuesMap.Any(s => s.property == property.property))
                        {
                            themeStyle.propertyValuesMap.Add(new Propertyvaluesmap {
                                property = property.property, value = "Default"
                            });
                        }
                    }
                }
            }
        }
Example #18
0
        /// <summary>
        /// 切换主题
        /// </summary>
        /// <param name="theme"></param>
        public void ChangeThemeModel(Novel novel, List <NovelContent> menulist, ThemeModel theme)
        {
            var dirInfo             = new DirectoryInfo(string.Format(BookHelper.DIR_PATH_NOVEL, novel.NovelID));
            var listModelContent    = CommonHelper.LoadHtmlFile(theme.ListModelPath);
            var chapterModelContent = CommonHelper.LoadHtmlFile(theme.ChapterModelPath);

            foreach (var fileInfo in dirInfo.GetFiles())
            {
                string fileName = fileInfo.FullName;
                var    doc      = CommonHelper.LoadHtmlFile(fileName);
                if (fileName.Contains("List.htm"))
                {
                    SaveNovelListToHtml(novel, menulist, listModelContent);
                }
                else
                {
                    var title   = CommonHelper.GetValue(doc, "<font class=\"article_title\">", "</font>");
                    var content = CommonHelper.GetValue(doc, "<!--BookContent Start-->", "<!--BookContent End-->");

                    CommonHelper.SaveToFile(
                        fileName,
                        chapterModelContent
                        .Replace(@"[[title]]", title.Replace("<br>", ""))
                        .Replace(@"[[Content]]", content));
                }
            }
        }
Example #19
0
        public Guid InsertTheme(ThemeModel theme)
        {
            Guid id = Guid.NewGuid();

            if (theme == null)
            {
                throw new NullReferenceException("theme");
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                THEME _new = new THEME
                {
                    ID            = id,
                    NAME          = theme.Name,
                    DESCRIPTION   = theme.Description,
                    IMAGE         = theme.Image,
                    IS_ACTIVE     = theme.IsActive,
                    CREATION_DATE = DateTime.Now,
                    UPDATE_DATE   = DateTime.Now
                };

                data.THEME.AddObject(_new);
                data.SaveChanges();
            }

            return(id);
        }
        public IActionResult Results(ThemeModel form)
        {
            string    username = form.TwitterHandle.Replace("@", string.Empty);
            ThemeSong theme    = new ThemeSong(username);
            Track     track    = theme.GetThemeSong();

            if (track != null)
            {
                ResultsModel results = new ResultsModel()
                {
                    Username  = username,
                    Track     = track,
                    ListenUrl = "https://open.spotify.com/embed?uri=spotify:album:" + track.album.id + "&theme=white&view=coverart",
                    Sentiment = theme.GetSentiment()
                };
                return(View(results));
            }
            else
            {
                ResultsModel results = new ResultsModel()
                {
                    Username = username
                };
                return(View("Error", results));
            }
        }
Example #21
0
 private void OnThemeSelected(ThemeModel selectedTheme)
 {
     foreach (var t in Themes)
     {
         t.IsSelected = t.Theme == selectedTheme.Theme;
     }
     _themeService.ChangeTheme(selectedTheme.Theme);
 }
Example #22
0
 public ThemeSerializer(ThemeModel themeModel)
 {
     this.id     = themeModel.Id;
     this.name   = themeModel.Name;
     this.first  = themeModel.First;
     this.second = themeModel.Second;
     this.third  = themeModel.Third;
 }
Example #23
0
        public async Task <ActionResult> Create([FromBody] ThemeModel themeModel)
        {
            var themeEntity = themeModel.ToEntity();

            await themeService.Create(themeEntity);

            return(Ok());
        }
Example #24
0
        public async Task <ThemeModel> AddAsync(ThemeModel model)
        {
            var theme = _mapper.Map <Theme>(model);

            _unitOfWork.ThemeRepository.Add(theme);
            await _unitOfWork.SaveAsync();

            return(_mapper.Map <ThemeModel>(theme));
        }
Example #25
0
        public async Task <ActionResult> CreateTheme(ThemeModel model)
        {
            ThemeDTO themeDto = new ThemeDTO {
                ThemeDesc = model.ThemeDesc, ThemeTitle = model.ThemeTitle, Id = RandomStringIdGenerator.GetUniqueId()
            };
            await ThemeService.CreateNew(themeDto);

            return(RedirectToAction("Index", "Home"));
        }
Example #26
0
 public static ThemeModel TryAddTheme(ThemeModel model)
 {
     AllThemes.Add(model);
     if (ThemeDic.TryAdd(model.NormalizedName, model))
     {
         return(model);
     }
     return(ThemeDic[model.NormalizedName]);
 }
        public String CreateNewTheme(ThemeSerializer themeSerializer)
        {
            ThemeModel themeModel = new ThemeModel();

            themeModel.Name   = themeSerializer.name;
            themeModel.First  = themeSerializer.first;
            themeModel.Second = themeSerializer.second;
            themeModel.Third  = themeSerializer.third;
            return(this._themeDao.Create(themeModel));
        }
        public void SetNewCurrent(ThemeModel themeModel)
        {
            if (currentskin != null)
            {
                currentskin.Unload();
            }

            currentskin = new ReferencedAssemblySkin(themeModel.ThemeName, new Uri(themeModel.ThemePath, UriKind.Relative), themeModel);
            OnCurrentSkinChange();
        }
Example #29
0
        public ThemeModel GetThemeDetails()
        {
            ThemeModel theme = new ThemeModel()
            {
                BackgroundColor = Colors.green.GetDescription(),
                FontColor       = Colors.orange.GetDescription(),
                FontFamily      = FontFamily.TimesNewRoman.GetDescription(),
            };

            return(theme);
        }
Example #30
0
        public ThemeModel GetThemeDetails()
        {
            ThemeModel theme = new ThemeModel()
            {
                BackgroundColor = Colors.red.GetDescription(),
                FontColor       = Colors.black.GetDescription(),
                FontFamily      = FontFamily.Arial.GetDescription(),
            };

            return(theme);
        }
Example #31
0
        /// <summary>
        /// 主题
        /// </summary>
        public ActionResult Theme()
        {
            ThemeModel model = new ThemeModel();

            #region 加载主题列表

            Type stringType = Type.GetType("System.String");

            DataTable pcThemeList = new DataTable();
            pcThemeList.Columns.Add("name", stringType);
            pcThemeList.Columns.Add("title", stringType);
            pcThemeList.Columns.Add("author", stringType);
            pcThemeList.Columns.Add("version", stringType);
            pcThemeList.Columns.Add("supVersion", stringType);
            pcThemeList.Columns.Add("createTime", stringType);
            pcThemeList.Columns.Add("copyright", stringType);

            string path = IOHelper.GetMapPath("/themes");
            DirectoryInfo dir = new DirectoryInfo(path);
            DirectoryInfo[] themeDirList = dir.GetDirectories();

            foreach (DirectoryInfo themeDir in themeDirList)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(themeDir.FullName + @"\theme.xml");

                DataRow row = pcThemeList.NewRow();
                row["name"] = themeDir.Name;
                foreach (XmlAttribute attribute in doc.DocumentElement.Attributes)
                    row[attribute.Name] = attribute.Value;
                pcThemeList.Rows.Add(row);
            }

            DataTable mobileThemeList = new DataTable();
            mobileThemeList.Columns.Add("name", stringType);
            mobileThemeList.Columns.Add("title", stringType);
            mobileThemeList.Columns.Add("author", stringType);
            mobileThemeList.Columns.Add("version", stringType);
            mobileThemeList.Columns.Add("supVersion", stringType);
            mobileThemeList.Columns.Add("createTime", stringType);
            mobileThemeList.Columns.Add("copyright", stringType);

            path = IOHelper.GetMapPath("/mobile/themes");
            dir = new DirectoryInfo(path);
            if (dir.Exists)
            {
                themeDirList = dir.GetDirectories();

                foreach (DirectoryInfo themeDir in themeDirList)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(themeDir.FullName + @"\theme.xml");

                    DataRow row = mobileThemeList.NewRow();
                    row["name"] = themeDir.Name;
                    foreach (XmlAttribute attribute in doc.DocumentElement.Attributes)
                        row[attribute.Name] = attribute.Value;
                    mobileThemeList.Rows.Add(row);
                }
            }

            #endregion

            model.PCThemeList = pcThemeList;
            model.DefaultPCTheme = WorkContext.ShopConfig.PCTheme;
            model.MobileThemeList = mobileThemeList;
            model.DefaultMobileTheme = WorkContext.ShopConfig.MobileTheme;

            return View(model);
        }
Example #32
0
 public ThemeViewModel(ThemeModel _model)
 {
     model = _model;
     LoadCommand = new ActionCommand(LoadAction);
 }