Пример #1
0
        public static void TgOnTabVisualUpdate(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb)
        {
            tab.Dispatch(delegate {
                ((UIElement)tab.Content).IsEnabled = IsTabEnabled(settings, gdb);
            });

            List <DbAttribute> attributes = settings.AttributeList.Attributes;

            if (gdb.LayoutIndexes != null)
            {
                AbstractProvider provider = AbstractProvider.GetProvider(gdb.LayoutIndexes);

                if (provider is GroupIndexProvider)
                {
                    return;
                }

                List <int> indexes = provider.GetIndexes();

                int row = 0;
                int column;

                for (int i = 0; i < indexes.Count; i += 2)
                {
                    column = 0;

                    if (indexes[i] > -1 && indexes[i] < attributes.Count)
                    {
                        var attribute = attributes[indexes[i]];
                        if (attribute.IsSkippable)
                        {
                            var  attached = gdb.Attached[attribute.DisplayName];
                            bool isSet    = attached == null || (bool)gdb.Attached[attribute.DisplayName];

                            tab.Dispatch(delegate {
                                var label   = tab._displayGrid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column);
                                var content = tab._displayGrid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column + 1);

                                if (label != null)
                                {
                                    label.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                    label.IsEnabled  = isSet;
                                }

                                if (content != null)
                                {
                                    content.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                    content.IsEnabled  = isSet;
                                }
                            });
                        }
                    }

                    column += 3;

                    if (i + 1 < indexes.Count)
                    {
                        if (indexes[i + 1] > -1 && indexes[i + 1] < attributes.Count)
                        {
                            var attribute = attributes[indexes[i + 1]];
                            if (attribute.IsSkippable)
                            {
                                var  attached = gdb.Attached[attribute.DisplayName];
                                bool isSet    = attached == null || (bool)gdb.Attached[attribute.DisplayName];

                                tab.Dispatch(delegate {
                                    var label   = tab._displayGrid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column);
                                    var content = tab._displayGrid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column + 1);

                                    if (label != null)
                                    {
                                        label.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                        label.IsEnabled  = isSet;
                                    }

                                    if (content != null)
                                    {
                                        content.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                        content.IsEnabled  = isSet;
                                    }
                                });
                            }
                        }
                    }

                    row += 2;
                }
            }
        }