MicroGDS @ \ Ɠ.

C # ɂ u R Ȑ v T v @

} E X ̈ړ O Ղ ɂ v Љ 𗘗p ċ @ \ Ă ̂ B

ȉ ̃T v \ [ X ́AMicroGDS V10 p ƂȂ. g } l [ W ̕ϐ ɃZ b g l ȉ ɒu Ă B
utrue v u-1 v
u false v u0 v

j @
@ ύX O @axCadEvMgr601.Initialize = true;
@ ύX @axCadEvMgr601.Initialize = -1;

p r

c [ o [ Ő 킨 ѐF I Ď R Ȑ } ͂ B 킨 ѐF I ē ͂ e L X g }

c [ 쐬 ̗


1. J p v W F N g 쐬
@ @ J p v F N g ̍쐬
@ @ MicroGDS .NET C u ̒lj
@ @ MicroGDS C x g } l [ W ̒lj @

2. c [ 쐬
@ @ \ [ X R [ h ̓ \ t
@ @ uForm1.cs v 2 ?? ̃ C x g processed
@ @ v W F N g r h Ď s t @ C i.exe j 쐬
3. s ̎d
4. \ [ X
5. T v \ [ X

1. J p v W F N g 쐬

Microsoft Visual Studio 2005 𗘗p āA J p v W F N g ̍쐬 菇 AMicroGDS .NET iMGDSNet j ̒lj @ AMicroGDS C x g } l [ W ̒lj B

J p v W F N g ̍쐬
  1. X ^ [ g j [ u Microsoft Visual Studio 2005 v s
  2. Microsoft Visual Studio ̃c [ j [ u t @ C ^ V K 쐬 ^ v W F N g v s

    c [ j [ Ɂu t @ C ^ V K 쐬 ^ v W F N g v A u t @ C ^ V v W F N g v processed ꍇ ́A Microsoft Visual Studio וJ processed fat u Visual Basic J processed v J l ̏ ꍇ ̓ j [ ڂ̖ ̂ قȂ ꍇ ̂ ǂreminated ւ Ď 菇 i ĂĂ B ̃y ꍇ ́ A u c [ ^ processed ̃ C | g ƃ G N X | E.B.U. [.h. u. B ́u processed ̐ texture ̕ۑ v _ C A v I Łu ց v N b N ͂ B ā u. ̑I v _ C A O Łu S ʓI ȊJ process v I Łu v N b N Ō Ɂu Z b g N b N ƁA J plasmic ύX 邱 Ƃ ł ̂ B

  3. u v W F N g ̎ ‥ v u Visual C # v I A u e v g v u Windows A v P [ V v I ̂ B ̂ u v W F N g v ɍ쐬 A v P [ V ̖ O uDrawFreeLine v ͂ ͂ B
  4. uOK v { ^ N b N ƃv W F N g 쐬
MicroGDS .NET C u ̒lj
  1. Microsoft Visual Studio ̃c [ j Microsoft
  2. u.NET v ^ u R | [ l g u Micro GDS API v I
  3. uOK v { ^ N b N ƃ\ [ V G N X v [ ̎Q Ɛ mirror Ɂu MGDSNet v lj A MicroGDS ̃J X ^ } Y ɕK v .NET C u g p ł 悤 ɂȂ ͂ B
MicroGDS C x g } l [ W ̒lj
  1. Microsoft Visual Studio ̃c [ j [ u c [ ^ c [ { b. ̑I v s ̂ B
  2. uCOM R | [ l g v ^ u 薼 O u Micro GDS Event Manager v ` F b.
  3. uOK v { ^ N b N A uForm1.cs [ f U C ] v ^ u ̃t H [ N b N ā A h b O ̃ A C R z u
    A C R h b O Ȃ ꍇ ́A Microsoft Visual Studio ̃c [ j [ u \ ^ c [ { b N X v s A c. u Micro GDS Event Manager v I ăt H [ ɔz u
  4. A C R z u Ƃ Ń \ [. ɁuAxCadevmgrLib60 v ƁuCadevmgrLib60 v Ƃ lj A MicroGDS C x g } l ɂȂ.

2. c [ 쐬

\ [ X R [ h ̓ \ t
  1. Microsoft Visual Studio ́uForm1.cs [.f U C ] v ^ u b N B
  2. c [ j [ u \ ^ R ] h v s
  3. c [ j X R [ h ׂđI ̂ B
  4. c [ j [ u ȏW ^ 폜 v s A ̃ \ [ h. ׂč폜.
  5. ̃y [ W ̃T v \ [ X Web u E U Ń R ā A Microsoft Visual Studio ̃ c [ j t v s A \ [ X R [ h \ t B
uForm1.cs v 2 ?? ̃C x g
  1. Microsoft Visual Studio ́uForm1.cs [.f U C ] v ^ u b N B
  2. c [ j [ u \ ^ v p e B E B h E v. s
  3. v p e B E B h E 㑤 ̃R g [ I R X uForm1 v I B
  4. R { { b N X ̃c [ o N b N ̂ B
  5. v p e B O b h ́uLoad v N b N A E ̃R { { b N X uForm1_Load v I āA t H [ Ǎ ̃C x g ֘A t B
  6. . ā A t H [ ?? ̃ C x g ֘A t ̂ B
v F N g h Ď s t @ C i.exe j 쐬
  1. Microsoft Visual Studio ̃c [ j [ u r h ^ \ [ V ̃r h v s

    \ [ X R [ h r h ꂽ.ۂɃG [ \ ꂽ.ꍇ ́A Ēł̎ 菇 ̂ ꂩ.ō Ƃ Ă 邱 Ƃ l Ă B

  2. Microsoft Visual Studio ̃c [ j [ u \ ^ o ́v s ̂ B
  3. r h ɏ I A o ̓E B h E Ɂu r h: 1 I ͍Ő V ̏ s A0 X L b v v ƕ \ Ă B
  4. o ̓E B h E ́uDrawFreeLine-> v ̍s ɁA s t @ C i.exe j 쐬 ꂽ t H ̃ p X m F ł B ̎ s t H _ Ɉȉ ̃c [ o [ p r b g } b v t @ C i v6 t @ C j E [.
    customize_sample03_draw.bmp
    customize_sample03_text.bmp
    customize_sample03_red.bmp
    customize_sample03_blue.bmp
    customize_sample03_green.bmp
    customize_sample03_exit.bmp
    Web u E U Microsoft Internet Explorer ̏ ꍇ ́A L \ ̃ t @ C ͉ N b N āu Ώۂ t @ C ɕۑ v s A u r.b.g. C [ W v ` Ŏ s t @ C i.exe j Ɠ t H _ ɕۑ Ă B
    ph t H g ̃p X ́u } C h L g v t H _. Studio 2005 \ Projects \ DrawFreeLine \ DrawFreeLine \ bin \ Debug v ł A J ?? ɂ ĈقȂ.

3. s ̎d

  1. MicroGDS 10.0 ··· N ··· A · V · K · 쐬 · Łu · V · K · V · · O · · · [· U · [· t · @ · C · · v Lutetium B
  2. MicroGDS ́u ~ j E B h E G f B ^ v A C i g ɐurate 肵 ͂ B
  3. Microsoft Visual Studio ̃c [ j [ u f o b O ^ f.o.b.O.J.n.v ] s ̂ B
  4. MicroGDS ̉ Ɂu FreeLine v c [ o [ 쐬 ͂ B
    e { ^ ̋@ \ ̓X e [ ^ X o [ уc [ o [ ɕ\ i c [ ` b v j Q l ɂ Ă B
  5. c [ o [ ́u c [ ̏I v N b N ƃc 폜 A Microsoft Visual Studio ̃f o b O ‥ I A v O I B

4. \ [ X

  1. MicroGDS .NET C u i MGDS Net j ̃ l [ X y [. C MicroGDS .NET C u g p ۂɁu Informatix.MGDS.Cad. ` v ȗ āu Cad. ` v Ƃ Ďg 悤 ɂ ̂ B
    using Informatix.MGDS;
    
  2. MicroGDS C x g } l [ W 𗘗p 邽 ɂ̓t [ U C ^ [ ͔̂ \ ɂ Ă ̂ B N MicroGDS ʂ Z b V ID Micro GDS C x g } l [ W Ƀ Z b g Ă ɂ A MicroGDS Ŕ C x g v O ɓ` B 悤 ɂȂ. C x g ̒ `. ̓ \ [. X R [. ōs Ȃ Ă ͂ B MicroGDS ̃c [ o [ ̂ ꂩ.̃ { ^ ꂽ. v C x g ʒ m B ̃ C x ۂ Ɂ A v O łǂ̋ @ \ s 邩 𕪊 encapsulated Ĕ f ͂ B ̃T v ł (); v Ƃ ` C # ̓ \ b h ̋L q 𗘗p Ē ` A \ [ X R [ h ̎ F Ă Ă B J g ̃ h L g ύX ꂽ ɂ́uCurDocChange v C x g ʒm A ̏ꍇ ̓c [ o [ ̃X ^ C ̒ ` X V B v O I O Micro GDS I ꂽ ꍇ ́uMgdsClose v C x g ʒm A iMicroGDS Ƃ͓Ɨ j ̃v O I B Micro GDS Ń} E X 𓮂 Ɓu Dynamic Pos v C x g ʒm ͂ A R Ȑ ̎w ̍ۂɂ̂ extracted p ̂ŁA ł̓C.x.肾 s Ȃ Ă ŏI I ȃC x g ا n ́uaxCadEvMgr601.EV_ ` v ƁuaxCadEvMgr601.Initialize v ƂɁutrue B
            /// 
            /// �t�H�[���Ǎ����̃C�x���g
            /// 
            private void Form1_Load(object sender, EventArgs e)
            {
            	�i�ȗ��j
            }
    
  3. ̃c [ ̓t H [ ^ ̃A v P [ V Ȃ̂ŁA t H [ ???.. チ \ b h uthis.Close () v s 邱 ƂŁA v O I B v O ̏ I ɂ ̃ C x g ̂ Ł } l [ W ̃ C x g ʒm ~
            /// 
            /// �t�H�[����‚������̃C�x���g
            /// 
            private void Form1_FormClosed(object sender, FormClosedEventArgs e)
            {
            	�i�ȗ��j
            }
    
  4. MicroGDS Ƃ̒ʐM J n A c [ o 𔻒 f 1 `999 Ŕ 肵 ͂ B ł ́uCad.GetFreeToolbarEvent v g ƂŁ A Micro GDS ID ā A c [ o [ ~ [ 쐬 A MicroGDS Ƃ̒ʐM ؒf ͂ B
            /// 
            /// �c�[���o�[�̍쐬
            /// 
            private bool prepareToolBarButtons()
            {
            	�i�ȗ��j
            }
    
  5. J g ̃h L g ɒ ` Ă 킨 ѕ. c [ o [ ̃R { { b N X ɐprocess 肵 ͂ B ̃ \ b h 2 ӏ i c [ o [ ̍쐬 уJ g ̃h.L. g ؂ ւ j Ă ΂. 邽 A Ɨ \ b h ɂ Ă ̂ B ѕ. ̎ 擾 ɂ͋ ʕ ̂ŁA L ă \ [ X R [ h 炵 Ă ͂ B
            /// 
            /// �X�^�C�����X�g�̃R���{�{�b�N�X�̓��e��ݒ�
            /// 
            private void setupStyleCombo()
            {
            	�i�ȗ��j
            }
    
            /// 
            /// �R���{�{�b�N�X�̓��e��ݒ�
            /// 
            private void setupComboText(string listName, string curStyle, Style styleType)
            {
            	�i�ȗ��j
            }
    
  6. c. [ o lj ł̓ { ^ x ɁA ꂽ. { ^ 폜 A ̐F ̃{ ^ lj Ă ̂ B lj ۂɂ͏I.悤 Ɂ A I { ^ ̈ʒu 𓮓 I Ɏ 擾 Ă
            /// 
            /// �F�ύX�{�^���̍쐬
            /// 
            private void setColourButton(int eventNo)
            {
            	�i�ȗ��j
            }
    
  7. R Ȑ ̍ } s Ȃ \ b h ł B ̋@ \ s ɂ͑ ̋ @ \ 삵 Ȃ 悤 Ɂu Custom Command v C x g Ă B J n ʒu X i b v ď I ʒu X i b v ͂ł ة ́u Dynamic Pos v C x g ̒ʒm 悤 Ɂuax CadEvMgr601.EV_DynamicPos v ̒l ύX } E X x Ƀ C x g uForm1_Load v uDynamicPos v C x g ł́uCad.LineTo v s A } E X ̋O Ղɐ . Ă ̂ B Z 铮 Undo ̏ Ŏ Ă
            /// 
            /// ���R�Ȑ��̍�}
            /// 
            private void EvMgr_Draw()
            {
            	�i�ȗ��j
            }
    
  8. e L X g ̍ } s Ȃ \ b h B ̋ @ \ 삵 Ȃ 悤 Ɂu Custom Command v C x g 〜 Ă ̂ B b O 邽 ɂ ́A x } ʏ.ɍ } K v A } ʂ̕ \ ̈. 擾 āA \ ̈ O ֈꎞ I ɍ } ăh b O ɗ p Ă \ 邾 œ e i v e m F ł 悤 ɂ Ȃ ͂ B z u I ɍ } I u W F N g ̃ t b N _ ړ v ~ e B u 폜 A e L X g v. u } 邱 ƂŁ A v ~ e B u ^ C v ̒u B
            /// 
            /// �e�L�X�g�̍�}
            /// 
            private void EvMgr_Text()
            {
            	�i�ȗ��j
            }
    
  9. I ̏ s Ȃ \ b h ł B ł̓c. A uthis.Close () v \ b h s ăv O I
            /// 
            /// �I���̏���
            /// 
            private void EvMgr_Exit()
            {
            	�i�ȗ��j
            }
    
  10. R Ȑ уe L X g } ` } ۂɁA c [ o [ Ő A MicroGDS ̎ ۂ̐ F Ƃ Đ silicate 肵 Ă B
            /// 
            /// �F�̐ݒ�
            /// 
            private void setColour(int ColNo)
            {
            	�i�ȗ��j
            }
    
  11. R Ȑ } Ă Œ ŁA } E X ̈ړ Ȃ ꍇ A } Ȃ 悤 ɔ 肷 郁 \ b h ł B s Ȃ ƂŁA ̒Z i short vector j 邱 Ƃ h ~
            /// 
            /// �����̔���
            /// 
            private bool isSamePos(double x1, double y1, double x2, double y2)
            {
            	�i�ȗ��j
            }
    
  12. R Ȑ уe L X g } ` ̍ } O MicroGDS ̃p Ȃ 悤 Ɂ A e p [ ^ ۑ A N X ł B
            /// 
            /// �p�����[�^�ۑ��p�̃N���X
            /// 
            private class cSaveParams
            {
            	�i�ȗ��j
            }
    
  13. MicroGDS ̃A v P [ V E B h E Ƀ b Z [ W. o N X ł B ̃c [ Micro GDS Ƃ͓Ɨ v Z X œ 삷 v O ł B ̂ Ƀc [ 烁 b Z [ W { b N X \ ƁA ^ C ~ O ɂ Ă.Micro GDS ̃A v P ɖ ͂ Ă ͂ A b Z [ W { b N X o Ă ɂ ւ 炸 A ̃ b Z. h E n h processed 肵 A b Z [ W { b.N ƂŁA MicroGDS ̃A v P [ V E B h E Ƀ b Z [ W { b N X \ A m Ƀ b Z [ W ` 邱 Ƃ ł 悤 ɂȂ.
            /// 
            /// IWin32Window����������N���X
            /// 
            private class WinHandle : IWin32Window
            {
            	�i�ȗ��j
            }
    

5. T v \ [ X

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Informatix.MGDS;

namespace DrawFreeLine
{
    public partial class Form1 : Form
    {
        //�ϐ��̏�����
        private Conversation cv = null;             //MicroGDS�Ƃ̒ʐM�p
        private cSaveParams CurParam = null;        //�p�����[�^�̕ێ��p
        private int[] EventsNo = new int[4];        //�C�x���gID�̕ێ��p
        private const string tbname = "FreeLine";   //�c�[���o�[�̖���
        private int curcol = 2;                     //�I�𒆂̐F
        private double LastDragX = 0.0;             //�h���b�O���̍ŏIX���W
        private double LastDragY = 0.0;             //�h���b�O���̍ŏIY���W
        private const double epsilon = 0.5;         //���ʒu�̔���p�}�[�W��

        /// 
        /// �t�H�[���̃R���X�g���N�^
        /// 
        public Form1()
        {
            InitializeComponent();
        }

        /// 
        /// �t�H�[���Ǎ����̃C�x���g
        /// 
        private void Form1_Load(object sender, EventArgs e)
        {
            //�t�H�[�����\���ɂ���
            this.Opacity = 0;
            this.ShowInTaskbar = false;

            //MicroGDS�Ƃ̒ʐM������
            cv = new Conversation();

            //�p�����[�^�ێ��p�̃N���X��������
            CurParam = new cSaveParams();

            //�c�[���o�[�ƃR�}���h�p�C�x���g�̐ݒ�
            if (!prepareToolBarButtons())
            {
                //�X���b�h�̃��b�Z�[�W���[�v���I������
                Application.ExitThread();
                return;
            }

            //MicroGDS�̃Z�b�V����ID���擾
            int[] sessions = new int[1];
            Cad.GetSessionIDs(sessions, 1);

            //�C�x���g�Ď��Ώۂ�MicroGDS��ݒ�
            axCadEvMgr601.SessionID = sessions[0];

            //�C�x���g�̐ݒ�i�J�X�^���R�}���h���I�΂ꂽ���ɔ����j
            axCadEvMgr601.CustomCommand += delegate(object sender_sub,
                AxCadevmgrLib60._DCadEvMgrEvents60_CustomCommandEvent e_sub)
            {
                if (e_sub.userData == EventsNo[0])
                {
                    //���R�Ȑ��̍�}
                    EvMgr_Draw();
                }
                else if (e_sub.userData == EventsNo[1])
                {
                    //�e�L�X�g�̍�}
                    EvMgr_Text();
                }
                else if (e_sub.userData == EventsNo[2])
                {
                    //�F�ύX�{�^���̕ύX
                    setColourButton(EventsNo[2]);
                }
                else if (e_sub.userData == EventsNo[3])
                {
                    //�I���̏���
                    EvMgr_Exit();
                }
            };

            //�C�x���g�̐ݒ�i�J�����g�̃h�L�������g���ύX���ꂽ���ɔ����j
            axCadEvMgr601.CurDocChange += delegate
            {
                //�X�^�C���R���{�{�b�N�X�̓��e���Đݒ�
                setupStyleCombo();
            };

            //�C�x���g�̐ݒ�iMicroGDS���I���������ɔ����j
            axCadEvMgr601.MgdsClose += delegate
            {
                //�c�[�����I��
                this.Close();
            };

            //�C�x���g�̐ݒ�i�h���b�O���`��p��DynamicPos�C�x���g�j
            axCadEvMgr601.DynamicPos += delegate(object sender_sub,
                AxCadevmgrLib60._DCadEvMgrEvents60_DynamicPosEvent e_sub)
            {
                //�E�B���h�E�͈͊O�͏������Ȃ�
                if (e_sub.x == 0.0 && e_sub.y == 0.0 && e_sub.snapCode == 0)
                {
                    return;
                }

                //Short Vector�̖h�~
                if (isSamePos(LastDragX, LastDragY, e_sub.x, e_sub.y))
                {
                    return;
                }

                //���R�Ȑ��̕`��
                Cad.Vector cvec = new Cad.Vector(e_sub.x, e_sub.y, 0.0);
                Cad.LineTo(cvec);

                //short vector�̖h�~�p�ɒl��ێ�
                LastDragX = e_sub.x;
                LastDragY = e_sub.y;
            };

            //�C�x���g�Ď��̊J�n
            axCadEvMgr601.EV_CustomCommand = true;
            axCadEvMgr601.EV_CurDocChange = true;
            axCadEvMgr601.EV_MgdsClose = true;
            axCadEvMgr601.Initialize = true;
        }

        /// 
        /// �t�H�[����‚������̃C�x���g
        /// 
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            //�C�x���g�Ď��̒�~
            axCadEvMgr601.Initialize = false;
        }

        /// 
        /// �c�[���o�[�̍쐬
        /// 
        private bool prepareToolBarButtons()
        {
            bool status = false;

            try
            {
                //MicroGDS�ƒʐM�J�n
                cv.Start();

                //�c�[���o�[���쐬
                Cad.TBarCustomCreate(tbname, Docking.Bottom, string.Empty, 0, 0);

                //���R�Ȑ��{�^����lj�
                EventsNo[0] = Cad.GetFreeToolbarEvent(0);
                Cad.TBarInsertButtonFromFile(tbname, 0, "Draw", "{/e" +
                    EventsNo[0].ToString() + " /tmw}", TBarButton.Push, "���R�Ȑ���`��",
                    EventsNo[0], Application.StartupPath + @"\customize_sample03_draw.bmp");

                //�e�L�X�g�{�^����lj�
                EventsNo[1] = Cad.GetFreeToolbarEvent(0);
                Cad.TBarInsertButtonFromFile(tbname, 1, "Text", "{/e" +
                    EventsNo[1].ToString() + " /tmw}", TBarButton.Push, "�e�L�X�g���L��",
                    EventsNo[1], Application.StartupPath + @"\customize_sample03_text.bmp");

                //�e�L�X�g�{�b�N�X��lj�
                Cad.TBarInsertControl(tbname, 2, "TextBox", TBar.EditText,
                    200, 0, string.Empty, 0, 0, "��}����e�L�X�g�����", 0);

                //����R���{�{�b�N�X��lj�
                Cad.TBarInsertControl(tbname, 3, "lslist", TBar.StaticCombo,
                    150, 0, string.Empty, 0, 0, "�鏑���p����", 0);

                //������R���{�{�b�N�X��lj�
                Cad.TBarInsertControl(tbname, 4, "cslist", TBar.StaticCombo,
                    150, 0, string.Empty, 0, 0, "�鏑���p������", 0);

                //�X�^�C���R���{�{�b�N�X�̓��e��ݒ�
                setupStyleCombo();

                //�F�{�^����lj�
                EventsNo[2] = Cad.GetFreeToolbarEvent(0);
                setColourButton(EventsNo[2]);

                //�I���{�^����lj�
                EventsNo[3] = Cad.GetFreeToolbarEvent(0);
                Cad.TBarInsertButtonFromFile(tbname, 6, "Exit", "{/e" +
                    EventsNo[3].ToString() + "}", TBarButton.Push, "�c�[���̏I��",
                    EventsNo[3], Application.StartupPath + @"\customize_sample03_exit.bmp");

                status = true;
            }
            catch (Exception ee)
            {
                MessageBox.Show("�c�[���o�[�̍쐬�Ɏ��s���܂����B\n" + ee.Message,
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //MicroGDS�ƒʐM�ؒf
                if (cv.Started)
                {
                    cv.Stop();
                }
            }

            return status;
        }

        /// 
        /// �X�^�C�����X�g�̃R���{�{�b�N�X�̓��e��ݒ�
        /// 
        private void setupStyleCombo()
        {
            //MicroGDS�ƒʐM�J�n
            bool cvstart = false;
            if (!cv.Started)
            {
                cv.Start();
                cvstart = true;
            }

            //�ݒ�E�B���h�E�̊m�F
            try
            {
                string wname;
                Cad.GetSetWndName(out wname);
            }
            catch
            {
                //�ݒ�E�B���h�E�������ꍇ
                if (cvstart)
                {
                    //MicroGDS�ƒʐM�ؒf
                    if (cv.Started)
                    {
                        cv.Stop();
                    }
                }

                return;
            }

            //���탊�X�g�̐ݒ�
            string curlstyle;
            Cad.GetSetLineStyle(out curlstyle);
            setupComboText("lslist", curlstyle, Style.Line);

            //�����탊�X�g�̐ݒ�
            string curcstyle;
            Cad.GetSetCharStyle(out curcstyle);
            setupComboText("cslist", curcstyle, Style.Char);

            //MicroGDS�ƒʐM�ؒf
            if (cvstart)
            {
                if (cv.Started)
                {
                    cv.Stop();
                }
            }
        }

        /// 
        /// �R���{�{�b�N�X�̓��e��ݒ�
        /// 
        private void setupComboText(string listName, string curStyle, Style styleType)
        {
            //��`���ꂽ�X�^�C�����擾
            string styleList = string.Empty;
            string tempStyle;
            int CurCount = 0;
            int SelNo = 0;
            for (bool bStat = Cad.StyleScan(styleType, out tempStyle);
                            bStat; bStat = Cad.StyleScanNext(styleType, out tempStyle))
            {
                if (curStyle == tempStyle)
                {
                    SelNo = CurCount;
                }

                if (CurCount > 0)
                {
                    styleList += "\n";
                }

                styleList += tempStyle;
                CurCount++;
            }

            //���X�g�̓��e��ݒ�
            Cad.TBarSetItemText(tbname, listName, styleList);

            //�R���{�{�b�N�X�̍��ڂ�I��
            Cad.TBarSetListCurSel(tbname, listName, SelNo);
        }

        /// 
        /// �F�ύX�{�^���̍쐬
        /// 
        private void setColourButton(int eventNo)
        {
            //MicroGDS�ƒʐM�J�n
            bool convstart = false;
            if (!cv.Started)
            {
                cv.Start();
                convstart = true;
            }

            //�F�ύX�{�^���̍폜
            string tagName;
            for (bool bStat = Cad.TBarItemScan(out tagName, tbname);
                                bStat; bStat = Cad.TBarItemNext(out tagName))
            {
                if (tagName == "colb")
                {
                    Cad.TBarRemoveItem(tbname, "colb");
                    break;
                }
            }

            //�I���{�^���̈ʒu������
            int TarExistIndex = 0;
            for (bool bStat = Cad.TBarItemScan(out tagName, tbname);
                                bStat; bStat = Cad.TBarItemNext(out tagName))
            {
                if (tagName == "Exit")
                {
                    break;
                }

                TarExistIndex++;
            }

            //�F�ύX�{�^����lj�
            string TarBmpFile = string.Empty;
            if (curcol == 0)
            {
                curcol = 1;
                TarBmpFile = "customize_sample03_blue.bmp";
            }
            else if (curcol == 1)
            {
                curcol = 2;
                TarBmpFile = "customize_sample03_green.bmp";
            }
            else
            {
                curcol = 0;
                TarBmpFile = "customize_sample03_red.bmp";
            }
            Cad.TBarInsertButtonFromFile(tbname, TarExistIndex, "colb", "{/e" +
                eventNo.ToString() + "}", TBarButton.Push, "�F�̕ύX�A�ԁ�����",
                eventNo, Application.StartupPath + @"\" + TarBmpFile);

            //MicroGDS�ƒʐM�ؒf
            if (convstart)
            {
                cv.Stop();
            }
        }

        /// 
        /// ���R�Ȑ��̍�}
        /// 
        private void EvMgr_Draw()
        {
            //�R�}���h�{�^���C�x���g�͎󂯂Ȃ�
            axCadEvMgr601.EV_CustomCommand = false;

            try
            {
                //MicroGDS�ƒʐM
                cv.Start();

                //�ݒ背�C���̊m�F
                int SetLayNo = -1;
                try
                {
                    SetLayNo = Cad.GetSetLayLink();
                }
                catch
                {
                    SetLayNo = -1;
                }

                if (SetLayNo == -1)
                {
                    throw new Exception("�ݒ背�C��������܂���B");
                }

                //���݂̐ݒ�l��ێ�
                CurParam.save();

                //�v���O�����Ŏg�p����k�ځE�F�ɕύX
                Cad.SelectObject();
                Cad.SetAxesScale(1.0);
                setColour(curcol);
                Cad.InfoBarButton(InfoBar.SnapGuides, false);

                //����̕ύX
                string editText;
                Cad.TBarGetEditItemText(out editText, tbname, "lslist");
                Cad.SetLineStyle(editText);

                //Undo�}�[�J�̃��[�h�𖾎��I�}���ɂ���
                Cad.UndoDisable();

                //Undo�}�[�J��}��
                Cad.UndoSetMarker();

                //BackSpace�ł�UNDO�p�J�E���g��������
                int undocount = 0;

                //���R�Ȑ��̕`��
                bool newobj = true;
                for (; ; )
                {
                    //���R�Ȑ��̊J�n�ʒu�̎擾
                    Cad.Vector cvPos = new Cad.Vector(0, 0, 0);
                    string argSnap = string.Empty;
                    string argPrompt = "���̊J�n�ʒu���X�i�b�v�A�I��[Enter]�A�߂�[BackSpace]";
                    Snap argSnapType = Snap.Nothing;
                    Snapped snStat = Cad.GetArg(out cvPos, ref argSnap, argPrompt, argSnapType);

                    //Enter�ŏ����̏I��
                    if (snStat == Snapped.Enter)
                    {
                        break;
                    }

                    //�߂�����
                    if (snStat == Snapped.Backspace)
                    {
                        //�O�ɕ`�������̂�����
                        if (undocount > 0)
                        {
                            if (Cad.CanUndo())
                            {
                                Cad.Undo();
                            }
                            undocount--;
                        }

                        continue;
                    }

                    //�}�E�X�N���b�N�̏ꍇ
                    if (snStat == Snapped.Mouse)
                    {
                        //�I�u�W�F�N�g���쐬
                        if (newobj)
                        {
                            Cad.CreateObject("�鏑��:��", cvPos);
                            newobj = false;
                        }

                        //�`��̊J�n
                        Cad.MoveTo(cvPos);
                        LastDragX = cvPos.x;
                        LastDragY = cvPos.y;
                        for (; ; )
                        {
                            //DynamicPos�C�x���g�̊J�n
                            axCadEvMgr601.EV_DynamicPos = true;

                            //���R�Ȑ��̒ʉ߈ʒu�̎擾
                            argPrompt = "�}�E�X�h���b�O�ŕ`��A�X�i�b�v�Ő����I��";
                            snStat = Cad.GetArg(out cvPos, ref argSnap, argPrompt, argSnapType);

                            //DynamicPos�C�x���g�̒�~
                            axCadEvMgr601.EV_DynamicPos = false;

                            //�}�E�X�N���b�N�̏ꍇ
                            if (snStat == Snapped.Mouse)
                            {
                                //�N���b�N�ʒu�܂ŕ`�悷��
                                if (!isSamePos(cvPos.x, cvPos.y, LastDragX, LastDragY))
                                {
                                    Cad.LineTo(cvPos);
                                }

                                //Undo�}�[�J�̑}���i�}�[�N�̋L���P�ʂ�Undo�j
                                Cad.UndoSetMarker();
                                undocount++;

                                //�����𔲂���
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                //MicroGDS�̃E�B���h�E��Ƀ��b�Z�[�W�{�b�N�X���o������
                int CurWnd = 0;
                if (cv.Started)
                {
                    CurWnd = Cad.GetSetWndHandle();
                }
                WinHandle MgHandle = new WinHandle(CurWnd);

                //�G���[���b�Z�[�W
                MessageBox.Show(MgHandle, "MicroGDS Error\n" + ee.Message,
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //�ݒ�l�����ɖ߂�
                Cad.SelectObject();
                CurParam.restore();

                //Undo�}�[�J�[�}����ʏ탂�[�h�ɂ���
                Cad.UndoEnable();

                //MicroGDS�ƒʐM�ؒf
                if (cv.Started)
                {
                    cv.Stop();
                }
            }

            //�R�}���h�{�^���C�x���g��t�̍ĊJ
            axCadEvMgr601.EV_CustomCommand = true;
        }

        /// 
        /// �e�L�X�g�̍�}
        /// 
        private void EvMgr_Text()
        {
            //�R�}���h�{�^���C�x���g�͎󂯂Ȃ�
            axCadEvMgr601.EV_CustomCommand = false;

            try
            {
                //MicroGDS�ƒʐM
                cv.Start();

                //�ݒ背�C���̊m�F
                int SetLayNo = -1;
                try
                {
                    SetLayNo = Cad.GetSetLayLink();
                }
                catch
                {
                    SetLayNo = -1;
                }

                if (SetLayNo == -1)
                {
                    throw new Exception("�ݒ背�C��������܂���B");
                }

                //�e�L�X�g���擾
                string etext = string.Empty;
                Cad.TBarGetEditItemText(out etext, tbname, "TextBox");
                if (etext == string.Empty)
                {
                    throw new Exception("��}����e�L�X�g������܂���B");
                }

                //���݂̐ݒ��ێ�
                CurParam.save();

                //�v���O�����Ŏg�p����k�ځE�F�ɕύX
                Cad.SelectObject();
                Cad.SetAxesScale(1.0);
                setColour(curcol);

                //������̕ύX
                string editText;
                Cad.TBarGetEditItemText(out editText, tbname, "cslist");
                Cad.SetCharStyle(editText);

                //Undo�}�[�J�̃��[�h�𖾎��I�}���ɂ���
                Cad.UndoDisable();

                //Undo�}�[�J��}��
                Cad.UndoSetMarker();

                //�}�ʗ̈�̎擾
                double xl, xh, yh, yl;
                Cad.GetZoomArea(out xl, out yh, out xh, out yl);

                //�h���b�O�p�̃I�u�W�F�N�g��}�ʗ̈�O�ɍ쐬
                Cad.Vector opos = new Cad.Vector(xh * 10.0, yh * 10.0, 0.0);
                Cad.CreateObject("�鏑��:�e�L�X�g", opos);
                Cad.CreateText(etext, opos);

                //�쐬�����e�L�X�g�v���~�e�B�u���J�����g�ɂ���
                Cad.PriTriple[] plist = new Cad.PriTriple[1];
                Cad.GetPriSelections(1, plist);
                Cad.CurPrimitive(plist[0].llink, plist[0].vlink, plist[0].plink);

                //�h���b�O���Ƀe�L�X�g�����ʂł���悤�Ƀe�L�X�g��}�`����
                Cad.LinesFromCurText();

                //�J�����g�̃I�u�W�F�N�g��I����Ԃɂ���
                Cad.SelectObject();
                Cad.SelectAdd();

                //�I��}�`�̈ړ�����擾
                string snap = string.Empty;
                Snapped sStat = Cad.DragSelection(out opos, ref snap,
                    "�e�L�X�g�z�u��A�L�����Z��[Esc]", Snap.Nothing, opos,
                    true, DragFence.Ignore, string.Empty);
                if (sStat == Snapped.Escape)
                {
                    //�L�����Z���̏ꍇ�͑I��}�`���폜
                    Cad.DeleteSelection();
                }
                else
                {
                    //�J�����g�̃I�u�W�F�N�g���ړ�����
                    Cad.CurObjHook(opos);

                    //�J�����g�̃I�u�W�F�N�g����h���b�O�p�̑S�v���~�e�B�u���폜
                    int[] prilist = Cad.GetPriLinks();
                    foreach (int pl in prilist)
                    {
                        Cad.DeletePrimitive(plist[0].llink, plist[0].vlink, pl);
                    }

                    //�J�����g�̃I�u�W�F�N�g�Ƀe�L�X�g�v���~�e�B�u���쐬
                    Cad.CreateText(etext, opos);
                }
            }
            catch (Exception ee)
            {
                //MicroGDS�̃E�B���h�E��Ƀ��b�Z�[�W�{�b�N�X���o������
                int CurWnd = 0;
                if (cv.Started)
                {
                    CurWnd = Cad.GetSetWndHandle();
                }
                WinHandle MgHandle = new WinHandle(CurWnd);

                //�G���[���b�Z�[�W
                MessageBox.Show(MgHandle, "MicroGDS Error\n" + ee.Message,
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //�ݒ�����ɖ߂�
                Cad.SelectObject();
                CurParam.restore();

                //Undo�}�[�J�[�}����ʏ탂�[�h��
                Cad.UndoEnable();

                //MicroGDS�ƒʐM���I��
                if (cv.Started)
                {
                    cv.Stop();
                }
            }

            //�R�}���h�{�^���C�x���g��t�̍ĊJ
            axCadEvMgr601.EV_CustomCommand = true;
        }

        /// 
        /// �I���̏���
        /// 
        private void EvMgr_Exit()
        {
            //MicroGDS�ƒʐM�J�n
            cv.Start();

            try
            {
                Cad.TBarDelete(tbname);
            }
            catch (Exception ee)
            {
                //MicroGDS�̃E�B���h�E��Ƀ��b�Z�[�W�{�b�N�X���o������
                int CurWnd = 0;
                if (cv.Started)
                {
                    CurWnd = Cad.GetSetWndHandle();
                }
                WinHandle MgHandle = new WinHandle(CurWnd);

                //�G���[���b�Z�[�W
                MessageBox.Show(MgHandle, "�c�[���o�[�̍폜�Ɏ��s���܂����B\n" + ee.Message,
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //MicroGDS�ƒʐM�ؒf
                if (cv.Started)
                {
                    cv.Stop();
                }
            }

            //�c�[�����I��
            this.Close();
        }

        /// 
        /// �F�̐ݒ�
        /// 
        private void setColour(int ColNo)
        {
            if (ColNo == 0)
            {
                //��
                Cad.SetColourEx(-1, 255, 0, 0, 200);
            }
            else if (ColNo == 1)
            {
                //��
                Cad.SetColourEx(-1, 0, 0, 255, 200);
            }
            else
            {
                //��
                Cad.SetColourEx(-1, 0, 255, 0, 200);
            }
        }

        /// 
        /// �����̔���
        /// 
        private bool isSamePos(double x1, double y1, double x2, double y2)
        {
            double xdist = x2 - x1;
            double ydist = y2 - y1;
            double dist = Math.Sqrt(xdist * xdist + ydist * ydist);
            if (dist < epsilon)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// 
        /// �p�����[�^�ۑ��p�̃N���X
        /// 
        private class cSaveParams
        {
            //�ۑ��t���O
            private bool IsSaved = false;

            //�ݒ�ۑ��p
            private double savescale = 0.0;
            private int[] savecol = new int[5] { 0, 0, 0, 0, 0 };
            private string savelstyle = string.Empty;
            private string savecstyle = string.Empty;
            private int saveobj = 0;
            private bool snapguidesetting;

            public void save()
            {
                //���݂̏k�ڂ��L�^
                Cad.GetSetAxesScale(out savescale);

                //���݂̐ݒ�F���L�^
                Cad.GetSetColourEx(out savecol[0], out savecol[1],
                    out savecol[2], out savecol[3], out savecol[4]);

                //���݂̐ݒ�X�^�C�����L�^
                Cad.GetSetLineStyle(out savelstyle);
                Cad.GetSetCharStyle(out savecstyle);

                //���݂̐ݒ�I�u�W�F�N�g���L�^
                int tolink;
                try
                {
                    tolink = Cad.GetSetObjLink();
                }
                catch
                {
                    tolink = 0;
                }
                saveobj = tolink;

                //���o�[�{�^���uSnapGuide�v�̏�Ԃ��L�^
                snapguidesetting = Cad.GetInfoBarButton(InfoBar.SnapGuides);

                //�ۑ�����
                IsSaved = true;
            }

            public void restore()
            {
                if (!IsSaved)
                {
                    //�ۑ�����Ă��Ȃ�
                    return;
                }

                //�ݒ�k�ڂ𕜌�
                Cad.SetAxesScale(savescale);

                //�ݒ�F�𕜌�
                Cad.SetColourEx(savecol[0], savecol[1], savecol[2], savecol[3], savecol[4]);

                //�ݒ�X�^�C���𕜌�
                Cad.SetLineStyle(savelstyle);
                Cad.SetCharStyle(savecstyle);

                //�ݒ�I�u�W�F�N�g�𕜌�
                if (saveobj != 0)
                {
                    Cad.SetObject(Cad.GetSetLayLink(), saveobj);
                }

                //���o�[�̐ݒ�
                Cad.InfoBarButton(InfoBar.SnapGuides, snapguidesetting);

                //�t���O���N���A
                IsSaved = false;
            }
        }

        /// 
        /// IWin32Window����������N���X
        /// 
        private class WinHandle : IWin32Window
        {
            private IntPtr _Handle = IntPtr.Zero;

            public WinHandle(int newHandle)
            {
                _Handle = (IntPtr)newHandle;
            }

            public IntPtr Handle
            {
                get
                {
                    return _Handle;
                }
            }
        }
    }
}