Methods


ShowPalette


This sample show the ShowPalette method that shows the default Palette dialog for the control.

It is possible to localize the dialog string using some internal properties as shown in the picture below:

C#

using System;
using System.Windows.Forms;
using DXFReaderNET;
using DXFReaderNET.Entities;

namespace ShowPalette
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private AciColor newColor;
        private void Form1_Load(object senderEventArgs e)
        {
            dxfReaderNETControl1.NewDrawing();
            dxfReaderNETControl1.CustomCursor = CustomCursorType.CrossHair;
            dxfReaderNETControl1.ReadDXF(@"..\..\drawing.dxf");
            newColor = dxfReaderNETControl1.DXF.CurrentColor;
        }

        private void button1_Click(object senderEventArgs e)
        {
            ShowPalette();
        }

        private void button2_Click(object senderEventArgs e)
        {
            dxfReaderNETControl1.ColorPaletteDialogText = "选择颜色";
            dxfReaderNETControl1.ColorPaletteDialogButtoOkText = "好";
            dxfReaderNETControl1.ColorPaletteDialogButtonCancelText = "取消";
            dxfReaderNETControl1.ColorPaletteDialogLabelIndexColor = "索引色";
            dxfReaderNETControl1.ColorPaletteDialogLabelRGB = "红,绿,蓝";
            dxfReaderNETControl1.ColorPaletteDialogLabelColor = "颜色";
            ShowPalette();
        }

        private void ShowPalette()
        {
            newColor = dxfReaderNETControl1.ShowPalette(newColor);
            if (newColor != dxfReaderNETControl1.DXF.CurrentColor)
            {
                foreach (EntityObject entity in dxfReaderNETControl1.DXF.Entities)
                {
                    entity.Color = newColor;
                }
                dxfReaderNETControl1.Refresh();
            }
        }
    }
}

Here is the result:


Download C# code from GitHub

 


Warning!
All samples, data, places and images in this section are only for tutorial scope. They are fictitious and may not correspond to real cases.

Any similarities to actual persons or places is merely coincidental.

To evaluate all code samples you need to download and install the DXFReader.NET Compoonent first.