Example #1
0
        private void buttonPropertyData_Click(object sender, EventArgs e)
        {
            DocProperty docTemplate = (DocProperty)this.m_target;

            if(docTemplate.PropertyType == DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE)
            {
                // browse for property enumeration
                using(FormSelectPropertyEnum form = new FormSelectPropertyEnum(this.m_project, null))
                {
                    if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        if (form.Selection != null)
                        {
                            docTemplate.PrimaryDataType = form.Selection.Name;
                        }
                        else
                        {
                            docTemplate.PrimaryDataType = String.Empty;
                        }
                        this.textBoxPropertyData.Text = docTemplate.PrimaryDataType;
                    }
                }
                return;
            }

            string basetypename = "IfcValue";
            switch (docTemplate.PropertyType)
            {
                case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE:
                    basetypename = "IfcObjectReferenceSelect";
                    break;
            }            

            DocObject docobj = null;
            DocDefinition docEntity = null;
            if (this.m_map.TryGetValue(basetypename, out docobj))
            {
                docEntity = (DocDefinition)docobj;
            }

            // get selected entity
            DocObject target = null;
            DocDefinition entity = null;
            if (docTemplate.PrimaryDataType != null && m_map.TryGetValue(docTemplate.PrimaryDataType, out target))
            {
                entity = (DocDefinition)target;
            }

            using (FormSelectEntity form = new FormSelectEntity(docEntity, entity, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type))
            {
                DialogResult res = form.ShowDialog(this);
                if (res == DialogResult.OK && form.SelectedEntity != null)
                {
                    docTemplate.PrimaryDataType = form.SelectedEntity.Name;
                    this.textBoxPropertyData.Text = docTemplate.PrimaryDataType;
                }
            }            
        }