Beispiel #1
0
 private void InitializeDataSourcesAndControls()
 {
     this.groupComboBox.Sorted     = true;
     this.groupComboBox.DataSource = System.Enum.GetValues(typeof(BuiltInParameterGroup));
     this.groupComboBox.Format    += new ListControlConvertEventHandler(this.groupComboBox_Format);
     this.typeComboBox.Sorted      = true;
     this.typeComboBox.DataSource  = System.Enum.GetValues(typeof(ParameterType));
     foreach (Category item in this.m_categories)
     {
         this.categoryCheckedListBox.Items.Add(item);
     }
     this.categoryCheckedListBox.DisplayMember = "Name";
     this.projectParameterRadioButton.Checked  = this.m_parameterInfo.ParameterIsProject;
     this.sharedParameterRadioButton.Checked   = !this.m_parameterInfo.ParameterIsProject;
     this.typeRadioButton.Checked     = this.m_parameterInfo.ParameterForType;
     this.instanceRadioButton.Checked = !this.m_parameterInfo.ParameterForType;
     this.nameTextBox.Text            = this.m_parameterInfo.ParameterName;
     this.groupComboBox.SelectedItem  = this.m_parameterInfo.ParameterGroup;
     this.typeComboBox.SelectedItem   = this.m_parameterInfo.ParameterType;
     if (this.m_parameterInfo.Categories != null)
     {
         foreach (Category value in this.m_parameterInfo.Categories)
         {
             int index = this.categoryCheckedListBox.Items.IndexOf(value);
             this.categoryCheckedListBox.SetItemChecked(index, true);
         }
     }
     ParameterPropertyForm.ComboBoxDropDownWidthFitToContent(this.groupComboBox);
     ParameterPropertyForm.ComboBoxDropDownWidthFitToContent(this.typeComboBox);
 }
Beispiel #2
0
 private static void ComboBoxDropDownWidthFitToContent(System.Windows.Forms.ComboBox cbo)
 {
     cbo.DropDownWidth = ParameterPropertyForm.GetLargestTextExtent(cbo);
 }
Beispiel #3
0
 private void addButton_Click(object sender, System.EventArgs e)
 {
     using (ParameterPropertyForm parameterPropertyForm = new ParameterPropertyForm(this.m_revitUiApp))
     {
         if (parameterPropertyForm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 if (!this.m_parameterCreation.CreateUserDefinedParameter(parameterPropertyForm.ParameterInfo))
                 {
                     MessageBox.Show(RDBResource.GetString("MessageBox_Import_CreateParameterFailed"));
                 }
                 else
                 {
                     ParameterInfo parameterInfo = parameterPropertyForm.ParameterInfo;
                     this.parameterListBox.Items.Add(parameterInfo.ParameterName);
                     this.parameterListBox.SelectedItem = parameterInfo.ParameterName;
                     foreach (Category category in parameterInfo.Categories)
                     {
                         if (category != null)
                         {
                             string tableKey  = RDBResource.GetTableKey(category.Id.IntegerValue, parameterInfo.ParameterForType);
                             string tableName = RDBResource.GetTableName(tableKey);
                             if (tableName != null && !Command.ColumnExists(tableName, parameterInfo.ParameterName))
                             {
                                 bool flag = Command.AddColumn(parameterInfo.ParameterName, DatabaseManager.GetDataType(parameterInfo.ParameterType), tableName);
                                 if (flag)
                                 {
                                     bool      flag2     = true;
                                     TableInfo tableInfo = this.m_tableInfoSet[tableKey];
                                     foreach (ColumnInfo current in tableInfo.Values)
                                     {
                                         if (current.Name == parameterInfo.ParameterName)
                                         {
                                             flag2 = false;
                                             break;
                                         }
                                     }
                                     if (flag2)
                                     {
                                         tableInfo.AddColumn(new CustomColumnInfo(parameterInfo.ParameterName, DatabaseManager.GetDataType(parameterInfo.ParameterType)));
                                     }
                                     if (this.m_dataSet.Tables.Contains(tableName))
                                     {
                                         Log.WriteLine("Refresh data table " + tableName + " after addding column");
                                         Command.RefreshDataTable(this.m_dataSet.Tables[tableName]);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             catch (System.Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 Log.WriteLine(ex.ToString());
             }
         }
     }
 }