Exemplo n.º 1
0
        private void openButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                //AutoCADが起動していない時AutoCADを起動する
                if (!WindowController2.ExistAutoCad())
                {
                    throw new ApplicationException(Messages.PleaseLaunchAutoCAD());
                    //WindowController.LaunchAutoCAD();プログラムから起動すると、なぜかFatalErrorが頻発するので、やめ。
                    //ユーザーに起動してもらう
                }

                var dataRow  = this.dataGridView.SelectedRows[0].DataBoundItem as DataRowView;
                var drawings = dataRow["Drawings"] as List <Drawing>;
                var count    = this.OpenFiles(drawings);

                //new AdjustGrid0point().Run();

                this.Activate();
                if (count > 0)
                {
                    MessageDialog.ShowInformation(this, Messages.FileOpened(count));
                }
                else
                {
                    MessageDialog.ShowInformation(this, Messages.FileAlreadyOpened());
                }

                this.Close();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex);

                //途中でエラーになると、中途半端にStaticが更新されてしまう。
                //そうなった時は、ConstructionCodeをnullにしてコントロールのenableを切る。
                Static.ConstructionCode = null;

                this.DialogResult = DialogResult.None;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }