public void SaveTheme(Theme theme, string filePath) { var xmlSerializer = new XmlSerializer(typeof(Theme)); using (Stream writer = new FileStream(filePath, FileMode.Create)) { xmlSerializer.Serialize(writer, theme); } }
public void ComponentExists_ComponentDoesNotExist_NoComponents_ReturnsFalse() { // Arrange var theme = new Theme(); // Act var result = theme.ComponentExists(ThemeComponentType.BorderColor, "test"); // Assert Assert.AreEqual(false, result); }
public async Task SaveThemeAsync(Theme theme, string filePath) { await Task.Run(() => { var xmlSerializer = new XmlSerializer(typeof (Theme)); using (Stream writer = new FileStream(filePath, FileMode.Create)) { xmlSerializer.Serialize(writer, theme); } }); }
public void ComponentExists_ComponentDoesNotExist_DifferentNameSameType_ReturnsFalse() { // Arrange var theme = new Theme(); var testInputComponentTargetType = ThemeComponentType.TextColor; const string TestInputComponentName = "test"; theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color()); // Act var result = theme.ComponentExists(testInputComponentTargetType, "blah"); // Assert Assert.AreEqual(false, result); }
public void ComponentExists_ComponentDoesExist_ReturnsTrue() { // Arrange var theme = new Theme(); var testInputComponentTargetType = ThemeComponentType.TextColor; const string TestInputComponentName = "test"; theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color()); // Act var result = theme.ComponentExists(testInputComponentTargetType, TestInputComponentName); // Assert Assert.AreEqual(true, result); }
public void ApplyThemeToScript(Theme theme, ItemFilterScript script) { var mismatchedComponents = false; foreach (var component in theme.Components) { var componentMatched = false; Type targetType = null; switch (component.ComponentType) { case ThemeComponentType.BackgroundColor: targetType = typeof (BackgroundColorBlockItem); break; case ThemeComponentType.TextColor: targetType = typeof (TextColorBlockItem); break; case ThemeComponentType.BorderColor: targetType = typeof (BorderColorBlockItem); break; } foreach (var block in script.ItemFilterBlocks) { foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == targetType)) { var colorBlockItem = (ColorBlockItem) blockItem; if (colorBlockItem.ThemeComponent != null && colorBlockItem.ThemeComponent.ComponentName == component.ComponentName) { colorBlockItem.Color = component.Color; componentMatched = true; } } } if (!componentMatched) { mismatchedComponents = true; } } if (mismatchedComponents) { _messageBoxService.Show("Possible Theme Mismatch", "Not all theme components had matches - are you sure this theme is designed for this script?", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }