public TreeNodeConnectionItem(ConnectionItem item)
 {
     _item = item;
     Text  = _item.ToString();
     if (item.IsValid)
     {
         ImageIndex = IMG_CNN;
     }
     else
     {
         ImageIndex = IMG_CNN_ERR;
     }
     SelectedImageIndex = ImageIndex;
     this.Nodes.Add(new CLoad());
 }
示例#2
0
 private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
 {
     if (string.CompareOrdinal(e.ChangedItem.PropertyDescriptor.Name, "Name") == 0)
     {
         ConnectionItem ci = propertyGrid1.SelectedObject as ConnectionItem;
         if (ci != null)
         {
             TreeNodeConnectionItem tnc = treeView1.SelectedNode as TreeNodeConnectionItem;
             if (tnc != null)
             {
                 if (tnc.OwnerItem.ConnectionGuid == ci.ConnectionGuid)
                 {
                     tnc.Text = ci.ToString();
                 }
             }
         }
     }
 }
示例#3
0
 private void toolStripButtonDelete_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         TreeNodeConnectionItem tc = treeView1.SelectedNode as TreeNodeConnectionItem;
         if (tc == null)
         {
             tc = treeView1.SelectedNode.Parent as TreeNodeConnectionItem;
         }
         if (tc != null)
         {
             ConnectionItem ci = tc.OwnerItem;
             if (ci != null)
             {
                 if (MessageBox.Show(this, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Do you want to delete connection [{0}]?", ci.ToString()), "Database Connection Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                 {
                     if (System.IO.File.Exists(ci.FullFilePath))
                     {
                         try
                         {
                             System.IO.File.Delete(ci.FullFilePath);
                         }
                         catch (Exception err)
                         {
                             MessageBox.Show(this, err.Message, "Database Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                     }
                     propertyGrid1.SelectedObject = null;
                     tc.Remove();
                     _connectionList.Remove(ci);
                     ConnectionConfig.RemoveConnection(ci.ConnectionObject.ConnectionGuid);
                 }
             }
         }
     }
 }