Beispiel #1
0
        private void BuildColorRow(string selectedValue)
        {
            string value = "";

            if (selectedValue == AfaStrings.AnyValue)
            {
                value = "";
            }
            else if (selectedValue == "Select Color...")
            {
                var          colorDialog  = new Autodesk.AutoCAD.Windows.ColorDialog();
                DialogResult dialogResult = colorDialog.ShowDialog();
                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    string text = DXFCode.TranstateColorIndexToString(colorDialog.Color.ColorIndex);
                    if (!this._mColorList.Contains(text))
                    {
                        this._mColorList.Add(text);
                        this.cbValue.ItemsSource = this._mColorList;
                    }
                    this.cbValue.SelectedValue = text;
                    value = text;
                }
            }
            else
            {
                short colorIndex = DXFCode.TranslateColorString(selectedValue);
                value = DXFCode.TranstateColorIndexToString(colorIndex);
            }
            int index;

            if (this.QueryDataContainsRow(AfaStrings.Color, out index))
            {
                this.QueryData.Rows.RemoveAt(index);
            }
            if (!string.IsNullOrEmpty(value))
            {
                DataRow dataRow = this.QueryData.NewRow();
                dataRow["Value"] = value;
                dataRow["Type"]  = AfaStrings.Color;
                this.QueryData.Rows.Add(dataRow);
            }
        }
Beispiel #2
0
        private void SelectValueFromEntity(string propertyType)
        {
            Document document = AfaDocData.ActiveDocData.Document;
            Database database = document.Database;
            Editor   editor   = document.Editor;

            try
            {
                using (document.LockDocument((DocumentLockMode)20, null, null, false))
                {
                    var transactionManager = database.TransactionManager;
                    using (Transaction transaction = transactionManager.StartTransaction())
                    {
                        PromptEntityOptions promptEntityOptions = new PromptEntityOptions("\nPick a sample entity: ");
                        promptEntityOptions.SetRejectMessage("Invalid pick: must be AutoCAD entity.");
                        promptEntityOptions.AddAllowedClass(typeof(Entity), false);
                        PromptEntityResult entity = editor.GetEntity(promptEntityOptions);
                        if (entity.Status == (PromptStatus)5100)
                        {
                            Entity entity2 = (Entity)transaction.GetObject(entity.ObjectId, 0);
                            if (propertyType == "Layer")
                            {
                                this.cbValue.SelectedValue = entity2.Layer;
                            }
                            else if (propertyType == "Color")
                            {
                                this.cbValue.SelectedValue = DXFCode.TranstateColorIndexToString(entity2.Color.ColorIndex);
                            }
                            else if (propertyType == "Linetype")
                            {
                                this.cbValue.SelectedValue = entity2.Linetype;
                            }
                            else if (propertyType == "Lineweight")
                            {
                                this.cbValue.SelectedValue = entity2.LineWeight.ToString();
                            }
                            else if (propertyType == "Text Style")
                            {
                                if (entity2 is DBText)
                                {
                                    DBText dBText        = (DBText)entity2;
                                    string textStyleName = dBText.TextStyleName;
                                    this.cbValue.SelectedValue = textStyleName;
                                }
                                else if (entity2 is MText)
                                {
                                    MText  mText          = (MText)entity2;
                                    string textStyleName2 = mText.TextStyleName;
                                    this.cbValue.SelectedValue = textStyleName2;
                                }
                            }
                            else if (propertyType == "Block Name" && entity2 is BlockReference)
                            {
                                BlockReference blockReference = (BlockReference)entity2;
                                this.cbValue.SelectedValue = blockReference.BlockName;
                            }
                        }
                        transaction.Commit();
                    }
                }
            }
            catch
            {
            }
        }