Ejemplo n.º 1
0
        /// <summary>
        /// Отображение диалогового окна AutoCAD с выбором типа линии
        /// </summary>
        private void LineType_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            using (AcadUtils.Document.LockDocument())
            {
                var ltd = new LinetypeDialog {
                    IncludeByBlockByLayer = false
                };
                if (ltd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (!ltd.Linetype.IsNull)
                    {
                        using (var tr = AcadUtils.Document.TransactionManager.StartOpenCloseTransaction())
                        {
                            using (var ltr = tr.GetObject(ltd.Linetype, OpenMode.ForRead) as LinetypeTableRecord)
                            {
                                if (ltr != null)
                                {
                                    ((TextBox)sender).Text = ltr.Name;
                                }
                            }

                            tr.Commit();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens an AutoCAD linetype dialog box to let the user choose a linetype for the currently selected layer
        /// </summary>
        private void SelectLine()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;

            // default setting for linetype, in case one is not selected
            string lineName = "Continuous";

            LinetypeDialog ltd = new LinetypeDialog();

            // using will close connection when finished. Causes problems otherwise
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                LinetypeTable lt = (LinetypeTable)tr.GetObject(db.LinetypeTableId, OpenMode.ForRead);

                DialogResult dr = ltd.ShowDialog();

                // if OK is clicked on linetype dialog box
                if (dr == DialogResult.OK)
                {
                    LinetypeTableRecord symbol = (LinetypeTableRecord)tr.GetObject(ltd.Linetype, OpenMode.ForRead);

                    // if user does not select ByLayer or ByBlock as linetype, set lineName to their selection
                    // otherwise, leave it as Continuous
                    if (!symbol.Name.Equals("ByLayer") && !symbol.Name.Equals("ByBlock"))
                    {
                        lineName = symbol.Name;
                    }
                }
            }

            // set line in selected Layer in layerList
            ////    layerList[the selected layer name]
            this.layerList[this.layersListBox.SelectedItem.ToString()].SetLine(lineName);

            // brings form back to the front
            this.Activate();
        }