Beispiel #1
0
        protected override async Task OnInitializedAsync()
        {
            head.Title    = "Themes | Administration";
            selectedTheme = await manageThemes.GetSelectedThemeNameAsync();

            var themes = System.IO.Directory.GetDirectories("wwwroot/custom-themes/");

            foreach (var theme in themes)
            {
                var lines = System.IO.File.ReadLines(theme + "/styles.css");

                if (lines != null && lines.Count() > 0)
                {
                    var themeInfo = new ThemeInfo
                    {
                        ThemeName   = GetThemeInfo(lines, "Theme Name").Replace("Theme Name:", "").Trim(),
                        TextDomain  = GetThemeInfo(lines, "Text Domain").Replace("Text Domain:", "").Trim(),
                        Author      = GetThemeInfo(lines, "Author").Replace("Author:", "").Trim(),
                        Description = GetThemeInfo(lines, "Description").Replace("Description:", "").Trim(),
                        Version     = GetThemeInfo(lines, "Version").Replace("Version:", "").Trim()
                    };
                    themeInfoList.Add(themeInfo);
                }
            }
        }
Beispiel #2
0
        public void Test003()
        {
            // Arrange - create two instances of the ThemeInfo class to passs to the ThemedButton
            var theme = new ThemeInfo()
            {
                Value = "BUTTON"
            };
            var titleTheme = new ThemeInfo()
            {
                Value = "BAR"
            };

            // Act - Render the ThemedButton component, passing in the instances of ThemeInfo
            // as an _unnamed_ and a _named_ cascading value.
            //
            // This is equivalent to the follow Razor code:
            //
            // <CascadingValue Value="theme">
            //     <CascadingValue Name="Title" Value="titleTheme">
            //         <ThemedButton></ThemedButton>
            //     </CascadingValue>
            // </CascadingValue>
            var cut = RenderComponent <ThemedButton>(
                CascadingValue(theme),
                CascadingValue(nameof(ThemedButton.Title), titleTheme)
                );

            // Assert - check that the class and title specified in the cascading values was indeed used.
            var elm = cut.Find("button");

            elm.ClassList.ShouldContain(theme.Value);
            elm.GetAttribute("title").ShouldContain(titleTheme.Value);
        }
Beispiel #3
0
 /// <summary>
 /// 主题设置数据更改
 /// </summary>
 /// <param name="mTheme">主题设置实体</param>
 public void UpdateTheme(ThemeInfo mTheme)
 {
     //var model = Context.ThemeInfo.FirstOrDefault(s => s.ThemeId == mTheme.ThemeId);
     var model = DbFactory.Default.Get<ThemeInfo>().Where(s => s.ThemeId == mTheme.ThemeId).FirstOrDefault();
     if (model == null)
     {
         model = new ThemeInfo()
         {
             ThemeId = 1,
             ClassifiedsColor = "#00ffff",
             FrameColor = "#ff00ff",
             MainColor = "#ffff00",
             SecondaryColor = "#ffff00",
             TypeId = ThemeType.Customize,
             WritingColor = "#cc0000"
         };
         //Context.ThemeInfo.Add(model);
         DbFactory.Default.Add(model);
     }
     model.TypeId = mTheme.TypeId;
     model.WritingColor = mTheme.WritingColor;
     model.SecondaryColor = mTheme.SecondaryColor;
     model.MainColor = mTheme.MainColor;
     model.FrameColor = mTheme.FrameColor;
     model.ClassifiedsColor = mTheme.ClassifiedsColor;
     //Context.SaveChanges();
     DbFactory.Default.Update(model);
     Core.Cache.Remove(CacheKeyCollection.Themes);//清除缓存
 }
Beispiel #4
0
 private void LoadTheme()
 {
     ThemeInfo.Init();
     this.StyleManager       = styleManagerMain;
     this.StyleManager.Theme = ThemeInfo.StyleManager.Theme;
     this.StyleManager.Style = ThemeInfo.MainStyle;
 }
Beispiel #5
0
        public static ThemeInfo GetTemplate(string xmlPath)
        {
            ThemeInfo theme = new ThemeInfo();

            theme.Name    = "";
            theme.Author  = "";
            theme.PubDate = "";
            theme.Version = "";
            theme.Email   = "";
            theme.SiteUrl = "";


            if (!System.IO.File.Exists(xmlPath + @"\theme.xml"))
            {
                return(theme);
            }
            try
            {
                XmlDocument xml = new XmlDocument();

                xml.Load(xmlPath + @"\theme.xml");

                theme.Name    = xml.SelectSingleNode("theme/name").InnerText;
                theme.Author  = xml.SelectSingleNode("theme/author").InnerText;
                theme.Email   = xml.SelectSingleNode("theme/email").InnerText;
                theme.SiteUrl = xml.SelectSingleNode("theme/siteurl").InnerText;
                theme.PubDate = xml.SelectSingleNode("theme/pubdate").InnerText;
                theme.Version = xml.SelectSingleNode("theme/version").InnerText;
                return(theme);
            }
            catch
            {
                return(theme);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 通过数据读取获得主题内容
        /// </summary>
        /// <param name="datareader">数据读取</param>
        /// <returns></returns>
        public static ThemeInfo GetSpaceThemeInfo(IDataReader idatareader)
        {
            if (idatareader == null)
            {
                return(null);
            }

            if (idatareader.Read())
            {
                ThemeInfo spacethemeinfo = new ThemeInfo();
                spacethemeinfo.ThemeId    = TypeConverter.ObjectToInt(idatareader["themeid"]);
                spacethemeinfo.Directory  = idatareader["directory"].ToString();
                spacethemeinfo.Name       = idatareader["name"].ToString();
                spacethemeinfo.Type       = TypeConverter.ObjectToInt(idatareader["type"]);
                spacethemeinfo.Author     = idatareader["author"].ToString();
                spacethemeinfo.CreateDate = idatareader["createdate"].ToString();
                spacethemeinfo.CopyRight  = idatareader["copyright"].ToString();

                idatareader.Close();
                return(spacethemeinfo);
            }
            else
            {
                idatareader.Close();
                return(null);
            }
        }
Beispiel #7
0
        protected override void InitSessionInfo()
        {
            base.InitSessionInfo();

            AppServerInfo appServerInfo = new AppServerInfo();

            appServerInfo.Protocol      = "http";
            appServerInfo.Address       = "192.168.6.74";
            appServerInfo.Port          = 8081;
            appServerInfo.SupportHttps  = false;
            appServerInfo.SupportNetTcp = false;
            Session.AppServerInfo       = appServerInfo;

            DatabaseInfo dbInfo = new DatabaseInfo();

            dbInfo.TypeID              = 2;
            dbInfo.Host                = "192.168.4.182";
            dbInfo.Port                = 1433;
            dbInfo.DBName              = "UMPDataDB0909";
            dbInfo.LoginName           = "PFDEV";
            dbInfo.Password            = "******";
            dbInfo.RealPassword        = "******";
            Session.DatabaseInfo       = dbInfo;
            Session.DBType             = dbInfo.TypeID;
            Session.DBConnectionString = dbInfo.GetConnectionString();

            ThemeInfo theme = Session.SupportThemes.FirstOrDefault(t => t.Name == "Style01");

            if (theme != null)
            {
                Session.ThemeInfo = theme;
                Session.ThemeName = theme.Name;
            }
        }
        protected override void PageHead_PageHeadEvent(object sender, PageHeadEventArgs e)
        {
            base.PageHead_PageHeadEvent(sender, e);
            switch (e.Code)
            {
            //切换主题
            case 100:
                ThemeInfo themeInfo = e.Data as ThemeInfo;
                if (themeInfo != null)
                {
                    ThemeInfo             = themeInfo;
                    App.Session.ThemeInfo = themeInfo;
                    App.Session.ThemeName = themeInfo.Name;
                    ChangeTheme();
                    SendThemeChangeMessage();
                }
                break;

            //切换语言
            case 110:
                LangTypeInfo langType = e.Data as LangTypeInfo;
                if (langType != null)
                {
                    LangTypeInfo             = langType;
                    App.Session.LangTypeInfo = langType;
                    App.Session.LangTypeID   = langType.LangID;
                    MyWaiter.Visibility      = Visibility.Visible;
                    mWorker                     = new BackgroundWorker();
                    mWorker.DoWork             += (s, de) => App.InitAllLanguageInfos();
                    mWorker.RunWorkerCompleted += (s, re) =>
                    {
                        mWorker.Dispose();
                        MyWaiter.Visibility = Visibility.Collapsed;
                        ChangeLanguage();
                        PopupPanel.ChangeLanguage();
                        SendLanguageChangeMessage();
                    };
                    mWorker.RunWorkerAsync();
                }
                break;

            //展开或关闭侧边栏
            case 121:
                OpenCloseLeftPanel();
                break;

            case 120:
                SendChangePasswordMessage();
                break;

            case 201:
                SendLogoutMessage();
                break;

            case 202:
                SendNavigateHomeMessage();
                break;
            }
        }
Beispiel #9
0
        /// <summary>
        /// get skin files in the skin.
        /// </summary>
        /// <param name="portalSettings"></param>
        /// <param name="theme"></param>
        /// <returns></returns>
        public IList <ThemeFileInfo> GetThemeFiles(PortalSettings portalSettings, ThemeInfo theme)
        {
            var themePath  = Path.Combine(Globals.ApplicationMapPath, theme.Path);
            var themeFiles = new List <ThemeFileInfo>();

            if (Directory.Exists(themePath))
            {
                bool fallbackSkin;
                if (theme.Type == ThemeType.Skin)
                {
                    fallbackSkin = IsFallbackSkin(themePath);
                }
                else
                {
                    fallbackSkin = IsFallbackContainer(themePath);
                }

                var strSkinType = themePath.IndexOf(Globals.HostMapPath, StringComparison.InvariantCultureIgnoreCase) != -1 ? "G" : "L";

                var canDeleteSkin = SkinController.CanDeleteSkin(themePath, portalSettings.HomeDirectoryMapPath);
                var arrFiles      = Directory.GetFiles(themePath, "*.ascx");

                foreach (var strFile in arrFiles)
                {
                    var file = strFile.ToLowerInvariant();

                    var themeFile = new ThemeFileInfo();
                    themeFile.ThemeName = theme.PackageName;
                    themeFile.Type      = theme.Type;
                    themeFile.Level     = theme.Level;

                    var imagePath = string.Empty;
                    foreach (var ext in ImageExtensions)
                    {
                        var path = Path.ChangeExtension(file, ext);
                        if (File.Exists(path))
                        {
                            imagePath = path;
                            break;
                        }
                    }

                    if (!string.IsNullOrEmpty(imagePath))
                    {
                        themeFile.Thumbnail = CreateThumbnail(imagePath);
                    }


                    themeFile.Name      = Path.GetFileNameWithoutExtension(file);
                    themeFile.Path      = FormatThemePath(portalSettings, themePath, Path.GetFileName(strFile), theme.Type);
                    themeFile.CanDelete = (UserController.Instance.GetCurrentUserInfo().IsSuperUser || strSkinType == "L") &&
                                          (!fallbackSkin && canDeleteSkin);

                    themeFiles.Add(themeFile);
                }
            }

            return(themeFiles);
        }
Beispiel #10
0
        protected override void InitSessionInfo()
        {
            base.InitSessionInfo();

            if (Session == null)
            {
                return;
            }

            AppServerInfo appServerInfo = new AppServerInfo
            {
                Protocol      = "http",
                Address       = "192.168.6.29",
                Port          = 8081,
                SupportHttps  = false,
                SupportNetTcp = false
            };

            Session.AppServerInfo = appServerInfo;

            DatabaseInfo dbInfo = new DatabaseInfo
            {
                TypeID    = 2,
                Host      = "192.168.4.182",
                Port      = 1433,
                DBName    = "UMPDataDB_SEF_2",
                LoginName = "sa",
                //Password = "******"
                RealPassword = "******"
            };

            Session.DatabaseInfo       = dbInfo;
            Session.DBType             = dbInfo.TypeID;
            Session.DBConnectionString = dbInfo.GetConnectionString();

//             DatabaseInfo dbInfo = new DatabaseInfo
//             {
//                 TypeID = 3,
//                 TypeName = "ORCL",
//                 Host = "192.168.4.182",
//                 Port = 1521,
//                 DBName = "PFOrcl",
//                 LoginName = "PFDEV831",
//                 Password = "******"
//             };
//             Session.DatabaseInfo = dbInfo;
//             Session.DBType = dbInfo.TypeID;
//             Session.DBConnectionString = dbInfo.GetConnectionString();

            ThemeInfo theme = Session.SupportThemes.FirstOrDefault(t => t.Name == "Style01");

            if (theme != null)
            {
                Session.ThemeInfo = theme;
                Session.ThemeName = theme.Name;
            }
        }
Beispiel #11
0
        public ActionResult Index(ThemesViewModel model, IFormCollection collection)
        {
            ThemesViewModel model2 = new ThemesViewModel();

            try
            {
                int itemsPerPage = 6;
                int currentPage  = model.PageNumber;

                string next = collection["next"];
                string prev = collection["prev"];

                if (next != null)
                {
                    currentPage++;
                }
                if (prev != null)
                {
                    currentPage--;
                }

                IRequestCultureFeature culture       = Request.HttpContext.Features.Get <IRequestCultureFeature>();
                List <ThemeInfo>       themeInfoList = Configuration.ThemeHelper.GetInstalledThemesInfo(culture);

                themeInfoList.OrderBy(o => o.ThemeName);
                ThemeInfo currentTheme = themeInfoList.Where(i => i.ThemeName == Configuration.GlobalWebsiteConfig.ThemeName).First();
                themeInfoList.Remove(currentTheme);
                themeInfoList.Insert(0, currentTheme);


                JasperPaging <ThemeInfo> paging = new JasperPaging <ThemeInfo>(themeInfoList, currentPage, itemsPerPage);


                model2.SelectedThemeName  = Configuration.GlobalWebsiteConfig.ThemeName;
                model2.ThemeFolder        = Configuration.ThemeFolder;
                model2.PageNumber         = paging.CurrentPageNumber;
                model2.ItemsPerPage       = paging.ItemsPerPage;
                model2.TotalNumberOfPages = paging.NumberOfPagesNeeded;
                model2.ThemeInfoList      = paging.GetCurrentPageItems();
            }
            catch
            {
                TempData["ErrorMessage"] = "Při provádění pořadavku došlo k chybě";
            }

            bool isAjaxRequest = Request.Headers["x-requested-with"] == "XMLHttpRequest";

            if (isAjaxRequest)
            {
                ModelState.Clear();
                return(PartialView("ThemesPartialView", model2));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Beispiel #12
0
        void BtnGreen_Click(object sender, RoutedEventArgs e)
        {
            ThemeInfo themeInfo = new ThemeInfo();

            themeInfo.Name  = "MetroLight";
            themeInfo.Color = "Green";
            ThemeInfo       = themeInfo;
            ChangeTheme();
        }
Beispiel #13
0
        void BtnBlue_Click(object sender, RoutedEventArgs e)
        {
            ThemeInfo themeInfo = new ThemeInfo();

            themeInfo.Name  = "Default";
            themeInfo.Color = "Blue";
            ThemeInfo       = themeInfo;
            ChangeTheme();
        }
Beispiel #14
0
        public SettingsForm(ThemeInfo _theme)
        {
            InitializeComponent();
            theme = _theme;
            ApplyTheme();

            var labels = Commands.GetAllControls(this, typeof(Label));

            ActivateRadioButtonFromTheme();
        }
Beispiel #15
0
        internal static void LoadTheme(ResourceDictionary targetResources, string name)
        {
            ThemeInfo theme = new ThemeInfo();

            string themeXaml = GetThemeXaml(name, "Theme", /* lookupShared */ false);

            try {
                ExtractThemeContent(themeXaml, theme, /* extractIncludes */ true);
                if ((theme.Includes.Length == 0) && (theme.Keys.Count != 0))
                {
                    UserControl        userControl    = (UserControl)XamlReader.Load(themeXaml);
                    ResourceDictionary themeResources = userControl.Resources;

                    foreach (string key in theme.Keys)
                    {
                        targetResources.Add(key, themeResources[key]);
                    }

                    return;
                }
            }
            catch (Exception e) {
                throw new InvalidOperationException("The theme named '" + name + "' contained invalid XAML.", e);
            }

            if (theme.Includes.Length != 0)
            {
                string[] includes = theme.Includes.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < includes.Length; i++)
                {
                    string includeXaml = GetThemeXaml(name, includes[i], /* lookupShared */ true);
                    try {
                        ExtractThemeContent(includeXaml, theme, /* extractIncludes */ false);
                    }
                    catch (Exception e) {
                        throw new InvalidOperationException("The include named '" + includes[i] + "' in the theme named '" + name + "' contained invalid XAML.", e);
                    }
                }
            }

            try {
                string             mergedXaml     = theme.GetXml();
                UserControl        userControl    = (UserControl)XamlReader.Load(mergedXaml);
                ResourceDictionary themeResources = userControl.Resources;

                foreach (string key in theme.Keys)
                {
                    targetResources.Add(key, themeResources[key]);
                }
            }
            catch (Exception e) {
                throw new InvalidOperationException("The theme named '" + name + "' contained invalid XAML.", e);
            }
        }
Beispiel #16
0
        /// <summary>
        /// Parse skin package.
        /// </summary>
        /// <param name="portalSettings"></param>
        /// <param name="theme"></param>
        /// <param name="parseType"></param>
        public void ParseTheme(PortalSettings portalSettings, ThemeInfo theme, ParseType parseType)
        {
            var strRootPath = Null.NullString;

            switch (theme.Level)
            {
            case ThemeLevel.Global:     //global
                strRootPath = Globals.HostMapPath;
                break;

            case ThemeLevel.Site:     //local
                strRootPath = portalSettings.HomeDirectoryMapPath;
                break;
            }
            var objSkinFiles = new SkinFileProcessor(strRootPath, theme.Type == ThemeType.Container ? SkinController.RootContainer : SkinController.RootSkin, theme.PackageName);
            var arrSkinFiles = new ArrayList();

            var strFolder = Path.Combine(Globals.ApplicationMapPath, theme.Path);

            if (Directory.Exists(strFolder))
            {
                var arrFiles = Directory.GetFiles(strFolder);
                foreach (var strFile in arrFiles)
                {
                    switch (Path.GetExtension(strFile))
                    {
                    case ".htm":
                    case ".html":
                    case ".css":
                        if (strFile.ToLower().IndexOf(Globals.glbAboutPage.ToLower()) < 0)
                        {
                            arrSkinFiles.Add(strFile);
                        }
                        break;

                    case ".ascx":
                        if (File.Exists(strFile.Replace(".ascx", ".htm")) == false && File.Exists(strFile.Replace(".ascx", ".html")) == false)
                        {
                            arrSkinFiles.Add(strFile);
                        }
                        break;
                    }
                }
            }
            switch (parseType)
            {
            case ParseType.Localized:     //localized
                objSkinFiles.ProcessList(arrSkinFiles, SkinParser.Localized);
                break;

            case ParseType.Portable:     //portable
                objSkinFiles.ProcessList(arrSkinFiles, SkinParser.Portable);
                break;
            }
        }
Beispiel #17
0
 public ThemeInfo LoadStyle(ThemeInfo name)
 {
     if (CurrentStyleFolder != name.Path)
     {
         return(LoadStyles(Application.Current.GetType().Assembly.GetName().Name, name.Path, _dic));
     }
     else
     {
         return(name);
     }
 }
Beispiel #18
0
 /// <summary>
 /// This function is responsible for picking up objects and checking the
 /// number of stars to be displayed on the level screen.
 /// It also checks the scene of the current theme.
 /// </summary>
 void Start()
 {
     themeInfo       = this;
     soundController = FindObjectOfType(typeof(SoundController)) as SoundController;
     finalPoints     = PlayerPrefs.GetInt("finalScore_" + themeID.ToString());
     themeScene      = FindObjectOfType(typeof(ThemeScene)) as ThemeScene;
     Stars();
     // textThemeID.text = themeID.ToString();
     themeButton = GetComponent <Button>();
     VerifyMinPoints();
 }
        void ResetParam()
        {
            var charts = transform.GetComponentsInChildren <BaseChart>();

            foreach (var chart in charts)
            {
                chart.themeInfo.defaultLegendTextColor = ThemeInfo.GetColor("#514D4D");
                chart.legend.itemWidth          = 20f;
                chart.legend.itemHeight         = 10f;
                chart.legend.textStyle.fontSize = 16;
            }
        }
Beispiel #20
0
        public void ApplyTheme(ThemeInfo themeInfo)
        {
            var application          = Application.Current;
            var applicationResources = application.Resources;
            var resourceDictionary   = Orchestra.ThemeHelper.GetAccentColorResourceDictionary();

            MahAppsThemeHelper.CreateTheme(themeInfo.BaseColorScheme, themeInfo.AccentBaseColor, changeImmediately: true);

            // Note: important to add the resources dictionary *after* changing the app style, but then insert at the top
            // so Fluent.Ribbon theme detection performance is best
            applicationResources.MergedDictionaries.Insert(1, resourceDictionary);
        }
Beispiel #21
0
        public ThemeInfo GetThemeDescriptorFromText(string text)
        {
            var themeDescriptor = new ThemeInfo();

            try
            {
                var themeConfiguration = JsonConvert.DeserializeObject <ThemeConfiguration>(text);
                themeDescriptor.FriendlyName = themeConfiguration.Title;
            }
            catch { }

            return(themeDescriptor);
        }
Beispiel #22
0
 /// <summary>
 /// 主题设置添加
 /// </summary>
 /// <param name="mTheme">主题设置实体</param>
 public void AddTheme(ThemeInfo mTheme)
 {
     //string imgUrl = string.Empty;
     //var data = Context.ThemeInfo.ToList();
     var data = DbFactory.Default.Get<ThemeInfo>().Exist();
     if (!data)
     {
         //Context.ThemeInfo.Add(mTheme);
         //Context.SaveChanges();
         DbFactory.Default.Add(mTheme);
         Core.Cache.Remove(CacheKeyCollection.Themes);//清除缓存
     }
 }
Beispiel #23
0
        public virtual ThemeInfo GetThemeInfo()
        {
            var accentColor = _accentColorService.GetAccentColor();

            var themeInfo = new ThemeInfo
            {
                BaseColorScheme = _baseColorSchemeService.GetBaseColorScheme(),
                AccentBaseColor = accentColor,
                HighlightColor  = accentColor
            };

            return(themeInfo);
        }
Beispiel #24
0
 public ThemePage()
 {
     InitializeComponent();
     _themeManager = ThemeManager.getInstance();
     if (!_themeManager.ThemingActive)
     {
         return;
     }
     _themeManager = ThemeManager.getInstance();
     _themeManager.ThemeChanged += ApplyTheme;
     _oriTheme         = _themeManager.ActiveTheme;
     _oriActiveTheming = _themeManager.ThemingActive;
 }
Beispiel #25
0
        private static ThemeInfo GetThemeEntity(IDataReader reader)
        {
            ThemeInfo ti = new ThemeInfo();

            ti.ThemeId    = TypeConverter.ObjectToInt(reader["themeid"], 0);
            ti.Directory  = reader["directory"].ToString();
            ti.Name       = reader["name"].ToString();
            ti.Type       = TypeConverter.ObjectToInt(reader["type"], 0);
            ti.Author     = reader["author"].ToString();
            ti.CreateDate = reader["createdate"].ToString();
            ti.CopyRight  = reader["copyright"].ToString();
            return(ti);
        }
Beispiel #26
0
        public void SetMainPageContent(ThemeInfo theme, bool keepOldData)
        {
            if (keepOldData)
            {
                foreach (var themeRequiredField in theme.ThemeRequiredProperties)
                {
                    //Checks if exist in the current content config
                    var field = _mainPageContentRepository.FirstOrDefault(a => a.Key == themeRequiredField.Key);

                    if (field == null)
                    {
                        _mainPageContentRepository.InsertOrUpdateAndGetId(new MainPageContent()
                        {
                            Value              = themeRequiredField.Value,
                            Key                = themeRequiredField.Key,
                            ThemeReferenceId   = theme.ThemeUniqueName,
                            ThemeReferenceName = theme.ThemeName,
                            IsStatic           = true,
                            Type               = themeRequiredField.Type
                        });
                    }
                }
            }
            else
            {
                foreach (var themeRequiredField in theme.ThemeRequiredProperties)
                {
                    //Checks if exist in the current content config
                    var field = _mainPageContentRepository.FirstOrDefault(a => a.Key == themeRequiredField.Key);

                    if (field == null)
                    {
                        _mainPageContentRepository.InsertOrUpdateAndGetId(new MainPageContent()
                        {
                            Value              = themeRequiredField.Value,
                            Key                = themeRequiredField.Key,
                            ThemeReferenceId   = theme.ThemeUniqueName,
                            ThemeReferenceName = theme.ThemeName,
                            IsStatic           = true,
                            Type               = themeRequiredField.Type
                        });
                    }
                    else
                    {
                        field.Value = themeRequiredField.Value;
                    }
                }
            }
            CurrentUnitOfWork.SaveChanges();
        }
 /// <summary>
 /// Gets current theme info or null if no theme is set
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public static ThemeInfo GetThemeInfo(this HttpContextBase ctx)
 {
     var t= ctx.Get<ThemeInfo>(ThemeInfoKey);
     if (t == null)
     {
         var theme = ctx.GetCurrentThemeName();
         if (!theme.IsNullOrEmpty())
         {
             t = new ThemeInfo(ctx,theme);
             ctx.Items[ThemeInfoKey] = t;
         }
     }
     return t;
 }
Beispiel #28
0
        internal static void LoadTheme(ResourceDictionary targetResources, string name)
        {
            ThemeInfo theme = new ThemeInfo();

            string themeXaml = GetThemeXaml(name, "Theme", /* lookupShared */ false);
            try {
                ExtractThemeContent(themeXaml, theme, /* extractIncludes */ true);
                if ((theme.Includes.Length == 0) && (theme.Keys.Count != 0)) {
                    UserControl userControl = (UserControl)XamlReader.Load(themeXaml);
                    ResourceDictionary themeResources = userControl.Resources;

                    foreach (string key in theme.Keys) {
                        targetResources.Add(key, themeResources[key]);
                    }

                    return;
                }
            }
            catch (Exception e) {
                throw new InvalidOperationException("The theme named '" + name + "' contained invalid XAML.", e);
            }

            if (theme.Includes.Length != 0) {
                string[] includes = theme.Includes.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < includes.Length; i++) {
                    string includeXaml = GetThemeXaml(name, includes[i], /* lookupShared */ true);
                    try {
                        ExtractThemeContent(includeXaml, theme, /* extractIncludes */ false);
                    }
                    catch (Exception e) {
                        throw new InvalidOperationException("The include named '" + includes[i] + "' in the theme named '" + name + "' contained invalid XAML.", e);
                    }
                }
            }

            try {
                string mergedXaml = theme.GetXml();
                UserControl userControl = (UserControl)XamlReader.Load(mergedXaml);
                ResourceDictionary themeResources = userControl.Resources;

                foreach (string key in theme.Keys) {
                    targetResources.Add(key, themeResources[key]);
                }
            }
            catch (Exception e) {
                throw new InvalidOperationException("The theme named '" + name + "' contained invalid XAML.", e);
            }
        }
Beispiel #29
0
        protected override void PageHead_PageHeadEvent(object sender, PageHeadEventArgs e)
        {
            base.PageHead_PageHeadEvent(sender, e);

            try
            {
                switch (e.Code)
                {
                //切换主题
                case 100:
                    ThemeInfo themeInfo = e.Data as ThemeInfo;
                    if (themeInfo != null)
                    {
                        ThemeInfo             = themeInfo;
                        App.Session.ThemeInfo = themeInfo;
                        App.Session.ThemeName = themeInfo.Name;
                        ChangeTheme();
                        SendThemeChangeMessage();
                    }
                    break;

                //切换语言
                case 110:
                    LangTypeInfo langType = e.Data as LangTypeInfo;
                    if (langType != null)
                    {
                        LangTypeInfo             = langType;
                        App.Session.LangTypeInfo = langType;
                        App.Session.LangTypeID   = langType.LangID;
                        MyWaiter.Visibility      = Visibility.Visible;
                        mWorker                     = new BackgroundWorker();
                        mWorker.DoWork             += (s, de) => App.InitAllLanguageInfos();
                        mWorker.RunWorkerCompleted += (s, re) =>
                        {
                            mWorker.Dispose();
                            MyWaiter.Visibility = Visibility.Hidden;
                            ChangeLanguage();
                            SendLanguageChangeMessage();
                        };
                        mWorker.RunWorkerAsync();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                App.ShowExceptionMessage(ex.Message);
            }
        }
Beispiel #30
0
        IEnumerator ComponentVisualMap()
        {
            chart.title.subText = "VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";

            chart.visualMap.enable     = true;
            chart.visualMap.show       = true;
            chart.visualMap.orient     = Orient.Vertical;
            chart.visualMap.calculable = true;
            chart.visualMap.min        = 0;
            chart.visualMap.max        = 100;
            chart.visualMap.range[0]   = 0;
            chart.visualMap.range[1]   = 100;

            var colors = new List <string> {
                "#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
                "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"
            };

            chart.visualMap.inRange.Clear();
            foreach (var str in colors)
            {
                chart.visualMap.inRange.Add(ThemeInfo.GetColor(str));
            }
            chart.grid.left   = 80;
            chart.grid.bottom = 100;
            chart.RefreshChart();

            yield return(new WaitForSeconds(1f));

            while (chart.visualMap.rangeMin < 40)
            {
                chart.visualMap.rangeMin += speed * Time.deltaTime;
                chart.RefreshChart();
                yield return(null);
            }
            while (chart.visualMap.rangeMax > 60)
            {
                chart.visualMap.rangeMax -= speed * Time.deltaTime;
                chart.RefreshChart();
                yield return(null);
            }
            while (chart.visualMap.rangeMin > 0 || chart.visualMap.rangeMax < 100)
            {
                chart.visualMap.rangeMin -= speed * Time.deltaTime;
                chart.visualMap.rangeMax += speed * Time.deltaTime;
                chart.RefreshChart();
                yield return(null);
            }
        }
Beispiel #31
0
        private void Init()
        {
            ThemeInfo themeInfo = new ThemeInfo();

            themeInfo.Name  = "Default";
            themeInfo.Color = "Brown";
            ThemeInfo       = themeInfo;

            AppServerInfo webInfo = new AppServerInfo();

            webInfo.Address  = "192.168.6.75";
            webInfo.Port     = 8081;
            webInfo.Protocol = "http";
            AppServerInfo    = webInfo;
        }
    public override bool EvaluateTriggerCondition()
    {
        PsaiInfo psaiInfo = PsaiCore.Instance.GetPsaiInfo();

        if (psaiInfo != null)
        {
            ThemeInfo effectiveTheme = PsaiCore.Instance.GetThemeInfo(psaiInfo.effectiveThemeId);
            if (effectiveTheme != null)
            {
                return(!(effectiveTheme.type == this.themeType));
            }
        }

        return(true);
    }
        public ActionResult Create(ThemeInfo model)
        {
            if (!ModelState.IsValid)
            {
                return this.AjaxFail("Invalid or incomplete theme information provided.", HttpStatusCode.BadRequest);
            }

            try
            {
                var creator = new ThemeCreator(model);
                creator.Create();
            }
            catch (ThemeCreateException ex)
            {
                return this.AjaxFail(ex.Message, HttpStatusCode.InternalServerError);
            }

            return Json(new { success = true }, JsonRequestBehavior.AllowGet);
        }
Beispiel #34
0
        public ActionResult Create(ThemeInfo model)
        {
            if(!ModelState.IsValid)
            {
                return this.InvalidModelState(this.ModelState);
            }

            try
            {
                var creator = new ThemeCreator(model);
                creator.Create(this.Tenant);
            }
            catch(ThemeCreateException ex)
            {
                return this.Failed(ex.Message, HttpStatusCode.InternalServerError);
            }

            return this.Ok();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="theme"></param>
        /// <param name="folder"></param>
        /// <param name="location"></param>
        /// <param name="forWeb"></param>
        /// <returns></returns>
        internal string GetThemedPath(ThemeInfo theme, string folder, string location, bool forWeb)
        {
            if (theme == null) throw new ArgumentNullException("theme");
            if (folder == null) throw new ArgumentNullException("folder");
            if (location == null) throw new ArgumentNullException("folderName");

            string path;
            string unverifiedPath = this.GetUnverifiedThemedPath(theme.Name, folder, location);

            // check to see if the path is suppose to be from default
            if (theme.IsDefaultTheme && this.VerifyDefaultPath(unverifiedPath, out path))
                goto PathSuccess;
            // check to see if the path is suppose to be from community
            else if (theme.IsDefaultTheme == false && this.VerifyCommunityPath(theme.CommunityID, unverifiedPath, out path))
                goto PathSuccess;

            // if all else fails return null;
            return null;

            PathSuccess:
            if (forWeb)
                return this.GetAbsoluteUrl(path).ToString();

            return GetRelativeDiskPath(path);
        }
 internal CommunityThemeCollection(ThemeInfo[] themes)
 {
     this._collection = new ThemeCollection(themes);
 }
Beispiel #37
0
        private static void ExtractThemeContent(string xml, ThemeInfo theme, bool extractIncludes)
        {
            XmlReader xmlReader = XmlReader.Create(new StringReader(xml),
                                                   new XmlReaderSettings {
                                                       CheckCharacters = false,
                                                       DtdProcessing = DtdProcessing.Ignore,
                                                       IgnoreComments = true,
                                                       IgnoreProcessingInstructions = true,
                                                       IgnoreWhitespace = true,
                                                   });
            while (xmlReader.Read()) {
                if (xmlReader.NodeType == XmlNodeType.Element) {
                    // Found the first element
                    string tagName = xmlReader.Name;

                    // Extract all the xml namespaces
                    bool hasAttributes = xmlReader.MoveToFirstAttribute();
                    while (hasAttributes) {
                        if (xmlReader.Name.StartsWith("xmlns:")) {
                            string namespaceDeclaration = xmlReader.ReadContentAsString();
                            theme.AddNamespace(xmlReader.Name, namespaceDeclaration);
                        }
                        hasAttributes = xmlReader.MoveToNextAttribute();
                    }

                    if (extractIncludes) {
                        theme.Includes = xmlReader.GetAttribute("Includes");
                    }

                    string resourcesTag = tagName + ".Resources";
                    if (xmlReader.ReadToFollowing(resourcesTag)) {
                        xmlReader.MoveToContent();

                        // TODO: I would have expected MoveToContent to move to the first item
                        //       within the current tag, but apparently the reader is still
                        //       positioned at the current tag, unless a Read is performed.
                        xmlReader.Read();

                        while (xmlReader.EOF == false) {
                            if (xmlReader.NodeType == XmlNodeType.Element) {
                                string key = xmlReader.GetAttribute("x:Key");
                                if ((String.IsNullOrEmpty(key) == false) && (theme.ContainsKey(key) == false)) {
                                    string markup = xmlReader.ReadOuterXml();
                                    theme.AddItem(key, markup);
                                }
                                else {
                                    xmlReader.Skip();
                                }
                            }
                            else {
                                // No more items
                                break;
                            }
                        }
                    }

                    // We only look at the resources of the root tag, and so we're done
                    break;
                }
            }
        }
Beispiel #38
0
 public ThemeCollection(ThemeInfo[] themes)
 {
     this._collection = themes;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="theme"></param>
 /// <param name="folder"></param>
 /// <param name="location"></param>
 /// <returns></returns>
 internal string GetThemedPath(ThemeInfo theme, string folder, string location)
 {
     return this.GetThemedPath(theme, folder, location, true);
 }