private void menuFile_New_Click(object sender, EventArgs e) { FormDocument frmDocument = new FormDocument(); frmDocument.Show(this.dockMain, DockState.Document); frmDocument.FormMain = this; }
private void printDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { FormDocument activeDocument = this.ActiveMdiChild as FormDocument; if (activeDocument == null) { return; } activeDocument.PrintShapes(e.Graphics); }
private void menuFile_Print_Click(object sender, EventArgs e) { FormDocument activeDocument = this.ActiveMdiChild as FormDocument; if (activeDocument == null) { return; } this.printPreview = new PrintPreviewDialog(); this.printPreview.Document = this.printDoc; this.printPreview.ShowDialog(); }
private void menuFile_Export_Click(object sender, EventArgs e) { //As转换,如果转换失败,对象为空 FormDocument activeDocument = this.ActiveMdiChild as FormDocument; if (activeDocument == null) { return; } SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.Filter = "位图|*.bmp|JPEG|*.jpg|PNG|*.png|GIF|*.gif"; if (saveDlg.ShowDialog() != DialogResult.OK) { return; } string fileName = saveDlg.FileName; string extFileName = fileName.Substring(fileName.LastIndexOf(".") + 1);//这句话什么意思 extFileName = extFileName.ToUpper(); Bitmap bitmap = activeDocument.ExportToBitmap(); switch (extFileName) { case "BMP": bitmap.Save(fileName, ImageFormat.Bmp); break; case "JPG": bitmap.Save(fileName, ImageFormat.Jpeg); break; case "PNG": bitmap.Save(fileName, ImageFormat.Png); break; case "GIF": bitmap.Save(fileName, ImageFormat.Gif); break; } }
private void menuFile_Open_Click(object sender, EventArgs e) { FormDocument activeDocument = this.ActiveMdiChild as FormDocument; if (activeDocument == null) { activeDocument = new FormDocument(); activeDocument.FormMain = this; activeDocument.Show(this.dockMain, DockState.Document); } OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "Net.10|*.net.10|XML文件|*.xml|所有文件|*.*"; if (openDlg.ShowDialog() != DialogResult.OK) { return; } string fileName = openDlg.FileName; activeDocument.OpenDocument(fileName); }
private void menuFile_Save_Click(object sender, EventArgs e) { //As转换,如果转换失败,对象为空 FormDocument activeDocument = this.ActiveMdiChild as FormDocument; if (activeDocument == null) { return; } SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.Filter = "Net.10|*.net.10|XML文件|*.xml"; if (saveDlg.ShowDialog() != DialogResult.OK) { return; } string fileName = saveDlg.FileName; activeDocument.SaveDocument(fileName); }