Example #1
0
        /// <summary>
        /// Registers the theme.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="path">The path.</param>
        public static void RegisterTheme(string name, string path)
        {
            var manager = Config.GetManager();
            var config  = manager.GetSection <AppearanceConfig>();

            //ADD THEME IF APPLIABLE
            if (config.FrontendThemes.ContainsKey(name))
            {
                return;
            }

            //CREATE THEME
            var theme = new ThemeElement(config.FrontendThemes)
            {
                Name = name,
                Path = path
            };

            //ADD TO SYSTEM
            config.FrontendThemes.Add(theme);

            //SAVE TO STORAGE
            using (new ElevatedModeRegion(manager))
            {
                manager.SaveSection(config);
            }
        }
Example #2
0
 public GenDeploy(ThemeElement element)
 {
     Element = element;
     Spaces = new MultiMap<GenSpace>();
     XScale = 1F;
     YScale = 1F;
     ZScale = 1F;
 }
Example #3
0
        public void CanSelectASettingsTheme()
        {
            var settings      = MockAppFactory.GetMockSettings();
            var mapper        = new MockPathMapper();
            var themeElement  = new ThemeElement();
            var selectedTheme = themeElement.FindTheme(settings, mapper);

            Assert.AreEqual("PerfectBlemish", selectedTheme);
        }
Example #4
0
    public TMP_ColorGradient GradientFor(ThemeElement element)
    {
        var gradients = new Dictionary <ThemeElement, TMP_ColorGradient>
        {
            { ThemeElement.ButtonTextGradient, menuButtonTextGradient },
            { ThemeElement.SettingsTextGradient, settingsTextGradient },
        };

        return(gradients[element]);
    }
Example #5
0
    protected override bool ModifyInternal(RoomSpec spec)
    {
        UndeadTombTheme undeadTheme = spec.Theme as UndeadTombTheme;

        if (undeadTheme == null)
        {
            throw new ArgumentException("Theme needs to be undead themed.");
        }
        var                     tombCollection = undeadTheme.Tombs.SmartElement;
        ThemeElement            tombProto      = tombCollection.Proto;
        List <List <Bounding> > options        = spec.Grids.FindRectanglesMaximized(tombProto.GridWidth + 2, tombProto.GridLength + 2, true, new StrokedAction <GenSpace>()
        {
            UnitAction   = Draw.IsType <GenSpace>(GridType.Floor),
            StrokeAction = Draw.Walkable()
        }, spec.Grids.Bounding);

        #region DEBUG
        if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps))
        {
            BigBoss.Debug.printHeader(Logs.LevelGen, "Printing tomb layout options");
            for (int i = 0; i < options.Count; i++)
            {
                MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(spec.Grids);
                foreach (Bounding bound in options[i])
                {
                    tmp.DrawRect(bound.XMin, bound.XMax, bound.YMin, bound.YMax, new StrokedAction <GenSpace>()
                    {
                        UnitAction   = Draw.SetTo(GridType.Wall, spec.Theme),
                        StrokeAction = Draw.True <GenSpace>()
                    });
                }
                tmp.ToLog(Logs.LevelGen, "Option " + i);
            }
            BigBoss.Debug.printFooter(Logs.LevelGen, "Printing tomb layout options");
        }
        #endregion
        while (options.Count > 0)
        {
            List <Bounding> set = options.RandomTake(spec.Random);
            if (set.Count > MIN_TOMBS)
            {
                foreach (Bounding tombBound in set)
                {
                    GenDeploy tomb = new GenDeploy(tombCollection.Get(spec.Random));
                    spec.Grids.DrawRect(tombBound.XMin, tombBound.XMax, tombBound.YMin, tombBound.YMax, new StrokedAction <GenSpace>()
                    {
                        UnitAction   = Draw.MergeIn(tomb, spec.Theme),
                        StrokeAction = Draw.True <GenSpace>()
                    });
                }
                return(true);
            }
        }
        return(false);
    }
Example #6
0
        public void CanSelectAWebConfigTheme()
        {
            var settings     = MockAppFactory.GetMockSettings();
            var mapper       = new MockPathMapper();
            var themeElement = new ThemeElement {
                SelectedTheme = "PrePaid"
            };
            var selectedTheme = themeElement.FindTheme(settings, mapper);

            Assert.AreEqual("PrePaid", selectedTheme);
        }
Example #7
0
        public void ReturnsNullIfNeitherExists()
        {
            var settings = MockAppFactory.GetMockSettings();

            settings.BlogTheme = "";
            var mapper        = new MockPathMapper();
            var themeElement  = new ThemeElement();
            var selectedTheme = themeElement.FindTheme(settings, mapper);

            Assert.IsNull(selectedTheme);
        }
Example #8
0
        private void BtRestore_Click(object sender, RoutedEventArgs e)
        {
            try {
                TextBlock tbControl = ((StackPanel)((FrameworkElement)sender).Parent).Children.OfType <TextBlock>().FirstOrDefault();
                Label     lControl  = ((StackPanel)((FrameworkElement)sender).Parent).Children.OfType <Label>().FirstOrDefault();

                ThemeElement finded = _ThemeDefault.Find(x => x.Name == lControl.Content.ToString());

                tbControl.Background = finded.Element;

                ThemeClass.SetThemeColor(lControl.Content.ToString(), null, _settings, finded.Element);
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "ThemeModifier", "Error on BtRestore_Click()");
            }
        }
Example #9
0
    public Color ColorFor(ThemeElement element)
    {
        var colors = new DictionaryWithDefault <ThemeElement, Color>(defaultColor)
        {
            { ThemeElement.ButtonTextTint, menuButtonTextTint },
            { ThemeElement.PrimaryTextColor, headerTextColor },
            { ThemeElement.SecondaryTextColor, dialogueButtonTextTint },
            { ThemeElement.PrimaryBorderColor, borderTint },
            { ThemeElement.PanelTint, panelTint },
            { ThemeElement.SettingsTextTint, settingsTextTint },
            { ThemeElement.IconButtonTint, iconButtonTint },
            { ThemeElement.IconButtonHoverTint, iconButtonHoverTint },
            { ThemeElement.IconButtonPressedTint, iconButtonPressedTint },
            { ThemeElement.CreditsTint, creditsTint },
        };

        return(colors[element]);
    }
Example #10
0
        /// <summary>
        /// The find theme.
        /// </summary>
        /// <param name="themeElement">
        /// The theme element.
        /// </param>
        /// <param name="settingService">
        /// The setting service.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string FindTheme(this ThemeElement themeElement, ISettingService settingService)
        {
            string selectedTheme = themeElement.SelectedTheme;

            if (!string.IsNullOrEmpty(selectedTheme) && FolderExists(selectedTheme))
            {
                return(selectedTheme);
            }

            selectedTheme = settingService.BlogTheme;

            if (!string.IsNullOrEmpty(selectedTheme) && FolderExists(selectedTheme))
            {
                return(selectedTheme);
            }

            return(null);
        }
Example #11
0
        public static string FindTheme(this ThemeElement themeElement, ISettings settings, IPathMapper mapper)
        {
            var possibleTheme = themeElement.SelectedTheme;

            if (!string.IsNullOrEmpty(possibleTheme) && ThemeExists(possibleTheme, mapper))
            {
                return(possibleTheme);
            }

            possibleTheme = settings.BlogTheme;

            if (!string.IsNullOrEmpty(possibleTheme) && ThemeExists(possibleTheme, mapper))
            {
                return(possibleTheme);
            }

            return(null);
        }
        /// <summary>
        /// Registers the theme.
        /// </summary>
        private void RegisterTheme()
        {
            this.pageTemplate.Theme = this.pageTemplate.Name;

            ConfigManager manager             = Config.GetManager();
            var           appearanceConfig    = manager.GetSection <AppearanceConfig>();
            var           defaultSamplesTheme = new ThemeElement(appearanceConfig.FrontendThemes)
            {
                Name = this.pageTemplate.Theme,
                Path = string.Concat("~/App_Data/Sitefinity/WebsiteTemplates/", this.pageTemplate.Name, "/App_Themes/", this.pageTemplate.Name)
            };

            if (!appearanceConfig.FrontendThemes.ContainsKey(defaultSamplesTheme.Name))
            {
                appearanceConfig.FrontendThemes.Add(defaultSamplesTheme);
            }

            appearanceConfig.DefaultFrontendTheme = this.pageTemplate.Theme;

            manager.SaveSection(appearanceConfig);
        }
Example #13
0
            private static void OnControlThemeChanged(
                BindableObject bindable,
                object oldValue,
                object newValue)
            {
                IThemeElement themeElement = bindable as IThemeElement;

                if (bindable == null)
                {
                    return;
                }
                string key = (string)bindable.GetValue(ThemeElement.controlKeyProperty);

                if (bindable is VisualElement element)
                {
                    List <WeakReference <ResourceDictionary> > targetDictionaries = ThemeElement.StyleTargetDictionaries;
                    ResourceDictionary resourceDictionary;
                    // ISSUE: explicit non-virtual call
                    //if ((targetDictionaries != null ? (__nonvirtual(targetDictionaries.Count) > 0 ? 1 : 0) : 0) != 0 && ThemeElement.TryGetThemeDictionary(element, out resourceDictionary))
                    ThemeElement.TryGetThemeDictionary(element, out resourceDictionary);
                    ThemeElement.MergeThemeDictionary(key, resourceDictionary);
                }
                themeElement.OnControlThemeChanged((string)oldValue, (string)newValue);
            }
Example #14
0
        public void TestThemesTableColors()
        {
            // Load our two test workbooks
            XSSFWorkbook simple  = XSSFTestDataSamples.OpenSampleWorkbook(testFileSimple);
            XSSFWorkbook complex = XSSFTestDataSamples.OpenSampleWorkbook(testFileComplex);
            // Save and re-load them, to check for stability across that
            XSSFWorkbook simpleRS  = XSSFTestDataSamples.WriteOutAndReadBack(simple) as XSSFWorkbook;
            XSSFWorkbook complexRS = XSSFTestDataSamples.WriteOutAndReadBack(complex) as XSSFWorkbook;

            // Fetch fresh copies to test with
            simple  = XSSFTestDataSamples.OpenSampleWorkbook(testFileSimple);
            complex = XSSFTestDataSamples.OpenSampleWorkbook(testFileComplex);
            // Files and descriptions
            Dictionary <String, XSSFWorkbook> workbooks = new Dictionary <String, XSSFWorkbook>();

            workbooks.Add(testFileSimple, simple);
            workbooks.Add("Re-Saved_" + testFileSimple, simpleRS);
            workbooks.Add(testFileComplex, complex);
            workbooks.Add("Re-Saved_" + testFileComplex, complexRS);

            // Sanity check
            //Assert.AreEqual(rgbExpected.Length, rgbExpected.Length);

            // For offline testing
            bool createFiles = false;

            // Check each workbook in turn, and verify that the colours
            //  for the theme-applied cells in Column A are correct
            foreach (String whatWorkbook in workbooks.Keys)
            {
                XSSFWorkbook workbook = workbooks[whatWorkbook];
                XSSFSheet    sheet    = workbook.GetSheetAt(0) as XSSFSheet;
                int          startRN  = 0;
                if (whatWorkbook.EndsWith(testFileComplex))
                {
                    startRN++;
                }

                for (int rn = startRN; rn < rgbExpected.Length + startRN; rn++)
                {
                    XSSFRow row = sheet.GetRow(rn) as XSSFRow;
                    Assert.IsNotNull(row, "Missing row " + rn + " in " + whatWorkbook);
                    String   ref1 = (new CellReference(rn, 0)).FormatAsString();
                    XSSFCell cell = row.GetCell(0) as XSSFCell;
                    Assert.IsNotNull(cell,
                                     "Missing cell " + ref1 + " in " + whatWorkbook);

                    int          expectedThemeIdx = rn - startRN;
                    ThemeElement themeElem        = ThemeElement.ById(expectedThemeIdx);
                    Assert.AreEqual(themeElem.name.ToLower(), cell.StringCellValue,
                                    "Wrong theme at " + ref1 + " in " + whatWorkbook);

                    // Fonts are theme-based in their colours
                    XSSFFont font    = (cell.CellStyle as XSSFCellStyle).GetFont();
                    CT_Color ctColor = font.GetCTFont().GetColorArray(0);
                    Assert.IsNotNull(ctColor);
                    Assert.AreEqual(true, ctColor.IsSetTheme());
                    Assert.AreEqual(themeElem.idx, ctColor.theme);

                    // Get the colour, via the theme
                    XSSFColor color = font.GetXSSFColor();

                    // Theme colours aren't tinted
                    Assert.AreEqual(color.HasTint, false);
                    // Check the RGB part (no tint)
                    Assert.AreEqual(rgbExpected[expectedThemeIdx], HexDump.EncodeHexString(color.RGB),
                                    "Wrong theme colour " + themeElem.name + " on " + whatWorkbook);

                    long themeIdx = font.GetCTFont().GetColorArray(0).theme;
                    Assert.AreEqual(expectedThemeIdx, themeIdx,
                                    "Wrong theme index " + expectedThemeIdx + " on " + whatWorkbook
                                    );

                    if (createFiles)
                    {
                        XSSFCellStyle cs = row.Sheet.Workbook.CreateCellStyle() as XSSFCellStyle;
                        cs.SetFillForegroundColor(color);
                        cs.FillPattern = FillPatternType.SolidForeground;
                        row.CreateCell(1).CellStyle = (cs);
                    }
                }

                if (createFiles)
                {
                    FileStream fos = new FileStream("Generated_" + whatWorkbook, FileMode.Create, FileAccess.ReadWrite);
                    workbook.Write(fos);
                    fos.Close();
                }
            }
        }
Example #15
0
        public void ThemedAndNonThemedColours()
        {
            XSSFWorkbook  wb    = XSSFTestDataSamples.OpenSampleWorkbook(testFileComplex);
            XSSFSheet     sheet = wb.GetSheetAt(0) as XSSFSheet;
            XSSFCellStyle style;
            XSSFColor     color;
            XSSFCell      cell;

            String[] names          = { "White", "Black", "Grey", "Dark Blue", "Blue", "Red", "Green" };
            String[] explicitFHexes = { "FFFFFFFF", "FF000000", "FFC0C0C0", "FF002060",
                                        "FF0070C0", "FFFF0000", "FF00B050" };
            String[] explicitBHexes = { "FFFFFFFF", "FF000000", "FFC0C0C0", "FF002060",
                                        "FF0000FF", "FFFF0000", "FF00FF00" };
            Assert.AreEqual(7, names.Length);

            // Check the non-CF colours in Columns A, B, C and E
            for (int rn = 1; rn < 8; rn++)
            {
                int     idx = rn - 1;
                XSSFRow row = sheet.GetRow(rn) as XSSFRow;
                Assert.IsNotNull(row, "Missing row " + rn);

                // Theme cells come first
                XSSFCell     themeCell = row.GetCell(0) as XSSFCell;
                ThemeElement themeElem = ThemeElement.ById(idx);
                assertCellContents(themeElem.name, themeCell);
                // Sanity check names
                assertCellContents(names[idx], row.GetCell(1));
                assertCellContents(names[idx], row.GetCell(2));
                assertCellContents(names[idx], row.GetCell(4));

                // Check the colours

                //  A: Theme Based, Foreground
                style = themeCell.CellStyle as XSSFCellStyle;
                color = style.GetFont().GetXSSFColor();
                Assert.AreEqual(true, color.IsThemed);
                Assert.AreEqual(idx, color.Theme);
                Assert.AreEqual(rgbExpected[idx], HexDump.EncodeHexString(color.RGB));
                //  B: Theme Based, Foreground
                cell  = row.GetCell(1) as XSSFCell;
                style = cell.CellStyle as XSSFCellStyle;
                color = style.GetFont().GetXSSFColor();
                Assert.AreEqual(true, color.IsThemed);
                // TODO Fix the grey theme color in Column B
                if (idx != 2)
                {
                    Assert.AreEqual(true, color.IsThemed);
                    Assert.AreEqual(idx, color.Theme);
                    Assert.AreEqual(rgbExpected[idx], HexDump.EncodeHexString(color.RGB));
                }
                else
                {
                    Assert.AreEqual(1, color.Theme);
                    Assert.AreEqual(0.50, color.Tint, 0.001);
                }

                //  C: Explicit, Foreground
                cell  = row.GetCell(2) as XSSFCell;
                style = cell.CellStyle as XSSFCellStyle;
                color = style.GetFont().GetXSSFColor();
                Assert.AreEqual(false, color.IsThemed);
                Assert.AreEqual(explicitFHexes[idx], color.ARGBHex);

                // E: Explicit Background, Foreground all Black
                cell  = row.GetCell(4) as XSSFCell;
                style = cell.CellStyle as XSSFCellStyle;

                color = style.GetFont().GetXSSFColor();
                Assert.AreEqual(true, color.IsThemed);
                Assert.AreEqual("FF000000", color.ARGBHex);

                color = style.FillForegroundXSSFColor;
                Assert.AreEqual(false, color.IsThemed);
                Assert.AreEqual(explicitBHexes[idx], color.ARGBHex);
                color = style.FillBackgroundColorColor as XSSFColor;
                Assert.AreEqual(false, color.IsThemed);
                Assert.AreEqual(null, color.ARGBHex);
            }

            // Check the CF colours
            // TODO
        }
 public Color ColorFor(ThemeElement e) => theme.ColorFor(e);
        /// <summary>
        /// Registers the theme.
        /// </summary>
        private void RegisterTheme()
        {
            pageTemplate.Theme = pageTemplate.Name;

            ConfigManager manager = Config.GetManager();
            var appearanceConfig = manager.GetSection<AppearanceConfig>();
            var defaultSamplesTheme = new ThemeElement(appearanceConfig.FrontendThemes)
            {
                Name = pageTemplate.Theme,
                Path = string.Concat("~/App_Data/Sitefinity/WebsiteTemplates/", pageTemplate.Name, "/App_Themes/", pageTemplate.Name)
            };

            if (!appearanceConfig.FrontendThemes.ContainsKey(defaultSamplesTheme.Name))
                appearanceConfig.FrontendThemes.Add(defaultSamplesTheme);

            appearanceConfig.DefaultFrontendTheme = pageTemplate.Theme;

            manager.SaveSection(appearanceConfig);
        }
Example #18
0
 public static DrawAction <GenSpace> MergeIn(ThemeElement element, Theme theme, GridType type = GridType.Floor, bool typeOnlyDefault = true, bool themeOnlyDefault = false)
 {
     return(MergeIn(new GenDeploy(element), theme, type, typeOnlyDefault, themeOnlyDefault));
 }