Пример #1
0
        private void startEditingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectLayer selectLayer = new SelectLayer(this, axMapControl1.Map);

            if (selectLayer.ShowDialog() == DialogResult.OK)
            {
                sEditLayerName         = selectLayer.getLayerName();
                miStartEditing.Enabled = false;
                miStopEditing.Enabled  = true;
            }
        }
        public void EntriesLayer()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var ed  = doc.Editor;

            try
            {
                var selectedObjects = ed.SelectImplied();
                if (selectedObjects.Value == null)
                {
                    var pso = new PromptSelectionOptions
                    {
                        MessageForAdding   = $"\n{Language.GetItem(LangItem, "msg2")}",
                        MessageForRemoval  = "\n",
                        AllowSubSelections = false,
                        AllowDuplicates    = false
                    };
                    var psr = ed.GetSelection(pso);
                    if (psr.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    selectedObjects = psr;
                }

                if (selectedObjects.Value.Count > 0)
                {
                    var selectLayerWin = new SelectLayer();
                    if (selectLayerWin.ShowDialog() == true && selectLayerWin.LbLayers.SelectedIndex != -1)
                    {
                        var selectedLayer = (SelectLayer.SelLayer)selectLayerWin.LbLayers.SelectedItem;
                        using (var tr = doc.TransactionManager.StartTransaction())
                        {
                            foreach (SelectedObject so in selectedObjects.Value)
                            {
                                var selEnt = tr.GetObject(so.ObjectId, OpenMode.ForRead);
                                if (selEnt is BlockReference blockReference)
                                {
                                    ChangeLayer(blockReference.BlockTableRecord, selectedLayer.LayerId);
                                }
                            }

                            tr.Commit();
                        }

                        ed.Regen();
                    }
                }
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }