public void Disposed() { LocalCSSheets.Clear(); GlobalCSSheets.Clear(); GlobalRulesSheets.Clear(); GlobalCSRules.Clear(); }
//public bool StyleSheetIsNeeded(object component) //{ // if (component == null) // return false; // var componentType = component.GetType(); // return GlobalCSSheets.Any(x => x.Component?.GetType() == componentType); //} public bool StyleSheetIsNeeded(Type componentType) { if (componentType == null) { return(false); } //var componentType = component.GetType(); return(GlobalCSSheets.Any(x => x.ComponentType == componentType)); }
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(); } } } }