public void Connection(object sender, EventArgs e, SqlAnywhereConnectionManager newConnectionManager)
 {
     ((NewConnection)sender).Close();
     ConnectionManager = newConnectionManager;
     var item = ObjectTreeView.Items.GetItemAt(0) as TreeViewItem;
     item.ExpandSubtree();
     Image img = FindResource("connect") as Image;
     if (img != null) DatabaseIcon.Source = img.Source;
 }
        public MainWindow()
        {
            ConnectionManager = null;
            InitializeComponent();
            DataGrid.AutoGenerateColumns = false;
            ResultsDataGrid.AutoGenerateColumns = false;

            var treeviewitem = new DatabaseTreeView();
            ObjectTreeView.Items.Add(treeviewitem);
        }
 private void Test_Click(object sender, RoutedEventArgs e)
 {
     var connectionManager = new SqlAnywhereConnectionManager(UserIdBox.Text, PasswordBox.Password);
     if (connectionManager.ConnectToDatabase(DatabaseBox.Text))
     {
         connectionManager.DisconnectDatabase(DatabaseBox.Text);
         MessageLabel.Content = "Test Succesfull";
         
     }
     else
     {
         MessageLabel.Content = "Test Failed";
     }
 }
 private void Connect_Click(object sender, RoutedEventArgs e)
 {
     ConnectionManager = new SqlAnywhereConnectionManager("", "");
     ConnectionManager.UserId = UserIdBox.Text;
     ConnectionManager.Password = PasswordBox.Password;
     if (ConnectionManager.ConnectToDatabase(DatabaseBox.Text))
     {
         MessageLabel.Content = "Test Succesfull";
         if (NewConnectionEvent != null) NewConnectionEvent(this, e, ConnectionManager);
     }
     else
     {
         MessageLabel.Content = "Connection Failed";
         ConnectionManager.UserId = "";
     }
 }
 public NewConnection(SqlAnywhereConnectionManager connectionManager)
 {
     ConnectionManager = connectionManager;
     InitializeComponent();
 }
     private void EndConnection_Click(object sender, RoutedEventArgs e)
     {
         if (ConnectionManager == null)
         {
             MessageBox.Show("You are not connected to a database");
             return;
         }
 
         var dataBaseName = ((MenuItem) sender).Tag.ToString();
         ConnectionManager.DisconnectDatabase(dataBaseName);
         ConnectionManager = null;
         var item = ObjectTreeView.Items.GetItemAt(0) as TreeViewItem;
         item.IsExpanded = false;
         Image img = FindResource("disconnect") as Image;
         if (img != null) DatabaseIcon.Source = img.Source;
         ClearDatagrid();
     }