当前位置: 首页>>代码示例>>C#>>正文


C# SaveFileDialog.ShowDialog方法代码示例

本文整理汇总了C#中SaveFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog.ShowDialog方法的具体用法?C# SaveFileDialog.ShowDialog怎么用?C# SaveFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SaveFileDialog的用法示例。


在下文中一共展示了SaveFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveScreen

        public void SaveScreen(double x, double y, double width, double height)
        {
            int ix, iy, iw, ih;
            ix = Convert.ToInt32(x);
            iy = Convert.ToInt32(y);
            iw = Convert.ToInt32(width);
            ih = Convert.ToInt32(height);
            try
            {
                Bitmap myImage = new Bitmap(iw, ih);

                Graphics gr1 = Graphics.FromImage(myImage);
                IntPtr dc1 = gr1.GetHdc();
                IntPtr dc2 = NativeMethods.GetWindowDC(NativeMethods.GetForegroundWindow());
                NativeMethods.BitBlt(dc1, ix, iy, iw, ih, dc2, ix, iy, 13369376);
                gr1.ReleaseHdc(dc1);
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.DefaultExt = "png";
                dlg.Filter = "Png Files|*.png";
                DialogResult res = dlg.ShowDialog();
                if (res == System.Windows.Forms.DialogResult.OK)
                    myImage.Save(dlg.FileName, ImageFormat.Png);
            }
            catch { }
        }
开发者ID:mokeev1995,项目名称:ScreenShotSample,代码行数:25,代码来源:Window1.xaml.cs

示例2: exportHandler

    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|(*.svg)";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                //import header from a file.
                string[] header = { @"<?xml version =""1.0"" standalone=""no""?>", @"<!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" ""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"">", @"<svg xmlns=""http://www.w3.org/2000/svg"" version=""1.1"">" };
                //import the SVG shapes.

                using (StreamWriter writer = new StreamWriter(stream))
                {
                    foreach (string headerLine in header)
                    {
                        writer.WriteLine(headerLine);
                    }

                    foreach(Shape shape in shapes)
                    {
                        shape.drawTarget = new DrawSVG();
                        shape.Draw();
                        writer.WriteLine(shape.useShape);
                    }
                    writer.WriteLine("</svg>");
                }
            }
        }
    }
开发者ID:RobinSikkens,项目名称:MSO-Lab-4,代码行数:35,代码来源:ShapeDrawing.cs

示例3: ExportDataGrid

    public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows, string fileName)
    {
        if (Application.Current.HasElevatedPermissions)
        {

            var filePath ="C:" + Path.DirectorySeparatorChar +"Nithesh"+Path.DirectorySeparatorChar +fileName + ".XML";

            File.Create(filePath);
            Stream outputStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite);

            ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, "XML", outputStream);
        }
        else
        {
            SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2, DefaultFileName = fileName };

            if (objSFD.ShowDialog() == true)
            {
                string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
                Stream outputStream = objSFD.OpenFile();

                ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
            }
        }
    }
开发者ID:shenoyroopesh,项目名称:Gama,代码行数:25,代码来源:DataGridExtensions.cs

示例4: OnActivate

            protected override void OnActivate()
            {
                try
                {
                    // Step 1: Pop up a file save dialog to get a output path
                    SaveFileDialog saveDlg = new SaveFileDialog();
                    saveDlg.Filter = Resources.IDS_PNG_FILTER;
                    saveDlg.Title = Resources.IDS_SAVE_PICTURE_TITLE;
                    saveDlg.ShowDialog();

                    // Step 2: Output a png image
                    if (saveDlg.FileName != /*MSG0*/"")
                    {
                        CImageOutputUtil.OutputImageFromCurrentSence(IApp.theApp.RenderWindow, saveDlg.FileName);
                    }
                }
                catch (SystemException e)
                {
                    MessageBox.Show(e.Message);
                }
                finally
                {
                    Terminate();
                }
            }
开发者ID:unidevop,项目名称:sjtu-project-pipe,代码行数:25,代码来源:savepicturecommand.cs

示例5: exportHandler

    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|(*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of LaTeX
                //   commands to draw the shapes
                using(StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write("<?xml version='1.0' standalone='no'?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg xmlns='http://www.w3.org/2000/svg' version='1.1'> ");

                    Visual visual = new VisualSVG(writer);

                    //Draw all shapes
                    foreach (Shape shape in shapes)
                    {
                        shape.visual = visual;

                        shape.Draw();
                    }

                    writer.Write("</svg>");
                }
            }
        }
    }
开发者ID:Tyskai,项目名称:ShapesOpdracht3,代码行数:34,代码来源:ShapeDrawing.cs

示例6: exportHandler

    // What to do when the user wants to export a SVG or TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG image|*.svg|TeX file|*.tex";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            IGraphics graphics;

            switch (saveFileDialog.FilterIndex)
            {
                case 1:
                    graphics = new SVGGraphics(saveFileDialog.FileName);
                    break;
                case 2:
                    graphics = new TexGraphics(saveFileDialog.FileName);
                    break;
                default:
                    throw new Exception("savefiledialog filterindex: " + saveFileDialog.FilterIndex + " not supported");
                    break;
            }

            this.drawShapes(graphics);
        }
    }
开发者ID:CPutz,项目名称:MSOPracticum3,代码行数:28,代码来源:ShapeDrawing.cs

示例7: openSaveAs

        public void openSaveAs()
        {
            //Opens Save file dialog box
               SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            //Only allows .txt files to be saved
            saveFileDialog1.Filter = "Text Files|*.txt";

            //Users decision to act with SaveDialog
            bool? saveFileAs = saveFileDialog1.ShowDialog();

            //If user does press save
            if (saveFileAs == true)
            {
                //File Name of user choice
                string fileNameNew = saveFileDialog1.FileName;

                //Rename FileName
                fileName = fileNameNew;

                //Writes the text to the file
                File.WriteAllText(fileNameNew, TextBox_Editor.Text);

            }
            //If user decides not to save, do nothing.
            return;
        }
开发者ID:jeffward01,项目名称:07-Notepad,代码行数:27,代码来源:MainWindow.xaml.cs

示例8: ExportControlPoints

    public static Rhino.Commands.Result ExportControlPoints(Rhino.RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef objref;
        var get_rc = Rhino.Input.RhinoGet.GetOneObject("Select curve", false, Rhino.DocObjects.ObjectType.Curve, out objref);
        if (get_rc != Rhino.Commands.Result.Success)
          return get_rc;
        var curve = objref.Curve();
        if (curve == null)
          return Rhino.Commands.Result.Failure;
        var nc = curve.ToNurbsCurve();

        var fd = new SaveFileDialog();
        //fd.Filters = "Text Files | *.txt";
        //fd.Filter = "Text Files | *.txt";
        //fd.DefaultExt = "txt";
        //if( fd.ShowDialog(Rhino.RhinoApp.MainWindow())!= System.Windows.Forms.DialogResult.OK)
        if (fd.ShowDialog(null) != DialogResult.Ok)
          return Rhino.Commands.Result.Cancel;
        string path = fd.FileName;
        using( System.IO.StreamWriter sw = new System.IO.StreamWriter(path) )
        {
          foreach( var pt in nc.Points )
          {
        var loc = pt.Location;
        sw.WriteLine("{0} {1} {2}", loc.X, loc.Y, loc.Z);
          }
          sw.Close();
        }
        return Rhino.Commands.Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:30,代码来源:ex_exportcontrolpoints.cs

示例9: exportHandler

    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of SVG
                //   commands to draw the shapes

                String SVGtext = "<?xml version=\"1.0\" standalone=\"no\"?>" +
                    "\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" +
                    "\r\n\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" +
                    "\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";
                foreach (Shape shape in shapes)
                {
                    SVGtext = SVGtext + shape.Conversion("SVG");
                }
                SVGtext = SVGtext + "\r\n</svg>";
                    using (StreamWriter writer = new StreamWriter(stream))
                {
                        // Write strings to the file here using:
                        writer.WriteLine(SVGtext);
                }
            }
        }
    }
开发者ID:YannickMeijer,项目名称:Lab4,代码行数:33,代码来源:ShapeDrawing.cs

示例10: SaveScreen

        public void SaveScreen(double paramX, double paramY, double paramWidth, double paramHeight)
        {
            var ix = Convert.ToInt32(paramX);
            var iy = Convert.ToInt32(paramY);
            var iw = Convert.ToInt32(paramWidth);
            var ih = Convert.ToInt32(paramHeight);
            try
            {
                var myImage = new Bitmap(iw, ih);

                var gr1 = Graphics.FromImage(myImage);
                var dc1 = gr1.GetHdc();
                var dc2 = NativeMethods.GetWindowDC(NativeMethods.GetForegroundWindow());
                NativeMethods.BitBlt(dc1, ix, iy, iw, ih, dc2, ix, iy, 13369376);
                gr1.ReleaseHdc(dc1);
                var dlg = new SaveFileDialog {DefaultExt = "png", Filter = "Png Files|*.png"};
                var res = dlg.ShowDialog();
                if (res == System.Windows.Forms.DialogResult.OK)
                    myImage.Save(dlg.FileName, ImageFormat.Png);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("SaveScreen exception : {0}", ex.Message));
            }
        }
开发者ID:silverforge,项目名称:SignalRPoc,代码行数:25,代码来源:ScreenshotView.xaml.cs

示例11: Function

    public void Function()
    {
        string strProjectpath =
            PathMap.SubstitutePath("$(PROJECTPATH)") + @"\";
        string strFilename = "Testdatei";

        SaveFileDialog sfd = new SaveFileDialog();
        sfd.DefaultExt = "txt";
        sfd.FileName = strFilename;
        sfd.Filter = "Textdatei (*.txt)|*.txt";
        sfd.InitialDirectory = strProjectpath;
        sfd.Title = "Speicherort für Testdatei wählen:";
        sfd.ValidateNames = true;

        if (sfd.ShowDialog() == DialogResult.OK)
        {
            File.Create(sfd.FileName);
            MessageBox.Show(
                "Datei wurde erfolgreich gespeichert:\n" + sfd.FileName,
                "Information",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information
                );
        }

        return;
    }
开发者ID:Suplanus,项目名称:EplanElectricP8Automatisieren,代码行数:27,代码来源:01_SaveFileDialog.cs

示例12: UIBrowse_Click

    private void UIBrowse_Click(System.Object sender, System.EventArgs e)
    {
        SaveFileDialog dialog = new SaveFileDialog();
        dialog.Filter = ".ATR|*.ATR|.XFD|*.XFD";
        if (dialog.ShowDialog() != DialogResult.OK) return;

        UIFilename.Text = dialog.FileName;
    }
开发者ID:danlb2000,项目名称:Atari-Disk-Explorer,代码行数:8,代码来源:NewDiskImageForm.cs

示例13: Save_Click

 protected void Save_Click(Object sender, EventArgs e)
 {
     SaveFileDialog s = new SaveFileDialog();
     if(s.ShowDialog() == DialogResult.OK) {
       StreamWriter writer = new StreamWriter(s.OpenFile());
       writer.Write(text.Text);
       writer.Close();
     }
 }
开发者ID:jiteshjha,项目名称:TextEditor,代码行数:9,代码来源:texteditor.cs

示例14: UIBrowse_Click

    private void UIBrowse_Click(System.Object sender, System.EventArgs e)
    {
        SaveFileDialog dialog = new SaveFileDialog();

        if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            UIFileName.Text = dialog.FileName;
        }
    }
开发者ID:danlb2000,项目名称:Atari-Disk-Explorer,代码行数:9,代码来源:AtasciiFileSaveForm.cs

示例15: exportHandler

    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "Scalable Vector Graphics (*.svg)|*.svg|TeX files (*.tex)|*.tex";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                string name = saveFileDialog.FileName;
                string ext = Path.GetExtension(saveFileDialog.FileName).ToLower();

                switch(ext){
                    case ".tex":
                        LatexGenerator lg = new LatexGenerator();
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            lg.FileWriter = writer;
                            writer.WriteLine("\\documentclass{article}");
                            writer.WriteLine("\\usepackage{tikz}");
                            writer.WriteLine("\\begin{document}");
                            writer.WriteLine("\\begin{tikzpicture}");
                            writer.WriteLine("\\begin{scope}[yscale= -3, xscale= 3]");
                            foreach(Shape s in this.shapes)
                            {
                                s.OutputApi = lg;
                                s.Draw();
                            }
                            writer.WriteLine("\\end{scope}");
                            writer.WriteLine("\\end{tikzpicture}");
                            writer.WriteLine("\\end{document}");
                        }
                        break;
                    default: //save as svg by default
                        SvgGenerator sg = new SvgGenerator();
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            sg.FileWriter = writer;
                            writer.WriteLine("<?xml version=\"1.0\" standalone=\"no\"?>");
                            writer.WriteLine("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
                            writer.WriteLine("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
                            foreach (Shape s in this.shapes)
                            {
                                s.OutputApi = sg;
                                s.Draw();
                            }
                            writer.WriteLine("</svg>");
                        }
                        break;
                }
            }
        }
    }
开发者ID:Chronophobe,项目名称:MSO_P3b,代码行数:57,代码来源:ShapeDrawing.cs


注:本文中的SaveFileDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。