예제 #1
0
        public void newDrawing()
        {
            OpenFileDialog oDlg = new OpenFileDialog();
            oDlg.Filter = "Drawing Template (*.dwt)|*.dwt|Drawing (*.dwg)|*.dwg";
            oDlg.Title = "Open - " + this.Caption.Text;
            DialogResult DlgResult = oDlg.ShowDialog();
            if(DlgResult == DialogResult.OK)
            {
                string FileName;
                string[] FileParts = oDlg.FileName.Split('\\');
                string[] FileNames = FileParts[FileParts.Length-1].Split('.');

                switch(oDlg.FilterIndex)
                {
                    case 1:
                        FormGetNumFiles numForm = new FormGetNumFiles();
                        if(numForm.ShowDialog() == DialogResult.OK)
                        {
                            for(int i =0; i< numForm.NumFiles; i++)
                            {
                                string Number;
                                if(this.listBoxItem.Items.Count < 9)
                                {
                                    Number = "0" + ((int)(this.listBoxItem.Items.Count + 1)).ToString();
                                }
                                else
                                {
                                    Number = ((int)(this.listBoxItem.Items.Count + 1)).ToString();
                                }
                                FileName = this.Name + "-" + Number + "_";
                                FileName += FileNames[0];
                                if(AddFile(FileName,oDlg.FileName) == ERROR_MAX_FILES_EXCEEDED)
                                {
                                    MessageBox.Show("Error adding file.\n" +
                                        "The number of files has exceeded the maximum: " + this.FileList.AMSFiles.Length.ToString(),
                                        "Add New Drawing",MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    break;
                                }
                            }
                        }
                        break;
                    case 2:
                        FileName = FileNames[0];
                        if(AddFile(FileName,oDlg.FileName) == ERROR_MAX_FILES_EXCEEDED)
                        {
                            MessageBox.Show("Error adding file.\n" +
                                "The number of files has exceeded the maximum: " + this.FileList.AMSFiles.Length.ToString(),
                                "Add New Drawing",MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        break;
                    default:
                        break;
                }

            }
        }
예제 #2
0
        public void menuItemPaste_Click(object sender, System.EventArgs e)
        {
            /*IDataObject DataObj = Clipboard.GetDataObject();
            AMSFileList.AMSFileInfo FileInfo = (AMSFileList.AMSFileInfo)DataObj.GetData("AMSFileList.AMSFileInfo",true);
            if(FileInfo.FileName != null)
            {
                AddFile(FileInfo.FileName,FileInfo.FilePath);
            }*/
            if(this.copyItem.FileName != null)
            {
                this.UndoList.Add(PASTE,this.FileList);

                FormGetNumFiles numForm = new FormGetNumFiles();
                if(numForm.ShowDialog() == DialogResult.OK)
                {
                    string FileName;
                    for(int i =0; i< numForm.NumFiles; i++)
                    {
                        string Number;
                        if(this.listBoxItem.Items.Count < 9)
                        {
                            Number = "0" + ((int)(this.listBoxItem.Items.Count + 1)).ToString();
                        }
                        else
                        {
                            Number = ((int)(this.listBoxItem.Items.Count + 1)).ToString();
                        }
                        //Set name of new Item to A#-##-Filename (e.g. A0-10_Acad1)
                        FileName = this.Name + "-" + Number + "_";
                        FileName += this.copyItem.FileName;

                        if(AddFile(FileName,this.copyItem.FilePath) == ERROR_MAX_FILES_EXCEEDED)
                        {
                            MessageBox.Show("Error adding file.\n" +
                                "The number of files has exceeded the maximum: " + this.FileList.AMSFiles.Length.ToString(),
                                "Add New Drawing",MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
                        }
                    }
                }
                this.copyItem = new AMSFileList.AMSFileInfo();

                UpdateNumFile();
            }
        }