bool SaveStyleNameToUiData() { if (textStyleName.Text.Length == 0) { MessageBox.Show("Please specify a name for the schedule table style."); return(false); } Database db = ScheduleSample.GetDatabase(); DictionaryScheduleTableStyle dict = new DictionaryScheduleTableStyle(db); DBTransactionManager tm = db.TransactionManager; using (Transaction trans = tm.StartTransaction()) { if (dict.Has(textStyleName.Text, trans)) { MessageBox.Show("The style name you specified already exists. Please specify a new one."); return(false); } } runtimeData.scheduleTableStyleName = textStyleName.Text; return(true); }
// another way to find the index of a property definition //private static int FindPropertyDefinitionIndex(PropertySetDefinition psd, string propertyName) //{ // PropertyDefinition propDef = new PropertyDefinition(); // propDef.Name = propertyName; // return psd.Definitions.IndexOf(propDef); //} private static ScheduleTableStyle CreateStyle(UiData uiData, PropertySetDefinition psd, Transaction trans) { Database db = ScheduleSample.GetDatabase(); ScheduleTableStyle style = new ScheduleTableStyle(); style.SetToStandard(db); style.SubSetDatabaseDefaults(db); // sets the object type to which the schedule table style applies StringCollection filter = new StringCollection(); foreach (RXClass rc in uiData.classPropertiesMap.Keys) { filter.Add(rc.Name); } style.AppliesToFilter = filter; CreateChildNodes(uiData.headerColumnDesignData, style.Tree, psd, style); //add it into database DictionaryScheduleTableStyle scheduleTableStyleDict = new DictionaryScheduleTableStyle(db); style.Title = uiData.scheduleTableStyleName; scheduleTableStyleDict.AddNewRecord(uiData.scheduleTableStyleName, style); trans.AddNewlyCreatedDBObject(style, true); return(style); }