private MenuItem BuildCreateTableMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                  DatabaseMenuCommandsHandler dcmd)
        {
            var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                               dcmd.BuildTable);
            var createTableMenuItem = new MenuItem
            {
                Header           = "Build Table (beta)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/AddTable_5632.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
            return(createTableMenuItem);
        }
        private MenuItem BuildExportServerToLiteMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                         SqlServerDatabaseMenuCommandsHandler dcmd)
        {
            var exportServerToLiteCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                      dcmd.ExportServerDatabaseToSqlite);
            var exportServerToLiteMenuItem = new MenuItem
            {
                Header           = "Migrate to SQLite...",
                Icon             = ImageHelper.GetImageFromResource("../resources/ExportReportData_10565.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            exportServerToLiteMenuItem.CommandBindings.Add(exportServerToLiteCommandBinding);
            return(exportServerToLiteMenuItem);
        }
        private MenuItem BuildShowSqlEditorMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                    DatabaseMenuCommandsHandler dcmd)
        {
            var showSqlEditorCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                 dcmd.SpawnSqlEditorWindow);
            var showSqlEditorMenuItem = new MenuItem
            {
                Header           = "New Query",
                Icon             = ImageHelper.GetImageFromResource("../resources/NewQuery.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            showSqlEditorMenuItem.CommandBindings.Add(showSqlEditorCommandBinding);
            return(showSqlEditorMenuItem);
        }
        private MenuItem BuildScriptEfPocoDacPacMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                         SqlServerDatabaseMenuCommandsHandler dcmd)
        {
            var scriptEfDacPacCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                  dcmd.GenerateEfPocoFromDacPacInProject);
            var scriptEfPocoDacPacMenuItem = new MenuItem
            {
                Header           = "Add EF 6 DbContext (Code Based from Dacpac) to current Project... (alpha)",
                Icon             = ImageHelper.GetImageFromResource("../resources/Schema_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptEfPocoDacPacMenuItem.CommandBindings.Add(scriptEfDacPacCommandBinding);
            return(scriptEfPocoDacPacMenuItem);
        }
        public ViewsContextMenu(DatabaseMenuCommandParameters menuCommandParameters, ExplorerToolWindow parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var refreshCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                           dcmd.RefreshViews);
            var refreshMenuItem = new MenuItem
            {
                Header           = "Refresh",
                Icon             = ImageHelper.GetImageFromResource("../resources/refresh_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = menuCommandParameters
            };

            refreshMenuItem.CommandBindings.Add(refreshCommandBinding);
            Items.Add(refreshMenuItem);
        }
Exemple #6
0
        private MenuItem BuildRepairRecoverPossibleMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                            SqlCeDatabaseMenuCommandsHandler dcmd)
        {
            var repairRecoverPossibleCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                         dcmd.RepairDatabaseRecoverAllPossibleRows);
            var repairRecoverPossibleMenuItem = new MenuItem
            {
                Header           = "Repair (recover all possible)",
                Icon             = ImageHelper.GetImageFromResource("../resources/Hammer_Builder_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Repairs a corrupted database"
            };

            repairRecoverPossibleMenuItem.CommandBindings.Add(repairRecoverPossibleCommandBinding);
            return(repairRecoverPossibleMenuItem);
        }
Exemple #7
0
        private MenuItem BuildScriptEfPocoMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                   DatabaseMenuCommandsHandler dcmd)
        {
            var scriptEfPocoCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.GenerateEfPocoInProject);

            var scriptEfPocoMenuItem = new MenuItem
            {
                Header           = "Add Entity Data Model (Code First from Database) to current Project... (beta)",
                Icon             = ImageHelper.GetImageFromResource("../resources/Schema_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptEfPocoMenuItem.CommandBindings.Add(scriptEfPocoCommandBinding);
            return(scriptEfPocoMenuItem);
        }
        private MenuItem BuildAddFromSolutionMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                      DatabasesMenuCommandsHandler dcmd)
        {
            var addFromSolutionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                   dcmd.ScanConnections);
            var addFromSolutionMenuItem = new MenuItem
            {
                Header           = "Add Connections from Solution",
                Icon             = ImageHelper.GetImageFromResource("../resources/AddConnection_477.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                ToolTip          = "Scan current Solution for SQL Compact and SQLite files",
                CommandParameter = databaseMenuCommandParameters,
            };

            addFromSolutionMenuItem.CommandBindings.Add(addFromSolutionCommandBinding);
            return(addFromSolutionMenuItem);
        }
Exemple #9
0
        private static MenuItem BuildCopyConnectionMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                            SqlCeDatabaseMenuCommandsHandler dcmd)
        {
            var copyCeConnectionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                    dcmd.CopyCeDatabase);
            var copyCeConnectionMenuItem = new MenuItem
            {
                InputGestureText = "Ctrl+C",
                Header           = "Copy Database File",
                Icon             = ImageHelper.GetImageFromResource("../resources/Copy_6524.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            copyCeConnectionMenuItem.CommandBindings.Add(copyCeConnectionCommandBinding);
            return(copyCeConnectionMenuItem);
        }
Exemple #10
0
        private MenuItem BuildScriptDcMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                               CommandBinding scriptDcCommandBinding)
        {
            var scriptDcMenuItem = new MenuItem
            {
                Header           = "Add LINQ to SQL DataContext to current Project...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Schema_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = true
            };

            scriptDcMenuItem.CommandBindings.Add(scriptDcCommandBinding);
            scriptDcMenuItem.IsEnabled = DataConnectionHelper.IsV35Installed() &&
                                         DataConnectionHelper.IsV35DbProviderInstalled();
            return(scriptDcMenuItem);
        }
Exemple #11
0
        private MenuItem BuildCompactMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                              DatabaseMenuCommandsHandler dcmd)
        {
            var compactCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                           dcmd.CompactDatabase);
            var compactMenuItem = new MenuItem
            {
                Header           = "Compact",
                Icon             = ImageHelper.GetImageFromResource("../resources/Hammer_Builder_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Perform full database compaction"
            };

            compactMenuItem.CommandBindings.Add(compactCommandBinding);
            return(compactMenuItem);
        }
Exemple #12
0
        private MenuItem BuildVerifyMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                             SqlCeDatabaseMenuCommandsHandler dcmd)
        {
            var verifyCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.VerifyDatabase);
            var verifyMenuItem = new MenuItem
            {
                Header           = "Verify",
                Icon             = ImageHelper.GetImageFromResource("../resources/Hammer_Builder_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Verify the integrity of the database (enhanced)"
            };

            verifyMenuItem.CommandBindings.Add(verifyCommandBinding);
            return(verifyMenuItem);
        }
Exemple #13
0
        private MenuItem BuildPwdMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                          SqlCeDatabaseMenuCommandsHandler dcmd)
        {
            var setPwdCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.SetPassword);
            var pwdMenuItem = new MenuItem
            {
                Header           = "Set Password",
                Icon             = ImageHelper.GetImageFromResource("../resources/Hammer_Builder_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Set the database password"
            };

            pwdMenuItem.CommandBindings.Add(setPwdCommandBinding);
            return(pwdMenuItem);
        }
Exemple #14
0
        private MenuItem BuildShrinkMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                             DatabaseMenuCommandsHandler dcmd)
        {
            var shrinkCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.ShrinkDatabase);
            var shrinkMenuItem = new MenuItem
            {
                Header           = "Shrink",
                Icon             = ImageHelper.GetImageFromResource("../resources/Hammer_Builder_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Shrink database by deleting free pages"
            };

            shrinkMenuItem.CommandBindings.Add(shrinkCommandBinding);
            return(shrinkMenuItem);
        }
        private static MenuItem BuildScriptDatabaseSchemaSqLiteMenuItem(
            DatabaseMenuCommandParameters databaseMenuCommandParameters, ToolTip toolTip,
            CommandBinding scriptDatabaseCommandBinding)
        {
            var scriptDatabaseSchemaSqLiteMenuItem = new MenuItem
            {
                Header           = "Script Database Schema for SQLite...",
                Icon             = ImageHelper.GetImageFromResource("../resources/script_16xLG.png"),
                ToolTip          = toolTip,
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaSQLite
            };

            scriptDatabaseSchemaSqLiteMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            return(scriptDatabaseSchemaSqLiteMenuItem);
        }
        private MenuItem BuildExportServerMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                   SqlServerDatabaseMenuCommandsHandler dcmd, bool isSqlCe40Installed)
        {
            var exportServerCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.ExportServerDatabaseTo40);
            var exportServerMenuItem = new MenuItem
            {
                Header           = "Migrate to SQL Server Compact 4.0...",
                Icon             = ImageHelper.GetImageFromResource("../resources/ExportReportData_10565.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            exportServerMenuItem.CommandBindings.Add(exportServerCommandBinding);
            exportServerMenuItem.IsEnabled = (isSqlCe40Installed);
            return(exportServerMenuItem);
        }
        private static MenuItem BuildFixConnectionsMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                            DatabasesMenuCommandsHandler dcmd)
        {
            var fixConnectionsCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                  dcmd.FixConnections);
            var fixConnectionsMenuItem = new MenuItem
            {
                Header           = "Remove broken connections",
                Icon             = ImageHelper.GetImageFromResource("../resources/action_Cancel_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                ToolTip          = "Remove invalid connections",
                CommandParameter = databaseMenuCommandParameters,
            };

            fixConnectionsMenuItem.CommandBindings.Add(fixConnectionsCommandBinding);
            return(fixConnectionsMenuItem);
        }
Exemple #18
0
        private MenuItem BuildScriptModelMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                  DatabaseMenuCommandsHandler dcmd)
        {
            var scriptModelCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                               dcmd.GenerateModelCodeInProject);

            var scriptModelMenuItem = new MenuItem
            {
                Header           = "Add sqlite-net DataAccess.cs to current Project...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Schema_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptModelMenuItem.CommandBindings.Add(scriptModelCommandBinding);
            return(scriptModelMenuItem);
        }
Exemple #19
0
        private MenuItem BuildScriptDatabaseGraphMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                          DatabaseMenuCommandsHandler dcmd)
        {
            var scriptGraphCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                               dcmd.GenerateCeDgmlFiles);

            var scriptDatabaseGraphMenuItem = new MenuItem
            {
                Header           = "Create Database Graph (DGML)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Diagram_16XLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptDatabaseGraphMenuItem.CommandBindings.Add(scriptGraphCommandBinding);
            return(scriptDatabaseGraphMenuItem);
        }
        public DatabasesContextMenu(DatabaseMenuCommandParameters databaseMenuCommandParameters, ExplorerToolWindow parent)
        {
            var dcmd             = new DatabasesMenuCommandsHandler(parent);
            var ver40IsInstalled = DataConnectionHelper.IsV40Installed();
            var ver35IsInstalled = DataConnectionHelper.IsV35Installed();
            var pkg = parent.Package as SqlCeToolboxPackage;

            Items.Add(BuildAddCeDatabaseMenuItem(databaseMenuCommandParameters, dcmd, pkg, ver40IsInstalled));

            Items.Add(BuildAddCe35DatabaseMenuItem(databaseMenuCommandParameters, dcmd, pkg, ver35IsInstalled));

            Items.Add(BuildAddSqLiteDatabaseMenuItem(databaseMenuCommandParameters, dcmd));

            if (SqlCeToolboxPackage.IsVsExtension)
            {
                Items.Add(BuildAddSqlServerDatabaseMenuItem(databaseMenuCommandParameters, dcmd));
            }
            if (!SqlCeToolboxPackage.IsVsExtension)
            {
                Items.Add(BuildAddPrivateSqlServerDatabaseMenuItem(databaseMenuCommandParameters, dcmd));
            }

            if (SqlCeToolboxPackage.IsVsExtension)
            {
                Items.Add(BuildAddFromSolutionMenuItem(databaseMenuCommandParameters, dcmd));
            }

            Items.Add(BuildFixConnectionsMenuItem(databaseMenuCommandParameters, dcmd));
            Items.Add(new Separator());

            Items.Add(BuildDesignDatabaseMenuItem(databaseMenuCommandParameters, dcmd));
            Items.Add(new Separator());

            if (SqlCeToolboxPackage.IsVsExtension)
            {
                Items.Add(BuildLocalDatabaseCacheMenuItem(databaseMenuCommandParameters, dcmd, ver35IsInstalled));
            }

            if (SqlCeToolboxPackage.IsVsExtension)
            {
                Items.Add(new Separator());
            }

            Items.Add(BuildVersionDetectMenuItem(databaseMenuCommandParameters, dcmd));
        }
Exemple #21
0
        private MenuItem BuildScriptDatabaseDiffMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                         DatabaseMenuCommandsHandler dcmd)
        {
            var scriptDiffCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                              dcmd.GenerateDiffScript);
            var scriptDatabaseDiffMenuItem = new MenuItem
            {
                Header           = "Script Database Diff...",
                Icon             = ImageHelper.GetImageFromResource("../resources/DataCompare_9880.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptDatabaseDiffMenuItem.CommandBindings.Add(scriptDiffCommandBinding);
            scriptDatabaseDiffMenuItem.ToolTip =
                "Script all tables, columns and constraints in this database\r\nthat are missing/different in the target database.";
            return(scriptDatabaseDiffMenuItem);
        }
        private MenuItem BuildLocalDatabaseCacheMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                         DatabasesMenuCommandsHandler dcmd, bool ver35IsInstalled)
        {
            var localDatabaseCacheCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                      dcmd.SyncFxGenerateLocalDatabaseCacheCode);
            var localDatabaseCacheMenuItem = new MenuItem
            {
                Header           = "Generate Local Database Cache code...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Synchronize_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataBlobs
            };

            localDatabaseCacheMenuItem.CommandBindings.Add(localDatabaseCacheCommandBinding);
            localDatabaseCacheMenuItem.IsEnabled = (ver35IsInstalled && DataConnectionHelper.IsSyncFx21Installed());
            return(localDatabaseCacheMenuItem);
        }
Exemple #23
0
        private MenuItem BuildScriptDatabaseExportMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                           DatabaseMenuCommandsHandler dcmd)
        {
            var scriptExportCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.ExportToServer);

            var scriptDatabaseExportMenuItem = new MenuItem
            {
                Header           = "Migrate to SQL Server (incl. Azure/Express)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/ExportReportData_10565.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptDatabaseExportMenuItem.CommandBindings.Add(scriptExportCommandBinding);
            scriptDatabaseExportMenuItem.ToolTip = "Migrate entire database to a SQL Server database";
            return(scriptDatabaseExportMenuItem);
        }
Exemple #24
0
        private MenuItem BuildScriptUpgradeMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                    SqlCeDatabaseMenuCommandsHandler dcmd)
        {
            var scriptUpgradeCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                 dcmd.UpgradeTo40);

            var scriptUpgradeMenuItem = new MenuItem
            {
                Header           = "Upgrade to version 4.0...",
                Icon             = ImageHelper.GetImageFromResource("../resources/ExportReportData_10565.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptUpgradeMenuItem.CommandBindings.Add(scriptUpgradeCommandBinding);
            scriptUpgradeMenuItem.ToolTip = "Create a copy of this database in 4.0 format";
            return(scriptUpgradeMenuItem);
        }
        private void NewQuery_OnClick(object sender, RoutedEventArgs e)
        {
            var dbCommandHandler = new DatabaseMenuCommandsHandler(_parentWindow);
            var button           = sender as Button;

            if (button?.Tag is DatabaseInfo)
            {
                var parameter = new DatabaseMenuCommandParameters
                {
                    DatabaseInfo    = button.Tag as DatabaseInfo,
                    ExplorerControl = this
                };
                var theSender = new MenuItem
                {
                    CommandParameter = parameter
                };
                dbCommandHandler.SpawnSqlEditorWindow(theSender, null);
            }
        }
Exemple #26
0
        private MenuItem BuildSyncFxProvisionMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                      SqlCeDatabaseMenuCommandsHandler dcmd, DatabaseType dbType, bool isSyncFxInstalled)
        {
            var syncFxProvisionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                   dcmd.SyncFxProvisionScope);

            var syncFxProvisionMenuItem = new MenuItem
            {
                Header           = "Provision Sync Framework Scope...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Synchronize_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            syncFxProvisionMenuItem.CommandBindings.Add(syncFxProvisionCommandBinding);
            syncFxProvisionMenuItem.IsEnabled = dbType == DatabaseType.SQLCE35 &&
                                                isSyncFxInstalled;
            return(syncFxProvisionMenuItem);
        }
Exemple #27
0
        private MenuItem BuildSyncFxMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                             SqlCeDatabaseMenuCommandsHandler dcmd, DatabaseType dbType, bool isSyncFxInstalled)
        {
            var syncFxCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.SyncFxGenerateSyncCodeInProject);

            var syncFxMenuItem = new MenuItem
            {
                Header           = "Add Sync Framework Class to current Project...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Synchronize_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            syncFxMenuItem.CommandBindings.Add(syncFxCommandBinding);

            syncFxMenuItem.IsEnabled = dbType == DatabaseType.SQLCE35 &&
                                       isSyncFxInstalled;
            return(syncFxMenuItem);
        }
Exemple #28
0
        private MenuItem BuildSyncFxGenerateSnapshotMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                             SqlCeDatabaseMenuCommandsHandler dcmd, DatabaseType dbType, bool isSyncFxInstalled)
        {
            var syncFxGenerateSnapshotCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                          dcmd.SyncFxGenerateSnapshot);

            var syncFxGenerateSnapshotMenuItem = new MenuItem
            {
                Header           = "Generate snapshot database to initialize other clients...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Synchronize_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            syncFxGenerateSnapshotMenuItem.CommandBindings.Add(syncFxGenerateSnapshotCommandBinding);

            syncFxGenerateSnapshotMenuItem.IsEnabled = dbType == DatabaseType.SQLCE35 &&
                                                       isSyncFxInstalled;
            return(syncFxGenerateSnapshotMenuItem);
        }
Exemple #29
0
        private MenuItem BuildScriptWpdcMenuItem(DatabaseMenuCommandParameters databaseMenuCommandParameters,
                                                 CommandBinding scriptDcCommandBinding, DatabaseType dbType)
        {
            var scriptWpdcMenuItem = new MenuItem
            {
                Header           = "Add Windows Phone DataContext to current Project...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Schema_16xLG.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = false
            };

            scriptWpdcMenuItem.CommandBindings.Add(scriptDcCommandBinding);
            scriptWpdcMenuItem.IsEnabled = DataConnectionHelper.IsV35Installed() &&
                                           DataConnectionHelper.IsV35DbProviderInstalled();
            if (dbType != DatabaseType.SQLCE35)
            {
                scriptWpdcMenuItem.IsEnabled = false;
            }
            return(scriptWpdcMenuItem);
        }
Exemple #30
0
        public DatabaseContextMenu(DatabaseMenuCommandParameters databaseMenuCommandParameters, ExplorerControl parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var showSqlEditorCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                 dcmd.SpawnSqlEditorWindow);
            var showSqlEditorMenuItem = new MenuItem
            {
                Header           = "Open SQL Editor",
                Icon             = ImageHelper.GetImageFromResource("../resources/sqlEditor.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            showSqlEditorMenuItem.CommandBindings.Add(showSqlEditorCommandBinding);
            Items.Add(showSqlEditorMenuItem);

            var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                               dcmd.BuildTable);
            var createTableMenuItem = new MenuItem
            {
                Header           = "Build Table (alpha)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/sqlEditor.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };

            createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
            Items.Add(createTableMenuItem);

            Items.Add(new Separator());

            var scriptMenuItem = new MenuItem
            {
                Header = "Script",
                Icon   = ImageHelper.GetImageFromResource("../resources/database.png")
            };

            var scriptDatabaseCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                  dcmd.ScriptDatabase);
            var scriptDatabaseSchemaMenuItem = new MenuItem
            {
                Header           = "Script Database Schema...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.Schema
            };

            scriptDatabaseSchemaMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaMenuItem);

            var scriptDatabaseSchemaDataMenuItem = new MenuItem
            {
                Header           = "Script Database Schema and Data...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaData
            };

            scriptDatabaseSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaDataMenuItem);

            var scriptAzureSchemaDataMenuItem = new MenuItem
            {
                Header           = "Script Database Schema and Data for SQL Azure...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataAzure
            };

            scriptAzureSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptAzureSchemaDataMenuItem);

            var scriptSqliteSchemaDataMenuItem = new MenuItem
            {
                Header           = "Script Database Schema and Data for SQLite (beta)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataSQLite
            };

            scriptSqliteSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptSqliteSchemaDataMenuItem);

            var scriptDatabaseSchemaDataBLOBMenuItem = new MenuItem
            {
                Header           = "Script Database Schema and Data with BLOBs...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataBlobs
            };

            scriptDatabaseSchemaDataBLOBMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaDataBLOBMenuItem);

            var scriptDatabaseDataMenuItem = new MenuItem
            {
                Header           = "Script Database Data...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.DataOnly
            };

            scriptDatabaseDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseDataMenuItem);

            var scriptDatabaseDataForServerMenuItem = new MenuItem
            {
                Header           = "Script Database Data for SQL Server...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.DataOnlyForSqlServer
            };

            scriptDatabaseDataForServerMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseDataForServerMenuItem);

            Items.Add(scriptMenuItem);

            Items.Add(new Separator());

            var scriptDiffCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                              dcmd.GenerateDiffScript);

            var scriptDatabaseDiffMenuItem = new MenuItem
            {
                Header           = "Script Database Diff...",
                Icon             = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptDatabaseDiffMenuItem.CommandBindings.Add(scriptDiffCommandBinding);
            scriptDatabaseDiffMenuItem.ToolTip = "Script all tables, columns and constraints in this database\r\nthat are missing/different in the target database.";
            Items.Add(scriptDatabaseDiffMenuItem);

            Items.Add(new Separator());

            var scriptGraphCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                               dcmd.GenerateCeDgmlFiles);

            var scriptDatabaseGraphMenuItem = new MenuItem
            {
                Header           = "Create Database Graph (DGML)...",
                Icon             = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            scriptDatabaseGraphMenuItem.CommandBindings.Add(scriptGraphCommandBinding);
            Items.Add(scriptDatabaseGraphMenuItem);

            // Documentation menu item

            var docDbCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                         dcmd.GenerateDocFiles);
            var docDatabaseMenuItem = new MenuItem
            {
                Header           = "Create Database Documentation...",
                Icon             = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };

            docDatabaseMenuItem.CommandBindings.Add(docDbCommandBinding);
            Items.Add(docDatabaseMenuItem);

            Items.Add(new Separator());

            var scriptDCCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                            dcmd.GenerateDataContext);

            // Desktop Data Context
            var scriptDCMenuItem = new MenuItem
            {
                Header           = "Create LINQ to SQL DataContext class...",
                Icon             = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = true
            };

            scriptDCMenuItem.CommandBindings.Add(scriptDCCommandBinding);
            Items.Add(scriptDCMenuItem);

            //Windows Phone Data Context
            var scriptWPDCMenuItem = new MenuItem
            {
                Header           = "Create Windows Phone DataContext class...",
                Icon             = ImageHelper.GetImageFromResource("../resources/Phone.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = false
            };

            scriptWPDCMenuItem.CommandBindings.Add(scriptDCCommandBinding);
#if V35
            scriptWPDCMenuItem.IsEnabled = true;
#else
            scriptWPDCMenuItem.IsEnabled = false;
#endif
            Items.Add(scriptWPDCMenuItem);
            Items.Add(new Separator());

            var maintenanceMenuItem = new MenuItem
            {
                Header = "Maintenance",
                Icon   = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
            };

            var shrinkCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.ShrinkDatabase);
            var shrinkMenuItem = new MenuItem
            {
                Header           = "Shrink",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Shrink database by deleting free pages"
            };
            shrinkMenuItem.CommandBindings.Add(shrinkCommandBinding);
            maintenanceMenuItem.Items.Add(shrinkMenuItem);

            var compactCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                           dcmd.CompactDatabase);
            var compactMenuItem = new MenuItem
            {
                Header           = "Compact",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Perform full database compaction"
            };
            compactMenuItem.CommandBindings.Add(compactCommandBinding);
            maintenanceMenuItem.Items.Add(compactMenuItem);

            var verifyCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                          dcmd.VerifyDatabase);
            var verifyMenuItem = new MenuItem
            {
                Header           = "Verify",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Verify the integrity of the database (enhanced)"
            };
            verifyMenuItem.CommandBindings.Add(verifyCommandBinding);
            maintenanceMenuItem.Items.Add(verifyMenuItem);

            var repairDeleteCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.RepairDatabaseDeleteCorruptedRows);
            var repairDeleteMenuItem = new MenuItem
            {
                Header           = "Repair (delete corrupted rows)",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Repairs a corrupted database"
            };
            repairDeleteMenuItem.CommandBindings.Add(repairDeleteCommandBinding);
            maintenanceMenuItem.Items.Add(repairDeleteMenuItem);

            var repairRecoverAllCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                    dcmd.RepairDatabaseRecoverAllOrFail);
            var repairRecoverAllMenuItem = new MenuItem
            {
                Header           = "Repair (recover all or fail)",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Repairs a corrupted database"
            };
            repairRecoverAllMenuItem.CommandBindings.Add(repairRecoverAllCommandBinding);
            maintenanceMenuItem.Items.Add(repairRecoverAllMenuItem);

            var repairRecoverPossibleCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                         dcmd.RepairDatabaseRecoverAllPossibleRows);
            var repairRecoverPossibleMenuItem = new MenuItem
            {
                Header           = "Repair (recover all possible)",
                Icon             = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip          = "Repairs a corrupted database"
            };
            repairRecoverPossibleMenuItem.CommandBindings.Add(repairRecoverPossibleCommandBinding);
            maintenanceMenuItem.Items.Add(repairRecoverPossibleMenuItem);

            Items.Add(maintenanceMenuItem);

            Items.Add(new Separator());

            var addDescriptionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                  dcmd.AddDescription);
            var addDescriptionMenuItem = new MenuItem
            {
                Header           = "Edit description",
                Icon             = ImageHelper.GetImageFromResource("../resources/propes.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            addDescriptionMenuItem.CommandBindings.Add(addDescriptionCommandBinding);
            Items.Add(addDescriptionMenuItem);

            Items.Add(new Separator());

            var removeCeConnectionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                      dcmd.RemoveCeDatabase);
            var removeCeConnectionMenuItem = new MenuItem
            {
                Header           = "Remove Connection",
                Icon             = ImageHelper.GetImageFromResource("../resources/delete.png"),
                Command          = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            removeCeConnectionMenuItem.CommandBindings.Add(removeCeConnectionCommandBinding);
            Items.Add(removeCeConnectionMenuItem);
        }