private void btnAddAssembly_Click(object sender, EventArgs e)
        {
            using (AssemblyDetailsForm dForm = new AssemblyDetailsForm())
            {
                dForm.RevitDocument = this.RevitDocument;
                dForm.IsAdd = true;
                dForm.ShowDialog();

                BuildingComponent currComp = (BuildingComponent)lbExistingComps.SelectedItem;
                currComp.Assemblies.Add(dForm.CurrentAssembly);
                if (dForm.CurrentAssembly != null)
                    lbCompAssemblies.Items.Add(dForm.CurrentAssembly);
                dForm.ChangesMade = false;
            }
            lbCompAssemblies.ClearSelected();
        }
 private void lbCurrentOptions_MouseDoubleClick(object sender, MouseEventArgs args)
 {
     if (lbCurrentOptions.SelectedIndex >= 0)
     {
         Assembly assem = (Assembly)lbCurrentOptions.SelectedItem;
         AssemblyDetailsForm detFrm = new AssemblyDetailsForm();
         detFrm.CurrentAssembly = assem;
         detFrm.RevitDocument = this.RevitDocument;
         detFrm.Show();
     }
 }
        private void btnAssemblyDetails_Click(object sender, EventArgs e)
        {
            if (lbCompAssemblies.SelectedIndex < 0)
                MessageBox.Show("Please select an assembly to swap.");
            else
            {
                using (AssemblyDetailsForm dForm = new AssemblyDetailsForm())
                {
                    dForm.CurrentAssembly = (Assembly)lbCompAssemblies.SelectedItem;
                    dForm.RevitDocument = this.RevitDocument;
                    dForm.ShowDialog();

                    if (dForm.ChangesMade)
                    {
                        lbCompAssemblies.Items.RemoveAt(lbCompAssemblies.SelectedIndex);
                        lbCompAssemblies.Items.Add(dForm.CurrentAssembly);
                        lbCompAssemblies.SelectedItem = dForm.CurrentAssembly;
                        dForm.ChangesMade = false;
                    }
                }
                lbCompAssemblies.ClearSelected();
            }
        }