示例#1
0
        /// <summary>
        /// Apply a theme.
        /// </summary>
        /// <param name="targetElement">The target element.</param>
        /// <param name="dictionaryUri">The theme dictionary uri.</param>
        private static void ApplyTheme(FrameworkElement targetElement, Uri dictionaryUri)
        {
            if (targetElement == null)
            {
                return;
            }

            ThemeDictionary themeDictionary = null;

            if (dictionaryUri != null)
            {
                themeDictionary        = new ThemeDictionary();
                themeDictionary.Source = dictionaryUri;

                // add the new dictionary to the collection of merged dictionaries of the target object
                targetElement.Resources.MergedDictionaries.Insert(0, themeDictionary);
            }

            // find if the target element already has a theme applied
            List <ThemeDictionary> existingDictionaries = (from dictionary in targetElement.Resources.MergedDictionaries.OfType <ThemeDictionary>() select dictionary).ToList();

            // remove the existing dictionaries
            foreach (ThemeDictionary eachThemeDictionary in existingDictionaries)
            {
                if (themeDictionary == eachThemeDictionary)
                {
                    continue; // don't remove the newly added dictionary
                }

                targetElement.Resources.MergedDictionaries.Remove(eachThemeDictionary);
            }
        }
示例#2
0
 public static void LoadTheme(String fileName)
 {
     if (ThemeDictionary == null)
     {
         ThemeDictionary = (from s in Application.Current.Resources.MergedDictionaries where s.Source.OriginalString.EndsWith("Theme.xaml") select s).SingleOrDefault();
     }
     if (ThemeDictionary != null)
     {
         using (var stream = File.OpenRead(fileName))
         {
             ParserContext pc = new ParserContext();
             pc.XmlnsDictionary.Add("", "Magic.Tools");
             pc.XmlnsDictionary.Add("", "Magic.Package");
             var path = Environment.CurrentDirectory;
             if (!path.EndsWith("\\"))
             {
                 path = path + "\\";
             }
             pc.BaseUri = new Uri(path, UriKind.Absolute);
             ResourceDictionary resourceDictionary = XamlReader.Load(stream, pc) as ResourceDictionary;
             foreach (DictionaryEntry key in resourceDictionary)
             {
                 if (ThemeDictionary.Contains(key.Key))
                 {
                     ThemeDictionary.Remove(key.Key);
                 }
                 ThemeDictionary.Add(key.Key, key.Value);
             }
             getThemeName();
         };
     }
 }
示例#3
0
        /// <summary>
        /// Set the current theme
        /// </summary>
        /// <param name="name">The name of the theme</param>
        /// <returns>true if the new theme is set, false otherwise</returns>
        public bool SetCurrent(string name)
        {
            #if WINDOWS_APP
            if (ThemeDictionary.ContainsKey(name))
            {
                ITheme newTheme = ThemeDictionary[name];
                CurrentTheme = newTheme;

                //   ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0];
                ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0
                                                  ? Application.Current.Resources.MergedDictionaries[0]
                                                  : null;
                //  theme.BeginInit();
                //   theme.MergedDictionaries.Clear();
                if (appTheme != null)
                {
                    appTheme.BeginInit();
                    appTheme.MergedDictionaries.Clear();
                }
                else
                {
                    appTheme = new ResourceDictionary();
                    appTheme.BeginInit();
                    Application.Current.Resources.MergedDictionaries.Add(appTheme);
                }

                foreach (Uri uri in newTheme.UriList)
                {
                    ResourceDictionary newDict = new ResourceDictionary {
                        Source = uri
                    };

                    /*AvalonDock and menu style needs to move to the application
                     * 1. AvalonDock needs global styles as floatable windows can be created
                     * 2. Menu's need global style as context menu can be created
                     */
                    //if (uri.ToString().Contains("AvalonDock") ||
                    //    uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml"))
                    //{
                    appTheme.MergedDictionaries.Add(newDict);
                    //}
                    //else
                    //{
                    //    theme.MergedDictionaries.Add(newDict);
                    //}
                }
                appTheme.EndInit();

                //set Avalondock theme
                //todo in wpf dll       m_workspace.ADTheme = newTheme.ADTheme;

                //    theme.EndInit();
                _logger.Log("Theme set to " + name, LogCategory.Info, LogPriority.None);
                //todo         _eventAggregator.Publish<ThemeChangeEvent>()(newTheme);
            }
#endif
            return(false);
        }
示例#4
0
        /*CONSTRUCTOR*/

        #region Default constructor
        public HomeController(ThemeConverter tConverter, ThemeDictionary dictionary, IWebHostEnvironment environment, UserColorDataModel dataModel, IConfiguration config, ColorStringConverter cConverter, HelperModel hModel)
        {
            this.environment = environment;
            this.tConverter  = tConverter;
            this.dictionary  = dictionary;
            this.dataModel   = dataModel;
            this.config      = config;
            this.cConverter  = cConverter;
            this.hModel      = hModel;
        }
        public void ChangeTheme(String themeName)
        {
            // Ensure to be on Main UI Thread
            if (!MainThread.IsMainThread)
            {
                MainThread.BeginInvokeOnMainThread(() => ChangeTheme(themeName));
                return;
            }
            try
            {
                if (String.IsNullOrEmpty(themeName))
                {
                    return;
                }

                String validThemeName = themeName.ToLower();
                if (validThemeName == CurrentThemeName)
                {
                    return;
                }

                ResourceDictionary resourceDictionary = null;
                switch (validThemeName)
                {
                case "light":
                    resourceDictionary = new ThemeLight();
                    break;

                case "dark":
                    resourceDictionary = new ThemeDark();
                    break;

                default:
                    validThemeName     = "light";
                    resourceDictionary = new ThemeLight();
                    break;
                }

                // Clear and set new theme
                ThemeDictionary.Clear();
                ThemeDictionary.Add(resourceDictionary);

                // Store specified theme name
                CurrentThemeName = validThemeName;
            }
            catch { }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SiteSecurity.IsInRole("admin") == false)
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            ID = "EditConfigBox";

            SharedBasePage requestPage = Page as SharedBasePage;
            SiteConfig     siteConfig  = requestPage.SiteConfig;

            if (!IsPostBack)
            {
                textContact.Text                       = siteConfig.Contact;
                textCopyright.Text                     = siteConfig.Copyright;
                textPassword.Text                      = passwordPlaceHolder;
                textConfirmPassword.Text               = passwordPlaceHolder;
                textFrontPageCategory.Text             = siteConfig.FrontPageCategory;
                textFrontPageDayCount.Text             = siteConfig.FrontPageDayCount.ToString();
                textFrontPageEntryCount.Text           = siteConfig.FrontPageEntryCount.ToString();
                textEntriesPerPage.Text                = siteConfig.EntriesPerPage.ToString();
                textContentLookaheadDays.Text          = siteConfig.ContentLookaheadDays.ToString();
                textMainMaxDaysInRss.Text              = siteConfig.RssDayCount.ToString();
                textMainMaxEntriesInRss.Text           = siteConfig.RssMainEntryCount.ToString();
                textOtherMaxEntriesInRss.Text          = siteConfig.RssEntryCount.ToString();
                checkAlwaysIncludeContentInRSS.Checked = siteConfig.AlwaysIncludeContentInRSS;
                checkEnableRSSItemFooter.Checked       = siteConfig.EnableRssItemFooters;
                textRSSItemFooter.Text                 = siteConfig.RssItemFooter;
                txtRSSEndPointRewrite.Text             = siteConfig.RSSEndPointRewrite;
                checkPop3Enabled.Checked               = siteConfig.EnablePop3;
                textPop3Interval.Text                  = siteConfig.Pop3Interval.ToString();
                textPop3Server.Text                    = siteConfig.Pop3Server;
                textPop3SubjectPrefix.Text             = siteConfig.Pop3SubjectPrefix;
                textPop3Username.Text                  = siteConfig.Pop3Username;
                textPop3Password.Text                  = passwordPlaceHolder;
                textPop3PasswordRepeat.Text            = passwordPlaceHolder;
                textRoot.Text                                       = siteConfig.Root;
                textSmtpServer.Text                                 = siteConfig.SmtpServer;
                textSmtpPort.Text                                   = siteConfig.SmtpPort.ToString();
                checkUseSSLForSMTP.Checked                          = siteConfig.UseSSLForSMTP;
                textNotificationEmailAddress.Text                   = siteConfig.NotificationEMailAddress;
                textSubtitle.Text                                   = siteConfig.Subtitle;
                textSmtpServer.Text                                 = siteConfig.SmtpServer;
                checkEnableCoComment.Checked                        = siteConfig.EnableCoComment;
                checkComments.Checked                               = siteConfig.SendCommentsByEmail;
                checkPingbacks.Checked                              = siteConfig.SendPingbacksByEmail;
                checkReferrals.Checked                              = siteConfig.SendReferralsByEmail;
                checkPosts.Checked                                  = siteConfig.SendPostsByEmail;
                checkTrackbacks.Checked                             = siteConfig.SendTrackbacksByEmail;
                checkShowCommentCounters.Checked                    = siteConfig.ShowCommentCount;
                checkEnableAutoPingback.Checked                     = siteConfig.EnableAutoPingback;
                checkEnableBloggerApi.Checked                       = siteConfig.EnableBloggerApi;
                checkEnableComments.Checked                         = siteConfig.EnableComments;
                checkEnableCommentApi.Checked                       = siteConfig.EnableCommentApi;
                checkShowCommentsWhenViewingEntry.Checked           = siteConfig.ShowCommentsWhenViewingEntry;
                checkEnableConfigEditService.Checked                = siteConfig.EnableConfigEditService;
                checkEnableEditService.Checked                      = siteConfig.EnableEditService;
                checkEnableAutoSave.Checked                         = siteConfig.EnableAutoSave;
                checkEnablePingbackService.Checked                  = siteConfig.EnablePingbackService;
                checkEnableTrackbackService.Checked                 = siteConfig.EnableTrackbackService;
                checkEnableClickThrough.Checked                     = siteConfig.EnableClickThrough;
                checkEnableAggregatorBugging.Checked                = siteConfig.EnableAggregatorBugging;
                checkXssEnabled.Checked                             = siteConfig.EnableXSSUpstream;
                textXssEndpoint.Text                                = siteConfig.XSSUpstreamEndpoint;
                textXssInterval.Text                                = siteConfig.XSSUpstreamInterval.ToString();
                textXssPassword.Text                                = passwordPlaceHolder;
                textXssPasswordRepeat.Text                          = passwordPlaceHolder;
                textXssUsername.Text                                = siteConfig.XSSUpstreamUsername;
                textXssRssFilename.Text                             = siteConfig.XSSRSSFilename;
                checkPop3InlineAttachedPictures.Checked             = siteConfig.Pop3InlineAttachedPictures;
                textPop3AttachedPicturesPictureThumbnailHeight.Text = siteConfig.Pop3InlinedAttachedPicturesThumbHeight.ToString();
                mailDeletionAll.Checked                             = siteConfig.Pop3DeleteAllMessages;
                mailDeletionProcessed.Checked                       = !siteConfig.Pop3DeleteAllMessages;
                logIgnoredEmails.Checked                            = siteConfig.Pop3LogIgnoredEmails;
                checkShowItemDescriptionInAggregatedViews.Checked   = siteConfig.ShowItemDescriptionInAggregatedViews;
                checkEnableStartPageCaching.Checked                 = siteConfig.EnableStartPageCaching;
                checkEnableBlogrollDescription.Checked              = siteConfig.EnableBlogrollDescription;
                checkEntryTitleAsLink.Checked                       = siteConfig.EntryTitleAsLink;
                checkEnableUrlRewriting.Checked                     = siteConfig.EnableUrlRewriting;
                checkEnableCrosspost.Checked                        = siteConfig.EnableCrossposts;
                checkCategoryAllEntries.Checked                     = siteConfig.CategoryAllEntries;
                checkReferralUrlBlacklist.Checked                   = siteConfig.EnableReferralUrlBlackList;
                textReferralBlacklist.Text                          = siteConfig.ReferralUrlBlackList;
                checkCaptchaEnabled.Checked                         = siteConfig.EnableCaptcha;
                checkReferralBlacklist404s.Checked                  = siteConfig.EnableReferralUrlBlackList404s;
                textRSSChannelImage.Text                            = siteConfig.ChannelImageUrl;
                checkEnableTitlePermaLink.Checked                   = siteConfig.EnableTitlePermaLink;
                checkEnableTitlePermaLinkUnique.Checked             = siteConfig.EnableTitlePermaLinkUnique;
                checkEnableTitlePermaLinkSpaces.Checked             = siteConfig.EnableTitlePermaLinkSpaces;
                checkEnableEncryptLoginPassword.Checked             = siteConfig.EncryptLoginPassword;
                checkEnableSmtpAuthentication.Checked               = siteConfig.EnableSmtpAuthentication;
                textSmtpUsername.Text                               = siteConfig.SmtpUserName;
                textSmtpPassword.Text                               = passwordPlaceHolder;
                textRssLanguage.Text                                = siteConfig.RssLanguage;
                checkEnableSearchHighlight.Checked                  = siteConfig.EnableSearchHighlight;
                checkEnableEntryReferral.Checked                    = siteConfig.EnableEntryReferrals;
                textFeedBurnerName.Text                             = siteConfig.FeedBurnerName;
                checkUseFeedScheme.Checked                          = siteConfig.UseFeedSchemeForSyndication;
                checkLogBlockedReferrals.Checked                    = siteConfig.LogBlockedReferrals;

                //populate the title space replacement options
                dropDownTitlePermalinkReplacementCharacter.Items.Clear();//in casee someone adds them in the ascx
                foreach (string s in TitleMapperModule.TitlePermalinkSpaceReplacementOptions)
                {
                    dropDownTitlePermalinkReplacementCharacter.Items.Add(s);
                }
                dropDownTitlePermalinkReplacementCharacter.SelectedValue = siteConfig.TitlePermalinkSpaceReplacement;

                checkSpamBlockingEnabled.Checked = siteConfig.EnableSpamBlockingService;
                textSpamBlockingApiKey.Text      = siteConfig.SpamBlockingServiceApiKey;
                optionSpamHandling.SelectedValue = siteConfig.EnableSpamModeration ? SPAM_OPTION_SAVE : SPAM_OPTION_DELETE;

                // setup the checkbox list to select which tags to allow
                checkBoxListAllowedTags.DataSource     = siteConfig.AllowedTags;
                checkBoxListAllowedTags.DataTextField  = "Name";
                checkBoxListAllowedTags.DataValueField = "Name";

                // enable comment moderation
                checkCommentsRequireApproval.Checked = siteConfig.CommentsRequireApproval;

                // allow html and comments
                checkAllowHtml.Checked = siteConfig.CommentsAllowHtml;

                // populate from config - Gravatar
                GravatarPopulateForm();

                // supress email address display
                checkDisableEmailDisplay.Checked = siteConfig.SupressEmailAddressDisplay;

                checkEnableCommentDays.Checked = siteConfig.EnableCommentDays;

                checkAttemptToHtmlTidyContent.Checked = siteConfig.HtmlTidyContent;
                checkResolveCommenterIP.Checked       = siteConfig.ResolveCommenterIP;

                //if ( siteConfig.EnableCommentDays )
                //{
                if (siteConfig.DaysCommentsAllowed > 0)
                {
                    textDaysCommentsAllowed.Text = siteConfig.DaysCommentsAllowed.ToString();
                }
                //}
                //else
                //{
                //	textDaysCommentsAllowed.Text = null;
                //}

                // supress email address display
                checkDisableEmailDisplay.Checked = siteConfig.SupressEmailAddressDisplay;

                checkEnableCommentDays.Checked = siteConfig.EnableCommentDays;

                //if ( siteConfig.EnableCommentDays )
                //{
                if (siteConfig.DaysCommentsAllowed > 0)
                {
                    textDaysCommentsAllowed.Text = siteConfig.DaysCommentsAllowed.ToString();
                }
                //}
                //else
                //{
                //	textDaysCommentsAllowed.Text = null;
                //}

                // email daily report
                checkDailyReport.Text    = resmgr.GetString("text_daily_activity_report");
                checkDailyReport.Checked = siteConfig.EnableDailyReportEmail;

                WindowsTimeZoneCollection timeZones = WindowsTimeZone.TimeZones;
                foreach (WindowsTimeZone tz in timeZones)
                {
                    listTimeZones.Items.Add(new ListItem(tz.DisplayName, tz.ZoneIndex.ToString()));
                }
                listTimeZones.SelectedValue = siteConfig.DisplayTimeZoneIndex.ToString();
                checkUseUTC.Checked         = !siteConfig.AdjustDisplayTimeZone;

                //FIX: hardcoded path
                ThemeDictionary themes = BlogTheme.Load(SiteUtilities.MapPath("themes"));
                foreach (BlogTheme theme in themes.Values)
                {
                    // setting the selected item like this instead of
                    // using    listThemes.SelectedValue = siteConfig.Theme;
                    // prevents the page from breaking.

                    ListItem item = new ListItem(theme.Title, theme.Name);
                    if (item.Value == siteConfig.Theme)
                    {
                        item.Selected = true;
                    }
                    listThemes.Items.Add(item);
                }

                textTitle.Text = siteConfig.Title;

                checkBoxListPingServices.DataSource     = PingServiceCollection;
                checkBoxListPingServices.DataTextField  = "Hyperlink";
                checkBoxListPingServices.DataValueField = "Endpoint";

                drpEntryEditControl.Items.Clear();
                foreach (string potentialAssembly in Directory.GetFiles(HttpRuntime.BinDirectory, "*.dll"))
                {
                    try
                    {
                        Assembly a = Assembly.LoadFrom(potentialAssembly);
                        foreach (Type potentialType in a.GetTypes())
                        {
                            if (potentialType.BaseType == typeof(EditControlAdapter))
                            {
                                drpEntryEditControl.Items.Add(new ListItem(potentialType.Name, potentialType.AssemblyQualifiedName));
                            }
                        }
                    }
                    catch (Exception)
                    {
                        //swallow
                    }
                }

                //Reasonable default
                if (string.IsNullOrEmpty(siteConfig.EntryEditControl))
                {
                    siteConfig.EntryEditControl = typeof(TinyMCEAdapter).AssemblyQualifiedName;
                }
                DataBind();

                ListItem li = drpEntryEditControl.Items.FindByText(siteConfig.EntryEditControl);
                if (li != null)
                {
                    li.Selected = true;
                }
                else
                {
                    drpEntryEditControl.SelectedIndex = 0;
                }

                foreach (PingService ps in siteConfig.PingServices)
                {
                    checkBoxListPingServices.Items.FindByValue(ps.Endpoint).Selected = true;
                }

                foreach (ValidTag tag in siteConfig.AllowedTags)
                {
                    checkBoxListAllowedTags.Items.FindByValue(tag.Name).Selected = tag.IsAllowed;
                }

                //check for Smtp permission
                if (SecurityManager.IsGranted(new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort)))
                {
                    phSmtpTrustWarning.Visible = false;
                }
                else
                {
                    phSmtpTrustWarning.Visible = true;
                }

                //check for Socket permission
                SocketPermission sp;
                if (String.IsNullOrEmpty(textPop3Server.Text))
                {
                    sp = new SocketPermission(PermissionState.Unrestricted);
                }
                else
                {
                    sp = new SocketPermission(NetworkAccess.Connect, TransportType.Tcp, textPop3Server.Text, 110);
                }

                if (SecurityManager.IsGranted(sp))
                {
                    phPop3TrustWarning.Visible = false;
                }
                else
                {
                    phPop3TrustWarning.Visible = true;
                }

                // georss stuff
                checkEnableGeoRss.Checked     = siteConfig.EnableGeoRss;
                textGoogleMapsApi.Text        = siteConfig.GoogleMapsApiKey;
                textDefaultLatitude.Text      = siteConfig.DefaultLatitude.ToString(CultureInfo.InvariantCulture);
                textDefaultLongitude.Text     = siteConfig.DefaultLongitude.ToString(CultureInfo.InvariantCulture);
                checkEnableGoogleMaps.Checked = siteConfig.EnableGoogleMaps;
                checkEnableDefaultLatLongForNonGeoCodedPosts.Checked = siteConfig.EnableDefaultLatLongForNonGeoCodedPosts;

                // OpenId
                chkAllowOpenIdAdmin.Checked          = siteConfig.AllowOpenIdAdmin;
                chkAllowOpenIdCommenter.Checked      = siteConfig.AllowOpenIdComments;
                chkBypassSpamOpenIdCommenter.Checked = siteConfig.BypassSpamOpenIdComment;


                SeoMetaTags smt = new SeoMetaTags().GetMetaTags();

                txtMetaDescription.Text = smt.MetaDescription;
                txtMetaKeywords.Text    = smt.MetaKeywords;
                txtTwitterCard.Text     = smt.TwitterCard;
                txtTwitterSite.Text     = smt.TwitterSite;
                txtTwitterCreator.Text  = smt.TwitterCreator;
                txtTwitterImage.Text    = smt.TwitterImage;
                txtFaceBookAdmins.Text  = smt.FaceBookAdmins;
                txtFaceBookAppID.Text   = smt.FaceBookAppID;

                checkAmpEnabled.Checked = siteConfig.AMPPagesEnabled;
            } // end if !postback

            //enable list controls that may have been enabled client-side
            //in 2.0 if they are not enable we won't get there postback data
            checkBoxListAllowedTags.Enabled = true;
            dropGravatarRating.Enabled      = true;
        }
示例#7
0
 public PlusThemingOptions()
 {
     Themes = new ThemeDictionary();
 }
示例#8
0
 public AbpThemingOptions()
 {
     Themes = new ThemeDictionary();
 }
示例#9
0
 public static void SetThemeResources(DependencyObject obj, ThemeDictionary value)
 {
     ValidationHelper.NotNull(obj, "obj");
     obj.SetValue(ThemeResourcesProperty, value);
 }
示例#10
0
 public RocketThemingOptions()
 {
     Themes = new ThemeDictionary();
 }