Exemplo n.º 1
0
        /// <summary>
        /// Loads the alternate fonts checkbox list.
        /// </summary>
        /// <param name="selectedWeight">The selected weight.</param>
        private void LoadAlternateFontsCheckboxList(string selectedWeight)
        {
            List <FontAwesomeHelper.FontAwesomeIconCssWeight> alternateFontWeights = null;

            if (FontAwesomeHelper.HasFontAwesomeProKey())
            {
                alternateFontWeights = FontAwesomeHelper.FontAwesomeIconCssWeights.Where(a => a.IsConfigurable && a.WeightName != selectedWeight).ToList();
            }
            else
            {
                alternateFontWeights = FontAwesomeHelper.FontAwesomeIconCssWeights.Where(a => a.IsConfigurable && a.IncludedInFree && a.WeightName != selectedWeight).ToList();
            }

            if (alternateFontWeights.Count > 0)
            {
                cblFontAwesomeAlternateFonts.Visible = true;
                var selectedAlternateFonts = cblFontAwesomeAlternateFonts.Items.OfType <ListItem>().Where(a => a.Selected).Select(a => a.Value).ToList();
                cblFontAwesomeAlternateFonts.Items.Clear();
                foreach (var fontWeight in alternateFontWeights)
                {
                    cblFontAwesomeAlternateFonts.Items.Add(new ListItem(fontWeight.DisplayName, fontWeight.WeightName)
                    {
                        Selected = selectedAlternateFonts.Contains(fontWeight.WeightName)
                    });
                }
            }
            else
            {
                cblFontAwesomeAlternateFonts.Visible = false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                var fontAwesomeProKey    = FontAwesomeHelper.GetFontAwesomeProKey();
                var hasFontAwesomeProKey = FontAwesomeHelper.HasFontAwesomeProKey();
                tbFontAwesomeProKey.Text   = fontAwesomeProKey;
                pnlFontAwesomeFree.Visible = !hasFontAwesomeProKey;
                btnInstallUpdate.Text      = hasFontAwesomeProKey ? "Update" : "Install";
                fupFontAwesomeProPackage.UploadAsTemporary = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private void LoadDropDowns()
        {
            ddlFontAwesomeIconWeight.Items.Clear();

            if (FontAwesomeHelper.HasFontAwesomeProKey())
            {
                // If they have pro, any of the weights can be used as the primary weight
                foreach (var fontAwesomeIconCssWeight in FontAwesomeHelper.FontAwesomeIconCssWeights.Where(a => a.IsConfigurable))
                {
                    ddlFontAwesomeIconWeight.Items.Add(new ListItem(fontAwesomeIconCssWeight.DisplayName, fontAwesomeIconCssWeight.WeightName));
                }
            }
            else
            {
                // If they don't have pro, include list the weights that are included in the free version, and are allowed to be used a primary weight
                foreach (var fontAwesomeIconCssWeight in FontAwesomeHelper.FontAwesomeIconCssWeights.Where(a => a.IsConfigurable && a.IncludedInFree && !a.RequiresProForPrimary))
                {
                    ddlFontAwesomeIconWeight.Items.Add(new ListItem(fontAwesomeIconCssWeight.DisplayName, fontAwesomeIconCssWeight.WeightName));
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string cssOverrideFile = string.Format(@"{0}Themes/{1}/Styles/_css-overrides.less", Request.PhysicalApplicationPath, _themeName);

            if (File.Exists(cssOverrideFile))
            {
                File.WriteAllText(cssOverrideFile, ceOverrides.Text);
            }

            // get list of original values
            Dictionary <string, string> originalValues = GetVariables(_variableFile);

            StringBuilder overrideFile = new StringBuilder();

            if (pnlFontAwesomeSettings.Visible)
            {
                overrideFile.AppendLine(FontAwesomeHelper.VariableOverridesTokens.StartRegion);

                var selectedPrimaryWeight = FontAwesomeHelper.FontAwesomeIconCssWeights.FirstOrDefault(a => a.WeightName == ddlFontAwesomeIconWeight.SelectedValue);

                overrideFile.AppendLine(string.Format("{0} {1};", FontAwesomeHelper.VariableOverridesTokens.FontWeightValueLineStart, selectedPrimaryWeight.WeightValue));
                overrideFile.AppendLine(string.Format("{0} '{1}';", FontAwesomeHelper.VariableOverridesTokens.FontWeightNameLineStart, selectedPrimaryWeight.WeightName));

                if (FontAwesomeHelper.HasFontAwesomeProKey())
                {
                    overrideFile.AppendLine("@fa-edition: 'pro';");
                }

                overrideFile.AppendLine();

                if (!selectedPrimaryWeight.IncludedInFree)
                {
                    overrideFile.AppendLine(string.Format("{0} {1};", FontAwesomeHelper.VariableOverridesTokens.FontEditionLineStart, FontAwesomeHelper.VariableOverridesTokens.FontEditionPro));
                }

                overrideFile.AppendLine("@import \"../../../Styles/FontAwesome/_rock-fa-mixins.less\";");

                foreach (var alternateFontWeightName in cblFontAwesomeAlternateFonts.Items.OfType <ListItem>().Where(a => a.Selected).Select(a => a.Value).ToList())
                {
                    var alternateFont = FontAwesomeHelper.FontAwesomeIconCssWeights.Where(a => a.WeightName == alternateFontWeightName).FirstOrDefault();
                    if (alternateFont != null)
                    {
                        string suffixParam = string.Empty;
                        overrideFile.AppendLine(
                            string.Format("{0} '{1}', 'pro' );",
                                          FontAwesomeHelper.VariableOverridesTokens.FontFaceLineStart,
                                          alternateFont.WeightName
                                          ));
                    }
                }

                overrideFile.AppendLine(FontAwesomeHelper.VariableOverridesTokens.EndRegion);
            }

            foreach (var control in phThemeControls.Controls)
            {
                if (control is TextBox)
                {
                    var    textBoxControl = ( TextBox )control;
                    string variableName   = textBoxControl.ID.Replace(" ", "-").ToLower();

                    // find original value
                    if (originalValues.ContainsKey(variableName))
                    {
                        string originalValue = originalValues[variableName];

                        // color picker will convert #fff to #ffffff so take that into account
                        string secondaryValue = string.Empty;
                        if (originalValue.Length == 4 && originalValue[0] == '#')
                        {
                            secondaryValue = originalValue + originalValue.Substring(1, 3);
                        }

                        if (originalValue.ToLower() != textBoxControl.Text.ToLower() && secondaryValue.ToLower() != textBoxControl.Text.ToLower())
                        {
                            overrideFile.Append(string.Format("@{0}: {1};{2}", variableName, textBoxControl.Text, Environment.NewLine));
                        }
                    }
                }
            }

            File.WriteAllText(_variableOverrideFile, overrideFile.ToString());

            // compile theme
            string messages = string.Empty;
            var    theme    = new RockTheme(_themeName);

            if (!theme.Compile(out messages))
            {
                nbMessages.NotificationBoxType = NotificationBoxType.Danger;
                nbMessages.Text    = string.Format("An error occurred while compiling the {0} theme.\nMessage: <pre>{1}</pre>", theme.Name, messages);;
                nbMessages.Visible = true;
            }
            else
            {
                NavigateToParentPage();
            }
        }