Example #1
0
        private void UpdateGlobalRules()
        {
            var newRules = GetAllGlobalCSRules();

            if (newRules?.Count > 0)
            {
                GlobalCSRules.Clear();
                GlobalCSRules = newRules;
                GlobalRules.UpdateGlobalRules();
            }
        }
Example #2
0
        private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (var item in e.OldItems)
                {
                    //if (!((IGlobalCSSheet)item).FixStyle && ((IGlobalCSSheet)item).Component != null && !StyleSheetIsNeeded(((IGlobalCSSheet)item).Component))
                    //{
                    //    GlobalRulesSheets.Remove(GlobalRulesSheets.First(x => x.Component?.GetType() == ((IGlobalCSSheet)item).Component.GetType()));
                    //    RemoveOneStyleSheet((IGlobalCSSheet)item);
                    //    GlobalRules.UpdateGlobalRules();
                    //}
                    //else if (!((IGlobalCSSheet)item).FixStyle && ((IGlobalCSSheet)item).Component != null && ((IGlobalCSSheet)item).IsGlobal)
                    //{
                    //    GlobalCSSheets.First(x => x.Component?.GetType() == ((IGlobalCSSheet)item).Component.GetType()).IsGlobal = true;
                    //}
                    if (!((IGlobalCSSheet)item).FixStyle && ((IGlobalCSSheet)item).ComponentType != null && !StyleSheetIsNeeded(((IGlobalCSSheet)item).ComponentType))
                    {
                        GlobalRulesSheets.Remove(GlobalRulesSheets.First(x => x.ComponentType == ((IGlobalCSSheet)item).ComponentType));
                        RemoveOneStyleSheet((IGlobalCSSheet)item);
                        GlobalRules?.UpdateGlobalRules();
                        //Debug.WriteLine($"Removed StyleSheet for {((IGlobalCSSheet)item).ComponentType}");
                    }
                    else if (!((IGlobalCSSheet)item).FixStyle && ((IGlobalCSSheet)item).ComponentType != null && ((IGlobalCSSheet)item).IsGlobal)
                    {
                        GlobalCSSheets.First(x => x.ComponentType == ((IGlobalCSSheet)item).ComponentType).IsGlobal = true;
                    }
                }
            }

            if (e.NewItems != null)
            {
                foreach (var item in e.NewItems)
                {
                    if (!ComponentStyleExist(((IGlobalCSSheet)item).ComponentType))
                    {
                        //Debug.WriteLine($"Added StyleSheet for {((IGlobalCSSheet)item).ComponentType}");
                        GlobalRulesSheets.Add((IGlobalCSSheet)item);
                        ((IGlobalCSSheet)item).IsGlobal = true;
                        AddOneStyleSheet((IGlobalCSSheet)item);
                        GlobalRules?.UpdateGlobalRules();
                    }
                }
            }
        }