Exemple #1
0
        public ActionResult ChangeTheme(string themeId)
        {
            IUserData           user            = UserContext.CurrentUser;
            PersonalizeSettings userPersonalize = user.PersonalizeSettings();
            string         id     = userPersonalize.ThemeId;
            JsonDataResult result = new JsonDataResult();

            if (id != themeId)
            {
                userPersonalize.ThemeId = themeId;
                result.Result           = user.UpdatePersonalize(userPersonalize);
            }
            return(Json(result));
        }
Exemple #2
0
        /// <summary>
        /// 修改界面的背景主题
        /// </summary>
        /// <param name="background"></param>
        /// <returns></returns>
        public ActionResult ChangeBackground(string background)
        {
            IUserData           user            = UserContext.CurrentUser;
            PersonalizeSettings userPersonalize = user.PersonalizeSettings();
            string         bg     = userPersonalize.Background;
            JsonDataResult result = new JsonDataResult();

            if (bg != background)
            {
                userPersonalize.Background = background;
                result.Result = user.UpdatePersonalize(userPersonalize);
            }
            return(Json(result));
        }
Exemple #3
0
        public ActionResult UserProtrait()
        {
            IUserData           user            = UserContext.CurrentUser;
            PersonalizeSettings userPersonalize = user.PersonalizeSettings();

            byte[] protrait = userPersonalize.Portrait;
            if (protrait == null)
            {
                return(File("~/Content/images/protrait.png", "image/jpeg"));
            }
            else
            {
                return(File(protrait, "image/jpeg"));
            }
        }
Exemple #4
0
        private void SaveUserProtrait(string filePath)
        {
            FileInfo imageFile = new FileInfo(filePath);

            if (imageFile.Exists)
            {
                IUserData           user     = UserContext.CurrentUser;
                PersonalizeSettings settings = user.PersonalizeSettings();

                int size = 128;
                using (Image smallImage = ZoomOut(ImageCut(Image.FromFile(imageFile.FullName)), size, size))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        smallImage.Save(ms, ImageFormat.Png);
                        settings.Portrait = ms.ToArray();
                    }
                }
                imageFile.Delete();
                user.UpdatePersonalize(settings);
            }
        }