Пример #1
0
        private void menuItemNew_Click(object sender, System.EventArgs e)
        {
            //
            // tabPage Drawing List
            //
            TabPage newTab = new TabPage();
            newTab.Location = new System.Drawing.Point(4, 4);
            newTab.Name = "DrawingList" + ((int)(tabControlDrawingList.TabCount+1)).ToString();
            newTab.AutoScroll = true;
            newTab.AutoScrollPosition = new Point(0,0);
            newTab.TabIndex = tabControlDrawingList.TabCount;
            newTab.Text = "Drawing List " + ((int)(tabControlDrawingList.TabCount+1)).ToString();
            newTab.Click += new System.EventHandler(this.Control_Click);

            FormNewProject FNewProject = new FormNewProject();
            if(FNewProject.ShowDialog() == DialogResult.OK)
            {
                this.ProjectType[this.tabControlDrawingList.Controls.Count] = FNewProject.ProjectType;
                if(FNewProject.ProjectType == AMS)
                {
                    this.ProjSavePath[this.tabControlDrawingList.Controls.Count] = FNewProject.SavePath + "\\" + FNewProject.FileName;
                }
                else
                {
                    this.ProjSavePath[this.tabControlDrawingList.Controls.Count] = FNewProject.SavePath;
                }

                //Set Name
                newTab.Text = FNewProject.FileName;

                this.tabControlDrawingList.Controls.Add(newTab);
                this.tabControlDrawingList.SelectedTab = newTab;
                this.menuItemNewChild.Enabled = true;

                this.SaveProject(false);
            }
        }
Пример #2
0
        public void Save(bool bSaveAs)
        {
            if(bSaveAs)
            {
                FormNewProject FNewProject = new FormNewProject();
                if(FNewProject.ShowDialog() == DialogResult.OK)
                {
                    this.ProjectType = FNewProject.ProjectType;
                    this.ProjectName = FNewProject.FileName;
                    if(FNewProject.ProjectType == AMS)
                    {
                        this.ProjSavePath = FNewProject.SavePath + "\\" + FNewProject.FileName;
                    }
                    else
                    {
                        this.ProjSavePath = FNewProject.SavePath;
                    }
                }
                else
                {
                    return;
                }
            }
            Cursor.Current = Cursors.WaitCursor;

            if(this.ProjectType == AMS) //need to save directories and files
            {
                DirectoryInfo diTemp;
                DirectoryInfo di;
                string Path = this.ProjSavePath;
                try
                {
                    //Project Folder
                    di = new DirectoryInfo(Path);
                    if(!di.Exists)
                    {
                        di.Create();
                    }
                    //
                    //Save Directories and project
                    //
                    string TempPath = Path + "\\" + "temp";
                    diTemp = new DirectoryInfo(TempPath);
                    if(diTemp.Exists)
                    {
                        diTemp.Delete(true);
                    }

                    //Folder Issued
                    string subPath = Path + "\\" + sIssued;
                    di = new DirectoryInfo(subPath);
                    if(!di.Exists)
                    {
                        di.Create();
                    }

                    //Folder Drawing List
                    subPath = Path + "\\" + sDrawingList;
                    di = new DirectoryInfo(subPath);
                    if(!di.Exists)
                    {
                        di.Create();
                    }
                    else
                    {
                        di.MoveTo(TempPath);
                        ChangeFilePath(TempPath);
                        di = new DirectoryInfo(subPath);
                        di.Create();
                    }

                    //Folder Drawing For Attachment
                    subPath = Path + "\\" + sDrawingForAttachment;
                    di = new DirectoryInfo(subPath);
                    if(!di.Exists)
                    {
                        di.Create();
                    }

                    //Folder Information
                    subPath = Path + "\\" + sInformation;
                    di = new DirectoryInfo(subPath);
                    if(!di.Exists)
                    {
                        di.Create();
                    }
                }
                catch(Exception e)
                {
                    MessageBox.Show("Save error: \n" + e.Message,
                        "Drawing List Project",MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                for(int i=0 ; i< this.WindowCount; i++)
                {
                    this.DrawingListWindows[i].SavePath = this.ProjSavePath + "\\" + sDrawingList + "\\" + this.DrawingListWindows[i].Caption.Text;
                    this.DrawingListWindows[i].SaveAll();
                }
                ChangeFilePath();
                if(diTemp.Exists)
                {
                    diTemp.Delete(true);
                }
            }

            SaveOutlineBinary(this.ProjSavePath + "\\" + this.ProjectName + "." + sProjectTypesList[this.ProjectType]);

            Cursor.Current = Cursors.Default;
            /*
            MessageBox.Show("Drawing List " + this.ProjectName + " is saved to " + this.ProjSavePath,
                "Save Drawing List",MessageBoxButtons.OK, MessageBoxIcon.Information);
            */
        }