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


C# Microsoft.Win32.SaveFileDialog.OpenFile方法代码示例

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


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

示例1: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.Filter = "PDF files (*.pdf)|*.pdf";
            //var t = dlg.ShowDialog();
            if (dlg.ShowDialog().Value)
            {
                // create pdf document
                var pdf = new C1PdfDocument();
                pdf.Landscape = true;
                pdf.Compression = CompressionLevel.NoCompression;

                // render all grids into pdf document
                var options = new PdfExportOptions();
                options.ScaleMode = ScaleMode.ActualSize;
                GridExport.RenderGrid(pdf, _flex1, options);
                pdf.NewPage();
                GridExport.RenderGrid(pdf, _flex2, options);
                pdf.NewPage();
                GridExport.RenderGrid(pdf, _flex3, options);
                pdf.NewPage();
                GridExport.RenderGrid(pdf, _flex4, options);

                // save document
                using (var stream = dlg.OpenFile())
                {
                    pdf.Save(stream);
                }
            }
        }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:30,代码来源:MainWindow.xaml.cs

示例2: Execute

        public void Execute(ViewModel viewModel)
        {
            viewModel.Status = string.Empty;
            var request = new ScanRequest()
            {
                DeviceId = viewModel.Scanner.Device.DeviceId,
                Settings = new ScannerSettings
                {
                    PageSize = PageSizes.Letter,
                    ColorDepth = ColorDepths.Color,
                    Orientation = Orientations.Portrait,
                    Resolution = Resolutions.R300,
                    UseAutomaticDocumentFeeder = true
                }
            };

            IScanner proxy = DiscoveryHelper.CreateDiscoveryProxy();
            try
            {
                var response = proxy.Scan(request);

                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = "Document";
                dlg.DefaultExt = ".pdf";
                dlg.Filter = "Acrobat|*.pdf";

                var result = dlg.ShowDialog();

                if (result == true)
                {
                    using (var file = dlg.OpenFile())
                    {
                        CopyStream(response, file);
                    }
                }
            }
            catch (FaultException<ScanError> e)
            {
                viewModel.Status = e.Detail.ErrorMessage;
            }
            catch (CommunicationException)
            {

            }
            finally
            {
                ICommunicationObject comm = ((ICommunicationObject)proxy);

                if (comm.State == CommunicationState.Faulted)
                {
                    comm.Abort();
                }
                else
                {
                    comm.Close();
                }
            }
        }
开发者ID:sodablue,项目名称:RoxiScan,代码行数:58,代码来源:ScanCommand.cs

示例3: ExportToImage

        public static void ExportToImage(FrameworkElement surface)
        {
            Size size = new Size(surface.ActualWidth, surface.ActualHeight);
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32);
            renderBitmap.Render(surface);

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = DateTime.Now.ToString("yyyy-M-d-H_m_s");
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\WLANFolder";
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            dlg.InitialDirectory = path;
            dlg.OverwritePrompt = true;
            dlg.Filter = "JPEG Image|*.jpg|Bitmap Image|*.bmp|PNG Image|*.png";
            dlg.Title = "Save an Image File";
            dlg.ShowDialog();
            dlg.RestoreDirectory = true;

            if (dlg.FileName != "")
            {
                try
                {
                    using(FileStream outStream = (System.IO.FileStream)dlg.OpenFile())
                    {
                        switch (dlg.FilterIndex)
                        {
                            case 1:
                                {
                                    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                                    encoder.Save(outStream);
                                }
                                break;
                            case 2:
                                {
                                    BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                                    encoder.Save(outStream);
                                }
                                break;
                            case 3:
                                {
                                    PngBitmapEncoder encoder = new PngBitmapEncoder();
                                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                                    encoder.Save(outStream);
                                }
                                break;
                            default:
                                break;
                        }
                        System.Diagnostics.Process.Start(dlg.FileName);
                    }          
                }
                catch (ArgumentException)
                { return; }
            }
        }
开发者ID:Tripmaster-zhang,项目名称:Hello_World,代码行数:57,代码来源:SaveAsImage.cs

示例4: BtnStartClick

        private void BtnStartClick(object sender, RoutedEventArgs e)
        {
            List<string> validEmails;
            List<string> inValidEmails;
            SeleniumDriver.Program.Run(_eMails, out validEmails, out inValidEmails);

            // Configure save file dialog box
            var dlg = new Microsoft.Win32.SaveFileDialog
                {
                    FileName = "ValidEmails.txt",
                    Filter = "Text File | *.txt"
                };

            // Show save file dialog box
            var result = dlg.ShowDialog();

            // Process save file dialog box results 
            if (result == true)
            {
                var writer = new StreamWriter(dlg.OpenFile());
                foreach (var email in validEmails)
                {
                    writer.WriteLine(email);
                }
                writer.Dispose();
                writer.Close();
            }

            // Configure save file dialog box
            dlg = new Microsoft.Win32.SaveFileDialog
            {
                FileName = "InValidEmails.txt",
                Filter = "Text File | *.txt"
            };

            // Show save file dialog box
            result = dlg.ShowDialog();

            // Process save file dialog box results 
            if (result == true)
            {
                var writer = new StreamWriter(dlg.OpenFile());
                foreach (var email in inValidEmails)
                {
                    writer.WriteLine(email);
                }
                writer.Dispose();
                writer.Close();
            }
        }
开发者ID:abhishekshukla85,项目名称:SeleniumAutobots,代码行数:50,代码来源:MainWindow.xaml.cs

示例5: GuardarComoMenuItem_Click

        private void GuardarComoMenuItem_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog sdlg = new Microsoft.Win32.SaveFileDialog();

            sdlg.Filter = "Text File (*.txt)|*.txt|Show All Files (*.*)|*.*";
            sdlg.FileName = "Untitled";
            sdlg.Title = "Save As";

            Nullable<bool> result = sdlg.ShowDialog();

            if (result == true)
            {

                using (var stream = sdlg.OpenFile())
                {
                    var range = new TextRange(richTextBox1.Document.ContentStart,
                                              richTextBox1.Document.ContentEnd);
                    range.Save(stream, DataFormats.Rtf);
                }
            }
        }
开发者ID:kxrloz,项目名称:Notepad,代码行数:21,代码来源:MainWindow.xaml.cs

示例6: Export

 public static void Export(object columns, IEnumerable data, ExportType type = ExportType.Xls)
 {
     Microsoft.Win32.SaveFileDialog fileDialog = new Microsoft.Win32.SaveFileDialog();
     fileDialog.Filter = type == ExportType.Xls ? "(*.xls)|*.xls" : "(*.*)|*.*";
     fileDialog.FileName = "data_" + DateTime.Now.ToString("yyyyMMddHHmmss");
     if (fileDialog.ShowDialog() == true)
     {
         using (var stream = fileDialog.OpenFile())
         {
             var cols = GetDataColumns(columns);
             if (cols != null)
                 DoExport(stream, cols, data, type);
             else
                 DoExport(stream, data, type);
         }
         //TODO: open the folder of the file
         var dialog = new ExportResultDialog(fileDialog.FileName);
         dialog.Owner = Window.GetWindow(Application.Current.MainWindow);
         dialog.ShowDialog();
     }
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:21,代码来源:ExportHelper.cs

示例7: Save

		public void Save(MemoryStream data, string FileName)
		{
			// the actionscript API will show the dialog after the user event
			// has returned, so we must mimic it here

			1.AtDelay(
				delegate
				{
					var s = new Microsoft.Win32.SaveFileDialog();

					s.FileName = FileName;

					if (s.ShowDialog() ?? false)
					{
						using (var w = s.OpenFile())
						{
							var a = data.ToArray();
							w.Write(a, 0, a.Length);
						}
					}
				}
			);
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:23,代码来源:FileDialog.cs

示例8: SaveClicked

 private void SaveClicked(object sender, RoutedEventArgs e)
 {
     //
     var dialog = new Microsoft.Win32.SaveFileDialog() { AddExtension = true };
     dialog.Filter = "Portable Network Graphics|*.png";
     bool? result = dialog.ShowDialog();
     if (result.HasValue && result.Value)
     {
         try
         {
             using(Stream stream = dialog.OpenFile())
             {
                 var encoder = new TiffBitmapEncoder();
                 encoder.Frames.Add(BitmapFrame.Create((BitmapSource)this.image.Source));
                 encoder.Save(stream);
             }
             this.Close();
         }
         catch(SystemException ex)
         {
             MessageBox.Show("Can't save to the file. " + ex.Message, "File Error", MessageBoxButton.OK);
         }
     }
 }
开发者ID:vosen,项目名称:UAM.ImageProcessing,代码行数:24,代码来源:HorizonWindow.xaml.cs

示例9: annotationCanvas_SaveAnnotation

        void annotationCanvas_SaveAnnotation(Obany.Render.Objects.Canvas canvas, string mimeType)
        {
            _progressControl = new ProgressControl();

            AddWatermark(canvas);

            string files = CultureHelper.GetString(Properties.Resources.ResourceManager, "FILES");
            string allFiles = CultureHelper.GetString(Properties.Resources.ResourceManager, "ALLFILES");

            string ext = "";
            string filter = "";
            if (mimeType == "image/jpeg")
            {
                ext += ".jpg";
                filter = "Jpg " + files + " (*.jpg)|*.jpg";
                _progressControl.Status = CultureHelper.GetString(Properties.Resources.ResourceManager, "CREATING") + " Jpg";
            }
            else if (mimeType == "application/vnd.ms-xpsdocument")
            {
                ext += ".xps";
                filter = "Xps " + files + " (*.xps)|*.xps";
                _progressControl.Status = CultureHelper.GetString(Properties.Resources.ResourceManager, "CREATING") + " Xps";
            }
            else if (mimeType == "application/pdf")
            {
                ext += ".pdf";
                filter = "Pdf " + files + " (*.pdf)|*.pdf";
                _progressControl.Status = CultureHelper.GetString(Properties.Resources.ResourceManager, "CREATING") + " Pdf";
            }

            filter += "|" + allFiles + " (*.*)|*.*";

            #if SILVERLIGHT
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            #else
            Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
            if (!string.IsNullOrEmpty(_lastSavePath))
            {
                saveFileDialog.InitialDirectory = _lastSavePath;
            }
            #endif
            saveFileDialog.DefaultExt = ext;
            saveFileDialog.Filter = filter;

            if (saveFileDialog.ShowDialog().Value)
            {
            #if !SILVERLIGHT
                _lastSavePath = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
            #endif

                System.IO.Stream saveStream = saveFileDialog.OpenFile();

                DialogPanel.ShowDialog(Properties.Resources.ResourceManager, "PROGRESS", _progressControl, "buttonCancel", DialogButtons.Cancel,
                    delegate(DialogResult dialogControlResult)
                    {
                        _progressControl = null;
                    }
                );

                _saveTaskId = Guid.NewGuid();

                _coreLogic.AnnotationSave(_saveTaskId, saveStream, canvas, mimeType,
                    delegate(bool success, Guid saveTaskIdComplete)
                {
                    Action a = delegate()
                    {
                        if (_saveTaskId == saveTaskIdComplete)
                        {
                            if (!success)
                            {
                                DialogPanel.ShowInformationBox(CultureHelper.GetString(Properties.Resources.ResourceManager, "ANNOTATIONUNABLETOSAVE"),
                                                            DialogButtons.Ok, null);
                            }
                            else
                            {
                                if (annotationCanvas != null)
                                {
                                    annotationCanvas.ResetChanges();
                                }
                            }

                            if (_progressControl != null)
                            {
                                DialogPanel.Close(_progressControl, DialogResult.Close);
                            }
                            _saveTaskId = Guid.Empty;
                        }
                    };

            #if SILVERLIGHT
                    Dispatcher.BeginInvoke(a);
            #else
                    Dispatcher.Invoke(a);
            #endif
                });
            }
        }
开发者ID:justinstaines,项目名称:Shumbi-Discover,代码行数:97,代码来源:CoreInterface.xaml.cs

示例10: button1_Click

 //More tab save button
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     this.Cursor = Cursors.AppStarting;
     button2.IsEnabled = false;
     Microsoft.Win32.SaveFileDialog SaveFileDialog1 = new Microsoft.Win32.SaveFileDialog();
     SaveFileDialog1.Filter = "txt files (*.txt)|*.txt";
     if ((bool)SaveFileDialog1.ShowDialog())
     {
         using (System.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter(SaveFileDialog1.OpenFile()))
         {
             StreamWriter1.WriteLine("\n:::::::::::::::::{0}::::::::::::::::::", comboBox1.SelectedItem.ToString());
             StreamWriter1.WriteLine(textBox5.Text);
             StreamWriter1.Close();
         }
         MessageBox.Show("File saved successfully", "System Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     this.Cursor = Cursors.Arrow;
     button2.IsEnabled = true;
 }
开发者ID:hydrayu,项目名称:imobile-src,代码行数:20,代码来源:MainWindow.xaml.cs

示例11: Save

        protected virtual void Save(String path, Visifire.Charts.ExportType exportType, Boolean showDilog)
        {   
            if (_saveIconImage != null)
            {   
                _saveIconImage.Visibility = Visibility.Collapsed;
                _toolTip.Hide();
                _toolbarContainer.UpdateLayout();
            }
#if SL      
            try
            {   
                WriteableBitmap bitmap = new WriteableBitmap(this, null);
#if !WP
                if (bitmap != null)
                {   
                    SaveFileDialog saveDlg = new SaveFileDialog();

                    saveDlg.Filter = "JPEG (*.jpg)|*.jpg|BMP (*.bmp)|*.bmp";
                    saveDlg.DefaultExt = ".jpg";
                    
                    if ((bool)saveDlg.ShowDialog())
                    {
                        using (Stream fs = saveDlg.OpenFile())
                        {
                            String[] filename = saveDlg.SafeFileName.Split('.');
                            String fileExt;

                            if (filename.Length >= 2)
                            {
                                fileExt = filename[filename.Length - 1];
                                exportType = (Visifire.Charts.ExportType)Enum.Parse(typeof(Visifire.Charts.ExportType), fileExt, true);
                            }
                            else
                                exportType = Visifire.Charts.ExportType.Jpg;

                            MemoryStream stream = Graphics.GetImageStream(bitmap, exportType);

                            // Get Bytes from memory stream and write into IO stream
                            byte[] binaryData = new Byte[stream.Length];
                            long bytesRead = stream.Read(binaryData, 0, (int)stream.Length);
                            fs.Write(binaryData, 0, binaryData.Length);
                        }
                    }
                }
#endif
            }
            catch (Exception ex)
            {
                if (_saveIconImage != null)
                {
                    _saveIconImage.Visibility = Visibility.Visible;
                }
                System.Diagnostics.Debug.WriteLine("Note: Please make sure that Height and Width of the chart is set properly.");
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
#else       
            // Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
            // double dx = m.M11* 96;
            // double dy = m.M22 * 96;

            // Save current canvas transform
            Transform transform = this.LayoutTransform;
            
            // reset current transform (in case it is scaled or rotated)
            _rootElement.LayoutTransform = null;

            // Create a render bitmap and push the surface to it
            RenderTargetBitmap renderBitmap =
              new RenderTargetBitmap(
                    (int)(this.ActualWidth),
                    (int)(this.ActualHeight),
                    96d,
                    96d,
                    PixelFormats.Pbgra32);
            renderBitmap.Render(_rootElement);

            if (showDilog)
            {   
                Microsoft.Win32.SaveFileDialog saveDlg = new Microsoft.Win32.SaveFileDialog();

                saveDlg.Filter = "Jpg Files (*.jpg)|*.jpg|BMP Files (*.bmp)|*.bmp";
                saveDlg.DefaultExt = ".jpg";
                
                if ((bool)saveDlg.ShowDialog())
                {   
                    BitmapEncoder encoder;
               
                    if (saveDlg.FilterIndex == 2)
                        encoder = new BmpBitmapEncoder();
                    else
                        encoder = new JpegBitmapEncoder();

                    using (Stream fs = saveDlg.OpenFile())
                    {
                        encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                        // save the data to the stream
                        encoder.Save(fs);
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:zhangzy0193,项目名称:visifire,代码行数:101,代码来源:VisifireControl.cs

示例12: OnExportMenuItemClick

        private void OnExportMenuItemClick( object sender, RoutedEventArgs e )
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            dlg.Title = "Export Configuration";

            AssignCommonFileDialogProps( dlg );

            if( dlg.ShowDialog() != true ) return;

            try
            {
                _windowData.Document.Save( dlg.OpenFile(), WidgetDocSaveFormat.Xml );
            }
            catch( Exception ex )
            {
                ReportToUserApplicationError( ex, "There were issues exporting configuration." );
            }
        }
开发者ID:dxm007,项目名称:Droppy,代码行数:19,代码来源:MainWindow.xaml.cs

示例13: Run

		public override void Run(GraphController ctrl)
		{
			System.IO.Stream myStream;
			var saveFileDialog1 = new Microsoft.Win32.SaveFileDialog();

			saveFileDialog1.Filter = "Altaxo graph files (*.axogrp)|*.axogrp|All files (*.*)|*.*";
			saveFileDialog1.FilterIndex = 1;
			saveFileDialog1.RestoreDirectory = true;

			if (true == saveFileDialog1.ShowDialog((System.Windows.Window)Current.Workbench.ViewObject))
			{
				if ((myStream = saveFileDialog1.OpenFile()) != null)
				{
					Altaxo.Serialization.Xml.XmlStreamSerializationInfo info = new Altaxo.Serialization.Xml.XmlStreamSerializationInfo();
					info.BeginWriting(myStream);
					info.AddValue("Graph", ctrl.Doc);
					info.EndWriting();
					myStream.Close();
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:21,代码来源:GraphCommands.cs

示例14: Execute

            public void Execute(object parameter)
            {
                Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                sfd.OverwritePrompt = true;
                sfd.CheckPathExists = true;
                sfd.ValidateNames = true;
                if (sfd.ShowDialog() != true) return;

                using (System.IO.Stream s = sfd.OpenFile()) {
                    var list = vm.Rules.Where(x => x.Key < int.MaxValue - 1).Select(x => new Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair(x.Key, x.Value)).ToList();
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(list.GetType());
                    xs.Serialize(s, list);
                }
            }
开发者ID:c933103,项目名称:KanColleViewer,代码行数:14,代码来源:ProxyRulesViewModel.cs

示例15: ExportToExcel

        private void ExportToExcel()
        {
            //if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
            //{
                //MessageBox.Show("Due to restricted user-access permissions, this feature cannot be demonstrated when the Live Explorer is running as an XBAP browser application. Please download the full Xceed DataGrid for WPF package and run the Live Explorer as a desktop application to try out this feature.", "Feature unavailable");
                //return;
            //}

            // The simplest way to export in Excel format is to call the 
            // DataGridControl.ExportToExcel() method. However, if you want to specify export
            // settings, you have to take the longer, more descriptive and flexible route: 
            // the ExcelExporter class.

            // excelExporter.FixedColumnCount will automatically be set to the specified
            // grid's FixedColumnCount value.
            //ExcelExporter excelExporter = new ExcelExporter(this.GridDetails);
            //excelExporter.ExportStatFunctionsAsFormulas = this.exportStatFunctionsAsFormulasCheckBox.IsChecked.GetValueOrDefault();
            //excelExporter.IncludeColumnHeaders = this.includeColumnHeadersCheckBox.IsChecked.GetValueOrDefault();
            //excelExporter.IsHeaderFixed = this.isHeaderFixedCheckBox.IsChecked.GetValueOrDefault();
            //excelExporter.RepeatParentData = this.repeatParentDataCheckBox.IsChecked.GetValueOrDefault();
            //excelExporter.DetailDepth = Convert.ToInt32(this.detailDepthTextBox.Value);
            //excelExporter.StatFunctionDepth = Convert.ToInt32(this.statFunctionDepthTextBox.Value);
            //excelExporter.UseFieldNamesInHeader = this.UseFieldNamesInHeaderCheckBox.IsChecked.GetValueOrDefault();

            Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();

            saveFileDialog.Filter = "XML Spreadsheet (*.xml)|*.xml|All files (*.*)|*.*";

            try
            {
                if (saveFileDialog.ShowDialog().GetValueOrDefault())
                {
                    using (Stream stream = saveFileDialog.OpenFile())
                    {
                        //excelExporter.Export(stream);
                        GridDetails.ExportToExcel(stream);
                    }
                }
            }
            catch { }
        }
开发者ID:erwin-hamid,项目名称:LogPro,代码行数:41,代码来源:QueriesView.xaml.cs


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