Ejemplo n.º 1
0
        private string BuildColorText(string selectedValue)
        {
            if (selectedValue == "Any Color")
            {
                return("");
            }
            if (!(selectedValue == "Select Color..."))
            {
                return(selectedValue);
            }
            ColorDialog  colorDialog  = new ColorDialog();
            DialogResult dialogResult = colorDialog.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                string text = colorDialog.Color.ColorIndex.ToString();
                if (!this.mColorList.Contains(text))
                {
                    this.mColorList.Add(text);
                    this.cbValue.ItemsSource = this.mColorList;
                }
                this.cbValue.SelectedValue = text;
                return(text);
            }
            return("");
        }
Ejemplo n.º 2
0
        // TODO: file dialog by AutoCAD
        //public static void SaveFileDialogByAutoCAD()
        //{
        //}

        /// <summary>
        /// Shows AutoCAD color dialog.
        /// </summary>
        /// <returns>The color result.</returns>
        public static Color ColorDialog()
        {
            var cd = new ColorDialog();

            if (cd.ShowDialog() == DialogResult.OK)
            {
                return(cd.Color);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Открытие диалогового окна цветовой палитры для изменения свойства Color объекта.
        /// </summary>
        public void ChangeColorByDlg()
        {
            AcadAS.Document doc = AcadAS.Application.DocumentManager.MdiActiveDocument;
            Editor          ed  = doc.Editor;

            Autodesk.AutoCAD.Windows.ColorDialog dlg = new Autodesk.AutoCAD.Windows.ColorDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Color = dlg.Color;
            }
        }
Ejemplo n.º 4
0
        public static System.Drawing.Color SelectColor(System.Drawing.Color color)
        {
            var colorDialog = new Autodesk.AutoCAD.Windows.ColorDialog();

            colorDialog.Color = Color.FromColor(color);
            if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(colorDialog.Color.ColorValue);
            }
            return(color);
        }
Ejemplo n.º 5
0
        // TODO: file dialog by AutoCAD
        //public static void SaveFileDialogByAutoCAD()
        //{
        //}

        /// <summary>
        /// AutoCAD颜色对话框
        /// </summary>
        /// <returns>颜色</returns>
        public static Autodesk.AutoCAD.Colors.Color ColorDialog()
        {
            Autodesk.AutoCAD.Windows.ColorDialog cd = new Autodesk.AutoCAD.Windows.ColorDialog();
            if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(cd.Color);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        private void buttonColor_Click(object sender, EventArgs e)
        {
            // Выбор цвета для выбранного типа цвета
             TileColor tileColor = listBoxColor.SelectedItem as TileColor;
             if (tileColor == null)
            return;

             Autodesk.AutoCAD.Windows.ColorDialog colorDlg = new Autodesk.AutoCAD.Windows.ColorDialog();
             var res = colorDlg.ShowDialog();
             if (res == DialogResult.OK)
             {
            tileColor.Color = colorDlg.Color;
             }
        }
Ejemplo n.º 7
0
        private void buttonColor_Click(object sender, EventArgs e)
        {
            // Выбор цвета для выбранного типа цвета
            TileColor tileColor = listBoxColor.SelectedItem as TileColor;

            if (tileColor == null)
            {
                return;
            }

            Autodesk.AutoCAD.Windows.ColorDialog colorDlg = new Autodesk.AutoCAD.Windows.ColorDialog();
            var res = colorDlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                tileColor.Color = colorDlg.Color;
            }
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
0
        private void btnPickCountColor_Click(object sender, EventArgs e)
        {
            if (mCopy == null)
            {
                return;
            }
            Button btn = (Button)sender;

            Autodesk.AutoCAD.Windows.ColorDialog cd = new Autodesk.AutoCAD.Windows.ColorDialog();
            cd.SetDialogTabs(Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ACITab);
            cd.Color = Autodesk.AutoCAD.Colors.Color.FromColor(btn.BackColor);
            cd.IncludeByBlockByLayer = false;
            if (cd.ShowDialog() == DialogResult.OK)
            {
                mCopy.CountColor           = cd.Color;
                btn.BackColor              = cd.Color.ColorValue;
                posStylePreview.CountColor = cd.Color.ColorValue;
                posStylePreview.SetGroup();
            }
        }
Ejemplo n.º 10
0
        // Выделение цветом
        private static void SetColor(IEnumerable <ObjectId> objectIds, Database db)
        {
            var colorDialog = new Autodesk.AutoCAD.Windows.ColorDialog();

            if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (var tr = db.TransactionManager.StartTransaction())
                {
                    foreach (var objectId in objectIds)
                    {
                        var dim = (Dimension)tr.GetObject(objectId, OpenMode.ForWrite);
                        if (!string.IsNullOrEmpty(dim.DimensionText))
                        {
                            dim.Color = colorDialog.Color;
                        }
                    }

                    tr.Commit();
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Открытие диалогового окна цветовой палитры для изменения свойства Color объекта.
        /// </summary>
        public void ChangeColorByDlg()
        {
            AcadAS.Document doc = AcadAS.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            Autodesk.AutoCAD.Windows.ColorDialog dlg = new Autodesk.AutoCAD.Windows.ColorDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Color = dlg.Color;
            }
        }
Ejemplo n.º 12
0
 public static Autodesk.AutoCAD.Colors.Color SelectColor()
 {
     try
     {
         Autodesk.AutoCAD.Windows.ColorDialog cd = new Autodesk.AutoCAD.Windows.ColorDialog();
         cd.IncludeByBlockByLayer = true;
         cd.SetDialogTabs(Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ACITab);
         System.Windows.Forms.DialogResult resd = cd.ShowDialog();
         if (resd == System.Windows.Forms.DialogResult.Cancel)
         {
             return null;
         }
         return cd.Color;
     }
     catch (System.Exception ex)
     {
         AcadApp.AcaEd.WriteMessage("\nERROR: AcadApp.SelectColor() " + ex + "\n");
     }
     return null;
 }
Ejemplo n.º 13
0
 private void btnPickTextColor_Click(object sender, EventArgs e)
 {
     if (mCopy == null) return;
     Button btn = (Button)sender;
     Autodesk.AutoCAD.Windows.ColorDialog cd = new Autodesk.AutoCAD.Windows.ColorDialog();
     cd.SetDialogTabs(Autodesk.AutoCAD.Windows.ColorDialog.ColorTabs.ACITab);
     cd.Color = Autodesk.AutoCAD.Colors.Color.FromColor(btn.BackColor);
     cd.IncludeByBlockByLayer = false;
     if (cd.ShowDialog() == DialogResult.OK)
     {
         mCopy.TextColor = cd.Color;
         btn.BackColor = cd.Color.ColorValue;
         posStylePreview.TextColor = cd.Color.ColorValue;
         posStylePreview.SetGroup();
     }
 }