private void MenuStructureTree_Opening(object sender, CancelEventArgs cancelEventArgs)
        {
            var focusedItem = treeStructure.FocusedItem;

            tsmiSortStructure.Visible = focusedItem?.Parent != null;

            _controller.UpdateStructureCommands();
        }
Ejemplo n.º 2
0
        private void CreateAndBindCommands()
        {
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.DatabaseSchemaCaption.Subscribe(x => LabelHeaderDatabase.Text = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.MetadataStructureCaption.Subscribe(x =>
                                                                                                       LabelHeaderMeatdaStructure.Text = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.PropertiesBarCaption.Subscribe(x => LabelHeaderProperties.Text = x));

            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByServer.Subscribe(x => CheckBoxByServer.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByDatabase.Subscribe(x => CheckBoxByDatabase.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupBySchema.Subscribe(x => CheckBoxBySchema.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GroupByTypes.Subscribe(x => CheckBoxByTypes.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.GenerateObjects.Subscribe(x => CheckBoxGenerateObjects.Content = x));
            _subscriptions.Add(
                ActiveQueryBuilder.Core.Localization.MetadataEditor.StructureWillBeCleared.Subscribe(x => TextBlockWarning.Text = x));
            _subscriptions.Add(ActiveQueryBuilder.Core.Localization.Common.Proceed.Subscribe(x => ButtonProceed.Content         = x));
            _subscriptions.Add(ActiveQueryBuilder.Core.Localization.Common.Cancel.Subscribe(x => ButtonCancel.Content           = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataLoadAll, _controller.LoadContainerCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.LoadEntireContainer, x => MenuItemMetadataLoadAll.IsEnabled = x,
                                                  false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemDatabaseDelete, _controller.DeleteMetadataItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteMetadataItem, x => MenuItemDatabaseDelete.IsEnabled = x,
                                                  false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureAdd, _controller.AddStructureItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddStructureItem,
                                                  x => MenuItemMetadataStructureAdd.IsEnabled = x, false));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureDelete,
                                                  _controller.DeleteStructureItemCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.DeleteMetadataItem,
                                                  x => MenuItemMetadataStructureDelete.IsEnabled = x, false));

            _fillStructurePopupOpenCommand = new Command(MenuItemMetadataStructureFillFromSchema_OnClick);

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddLinkedServer, _controller.AddLinkedServerCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddServer, x => MenuItemAddLinkedServer.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddDatabase, _controller.AddDatabaseCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddDatabase, x => MenuItemAddDatabase.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddSchema, _controller.AddSchemaCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSchema, x => MenuItemAddSchema.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddPackage, _controller.AddPackageCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddPackage, x => MenuItemAddPackage.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddTable, _controller.AddTableCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddTable, x => MenuItemAddTable.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddView, _controller.AddViewCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddView, x => MenuItemAddView.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddProcedure, _controller.AddProcedureCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddProcedure, x => MenuItemAddProcedure.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddSynonym, _controller.AddSynonymCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddSynonym, x => MenuItemAddSynonym.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddField, _controller.AddFieldCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddField, x => MenuItemAddField.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemAddForeignKey, _controller.AddForeignKeyCommand,
                                                  ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.AddForeignKey, x => MenuItemAddForeignKey.IsEnabled = x));

            _subscriptions.Add(CommandBinder.Bind(MenuItemMetadataStructureFillFromSchema,
                                                  _fillStructurePopupOpenCommand, ActiveQueryBuilder.View.WPF.Commands.Descriptions.MetadataEditor.FillStructure,
                                                  x => MenuItemMetadataStructureFillFromSchema.IsEnabled = x));

            Loaded += (sender, args) =>
            {
                _controller.UpdateStructureCommands();
                _controller.UpdateContainerCommands();
            };
        }