Exemplo n.º 1
0
        public Dictionary <int, ParamProperties> SaveParameterSettings(Dictionary <int, ParamProperties> parameterDictionary, bool isInstance)
        {
            Dictionary <int, ParamProperties> paramDictionary = new Dictionary <int, ParamProperties>();

            paramDictionary = parameterDictionary;
            try
            {
                for (int i = 0; i < paramGridView.RowCount; i++)
                {
                    string strHeader = paramGridView.Rows[i].Cells[3].Value.ToString();
                    if (strHeader == "header")
                    {
                        continue;
                    }
                    int paramId = int.Parse(strHeader);

                    ParamProperties pp = paramDictionary[paramId];
                    pp.IsInstance = isInstance;
                    pp.IsVisible  = (bool)paramGridView.Rows[i].Cells[0].Tag;

                    switch ((LockType)paramGridView.Rows[i].Cells[2].Tag)
                    {
                    case LockType.LockAll:
                        pp.IsLockAll  = true;
                        pp.IsEditable = false;
                        break;

                    case LockType.Editable:
                        pp.IsEditable = true;
                        pp.IsLockAll  = false;
                        break;

                    case LockType.ReadOnly:
                        pp.IsEditable = false;
                        pp.IsLockAll  = false;
                        break;
                    }
                    paramDictionary.Remove(paramId);
                    paramDictionary.Add(pp.ParamID, pp);

                    if (pp.IsShared && sharedParameters[pp.CategoryName].ContainsKey(pp.ParamID))
                    {
                        sharedParameters[pp.CategoryName].Remove(pp.ParamID);
                        sharedParameters[pp.CategoryName].Add(pp.ParamID, pp);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save parameter settings.\n" + ex.Message, "ParameterSettings Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }


            return(paramDictionary);
        }
Exemplo n.º 2
0
        private Dictionary <string, Dictionary <int, ParamProperties> > CollectCategoryParamSettings(Dictionary <string, Dictionary <int, ParamProperties> > categoryParamSettings, string tableName)
        {
            Dictionary <string, Dictionary <int, ParamProperties> > paramSettings = new Dictionary <string, Dictionary <int, ParamProperties> >(categoryParamSettings);
            List <string> categoryNames = new List <string>(paramSettings.Keys.ToList());

            try
            {
                Recordset recordset;
                string    strSql = "";
                foreach (string categoryName in categoryNames)
                {
                    Dictionary <int, ParamProperties> paramDictionary = new Dictionary <int, ParamProperties>();
                    paramDictionary = paramSettings[categoryName];

                    strSql    = "SELECT * FROM [" + tableName + "] WHERE CategoryName ='" + categoryName + "'";
                    recordset = daoDB.OpenRecordset(strSql, RecordsetTypeEnum.dbOpenDynaset);
                    if (recordset.RecordCount > 0)
                    {
                        while (!recordset.EOF)
                        {
                            ParamProperties pp      = new ParamProperties();
                            int             paramId = int.Parse(recordset.Fields["ParamID"].Value);
                            if (paramDictionary.ContainsKey(paramId))
                            {
                                pp            = paramDictionary[paramId];
                                pp.IsVisible  = Convert.ToBoolean(recordset.Fields["IsVisible"].Value);
                                pp.IsLockAll  = Convert.ToBoolean(recordset.Fields["IsLockAll"].Value);
                                pp.IsEditable = Convert.ToBoolean(recordset.Fields["IsEditable"].Value);

                                paramDictionary.Remove(paramId);
                                paramDictionary.Add(paramId, pp);
                            }
                            recordset.MoveNext();
                        }
                        paramSettings.Remove(categoryName);
                        paramSettings.Add(categoryName, paramDictionary);
                    }
                    recordset.Close();
                }

                return(paramSettings);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect category parameter settings: \n" + ex.Message);
                return(null);
            }
        }
Exemplo n.º 3
0
        private Dictionary <int, Dictionary <int, ParamProperties> > CollectFamilyParamSettings(Dictionary <int, Dictionary <int, ParamProperties> > familyParamSettings, string tableName)
        {
            Dictionary <int, Dictionary <int, ParamProperties> > paramSettings = new Dictionary <int, Dictionary <int, ParamProperties> >(familyParamSettings);
            List <int> familyIds = new List <int>(paramSettings.Keys.ToList());

            try
            {
                Recordset recordset;
                string    strSql = "";
                foreach (int familyId in familyIds)
                {
                    Dictionary <int, ParamProperties> paramDictionary = new Dictionary <int, ParamProperties>();
                    paramDictionary = paramSettings[familyId];

                    strSql    = "SELECT * FROM [" + tableName + "] WHERE FamilyID ='" + familyId.ToString() + "'";
                    recordset = daoDB.OpenRecordset(strSql, RecordsetTypeEnum.dbOpenDynaset);
                    if (recordset.RecordCount > 0)
                    {
                        while (!recordset.EOF)
                        {
                            ParamProperties pp      = new ParamProperties();
                            int             paramId = int.Parse(recordset.Fields["ParamID"].Value);
                            if (paramDictionary.ContainsKey(paramId))
                            {
                                pp            = paramDictionary[paramId];
                                pp.IsVisible  = Convert.ToBoolean(recordset.Fields["IsVisible"].Value);
                                pp.IsLockAll  = Convert.ToBoolean(recordset.Fields["IsLockAll"].Value);
                                pp.IsEditable = Convert.ToBoolean(recordset.Fields["IsEditable"].Value);

                                paramDictionary.Remove(paramId);
                                paramDictionary.Add(paramId, pp);
                            }
                            recordset.MoveNext();
                        }
                        paramSettings.Remove(familyId);
                        paramSettings.Add(familyId, paramDictionary);
                    }
                    recordset.Close();
                }

                return(paramSettings);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect family parameter settings: \n" + tableName + "\n" + ex.Message, "RevitDBEditor Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }
        }
Exemplo n.º 4
0
        private void DisplayRow(ParamProperties property, int rowNum)
        {
            DataGridViewCellStyle readonlyStyle = new DataGridViewCellStyle();

            readonlyStyle.BackColor = System.Drawing.Color.White;
            readonlyStyle.ForeColor = System.Drawing.Color.Gray;

            paramGridView.Rows.Add();
            paramGridView.Rows[rowNum].Cells[0].Tag   = property.IsVisible; //parameter isVisible
            paramGridView.Rows[rowNum].Cells[1].Value = property.ParamName; //parameter ParamName

            if (property.IsShared && sharedParameters[property.CategoryName].ContainsKey(property.ParamID))
            {
                ParamProperties pp = sharedParameters[property.CategoryName][property.ParamID];
                property.IsLockAll  = pp.IsLockAll;
                property.IsEditable = pp.IsEditable;
                paramGridView.Rows[rowNum].Cells[0].Tag = pp.IsVisible;
            }

            if (property.IsReadOnly)
            {
                paramGridView.Rows[rowNum].Cells[1].Style = readonlyStyle;
                paramGridView.Rows[rowNum].Cells[2].Value = lockImages.Images[(int)LockType.ReadOnly]; //read only
                paramGridView.Rows[rowNum].Cells[2].Tag   = LockType.ReadOnly;
            }
            else if (property.IsLockAll)
            {
                paramGridView.Rows[rowNum].Cells[2].Value = lockImages.Images[(int)LockType.LockAll]; //lock all
                paramGridView.Rows[rowNum].Cells[2].Tag   = LockType.LockAll;
            }
            else if (property.IsEditable)
            {
                paramGridView.Rows[rowNum].Cells[2].Value = lockImages.Images[(int)LockType.Editable]; //Revit lock
                paramGridView.Rows[rowNum].Cells[2].Tag   = LockType.Editable;
            }
            else
            {
                paramGridView.Rows[rowNum].Cells[1].Style = readonlyStyle;
                paramGridView.Rows[rowNum].Cells[2].Value = lockImages.Images[(int)LockType.ReadOnly]; //read only
                paramGridView.Rows[rowNum].Cells[2].Tag   = LockType.ReadOnly;
            }

            paramGridView.Rows[rowNum].Cells[3].Value = property.ParamID;
            paramGridView.Rows[rowNum].Cells[3].Tag   = property;
        }