// load from settings file
 private void LoadFromSettingsFile()
 {
     if (File.Exists(UserConfigFile.FullFileName))
     {
         var configXml     = UserConfigFile.ConfigFileXml;
         var settingsXml   = configXml?.Element("Settings");
         var fastBlocksXml = settingsXml?.Element("mpFastBlocks");
         if (fastBlocksXml != null)
         {
             _fastBlocks.Clear();
             foreach (var fbXml in fastBlocksXml.Elements("FastBlock"))
             {
                 var fb = new FastBlock
                 {
                     Name      = fbXml.Attribute("Name")?.Value,
                     BlockName = fbXml.Attribute("BlockName")?.Value,
                     File      = fbXml.Attribute("File")?.Value
                 };
                 _fastBlocks.Add(fb);
             }
         }
     }
     else
     {
         ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(_langItem, "err4"), MessageBoxIcon.Close);
     }
 }
        // add item
        private void BtAddNewBlock_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_fastBlocks.Count < 10)
                {
                    var ofd = new OpenFileDialog(ModPlusAPI.Language.GetItem(_langItem, "err6"), string.Empty, "dwg", string.Empty,
                                                 OpenFileDialog.OpenFileDialogFlags.NoFtpSites | OpenFileDialog.OpenFileDialogFlags.NoUrls);
                    Topmost = false;
                    if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        var db = new Database(false, true);
                        db.ReadDwgFile(ofd.Filename, FileShare.Read, true, string.Empty);
                        var blocks = new List <string>();
                        using (var tr = db.TransactionManager.StartTransaction())
                        {
                            var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                            blocks.AddRange(from ObjectId id in bt
                                            select(BlockTableRecord) tr.GetObject(id, OpenMode.ForRead)
                                            into btRecord
                                            where !btRecord.IsLayout & !btRecord.IsAnonymous
                                            select btRecord.Name);
                        }

                        var validateNames = _fastBlocks.Select(fastBlock => fastBlock.Name).ToList();
                        var fbs           = new FastBlockSelection(validateNames)
                        {
                            LbBlocks = { ItemsSource = blocks }
                        };
                        if (fbs.ShowDialog() == true)
                        {
                            var fb = new FastBlock
                            {
                                Name      = fbs.TbBlockName.Text,
                                File      = ofd.Filename,
                                BlockName = fbs.LbBlocks.SelectedItem.ToString()
                            };
                            _fastBlocks.Add(fb);

                            // save
                            SaveToSettingsFile();

                            // reload
                            LwFastBlocks.ItemsSource = null;
                            LwFastBlocks.ItemsSource = _fastBlocks;
                        }
                    }

                    Topmost = true;
                }
                else
                {
                    ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(_langItem, "h33"), MessageBoxIcon.Alert);
                }
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }