public override bool Action(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_EXPORT_ALL || action == ACTION_EXPORT_SELECTED || action == ACTION_EXPORT_ACTIVE) { List<Framework.Data.Geocache> gcList = null; if (action == ACTION_EXPORT_ALL) { gcList = (from Framework.Data.Geocache a in Core.Geocaches select a).ToList(); } else if (action == ACTION_EXPORT_SELECTED) { gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); } else { if (Core.ActiveGeocache != null) { gcList = new List<Framework.Data.Geocache>(); gcList.Add(Core.ActiveGeocache); } } if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOGEOCACHESELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { using (System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog()) { dlg.FileName = ""; if (Properties.Settings.Default.ZipFile) { dlg.Filter = "*.zip|*.zip"; } else { dlg.Filter = "*.gpx|*.gpx"; } if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _filename = dlg.FileName; _gpxGenerator = new Utils.GPXGenerator(Core, gcList, string.IsNullOrEmpty(Properties.Settings.Default.GPXVersionStr) ? Utils.GPXGenerator.V101: Version.Parse(Properties.Settings.Default.GPXVersionStr)); _gpxGenerator.MaxNameLength = Properties.Settings.Default.MaxGeocacheNameLength; _gpxGenerator.MinStartOfname = Properties.Settings.Default.MinStartOfGeocacheName; _gpxGenerator.UseNameForGCCode = Properties.Settings.Default.UseNameAndNotCode; _gpxGenerator.AddAdditionWaypointsToDescription = Properties.Settings.Default.AddWaypointsToDescription; _gpxGenerator.UseHintsForDescription = Properties.Settings.Default.UseHintsForDescription; _gpxGenerator.AddFieldnotesToDescription = Properties.Settings.Default.AddFieldnotesToDescription; _gpxGenerator.ExtraCoordPrefix = Properties.Settings.Default.CorrectedNamePrefix; PerformExport(); } } } } } return result; }
private void DoAction(Mine2D game, int buttonNumber) { switch (buttonNumber) { case 0: game.gameState = GameState.Playing; break; case 1: System.Windows.Forms.SaveFileDialog saveWorld = new System.Windows.Forms.SaveFileDialog(); saveWorld.Filter = "Сжатые миры Mine2D|*.m2d"; if (saveWorld.ShowDialog() == System.Windows.Forms.DialogResult.OK) { game.gameState = GameState.SavingWorld; new System.Threading.Thread(delegate() { LevelManager.SaveLevel(game, saveWorld.FileName); }).Start(); } break; case 2: LevelManager.RecreateLevel(game); game.gameState = GameState.MainMenu; break; } }
private void _export_Click(object sender, RoutedEventArgs e) { //打开对话框 System.Windows.Forms.SaveFileDialog saveFile = new System.Windows.Forms.SaveFileDialog(); saveFile.Filter = "JPG(*.jpg)|*.jpg"; saveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } var saveFilePath = saveFile.FileName; if (saveFilePath != "") { if (web != null) { if (web.ReadyState == System.Windows.Forms.WebBrowserReadyState.Complete) { System.Drawing.Rectangle r = web.Document.Body.ScrollRectangle; web.Height = r.Height; web.Width = r.Width; Bitmap bitMapPic = new Bitmap(r.Width, r.Height); web.DrawToBitmap(bitMapPic, r); bitMapPic.Save(saveFilePath); Toolkit.MessageBox.Show("文件导出成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); } } } }
void menuitem_Click(object sender, EventArgs e) { if (_host.Chats.Length != 0) { System.Windows.Forms.SaveFileDialog sf = new System.Windows.Forms.SaveFileDialog(); sf.DefaultExt = ".xml"; sf.Filter = "XMLファイル(*.xml)|*.xml"; sf.FileName = "export_" + _host.Id + ".xml"; if (sf.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) { string xml = buildNicoXML(); if (xml != null) { try { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sf.FileName)) { sw.WriteLine(xml); sw.Close(); } _host.ShowStatusMessage("エクスポートに成功しました。"); } catch (Exception ex) { NicoApiSharp.Logger.Default.LogException(ex); _host.ShowFaitalMessage("エクスポートに失敗しました。詳しい情報はログファイルを参照してください"); } } } } }
protected override void OnClick() { if (IsExportMode) { var saveFile = new System.Windows.Forms.SaveFileDialog(); saveFile.AddExtension = true; saveFile.AutoUpgradeEnabled = true; saveFile.CheckPathExists = true; saveFile.DefaultExt = ExportModeDefaultExtension; saveFile.Filter = ExportModeExtensionFilter; saveFile.FilterIndex = 0; var result = saveFile.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { var fileName = saveFile.FileName; this.CommandParameter = fileName; base.OnClick(); } } else { base.OnClick(); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CaptureForm)); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.SuspendLayout(); // // CaptureForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); this.ClientSize = new System.Drawing.Size(604, 384); this.ControlBox = false; this.Cursor = System.Windows.Forms.Cursors.Cross; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "CaptureForm"; this.Opacity = 0.3; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "Form1"; this.TopMost = true; this.TransparencyKey = System.Drawing.Color.White; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.ResumeLayout(false); }
private void btnAddData_Click(object sender, EventArgs e) { ///////////////////////////////// //Replace with something that uses the default data provider System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.OverwritePrompt = true; sfd.Filter = "Shape Files|*.shp"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IFeatureSet _addedFeatureSet = new MapWindow.Data.Shapefile(); _addedFeatureSet.Filename = sfd.FileName; //If the features set is null do nothing the user probably hit cancel if (_addedFeatureSet == null) return; //If the feature type is good save it else { //This inserts the new featureset into the list textBox1.Text = System.IO.Path.GetFileNameWithoutExtension(_addedFeatureSet.Filename); base.Param.Value = _addedFeatureSet; base.Status = ToolStatus.Ok; base.LightTipText = MapWindow.MessageStrings.FeaturesetValid; } } }
/// <summary> /// Return true is user selects and confirms /// output file name and folder. /// </summary> static bool SelectFile( ref string folder_path, ref string filename) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "JSelect SON Output File"; dlg.Filter = "JSON files|*.js"; if( null != folder_path && 0 < folder_path.Length ) { dlg.InitialDirectory = folder_path; } dlg.FileName = filename; bool rc = DialogResult.OK == dlg.ShowDialog(); if( rc ) { filename = Path.GetFileName( dlg.FileName ); folder_path = Path.GetDirectoryName( filename ); } return rc; }
private void btnExport_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txbAPIKey.Text) || string.IsNullOrEmpty(txbEventId.Text)) { MessageBox.Show("Please enter all the information on the form.", "Export", MessageBoxButton.OK, MessageBoxImage.Error); return; } //load data from meetup should be async IMeetupService service = new MeetupService(new MeetupRepository(txbAPIKey.Text)); IList<RsvpItem> rsvpItems = service.GetRsvpsForEvent(long.Parse(txbEventId.Text)); //export it var saveFileDialog = new SaveFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), DefaultExt = "csv", AddExtension = true, Filter = @"CSV Files (*.csv)|*.csv" }; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { File.WriteAllText(saveFileDialog.FileName, new RsvpManager().GetAttendees(rsvpItems).ToCsv(true)); MessageBox.Show("Export done.", "Export", MessageBoxButton.OK, MessageBoxImage.Information); } catch { MessageBox.Show("Export Failed.", "Export", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public override void OnClick() { System.Data.IDbConnection resultConnection = CheckApplication.CurrentTask.ResultConnection as System.Data.OleDb.OleDbConnection; if (resultConnection == null) { DevExpress.XtraEditors.XtraMessageBox.Show("��ǰ����״̬�����Ϊ�Ѵ����������������ѱ��Ƴ���"); return; } System.Windows.Forms.SaveFileDialog dlgShpFile = new System.Windows.Forms.SaveFileDialog(); dlgShpFile.FileName = Environment.CurrentDirectory + "\\" + CheckApplication.CurrentTask.Name + ".xls"; dlgShpFile.Filter = "SHP �ļ�|*.Shp"; if (dlgShpFile.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string strFile = dlgShpFile.FileName; string strPath = System.IO.Path.GetDirectoryName(strFile); string strName = System.IO.Path.GetFileNameWithoutExtension(strFile); Hy.Check.Task.Task curTask = CheckApplication.CurrentTask; ErrorExporter exporter = new ErrorExporter(); exporter.BaseWorkspace = curTask.BaseWorkspace; exporter.ResultConnection = curTask.ResultConnection; exporter.SchemaID = curTask.SchemaID; exporter.Topology = curTask.Topology; exporter.ExportToShp(strPath, strName); }
private void saveBtn_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); save.DefaultExt = "txt"; save.Filter = Strings.GetLabelString("TxtFileDescriptionPlural")+"|*.txt|"+ Strings.GetLabelString("AllFileDescriptionPlural") +"|*"; save.Title = Strings.GetLabelString("SaveReportQuestion"); if (AAnalyzer.LastSavePath == null) save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); else save.InitialDirectory = AAnalyzer.LastSavePath; save.FileName = analyzer.game.Name + ".txt"; if (save.ShowDialog(this.GetIWin32Window()) != System.Windows.Forms.DialogResult.Cancel) { AAnalyzer.LastSavePath = Path.GetDirectoryName(save.FileName); try { StreamWriter writer = File.CreateText(save.FileName); writer.Write(prepareReport()); writer.Close(); saved = true; } catch(Exception ex) { TranslatingMessageHandler.SendError("WriteError", ex, save.FileName); } } }
public static void SaveTheme(this MsDev2013_Theme theme) { using (var sfd = new System.Windows.Forms.SaveFileDialog() { Filter = "YAML File|*.yml" }) { if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; theme.SaveTheme(sfd.FileName); } }
/// <summary> /// 导出用户选择的XML文件 /// </summary> /// <param name="ds">DataSet</param> public void ExportToXML(DataSet ds) { System.Windows.Forms.SaveFileDialog saveFileDlg = new System.Windows.Forms.SaveFileDialog(); saveFileDlg.DefaultExt = "xml"; saveFileDlg.Filter = "xml文件 (*.xml)|*.xml"; if (saveFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) doExportXML(ds, saveFileDlg.FileName); }
private void btnSaveImg_Click(object sender, RoutedEventArgs e) { var sfd = new System.Windows.Forms.SaveFileDialog { Title = "Select where do you want to save the Screenshot", Filter = "PNG Image (*.png)|*.png" }; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) SaveImage(sfd.FileName); }
private void SaveAsMenuItem_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog(); dialog.DefaultExt = ".bvh"; dialog.Filter = "BVHファイル(*.bvh)|*.bvh"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { bvhTo.BVH.Save(dialog.FileName); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.buildButton = new System.Windows.Forms.Button(); this.progressBar = new System.Windows.Forms.ProgressBar(); this.progressLabel = new System.Windows.Forms.Label(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.SuspendLayout(); // // buildButton // this.buildButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buildButton.FlatStyle = System.Windows.Forms.FlatStyle.System; this.buildButton.Location = new System.Drawing.Point(3, 3); this.buildButton.Name = "buildButton"; this.buildButton.Size = new System.Drawing.Size(86, 24); this.buildButton.TabIndex = 18; this.buildButton.Text = "&Build..."; this.buildButton.Click += new System.EventHandler(this.BuildButton_Click); // // progressBar // this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.progressBar.Location = new System.Drawing.Point(3, 53); this.progressBar.Name = "progressBar"; this.progressBar.Size = new System.Drawing.Size(294, 23); this.progressBar.TabIndex = 19; this.progressBar.Visible = false; // // progressLabel // this.progressLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.progressLabel.AutoEllipsis = true; this.progressLabel.Location = new System.Drawing.Point(3, 37); this.progressLabel.Name = "progressLabel"; this.progressLabel.Size = new System.Drawing.Size(294, 13); this.progressLabel.TabIndex = 20; this.progressLabel.Text = "Progress message..."; // // BuildStep // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(this.progressLabel); this.Controls.Add(this.progressBar); this.Controls.Add(this.buildButton); this.Name = "BuildStep"; this.Size = new System.Drawing.Size(300, 85); this.Tag = "Build the application syndication feed. All other steps must be completed before" + " the Build button will be activated."; this.ResumeLayout(false); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; saveBox = new System.Windows.Forms.SaveFileDialog(); saveBox.Title = "Save Level As"; saveBox.Filter = "Psychic Ninja Level File | *.xml"; openBox = new System.Windows.Forms.OpenFileDialog(); openBox.Title = "Load Psychic Ninja Level"; openBox.Filter = "Psychic Ninja Level File | *.xml"; }
public void ExportMapBehavior(object sender, TomShane.Neoforce.Controls.EventArgs e) { Button btn = (Button)sender; btn.Focused = false; System.Windows.Forms.SaveFileDialog exportMapDialog = new System.Windows.Forms.SaveFileDialog(); exportMapDialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.CommonProgramFilesX86); exportMapDialog.Filter = "Map files (*.datmap)|*.datmap"; exportMapDialog.FilterIndex = 1; exportMapDialog.Title = "Export your map"; exportMapDialog.FileOk += new System.ComponentModel.CancelEventHandler(SuccessfullyExportedMap); exportMapDialog.ShowDialog(); }
static ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); SimpleIoc.Default.Register<Model.User.IUserService, Model.User.UserService>(); SimpleIoc.Default.Register<Model.Checkout.ICheckoutService, Model.Checkout.CheckoutService>(); SimpleIoc.Default.Register<Model.Book.IBookService, Model.Book.BookService>(); SimpleIoc.Default.Register<Model.Amaz.IAmazService, Model.Amaz.AmazService>(); SimpleIoc.Default.Register<Model.Config.IConfigService, Model.Config.ConfigService>(); SimpleIoc.Default.Register<MainViewModel>(); SimpleIoc.Default.Register<Content.DefaultContentViewModel>(); SimpleIoc.Default.Register<Content.CheckoutContainerViewModel>(); SimpleIoc.Default.Register<Content.CheckoutManageViewModel>(); SimpleIoc.Default.Register<Content.BookManageViewModel>(); SimpleIoc.Default.Register<Content.BookSearchViewModel>(); SimpleIoc.Default.Register<Content.UserManageViewModel>(); SimpleIoc.Default.Register<Menu.DefaultMenuViewModel>(); SimpleIoc.Default.Register<Menu.MainMenuViewModel>(); SimpleIoc.Default.Register<Dialog.BookDialogViewModel>(); SimpleIoc.Default.Register<Dialog.BookBulkDialogViewModel>(); SimpleIoc.Default.Register<Dialog.AmazDialogViewModel>(); SimpleIoc.Default.Register<Dialog.CheckoutDialogViewModel>(); SimpleIoc.Default.Register<Dialog.OptionDialogViewModel>(); SimpleIoc.Default.Register<Dialog.UserDialogViewModel>(); SimpleIoc.Default.Register<Dialog.TagDialogViewModel>(); SimpleIoc.Default.Register<Dialog.NDCDialogViewModel>(); SimpleIoc.Default.Register<AmazViewModel>(); SimpleIoc.Default.Register<CategoryViewModel>(); Messenger.Default.Register<FileDialogMessage>(typeof(ViewModelLocator), message => { System.Windows.Forms.FileDialog dlg; if (message.IsSave) dlg = new System.Windows.Forms.SaveFileDialog { DefaultExt = message.DefaultExt, Filter = message.Filter, FileName = message.FileName, Title = message.Caption, }; else dlg = new System.Windows.Forms.OpenFileDialog { DefaultExt = message.DefaultExt, Filter = message.Filter, FileName = message.FileName, Title = message.Caption, }; var result = dlg.ShowDialog(); message.DialogResult = result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes; message.FileName = dlg.FileName; }); }
/// <summary> /// 选择保存路径 /// </summary> /// <param name="title"></param> /// <param name="filter"></param> /// <returns></returns> public static string SelectAndSavePath(string title, string filter) { var sp = new System.Windows.Forms.SaveFileDialog { Title = title, RestoreDirectory = true, Filter = filter }; if (sp.ShowDialog() != System.Windows.Forms.DialogResult.OK) return null; var oppath = sp.FileName; return oppath; }
public static void SaveProject(TestProject testProject, bool showDialogAlways = false) { System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog(); saveFileDialog.Title = "Save test project"; saveFileDialog.RestoreDirectory = true; saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); saveFileDialog.Filter = "Controller Tester Projects (*.fmpx) | *.fmpx"; saveFileDialog.FileName = testProject.Name; if (showDialogAlways == true || testProject.Path == null) { if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!saveFileDialog.FileName.Contains(".fmpx")) { testProject.Name = Path.GetFileNameWithoutExtension(saveFileDialog.FileName); testProject.Path = saveFileDialog.FileName + ".fmpx"; } else { testProject.Name = Path.GetFileNameWithoutExtension(saveFileDialog.FileName); testProject.Path = saveFileDialog.FileName; } } else { return; } } if (testProject.Path != null) { FileStream f = File.Create(testProject.Path); var listOfFaultModelAssemblies = (from lAssembly in AppDomain.CurrentDomain.GetAssemblies() where lAssembly.FullName.Contains("FaultModel") select lAssembly).ToArray(); var extraTypes = (from lAssembly in listOfFaultModelAssemblies from lType in lAssembly.GetTypes() where lType.IsSubclassOf(typeof(FM4CC.Environment.FaultModelConfiguration)) select lType).ToArray(); var extraTypes2 = (from lAssembly in listOfFaultModelAssemblies from lType in lAssembly.GetTypes() where lType.IsSubclassOf(typeof(FM4CC.TestCase.FaultModelTesterTestCase)) select lType).ToArray(); XmlSerializer xsSubmit = new XmlSerializer(typeof(TestProject), extraTypes.Concat(extraTypes2).ToArray()); XmlWriter writer = XmlWriter.Create(f); xsSubmit.Serialize(writer, testProject); f.Close(); } }
private void btnXuat_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.InitialDirectory = mTranSit.DuongDanHinh; dlg.Filter = "Excel Files | *.xlsx"; if (dlg.ShowDialog()==System.Windows.Forms.DialogResult.OK) { //ExportImport.ImportExportProcess.Export(dlg.FileName); //mImportExportProcess.Export(dlg.FileName); mImportExportProcess.ExportItem(dlg.FileName); } }
private void ButtonScreenshot_OnClick(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog Dialog = new System.Windows.Forms.SaveFileDialog { Filter = "PNG|*.png|MRC|*.mrc" }; System.Windows.Forms.DialogResult Result = Dialog.ShowDialog(); if (Result == System.Windows.Forms.DialogResult.OK) { Viewport.GrabScreenshot(Dialog.FileName); } }
/// <summary> /// Writes a Pac1 file. [Useable by scripts and interface components alike.] /// </summary> /// <param name="Direct_Data">Array of Completed Direct Sound Simulations Required</param> /// <param name="IS_Data">Array of Completed Image Source Simulations. Enter null if opted out.</param> /// <param name="Receiver">Array of Completed Ray-Tracing Simulation Receivers. Enter null if opted out.</param> public static void Write_Pac1(Direct_Sound[] Direct_Data, ImageSourceData[] IS_Data = null, Environment.Receiver_Bank[] Receiver = null) { System.Windows.Forms.SaveFileDialog sf = new System.Windows.Forms.SaveFileDialog(); sf.DefaultExt = ".pac1"; sf.AddExtension = true; sf.Filter = "Pachyderm Ray Data file (*.pac1)|*.pac1|" + "All Files|"; if (sf.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Write_Pac1(sf.FileName, Direct_Data, IS_Data, Receiver); } }
private void SelectFileButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog(); fileDialog.FileName = DateTime.Now.ToString("yyyy-MM") + ".csv"; fileDialog.AddExtension = true; fileDialog.OverwritePrompt = true; fileDialog.RestoreDirectory = false; fileDialog.Filter = "CSV (*.csv)|*.csv|All files (*.*)|*.*"; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) FilenameTextBox.Text = fileDialog.FileName; }
private void ExportButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog(); dialog.Filter = "Sql files(*.sql)|*.sql|All Files (*.*)|*.*"; dialog.Title = "Enter name of file to back up data"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file_name = dialog.FileName; if (Onion.MySQLHandler.MySQLHelper.BackUp(file_name)) MessageBox.Show("Database exported successfully"); } }
public void Save(TestDepthFrame frame) { using (var dialog = new System.Windows.Forms.SaveFileDialog()) { dialog.Filter = this.fileDialogFilter; dialog.FileName = frame.Id + ".xfrm"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { new TestFrameRepository().Save(frame.ToTestDepthFrame(), dialog.FileName); } } }
private void btnExport_Click(object sender, RoutedEventArgs e) { using(SaveFileDialog sf = new SaveFileDialog()) { // todo: localize? sf.Filter = "Registry file (*.reg)|*.reg"; sf.RestoreDirectory = true; DateTime dt = DateTime.Now; sf.FileName = "QTTabBarSettings-" + dt.Year + "-" + dt.Month + "-" + dt.Day + ".reg"; if(DialogResult.OK == sf.ShowDialog()) { RegFileWriter.Export(RegConst.Root, sf.FileName); } } }
public DocumentsPlugin() { state = new DocumentsState(); EventBroker.Subscribe(AppEvents.View, delegate(Document document) { string sourceFilename = ClientState.Current.Storage.ResolvePhysicalFilename(".", document.StreamName); string targetFileName = document.Filename; int i = 0; while (true) { if (i > 0) { targetFileName = String.Format("{0} ({1}){2}", Path.GetFileNameWithoutExtension(document.Filename), i, Path.GetExtension(document.Filename)); } if (File.Exists(Path.Combine(Path.GetTempPath(), targetFileName))) { i++; continue; } break; } var targetFilename = Path.Combine(Path.GetTempPath(), targetFileName); File.Copy(sourceFilename, targetFilename); new Process { StartInfo = new ProcessStartInfo(targetFilename) }.Start(); }); EventBroker.Subscribe(AppEvents.Save, delegate(Document document) { var dialog = new System.Windows.Forms.SaveFileDialog(); dialog.FileName = document.Filename; dialog.Filter = String.Format("{0} files (*.{0})|*.{0}|All files (*.*)|*.*", Path.GetExtension(document.Filename)); var result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string filename = ClientState.Current.Storage.ResolvePhysicalFilename(".", document.StreamName); File.Copy(filename, dialog.FileName); } }); }
private void saveButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog saveLog = new System.Windows.Forms.SaveFileDialog(); saveLog.Filter = "Logging-Files (*.log)|*.log|All files (*.*)|*.*"; saveLog.FilterIndex = 1; saveLog.RestoreDirectory = true; if (saveLog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamWriter sw = new StreamWriter(saveLog.FileName, false, Encoding.Default); sw.Write(textBlock.Text); sw.Flush(); sw.Close(); } }
private void Print_Click(object sender, RoutedEventArgs e) { int width = (int)Chart_P.ActualWidth; int height = (int)Chart_P.ActualHeight; System.Windows.Point position = Chart_P.PointToScreen(new System.Windows.Point(0d, 0d)); System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(/*(int)position.X*/ 0, /*(int)position.Y*/ 0, width, height + 86); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new System.Drawing.Point((int)position.X, (int)position.Y - 36), System.Drawing.Point.Empty, bounds.Size); } System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); //saveFileDialog1.Filter = "JPeg Image|*.jpg"; //saveFileDialog1.Title = "Сохранить график как изображение JPeg"; //saveFileDialog1.ShowDialog(); string imagePath = "hern.jpeg";//saveFileDialog1.FileName; bitmap.Save(imagePath, ImageFormat.Jpeg); Process.Start(imagePath); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { List <BitmapSource> images = new List <BitmapSource>(); foreach (var item in lstImages.Items) { images.Add((BitmapSource)(item as Image).Source); } System.Drawing.Bitmap bmp = MargeImages.Combine(images.ToArray()); // // Open Save Dialog // System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog(); SFD.Title = "Select Save Path"; SFD.DefaultExt = ".png"; SFD.FileName = "ScreenSnips.png"; if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { bmp.Save(SFD.FileName); } }
internal static bool SavePaletteFastLedWithGamma(Palette palette) { System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.DefaultExt = ".h"; sfd.Filter = "Fastled Palette |*.h"; sfd.FileName = palette.Name; sfd.Title = "Save FastLed Color Palette with Gamma correction"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { SaveFastLedPaletteWithGamma(sfd.FileName, palette); sfd.Dispose(); return(true); } catch (Exception ex) { MessageBox.Show(String.Format("{0} {1}", Properties.Resources.PaletteWindow_strErrorSave, ex.Message), "", MessageBoxButton.OK, MessageBoxImage.Error); } } sfd.Dispose(); return(false); }
/// <summary> /// Handles the Click event of the SavePalette control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> void SavePalette_Click(object sender, RoutedEventArgs e) { try { using (System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog()) { save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); save.Filter = "Palette files (*.palette)|*.palette"; save.FilterIndex = 0; save.RestoreDirectory = true; save.OverwritePrompt = true; save.CheckPathExists = true; save.DefaultExt = "palette"; save.AddExtension = true; if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StorePalette(this, save.FileName); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void btnCreateLibrary_Click(object sender, RoutedEventArgs e) { RenameDialog dialog = new RenameDialog(new RenameFields() { Title = Resource.Get("LibraryRename"), Label = Resource.Get("LibraryName"), Rename = Resource.Get("CreateLibrary") }); dialog.Closing += new CancelEventHandler(delegate { if (dialog.Selected) { // Select location System.Windows.Forms.SaveFileDialog fsdialog = new System.Windows.Forms.SaveFileDialog(); if (fsdialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Database db = new Database(); db.Location = fsdialog.FileName; db.Name = dialog.Fields.Value; Manager.Databases.Add(db); } } }); dialog.ShowDialog(); }
public bool SavePackageAs(BaseChangePackage package) { if (package == null) { return(true); } using (var fd = new System.Windows.Forms.SaveFileDialog()) { fd.DefaultExt = "ecp"; fd.Filter = "EZChange Files (*.ecp)|*.ecp|All files (*.*)|*.*"; fd.FilterIndex = 1; if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { package.PackageLocation = fd.FileName; SavePackage(package); return(true); } else { return(false); } } }
public void ImportExcelMethodHandler(object object_0, ImportExcelArgs importExcelArgs_0) { ExcelAccess excelAccess = new ExcelAccess(); excelAccess.Open(); excelAccess.MergeCells(1, 1, 1, this.body_0.Cols); excelAccess.SetFont(1, 1, 1, this.body_0.Cols, this.title_0.Font); excelAccess.SetCellText(1, 1, 1, this.body_0.Cols, this.title_0.Text); excelAccess.SetCellText((DataTable)this.DataSource, 3, 1, true); System.Windows.Forms.FileDialog fileDialog = new System.Windows.Forms.SaveFileDialog(); fileDialog.AddExtension = true; fileDialog.DefaultExt = ".xls"; fileDialog.Title = "保存到Excel文件"; fileDialog.Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls|模板(*.xlt)|*.xlt"; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && excelAccess.SaveAs(fileDialog.FileName, true)) { System.Windows.Forms.MessageBox.Show("数据成功保存到Excel文件!", "JLK.Utility.Excel", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk); } fileDialog.Dispose(); excelAccess.Close(); }
private void Button_Click_3(object sender, RoutedEventArgs e) { string localFilePath = ""; //string localFilePath, fileNameExt, newFileName, FilePath; System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); //设置文件类型 sfd.Filter = "Excel表格(*.xls)|*.xls"; //设置默认文件类型显示顺序 sfd.FilterIndex = 1; //保存对话框是否记忆上次打开的目录 sfd.RestoreDirectory = true; //点了保存按钮进入 if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { localFilePath = sfd.FileName.ToString(); //获得文件路径 string fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1); //获取文件名,不带路径 ExcelUtils.export(localFilePath, memberService.getList(departmentId)); } }
/// <summary> /// Opens standard save dialog and enter the filename with spec extension /// </summary> /// <param name="fileDescription"></param> /// <param name="extension"></param> /// <returns></returns> protected string promptToSaveFile(string fileDescription = "ANNdotNET standard file", string extension = "*.ann") { using (System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog()) { if (string.IsNullOrEmpty(extension)) { dlg.Filter = "Plain text files (*.csv;*.txt;*.dat)|*.csv;*.txt;*.dat |All files (*.*)|*.*"; } else { dlg.Filter = string.Format("{1} ({0})|{0}|All files (*.*)|*.*", extension, fileDescription); } if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(dlg.FileName); } else { return(null); } } }
void server_ReceiveImageEvent(MyImage image) { if (MessageBox.Show(string.Format("{0}给你发送了一张图片:\r\n{1}\r\n是否接收?", "服务器", image.ImageName), "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog(); sd.Title = "请设置保存路劲"; string extension = System.IO.Path.GetExtension(image.ImageName); sd.Filter = string.Format("所发的文件(*{0})|*{0}", extension); this.Dispatcher.Invoke(new Action(() => { if (sd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } FileHelper.SaveFileFromBytes(image.Data, sd.FileName); string msg = string.Format("{0} 接收图片完毕,保存在{1}", DateTime.Now, sd.FileName); UpdateText(msg, Colors.Green, true); })); }
private void SaveSettingsPicon2() { System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.InitialDirectory = this.Config.AllSettingsExportInitialFilePath; sfd.Filter = "Файл настройки Пикон2|*.p2sset"; sfd.Title = "Сохранение настроек \"Пикон2\""; sfd.FileName = "Настройки1"; if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (this.GetAllSettingsPicon2().Save(sfd.FileName)) { this.Config.AllSettingsExportInitialFilePath = sfd.FileName; ShowMessage("Файл сохранен успешно", "Сохранение настроек", MessageBoxImage.Information); } else { ShowMessage("Во время сохранения файла произошла ошибка", "Ошибка сохранения настроек", MessageBoxImage.Error); } uiSaveSettings.IsEnabled = true; }
/// <summary> /// 选择保存文件的名称以及路径 取消返回 空""; /// </summary> /// <param name="fileName"></param> /// <param name="filter"></param> /// <param name="title"></param> /// <returns></returns> public static string SaveFilePathName(string fileName = null, string filter = null, string title = null) { string path = ""; System.Windows.Forms.SaveFileDialog fbd = new System.Windows.Forms.SaveFileDialog(); if (!string.IsNullOrEmpty(fileName)) { fbd.FileName = fileName; } if (!string.IsNullOrEmpty(filter)) { fbd.Filter = filter;// "Excel|*.xls;*.xlsx;"; } if (!string.IsNullOrEmpty(title)) { fbd.Title = title;// "保存为"; } if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = fbd.FileName; } return(path); }
private void FiilSaveAs_Click(object sender, RoutedEventArgs e) { // if (!(sender is System.Windows.Controls.Image image)) return; if (ImgContorl.Source == null) { return; } System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog { Filter = "图像 File|*.BMP|格式|*.JPG|格式|*.JPEG|格式|*.PNG|所有文件|*.*", Title = "保存预览图像", FileName = DateTime.Now.ToLongDateString(), RestoreDirectory = true,//保存对话框是否记忆上次打开的目录 AddExtension = true }; System.Windows.Forms.DialogResult dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { SaveFileAs.Command.Execute(saveFileDialog.FileName); //System.Windows.Media.ImageSource sourceimg = image.Source; } }
public void SaveGame() { using (System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog()) { fileDialog.InitialDirectory = Path.GetFullPath("Content\\"); fileDialog.Filter = "grain sim (*.grain)|*.grain"; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Get the path of specified file string filePath = fileDialog.FileName; gameMap.Save(out ElementID[,] saveP, out float[,] saveT); saveContainer = new SaveContainer(saveP, saveT); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, saveContainer); stream.Close(); } } }
public void SaveColorMap(int subset) { if (subsets[subset].colorMap == null) { System.Windows.Forms.MessageBox.Show("No texture available to save", "Error"); } string texpath = subsets[subset].data.path; if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(texpath))) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(texpath)); } System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.RestoreDirectory = true; sfd.InitialDirectory = System.IO.Path.GetDirectoryName(texpath); sfd.FileName = System.IO.Path.GetFileNameWithoutExtension(texpath) + ".dds"; sfd.Filter = "DirectX surface (*.dds)|*.dds"; if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } TextureLoader.Save(sfd.FileName, ImageFileFormat.Dds, subsets[subset].colorMap); }
/// <summary> /// Save /// </summary> public void Save() { var dlg = new System.Windows.Forms.SaveFileDialog { Filter = FileFilters.TestFileFilter, InitialDirectory = Configuration.TestReportPath, AutoUpgradeEnabled = !SystemParameters.HighContrast, }; dlg.FileName = dlg.InitialDirectory.GetSuggestedFileName(FileType.TestResults); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { SaveAction.SaveSnapshotZip(dlg.FileName, this.ElementContext.Id, null, A11yFileMode.Test); } catch (Exception ex) { MessageDialog.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.SaveException + " " + ex.Message)); } } }
private async void SaveList() { var sfd = new System.Windows.Forms.SaveFileDialog(); sfd.Filter = "M3U list|*.m3u"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { using (var target = File.CreateText(sfd.FileName)) { foreach (var file in List) { target.WriteLine(file); } } } catch (Exception ex) { await _app.ShowMessageBox("Error", ex.Message, DialogButtons.Ok); } } }
private void btnExportIMG_Click(object sender, RoutedEventArgs e) { try { System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog(); SFD.Filter = "PNG files (*.png)|*.png|JPG files (*.jpg)|*.jpg|BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif|All files (*.*)|*.*"; if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BitmapSource BS = (BitmapSource)img.Source; PngBitmapEncoder PBE = new PngBitmapEncoder(); PBE.Frames.Add(BitmapFrame.Create(BS)); using (Stream stream = File.Create(SFD.FileName)) { PBE.Save(stream); } MessageBox.Show("导出成功!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Button_Save_Click(object sender, RoutedEventArgs e) { var saveFile = new System.Windows.Forms.SaveFileDialog(); saveFile.DefaultExt = string.Format("*.{0}", "txt"); saveFile.AddExtension = true; saveFile.Filter = string.Format("{0} files|*.{0}", "txt"); saveFile.OverwritePrompt = true; saveFile.CheckPathExists = true; saveFile.FileName = DateTime.Now.ToString("yyyyMMddhhmmss"); if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { this.WriteTextAsTxt(saveFile.FileName, this.Records); MessageBox.Show("扫码信息导出成功。"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private bool CheckProjectDirectory() { var path = Aphroreader.Properties.Settings.Default.DefaultProjectPath; if (File.Exists(path)) { return(true); } var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var dataDirectory = Path.Combine(appData, "Elgraiv", "Aphroreader"); var newProjectPath = Path.Combine(dataDirectory, "default.aphproj"); if (!Directory.Exists(dataDirectory)) { Directory.CreateDirectory(dataDirectory); } using (var saveDialog = new System.Windows.Forms.SaveFileDialog() { FileName = newProjectPath, Filter = "proj|*.aphproj" }) { var result = saveDialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return(false); } var newPath = saveDialog.FileName; using (var writer = new StreamWriter(newPath)) { writer.Write(JsonConvert.SerializeObject(new Model.AphroreaderProject())); } Aphroreader.Properties.Settings.Default.DefaultProjectPath = newPath; Aphroreader.Properties.Settings.Default.Save(); } return(true); }
private void btnPickFileWrite_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog(); System.Windows.Forms.DialogResult dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { try { System.IO.StreamReader streamReader = new System.IO.StreamReader(readfileName); /* * Loop through file, we are going to pull data for the following: * "city": * "key": * "postal_code": * "team_number": */ String teams = ""; while (!streamReader.EndOfStream) { string line = streamReader.ReadLine(); if (line.Contains("\"city\":")) { //Get rid of front - needed to add 6 to deal with spaces line = line.Remove(0, "\"city\":".Length + 6); //Get rid of ", at the end line = line.Substring(0, line.Length - 3); //MessageBox.Show(line);//troubleshooting teams += line + "\n"; } } MessageBox.Show(teams); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void ExportMethod(ReportType rType) { System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); switch (rType) { case ReportType.PDF: saveFileDialog1.Filter = "Adobe PDF (*.pdf)|*.pdf"; saveFileDialog1.FileName = _report.Report.DisplayName + ".pdf"; break; case ReportType.Excel: saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; saveFileDialog1.FileName = _report.Report.DisplayName + ".xls"; break; case ReportType.Word: saveFileDialog1.Filter = "Microsoft Word (*.doc)|*.doc"; saveFileDialog1.FileName = _report.Report.DisplayName + ".doc"; break; case ReportType.Image: saveFileDialog1.Filter = "Image PNG (*.png)|*.png"; saveFileDialog1.FileName = _report.Report.DisplayName + ".png"; break; } //saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this._report.Path = saveFileDialog1.FileName; this._report.Reporttype = rType; this._report.Print(); } }
/// <summary> /// Save events file /// </summary> public void SaveEvents() { if (this.EventRecorderId != null) { var la = ListenAction.GetInstance(this.EventRecorderId.Value); if (HasRecordedEvents()) { var dlg = new System.Windows.Forms.SaveFileDialog { Filter = FileFilters.EventsFileFilter, InitialDirectory = AppConfiguration.EventRecordPath, AutoUpgradeEnabled = !SystemParameters.HighContrast, }; dlg.FileName = dlg.InitialDirectory.GetSuggestedFileName(FileType.EventRecord); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Logger.PublishTelemetryEvent(TelemetryAction.Event_Save); try { SetupLibrary.FileHelpers.SerializeDataToJSON(this.dgEvents.Items, dlg.FileName); } catch (Exception ex) { ex.ReportException(); MessageDialog.Show(string.Format(CultureInfo.InvariantCulture, "Couldn't save the event record file: {0}", ex.Message)); } } return; } } MessageDialog.Show("There is no event to save."); }
private async void ViewModel_SaveGame(object sender, EventArgs e) { model.PauseGame(); timer.Stop(); korobeiniki?.Stop(); System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog(); fileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string path = fileDialog.FileName; await model.SaveGameAsync(path); if (MessageBox.Show("Game Saved\nPress OK to continue game", "Game Saved", MessageBoxButton.OK) == MessageBoxResult.OK) { model.ContinueGame(); timer.Start(); if (korobeiniki == null) { korobeiniki = new SoundPlayer(@"..\Resources\Korobeiniki.wav"); } korobeiniki?.PlayLooping(); return; } } if (MessageBox.Show("Game Paused\nPress OK to continue game", "Game Paused", MessageBoxButton.OK) == MessageBoxResult.OK) { model.ContinueGame(); timer.Start(); if (korobeiniki == null) { korobeiniki = new SoundPlayer(@"..\Resources\Korobeiniki.wav"); } korobeiniki?.PlayLooping(); return; } }
private void btn_ouput_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog saveFile1 = new System.Windows.Forms.SaveFileDialog(); saveFile1.Filter = "文本文件(.txt)|*.txt"; saveFile1.FilterIndex = 1; if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFile1.FileName.Length > 0) { System.IO.StreamWriter sw = new System.IO.StreamWriter(saveFile1.FileName, false); try { sw.WriteLine("所有报底:"); //只要这里改一下要输出的内容就可以了s var sql = "select * from baowen order by id;"; SqliteHelper sh = new SqliteHelper(); DataTable dt = sh.Select(sql); foreach (DataRow dr in dt.Rows) { //Situation s = new Situation(); //Baowen b = new Baowen(); //b.Id = int.Parse(dr["id"].ToString()); //b.Bw = dr["bw"].ToString(); //b.Pinyin = dr["pinyin"].ToString(); //b.Qianming = dr["qianming"].ToString(); string bw = dr["bw"].ToString(); bw = bw.Replace(" ", ""); sw.WriteLine(int.Parse(dr["id"].ToString()) + "." + bw); } } catch { throw; } finally { sw.Close(); } } }
private void newPlant() { System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); saveFileDialog1.Filter = "ref files (*.ref)|*.ref"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; saveFileDialog1.Title = "Create New Plant"; saveFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + ConfigurationManager.AppSettings["version"] + @"\"; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { TreeViewItem item = (TreeViewItem)navView.Items[0]; //CreatePlant plant = new CreatePlant(); //plant.WindowStartupLocation = WindowStartupLocation.CenterScreen; //if (plant.ShowDialog() == true) //{ string refFile = saveFileDialog1.FileName; int start_idx = refFile.LastIndexOf(@"\") + 1; int end_idx = refFile.LastIndexOf("."); string plantName = refFile.Substring(start_idx, end_idx - start_idx); string folder = Environment.CurrentDirectory + @"\temp\" + plantName; DirectoryInfo dirInfo = System.IO.Directory.CreateDirectory(folder); string templatedb = AppDomain.CurrentDomain.BaseDirectory.ToString() + "template.accdb"; string dbFile = folder + @"\" + dirInfo.Name + ".accdb"; System.IO.File.Copy(templatedb, dbFile, true); CSharpZip.CompressZipFile(folder, refFile); TreeViewItem subitem = GetTreeView(plantName, "images/plant.ico"); subitem.Name = plantName; subitem.Tag = folder; item.Items.Add(subitem); item.ExpandSubtree(); this.leftdockpanel.Visibility = Visibility.Visible; curFolder = folder; curRefFile = refFile; //} } }
private void Export_Click(object sender, RoutedEventArgs e) { using (System.Windows.Forms.SaveFileDialog exportDialog = new System.Windows.Forms.SaveFileDialog()) { exportDialog.Title = "Export"; exportDialog.RestoreDirectory = true; exportDialog.OverwritePrompt = true; exportDialog.AddExtension = true; exportDialog.AutoUpgradeEnabled = true; exportDialog.Filter = "CSV (Comma delimited)|*.csv|Text (Tab delimited)|*.txt|Text (Space delimited)|*.txt"; exportDialog.FileName = "status-history.csv"; if (exportDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && exportDialog.FileName != "") { switch (exportDialog.FilterIndex) { // Note: FilterIndex is not zero-based. The first index is 1. case 1: // CSV. WriteCollectionToFile(filePath: exportDialog.FileName, delimeter: ','); break; case 2: // Tab Delimited. WriteCollectionToFile(filePath: exportDialog.FileName, delimeter: '\t'); break; case 3: // Space delimited. WriteCollectionToFile(filePath: exportDialog.FileName, delimeter: ' '); break; default: break; } } } }
/// <summary> /// Launches OpenFileDialog and allows the user to select an output file /// </summary> /// <returns>The selected filename</returns> private string GetSavedFilenameFromOpenFileDialog() { string filename = null; using (System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog()) { if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dialog.Filter = String.Join("|", this.FileTypes.ToArray()); switch (this.SelectedOutputParserTypeIndex) { // FastQ case 1: dialog.FilterIndex = 1; break; // FastA case 2: dialog.FilterIndex = 2; break; default: dialog.FilterIndex = 0; break; } dialog.CheckFileExists = false; dialog.CheckPathExists = true; dialog.OverwritePrompt = true; filename = dialog.FileNames[0]; } } return(filename); }
// Export/Import Methods public static void ExportAcres(WorldAcre[] acres, SaveGeneration saveGeneration, string saveFileName) { using (var saveDialog = new System.Windows.Forms.SaveFileDialog()) { saveDialog.Filter = "ACSE Acre Save (*.aas)|*.aas"; saveDialog.FileName = saveFileName + " Acre Data.aas"; if (saveDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } try { using (var stream = new FileStream(saveDialog.FileName, FileMode.Create)) { using (var writer = new BinaryWriter(stream)) { writer.Write(new byte[] { 0x41, 0x41, 0x53 }); // "AAS" Identifier writer.Write((byte)acres.Length); // Total Acre Count writer.Write((byte)saveGeneration); // Save Generation writer.Write(new byte[] { 0, 0, 0 }); // Padding foreach (var t in acres) { writer.Write(BitConverter.GetBytes(t.AcreId)); } writer.Flush(); } } } catch { System.Windows.Forms.MessageBox.Show("Acre exportation failed!", "Acre Export Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } }
public void SaveData() { if (this.Items.Count >= 0) { string tmpStr = ""; for (int i = 0; i < this.Items.Count; i++) { for (int j = 0; j < this.Columns.Count; j++) { tmpStr += this.Items[i].SubItems[j].Text + ","; } } System.Windows.Forms.SaveFileDialog o = new System.Windows.Forms.SaveFileDialog(); o.Filter = myFileFilterString; if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(o.FileName, false)) { sw.Write(tmpStr); } } } }