コード例 #1
0
        private void RemoveStyles(Theme theme)
        {
            Theme theme1 = ThemeRepository.FindTheme(theme.Name);

            foreach (StyleGroup styleGroup1 in theme.StyleGroups)
            {
                for (int index = theme1.StyleGroups.Count - 1; index >= 0; --index)
                {
                    StyleGroup styleGroup2 = theme1.StyleGroups[index];
                    if (styleGroup2.IsCompatible(styleGroup1))
                    {
                        theme1.StyleGroups.Remove(styleGroup2);
                        break;
                    }
                }
            }
            foreach (StyleRepository repository1 in theme.Repositories)
            {
                for (int index = theme1.Repositories.Count - 1; index >= 0; --index)
                {
                    StyleRepository repository2 = theme1.Repositories[index];
                    if (repository2.Key == repository1.Key)
                    {
                        theme1.Repositories.Remove(repository2);
                        break;
                    }
                }
            }
            ThemeResolutionService.RaiseThemeChanged(theme.Name, "");
        }
コード例 #2
0
ファイル: StyleRepository.cs プロジェクト: RichardHaggard/BDC
 public StyleRepository(StyleRepository repository)
     : this()
 {
     this.itemType = repository.itemType;
     this.name     = repository.name;
     this.key      = repository.key;
     foreach (PropertySetting setting in repository.Settings)
     {
         this.Settings.Add(new PropertySetting(setting));
     }
 }
コード例 #3
0
ファイル: Theme.cs プロジェクト: RichardHaggard/BDC
 public void MergeRepositories()
 {
     lock (this.repositories)
     {
         foreach (StyleGroup styleGroup in this.StyleGroups)
         {
             lock (styleGroup.PropertySettingGroups)
             {
                 foreach (PropertySettingGroup propertySettingGroup in styleGroup.PropertySettingGroups)
                 {
                     if (!string.IsNullOrEmpty(propertySettingGroup.BasedOn))
                     {
                         string basedOn = propertySettingGroup.BasedOn;
                         char[] chArray = new char[1] {
                             ','
                         };
                         foreach (string key in basedOn.Split(chArray))
                         {
                             StyleRepository repository1 = this.FindRepository(key);
                             if (repository1 != null)
                             {
                                 bool flag = false;
                                 foreach (StyleRepository repository2 in propertySettingGroup.Repositories)
                                 {
                                     if (repository2.Key == repository1.Key)
                                     {
                                         flag = true;
                                         break;
                                     }
                                 }
                                 if (!flag)
                                 {
                                     propertySettingGroup.Repositories.Add(repository1);
                                     if (repository1.ItemType == "Border")
                                     {
                                         foreach (PropertySetting setting in repository1.Settings)
                                         {
                                             setting.PropertyMapper = new PropertyMapper(Theme.BorderPropertyMapper);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Theme.cs プロジェクト: RichardHaggard/BDC
 public void Combine(Theme theme, bool mergeRepositories, bool replaceExistingStyles)
 {
     foreach (StyleGroup styleGroup1 in theme.StyleGroups)
     {
         bool flag = false;
         foreach (StyleGroup styleGroup2 in this.styleGroups)
         {
             if (styleGroup2.IsCompatible(styleGroup1))
             {
                 styleGroup2.Combine(styleGroup1, replaceExistingStyles);
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             this.styleGroups.Add(styleGroup1);
         }
     }
     foreach (StyleGroup styleGroup in theme.StyleGroups)
     {
         foreach (PropertySettingGroup propertySettingGroup in styleGroup.PropertySettingGroups)
         {
             propertySettingGroup.Repositories.Clear();
         }
     }
     if (!mergeRepositories)
     {
         return;
     }
     foreach (StyleRepository repository1 in theme.Repositories)
     {
         StyleRepository repository2 = this.FindRepository(repository1.Key);
         if (repository2 != null)
         {
             this.Repositories.Remove(repository2);
         }
         this.Repositories.Add(repository1);
     }
     this.MergeRepositories();
 }
コード例 #5
0
        private void ReadRepositoryItem(ReaderContext context, XmlTextReader reader)
        {
            StyleRepository styleRepository = new StyleRepository();

            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "ItemType")
                {
                    styleRepository.ItemType = reader.Value;
                }
                else if (reader.Name == "DisplayName")
                {
                    styleRepository.Name = reader.Value;
                }
                else if (reader.Name == "Key")
                {
                    styleRepository.Key = reader.Value;
                }
            }
            context.theme.Repositories.Add(styleRepository);
            context.currentRepository = styleRepository;
        }
コード例 #6
0
ファイル: CSSThemeReader.cs プロジェクト: RichardHaggard/BDC
        private Theme Parse(CSSParser parser)
        {
            Theme theme = new Theme();

            theme.StyleGroups.Add(new StyleGroup());
            foreach (CSSGroup group in parser.groups)
            {
                if (group.name == "theme")
                {
                    theme.Name = group["name"].value;
                    StyleRegistration styleRegistration = new StyleRegistration();
                    theme.StyleGroups[0].Registrations.Add(styleRegistration);
                    if (group.Contains("elementType"))
                    {
                        styleRegistration.RegistrationType = "ElementTypeDefault";
                        styleRegistration.ElementType      = group["elementType"].value;
                    }
                    if (group.Contains("controlType"))
                    {
                        styleRegistration.RegistrationType = "ElementTypeControlType";
                        styleRegistration.ControlType      = group["controlType"].value;
                        styleRegistration.ElementType      = "Telerik.WinControls.RootRadElement";
                    }
                }
                else if (group.name.StartsWith("#"))
                {
                    StyleRepository styleRepository = new StyleRepository();
                    styleRepository.Key = group.name.Remove(0, 1).Trim();
                    foreach (CSSItem cssItem in group.items)
                    {
                        PropertySetting propertySetting = this.CreatePropertySetting(cssItem);
                        styleRepository.Settings.Add(propertySetting);
                    }
                    theme.Repositories.Add(styleRepository);
                }
                else
                {
                    PropertySettingGroup propertySettingGroup = new PropertySettingGroup();
                    if (group.BasedOn.Count > 0)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        for (int index = 0; index < group.BasedOn.Count; ++index)
                        {
                            string str = group.BasedOn[index];
                            stringBuilder.Append(str);
                            if (index < group.BasedOn.Count - 1)
                            {
                                stringBuilder.Append(",");
                            }
                        }
                        propertySettingGroup.BasedOn = stringBuilder.ToString();
                    }
                    propertySettingGroup.Selector       = new ElementSelector();
                    propertySettingGroup.Selector.Type  = ElementSelectorTypes.VisualStateSelector;
                    propertySettingGroup.Selector.Value = group.name;
                    if (!string.IsNullOrEmpty(group.childName))
                    {
                        propertySettingGroup.Selector.ChildSelector             = new ElementSelector(group.childName);
                        propertySettingGroup.Selector.ChildSelector.IsRecursive = true;
                    }
                    theme.StyleGroups[0].PropertySettingGroups.Add(propertySettingGroup);
                    foreach (CSSItem cssItem in group.items)
                    {
                        if (cssItem.name == "selectChild")
                        {
                            propertySettingGroup.Selector.ChildSelector             = new ElementSelector(ElementSelectorTypes.VisualStateSelector, cssItem.value);
                            propertySettingGroup.Selector.ChildSelector.IsRecursive = true;
                        }
                        else
                        {
                            if (cssItem.name == "selectChildClass")
                            {
                                propertySettingGroup.Selector.ChildSelector = new ElementSelector(ElementSelectorTypes.ClassSelector, cssItem.value);
                            }
                            PropertySetting propertySetting = this.CreatePropertySetting(cssItem);
                            propertySettingGroup.PropertySettings.Add(propertySetting);
                        }
                    }
                }
            }
            return(theme);
        }