예제 #1
0
 public DbTableNodeUI(DbTreeUI tree, TableName tname)
     : base(tname.Path, "Table_16x16.png")
 {
     this.tree = tree;
     Path      = tname;
     Expanded += node_Expanded;
     Selected += node_Selected;
 }
예제 #2
0
 public DbDatabaseNodeUI(DbTreeUI tree, DatabaseName dname)
     : base(dname.Path, "database.png")
 {
     this.tree = tree;
     Path      = dname;
     Expanded += node_Expanded;
     Selected += node_Selected;
 }
예제 #3
0
 public DbServerNodeUI(DbTreeUI tree, ServerName sname)
     : base($"{sname.Path} ({sname.Provider.DataSource})", "server.png")
 {
     this.tree = tree;
     Path      = sname;
     Expanded += node_Expanded;
     Selected += node_Selected;
 }
예제 #4
0
 public DbColumnNodeUI(DbTreeUI tree, ColumnSchema column)
     : base(GetSQLField(column), GetImage(column))
 {
     this.tree = tree;
     Path      = column;
 }
예제 #5
0
        private void InitializeComponent(IConnectionConfiguration cfg)
        {
            this.Width  = 1280;
            this.Height = 768;

            Button btnHome    = WpfUtils.NewImageButton(SqlCommands.Home, "Home", $"Home(Alt-H): {cfg.Home}", "Home_16x16.png");
            Button btnNew     = WpfUtils.NewImageButton(ApplicationCommands.New, "New", "New(Ctrl-N)", "New_16x16.png");
            Button btnOpen    = WpfUtils.NewImageButton(ApplicationCommands.Open, "Open", "Open(Ctrl-O)", "Open_16x16.png");
            Button btnSave    = WpfUtils.NewImageButton(ApplicationCommands.Save, "Save", "Save(Ctrl-S)", "Save_16x16.png");
            Button btnExecute = WpfUtils.NewImageButton(SqlCommands.Execute, "Execute", "Execute(F5)", "Next_16x16.png");

            this.comboPath = new ComboBox {
                Width = 300, HorizontalAlignment = HorizontalAlignment.Right
            };
            this.comboPath.SelectionChanged += ComboPath_SelectionChanged;
            DockPanel dockPanel = new DockPanel();

            this.Content = dockPanel;


            //Tool bar
            ToolBarTray tray = new ToolBarTray();

            tray.SetValue(DockPanel.DockProperty, Dock.Top);
            dockPanel.Children.Add(tray);

            ToolBar toolBar;

            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(btnHome);
            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(btnNew);
            toolBar.Items.Add(btnOpen);
            toolBar.Items.Add(btnSave);
            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(btnExecute);
            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(comboPath);

            //status bar
            StatusBar statusBar = new StatusBar {
                Height = 20
            };

            statusBar.Items.Add(new StatusBarItem {
                Content = lblMessage, HorizontalAlignment = HorizontalAlignment.Left
            });
            statusBar.Items.Add(new StatusBarItem {
                Content = lblCursorPosition, HorizontalAlignment = HorizontalAlignment.Right
            });
            statusBar.SetValue(DockPanel.DockProperty, Dock.Bottom);
            dockPanel.Children.Add(statusBar);


            #region tree, editor and results
            Grid grid = new Grid();
            dockPanel.Children.Add(grid);

            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(5)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            Grid grid1 = new Grid();
            grid1.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(25)
            });
            grid1.RowDefinitions.Add(new RowDefinition());

            GridSplitter vSplitter = new GridSplitter {
                Width = 5, VerticalAlignment = VerticalAlignment.Stretch
            };
            scriptTabControl = new ScriptResultControl(this);

            grid1.SetValue(Grid.ColumnProperty, 0);
            vSplitter.SetValue(Grid.ColumnProperty, 1);
            scriptTabControl.SetValue(Grid.ColumnProperty, 2);

            grid.Children.Add(grid1);
            grid.Children.Add(vSplitter);
            grid.Children.Add(scriptTabControl);

            textFilter = new TextBox
            {
                Margin              = new Thickness(2),
                ToolTip             = "Search table name",
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };
            textFilter.TextChanged += TextFilter_TextChanged;

            //Database Tree
            this.treeView = new DbTreeUI
            {
                //Width = 160,
                Foreground          = Brushes.White,
                Background          = Brushes.Black,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                MinWidth            = 120,
            };

            //Style style = new Style(typeof(TreeViewItem));
            //style.Setters.Add(new Setter { Property = Control.ForegroundProperty, Value = Brushes.White });
            //style.Setters.Add(new Setter { Property = Control.BackgroundProperty, Value = Brushes.Black });
            //style.Resources.Add(SystemColors.ControlBrushKey, Brushes.Black);
            //treeView.ItemContainerStyle = style;

            textFilter.SetValue(Grid.RowProperty, 0);
            treeView.SetValue(Grid.RowProperty, 1);
            grid1.Children.Add(textFilter);
            grid1.Children.Add(treeView);

            treeView.CreateTree(cfg);
            treeView.PathChanged += TreeView_PathChanged;

            #endregion


            CommandBinding    binding;
            RoutedUICommand[] commands = new RoutedUICommand[]
            {
                ApplicationCommands.New,
                ApplicationCommands.Open,
                ApplicationCommands.Save,
                SqlCommands.Home,
                SqlCommands.Execute,
                SqlCommands.Select,
                SqlCommands.Select1000,
            };

            foreach (var cmd in commands)
            {
                binding             = new CommandBinding(cmd);
                binding.Executed   += commandExecute;
                binding.CanExecute += commandCanExecute;
                this.CommandBindings.Add(binding);
            }
        }