public static void TgOnTabVisualUpdate(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { Exception exception = null; bool success = tab.Dispatch(delegate { try { UIElement content = (UIElement)tab.Content; // (UIElement)(tab.Content ?? ((Window)tab.AttachedProperty["AttachedWindow"]).Content); if (gdb.To <TKey>().TabGenerator == null || gdb.To <TKey>().TabGenerator.IsTabEnabledMethod == null) { content.IsEnabled = IsTabEnabled(settings, gdb); } else { content.IsEnabled = gdb.To <TKey>().TabGenerator.IsTabEnabledMethod(settings, gdb); } return(true); } catch (Exception err) { exception = err; return(false); } }); if (!success) { throw exception; } List <DbAttribute> attributes = settings.AttributeList.Attributes; if (gdb.LayoutIndexes != null) { foreach (var attribute in attributes) { if (attribute.IsSkippable) { bool isSet = _isAttributeEnabled(attribute, gdb); tab.Dispatch(delegate { var elements = DisplayablePropertyHelper.GetAll(tab.PropertiesGrid, attribute.DisplayName); foreach (var element in elements) { element.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed; element.IsEnabled = isSet; } }); } } } }
public void Show(bool enable, params DbAttribute[] attributes) { Settings.Control.Dispatch(delegate { try { foreach (var attribute in attributes) { var uiElements = DisplayablePropertyHelper.GetAll(Settings.Tab.PropertiesGrid, attribute); uiElements.ForEach(p => p.IsEnabled = enable); } } catch (Exception err) { ErrorHandler.HandleException(err); } }); }