Пример #1
0
        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;
                            }
                        });
                    }
                }
            }
        }
Пример #2
0
 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);
         }
     });
 }
Пример #3
0
        private GDbTab _gDbTabMaker(SdeDatabase database, TabControl control, BaseDb gdb)
        {
            GTabSettings <TKey, ReadableTuple <TKey> >  settings = new GTabSettings <TKey, ReadableTuple <TKey> >(gdb);
            GDbTabWrapper <TKey, ReadableTuple <TKey> > tab      = new GDbTabWrapper <TKey, ReadableTuple <TKey> >();
            Table <TKey, ReadableTuple <TKey> >         table    = gdb.To <TKey>().Table;

            settings.Table   = table;
            settings.Control = control;

            Settings.Control  = control;
            Settings.Gdb      = gdb;
            Settings.Tab      = tab;
            Settings.Table    = table;
            Settings.Database = database;

            InitStyle(tab, settings, gdb);
            InitAttributes(tab, settings, gdb);
            if (OnInitSettings != null)
            {
                OnInitSettings(tab, settings, gdb);
            }

            DisplayableProperty <TKey, ReadableTuple <TKey> > generalProperties = new DisplayableProperty <TKey, ReadableTuple <TKey> >();

            generalProperties.Spacing  = DefaultSpacing;
            Settings.GeneralProperties = generalProperties;

            SdeEditor.Instance.SelectionChanged += new SdeEditor.SdeSelectionChangedEventHandler((sender, oldTab, newTab) => {
                try {
                    TabItem item = newTab;

                    if (gdb.DbSource.AlternativeName != null)
                    {
                        if (WpfUtilities.IsTab(item, gdb.DbSource.Filename) || WpfUtilities.IsTab(item, gdb.DbSource.AlternativeName))
                        {
                            if (generalProperties.OnTabVisible != null)
                            {
                                generalProperties.OnTabVisible(this);
                            }
                            if (OnPreviewTabVisualUpdate != null)
                            {
                                OnPreviewTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabVisualUpdate != null)
                            {
                                OnTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabRefreshed != null)
                            {
                                OnTabRefreshed(Settings);
                            }
                        }
                    }
                    else
                    {
                        if (WpfUtilities.IsTab(item, gdb.DbSource))
                        {
                            if (generalProperties.OnTabVisible != null)
                            {
                                generalProperties.OnTabVisible(this);
                            }
                            if (OnPreviewTabVisualUpdate != null)
                            {
                                OnPreviewTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabVisualUpdate != null)
                            {
                                OnTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabRefreshed != null)
                            {
                                OnTabRefreshed(Settings);
                            }
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            });

            database.PreviewReloaded += delegate {
                if (OnPreviewDatabaseReloaded != null)
                {
                    OnPreviewDatabaseReloaded(tab, settings, gdb);
                }
            };

            database.Reloaded += delegate {
                //if (OnPreviewTabVisualUpdate != null) OnPreviewTabVisualUpdate(tab, settings, gdb);
                //if (OnTabVisualUpdate != null) OnTabVisualUpdate(tab, settings, gdb);

                DisplayablePropertyHelper.CheckAttributeRestrictions(tab, settings, gdb);

                if (OnDatabaseReloaded != null)
                {
                    OnDatabaseReloaded(tab, settings, gdb);
                }

                if (OnTabRefreshed != null)
                {
                    OnTabRefreshed(Settings);
                }
            };

            int line = 0;

            if (OnPreviewGenerateGrid != null)
            {
                OnPreviewGenerateGrid(ref line, Settings);
            }
            if (GenerateGrid != null)
            {
                GenerateGrid(ref line, Settings);
            }
            if (OnGenerateGrid != null)
            {
                OnGenerateGrid(ref line, Settings);
            }

            settings.DisplayablePropertyMaker = generalProperties;
            settings.ClientDatabase           = database;

            if (SetSettings != null)
            {
                SetSettings(tab, settings, gdb);
            }
            if (OnSetCustomCommands != null)
            {
                OnSetCustomCommands(tab, settings, gdb);
            }
            if (OnPreviewTabInitialize != null)
            {
                OnPreviewTabInitialize(tab, settings, gdb);
            }
            tab.Initialize(settings);
            if (OnAfterTabInitialize != null)
            {
                OnAfterTabInitialize(tab, settings, gdb);
            }
            return(tab);
        }