예제 #1
0
 private void FillConnectionList(IConnectionsGraph connections, ListBox lbox)
 {
     foreach (Connection connection in connections.Connections)
     {
         lbox.Items.Add(connection);
     }
     lbox.DoubleClick += (sender, args) =>
     {
         Connection connection = lbox.SelectedItem as Connection;
         if (connection == null)
         {
             return;
         }
         if (Settings.Default.AlwaysEdit)
         {
             if (connection.IsOpen)
             {
                 MessageBox.Show(Resources.EditConnection_Forbidden_Text, Resources.EditConnection_Forbidden_Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
             EditConnectionForm edit = new EditConnectionForm(connection, false);
             if (edit.ShowDialog() == DialogResult.OK)
             {
                 connection = edit.Connection;
                 try
                 {
                     connection.Open();
                     Program.MainForm.ShowStoreManagerForm(connection);
                     this.Close();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(string.Format(Resources.StartPage_Open_Error_Text, connection.Name, ex.Message), Resources.ConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             try
             {
                 connection.Open();
                 Program.MainForm.ShowStoreManagerForm(connection);
                 this.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(string.Format(Resources.StartPage_Open_Error_Text, connection.Name, ex.Message), Resources.ConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     };
 }
예제 #2
0
        private void QuickEditClick(object sender, EventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            Object tag = null;

            if (sender is Control)
            {
                tag = ((Control)sender).Tag;
            }
            else if (sender is ToolStripItem)
            {
                tag = ((ToolStripItem)sender).Tag;
            }
            else if (sender is Menu)
            {
                tag = ((Menu)sender).Tag;
            }

            if (tag != null)
            {
                if (tag is Connection)
                {
                    Connection connection = (Connection)tag;
                    if (connection.IsOpen)
                    {
                        MessageBox.Show(Resources.EditConnection_Forbidden_Text, Resources.EditConnection_Forbidden_Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    try
                    {
                        EditConnectionForm editConn = new EditConnectionForm(connection, false);
                        if (editConn.ShowDialog() == DialogResult.OK)
                        {
                            connection = editConn.Connection;
                            connection.Open();
                            this.ShowStoreManagerForm(connection);

                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(string.Format(Resources.QuickEdit_Error_Text, ex.Message), Resources.QuickEdit_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
예제 #3
0
 private void mnuNewFromExisting_Click(object sender, EventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         if (this.ActiveMdiChild is StoreManagerForm)
         {
             Connection         connection = ((StoreManagerForm)this.ActiveMdiChild).Connection;
             EditConnectionForm editConn   = new EditConnectionForm(connection, true);
             if (editConn.ShowDialog() == DialogResult.OK)
             {
                 editConn.Connection.Open();
                 ShowStoreManagerForm(editConn.Connection);
             }
             return;
         }
     }
     MessageBox.Show(Resources.NewFromExisting_Error_Text, Resources.NewFromExisting_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
예제 #4
0
        private void EditConnection(ListBox lbox)
        {
            Connection connection = lbox.SelectedItem as Connection;

            if (connection == null)
            {
                return;
            }

            if (connection.IsOpen)
            {
                MessageBox.Show("The selected connection is not editable", "Edit Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            EditConnectionForm edit = new EditConnectionForm(connection, false);

            if (edit.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            connection = edit.Connection;
            try
            {
                connection.Open();
                Program.MainForm.ShowStoreManagerForm(connection);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Resources.StartPage_Open_Error_Text, connection.Name, ex.Message), Resources.ConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //Add to Recent Connections
            Program.MainForm.AddRecentConnection(connection);

            this.Close();
        }