public override void OnExport() { base.OnExport(); ExportDialog frmExport = new ExportDialog(fpView); frmExport.ShowDialog(this); }
private void Export_Click(object sender, EventArgs e) { try { String ExportPath = Path.Combine(ApplicationInfo.ApplicationDocumentPath, "Export"); if (!Directory.Exists(ExportPath)) { Directory.CreateDirectory(ExportPath); } ExportDialog exportDialog = new ExportDialog(new ReportExportInfo() { ReportName = this.ReportCategory.ToString(), ReportFormat = EnumHelper.ExportFormat.HTML.ToString(), FileLocation = ExportPath }); if (exportDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ExportInfo item = new ExportInfo() { ReportDetails = new ReportInfo() { ExportFormat = exportDialog.reportExportInfo.ReportFormat, ReportName = exportDialog.reportExportInfo.ReportName, GeneratorName = "Adminstrator", ProductName = "AMT", ReportDate = DateTime.Now.ToString(), ExportPath = exportDialog.txtLocation.Text }, MachineInfo = wmimachineInfo }; ReportObject.ExportReportData(item); MessageBox.Show("Report exported successfully."); } } catch (Exception ex) { AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error); } }
private void ExportPasswords_Click(object sender, EventArgs e) { if (ExportDialog.ShowDialog() == DialogResult.OK) { passwords.SaveToFile(ExportDialog.FileName); } }
public override void OnExport() { base.OnExport(); ExportDialog frmExport = new ExportDialog(fpInventorySummary); frmExport.ShowDialog(this); }
public override void OnExecute(CommandEventArgs e) { using (ExportDialog dlg = new ExportDialog(e.Context)) { dlg.OriginPath = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)).FullPath; if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } SvnDepth depth = dlg.NonRecursive ? SvnDepth.Empty : SvnDepth.Infinity; e.GetService <IProgressRunner>().RunModal(CommandStrings.Exporting, delegate(object sender, ProgressWorkerArgs wa) { SvnExportArgs args = new SvnExportArgs(); args.Depth = depth; args.Revision = dlg.Revision; args.Overwrite = true; wa.Client.Export(dlg.ExportSource, dlg.LocalPath, args); }); } }
private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { using (var dialog = new ExportDialog(this._annotationPackageProvider)) { dialog.StartPosition = FormStartPosition.CenterParent; dialog.ShowDialog(this); } }
private void OnExportAction() { string key = GetSelectedKey(); ExportDialog dialog = new ExportDialog(); dialog.cmbBranch.Text = key; dialog.ShowDialog(this); }
/// <summary> /// コンストラクタ /// </summary> public MainWindow() { // ダイアログ表示時、タイトルバーをドラッグしてウィンドウを動かせなくなるので、 // ウィンドウ全体で左クリックで移動できるようにする DialogManager.DialogOpened += (s, e) => { this.MouseLeftButtonDown += this.MouseLeftButtonDownWindowMove; }; // ダイアログを閉じているときは移動させない DialogManager.DialogClosed += (s, e) => { this.MouseLeftButtonDown -= this.MouseLeftButtonDownWindowMove; }; this.DataContextChanged += (s, e) => { var model = e.NewValue as MainWindowViewModel; if (model != null) { model.SaveDialogViewAction = this.SaveDialog; model.OpenDialogViewAction = this.OpenDialog; model.ExportDialogViewAction = this.ShowExportDialog; this.Export = model.Export; } }; #region ExportDialog this.ExportDialog = new ExportDialog(); this.ExportDialog.DataContext = new ExportDialogViewModel(() => this.HideMetroDialogAsync(this.ExportDialog)); this.ExportDialog.Excute.Subscribe(m => { this.MouseLeftButtonDown -= this.MouseLeftButtonDownWindowMove; if (m != null) { this.Export(m); } }); #endregion ExportDialog InitializeComponent(); #region PanelSize var config = ConfigManager.Current.Config; this._EditorGrid.ColumnDefinitions[0].Width = new GridLength(config.LeftPanelWidth, GridUnitType.Star); this._EditorGrid.RowDefinitions[0].Height = new GridLength(config.TopPanelHeight, GridUnitType.Star); this._EditorGrid.RowDefinitions[4].Height = new GridLength(config.BottomPanelHeight, GridUnitType.Star); this._EditorGrid.ColumnDefinitions[2].Width = new GridLength(config.MainPanelWidth, GridUnitType.Star); this._EditorGrid.RowDefinitions[2].Height = new GridLength(config.MainPanelHeight, GridUnitType.Star); this._MainGrid.ColumnDefinitions[0].Width = new GridLength(config.NodePanelWidth, GridUnitType.Star); this._MainGrid.ColumnDefinitions[2].Width = new GridLength(config.LeftPanelWidth + config.MainPanelWidth, GridUnitType.Star); #endregion PanelSize }
private void ExportMany(OneNote one, List <string> pageIDs) { OneNote.ExportFormat format; string path; using (var dialog = new ExportDialog(pageIDs.Count)) { if (dialog.ShowDialog(owner) != DialogResult.OK) { return; } path = dialog.FolderPath; format = dialog.Format; } string ext = null; switch (format) { case OneNote.ExportFormat.HTML: ext = ".htm"; break; case OneNote.ExportFormat.PDF: ext = ".pdf"; break; case OneNote.ExportFormat.Word: ext = ".docx"; break; case OneNote.ExportFormat.XML: ext = ".xml"; break; } string formatName = format.ToString(); using (var progress = new ProgressDialog()) { progress.SetMaximum(pageIDs.Count); progress.Show(owner); foreach (var pageID in pageIDs) { var page = one.GetPage(pageID); var filename = Path.Combine(path, page.Title.Replace(' ', '_') + ext); progress.SetMessage(filename); progress.Increment(); if (format == OneNote.ExportFormat.XML) { SaveAsXML(page.Root, filename); } else { SaveAs(one, page.PageId, filename, format, formatName); } } } UIHelper.ShowMessage(string.Format(Resx.SaveAsMany_Success, pageIDs.Count, path)); }
private void ExportResultsStripMenuItem_Click(object?sender, EventArgs e) { exportResultsStripMenuItem.Enabled = false; calculateStripMenuItem.Enabled = false; if (saveFileDialog.ShowDialog() is not DialogResult.OK || DataToExport is null || LastCalculatedResults is null) { return; } string filePath = saveFileDialog.FileName; var discreteOutputParameters = new Dictionary <string, IList <Parameter> >(); discreteOutputParameters.Add("Производительность канала", new[] { new Parameter(null, canalProductivityOutput.ParameterName, string.Empty, canalProductivityOutput.MeasureUnit, canalProductivityOutput.Value) }); discreteOutputParameters.Add("Показатели качества", new List <ParameterOutput> { productTemperatureOutput, productViscosityOutput } .Select(po => new Parameter(null, po.ParameterName, string.Empty, po.MeasureUnit, po.Value)).ToArray()); DataToExport.DiscreteOutputParameters = discreteOutputParameters; DataToExport.ContiniousResults = LastCalculatedResults.ResultsTable .Select(t => (new Parameter(null, "Координата по длине канала", string.Empty, "м", t.coordinate), new Parameter(null, "Температура", string.Empty, "°C", t.tempreture), new Parameter(null, "Вязкость", string.Empty, "Па⋅c", t.viscosity))).ToArray(); var exportDialog = new ExportDialog(); exportDialog.GetExportStatusAsync += async() => { bool success; try { success = await ExportToFileAsync !.Invoke(DataToExport, filePath); } catch { success = false; } if (success is true) { return(ExportStatus.FinishedSuccessfully); } else { return(ExportStatus.FinishedWithError); } }; exportDialog.Show(); exportResultsStripMenuItem.Enabled = true; calculateStripMenuItem.Enabled = true; }
private void Export() { var manager = new ExportManager { SetWaiting = status => Waiting = status }; var dialog = new ExportDialog(manager); dialog.Show(); }
public void ExportToServer(object sender, ExecutedRoutedEventArgs e) { try { var databaseInfo = ValidateMenuInfo(sender); if (databaseInfo == null) { return; } #if SSMS var connStr = DataConnectionHelper.PromptForConnectionString(package); if (string.IsNullOrEmpty(connStr)) { return; } var targetInfo = new DatabaseInfo { DatabaseType = DatabaseType.SQLServer, ConnectionString = connStr }; #else var databaseList = DataConnectionHelper.GetDataConnections(package, includeServerConnections: true, serverConnectionsOnly: true); var cd = new ExportDialog(databaseList); var result = cd.ShowModal(); if (!result.HasValue || result.Value != true || (cd.TargetDatabase.Key == null)) { return; } var targetInfo = cd.TargetDatabase.Value; #endif var bw = new BackgroundWorker(); var parameters = new List <object> { databaseInfo.DatabaseInfo, targetInfo }; bw.DoWork += bw_DoExportWork; bw.RunWorkerCompleted += (s, ea) => { try { if (ea.Error != null) { DataConnectionHelper.SendError(ea.Error, databaseInfo.DatabaseInfo.DatabaseType, false); } DataConnectionHelper.LogUsage("DatabasesExportToServer"); } finally { bw.Dispose(); } }; bw.RunWorkerAsync(parameters); } catch (Exception ex) { DataConnectionHelper.SendError(ex, DatabaseType.SQLServer); } }
protected virtual void OnExportActionActivated(object sender, System.EventArgs e) { ExportDialog dlg = new ExportDialog(); if (dlg.Run() == (int)ResponseType.Ok) { m_GeneratorController.Export(dlg.GetExporter(), dlg.GetFilename()); } dlg.Destroy(); }
public override bool Load() { dataBook = (DataBook)GetDataBook(mainWindow); AddMenuItems(uiManager); dataBook.PageRemoved += new DataView.DataViewEventHandler(OnDataViewRemoved); dataBook.SwitchPage += new SwitchPageHandler(OnSwitchPage); exportDialog = new ExportDialog(dataBook, mainWindow); loaded = true; return(true); }
public void ExportAllToExcelCommandExecuted() { ExportViewModel exportViewModel = new ExportViewModel(); var exportDialog = new ExportDialog { DataContext = exportViewModel }; if (exportDialog.ShowDialog() == true) { var exporter = new ExcelExporter(this.Tabs[selectedTabIndex]); exporter.SaveTo(exportViewModel.FilePath); } }
private void btnExportLibrary_Click(object sender, RoutedEventArgs e) { //System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog(); //dialog.CheckPathExists = true; //dialog.OverwritePrompt = true; //dialog.AutoUpgradeEnabled = true; //dialog.DefaultExt = ".xls"; //dialog.Title = Resource.Get("ExportTitle"); //if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) // Database.ExportToExcel(dialog.FileName); ExportDialog dialog = new ExportDialog(); dialog.ExportClick += new ExportHandler(ExportLibrary); dialog.ShowDialog(); }
private void ExportCost() { try { InventoryOnhandController ctlInvent = new InventoryOnhandController(); if (shtView.Rows.Count == 0) { return; } int row = shtView.Rows.Count; //int rowfilter= shtView.RowFilter.SheetView.Rows.Count; List <string> ItemCodes = new List <string>(); for (int i = 0; i < row; i++) { if (shtView.Cells[i, (int)eColView.ITEM_CODE].Value != null) { if (!ItemCodes.Contains(shtView.Cells[i, (int)eColView.ITEM_CODE].Value.ToString())) { ItemCodes.Add(shtView.Cells[i, (int)eColView.ITEM_CODE].Value.ToString()); } } } DataTable dtCostView = ctlInvent.GetCostView(ItemCodes); if (dtCostView == null) { return; } FarPoint.Win.Spread.FpSpread fpCost = new FarPoint.Win.Spread.FpSpread(); FarPoint.Win.Spread.SheetView shtCost = new FarPoint.Win.Spread.SheetView(); shtCost.DataSource = dtCostView; shtCost.Columns[0].CellType = CtrlUtil.CreateDateTimeCellType(); fpCost.Sheets.Add(shtCost); ExportDialog frmExport = new ExportDialog(fpCost); frmExport.DefaultExcel_Filename = Environment.CurrentDirectory + "\\Cost View.xls"; //frmExport.de frmExport.ShowDialog(this); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
private void btnExport_Click(object sender, EventArgs e) { var exportDlg = new ExportDialog(AppSettings.CsvExportPath, AppSettings.CsvExportItems); DialogResult result = exportDlg.ShowDialog(this); if (result != DialogResult.OK) { return; } // save settings AppSettings.CsvExportPath = exportDlg.ExportPath; AppSettings.CsvExportItems = exportDlg.ItemsToExport; // perform export for user StartExport(exportDlg.ItemsToExport); }
private void tsbExport_Click(object sender, EventArgs e) { if (ExportGrid != null) { if (ExportGrid.Rows.Count > 0) { try { using (ExportDialog expDlg = new ExportDialog(ExportGrid)) { expDlg.ShowDialog(this); } } catch (Exception ex) { rMessageBox.ShowException(this, ex); } } else { rMessageBox.ShowInfomation(this, MessageCode.INF0001); } } }
public override void Execute() { // make sure only one image is visible if (models.NumEnabled != 1) { models.Window.ShowErrorDialog("Exactly one image equation should be visible when exporting."); return; } // get active final image var id = models.GetFirstEnabledPipeline(); var tex = models.Pipelines[id].Image; if (tex == null) { return; // not yet computed? } float multiplier = 1.0f; // ReSharper disable once CompareOfFloatsByEqualityOperator if (models.Display.Multiplier != 1.0f) { if (models.Window.ShowYesNoDialog( $"Color multiplier is currently set to {models.Display.MultiplierString}. Do you want to include the multiplier in the export?", "Keep Color Multiplier?")) { multiplier = models.Display.Multiplier; } } // set proposed filename var firstImageId = models.Pipelines[id].Color.FirstImageId; var firstImage = models.Images.Images[firstImageId].Filename; var proposedFilename = System.IO.Path.GetFileNameWithoutExtension(firstImage); // set or keep export directory var exportDirectory = GetExportDirectory(firstImage); if (exportExtension == null) { exportExtension = System.IO.Path.GetExtension(firstImage); if (exportExtension != null && exportExtension.StartsWith(".")) { exportExtension = exportExtension.Substring(1); } } if (exportFormat == null) { exportFormat = models.Images.Images[firstImageId].OriginalFormat; } // open save file dialog Debug.Assert(exportDirectory != null); Debug.Assert(proposedFilename != null); var sfd = new SaveFileDialog { Filter = GetFilter(exportExtension, tex.Is3D), InitialDirectory = exportDirectory, FileName = proposedFilename }; if (sfd.ShowDialog(models.Window.TopmostWindow) != true) { return; } exportExtension = System.IO.Path.GetExtension(sfd.FileName).Substring(1); var exportFilename = System.IO.Path.GetFileNameWithoutExtension(sfd.FileName); exportDirectory = System.IO.Path.GetDirectoryName(sfd.FileName); SetExportDirectory(exportDirectory); models.Export.Mipmap = models.Display.ActiveMipmap; models.Export.Layer = models.Display.ActiveLayer; var viewModel = new ExportViewModel(models, exportExtension, exportFormat.Value, sfd.FileName, tex.Is3D, models.Statistics[id].Stats); var dia = new ExportDialog(viewModel); if (models.Window.ShowDialog(dia) != true) { return; } var desc = new ExportDescription(exportDirectory + "/" + exportFilename, exportExtension, models.Export); desc.TrySetFormat(viewModel.SelectedFormatValue); desc.Multiplier = multiplier; exportFormat = desc.FileFormat; models.Export.ExportAsync(tex, desc); }
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { ExportDialog.ShowDialog(); }
private void ExpBtn_Click(object sender, EventArgs e) { String FName = ""; long RecNo = 1; try { StatusLabel.Text = Localizate.getMessage(Word.PLEASE_WAIT); FileNameCombo.Enabled = false; Enabled = false; if (DatDatas.Count == 0) { StatusLabel.Text = Localizate.getMessage(Word.ERROR) + Localizate.getMessage(Word.SYSTEM_FOLDER_IS_EMPTY); return; } ExportDialog.InitialDirectory = Application.StartupPath; ExportDialog.FileName = selectedComboName.Substring(0, selectedComboName.LastIndexOf(".")); ExportDialog.Filter = "Tab-SeparatedValues files (*.tsv)|*.tsv"; ExportDialog.FilterIndex = 1; ExportDialog.RestoreDirectory = true; if (ExportDialog.ShowDialog() == DialogResult.OK) { Encoding enc = Encoding.GetEncoding(RConfig.Instance.TextEncoding); var sr = new StreamWriter(ExportDialog.FileName, false, enc); // Write Headers sr.Write("# "); for (int i = 0; i < DatInfo.getFieldNames().Count; i++) { Definition info = DatDatas[0]; FName = DatInfo.getFieldNames()[i]; FieldInfo FType = DatInfo.getDefinition().GetType().GetField(FName); if (FType == null) { continue; } Object obj = FType.GetValue(info); if (obj == null) { continue; } if (obj is IType) { var type = (IType)obj; type.writeHeader(FName, sr); } else { throw new NotImplementedException("Type " + obj.GetType().Name + " is not implement IType"); } } sr.Write("\r\n"); onStart(DatDatas.Count); // Write Datas for (int i = 0; i < DatDatas.Count; i++) { Definition info = DatDatas[i]; for (int j = 0; j < DatInfo.getFieldNames().Count; j++) { FName = DatInfo.getFieldNames()[j]; FieldInfo FType = DatInfo.getDefinition().GetType().GetField(FName); if (FType == null) { continue; } String TmpStr = ""; if (FType.GetValue(info) != null) { Object obj = FType.GetValue(info); if (obj is IType) { var type = (IType)obj; TmpStr = type.ToString(); } else { throw new NotImplementedException("Type " + obj.GetType().Name + " is not implement IType"); } sr.Write(TmpStr); if (j < DatInfo.getFieldNames().Count - 1) { sr.Write('\t'); } } } sr.Write("\r\n"); setValue(i); RecNo++; } sr.Close(); } else { return; } } catch (Exception ex) { _log.Info("Exception: " + ex, ex); } finally { Enabled = true; FileNameCombo.Enabled = true; onEnd(); } StatusLabel.Text = Localizate.getMessage(Word.COMPLETE) + String.Format(Localizate.getMessage(Word.EXPORTED_DATA), DatDatas.Count); }
protected void OnExportButtonClick(object sender, EventArgs e) { ExportDialog export = new ExportDialog(); export.ShowModalAsync(this); }
private void ExportConfig_Click(object sender, EventArgs e) { try { if (ExportDialog.ShowDialog() == DialogResult.OK) { StringBuilder SettingsToText = new StringBuilder(); SettingsToText.AppendLine(String.Format("ConfName = {0}", Path.GetFileNameWithoutExtension(ExportDialog.FileName))); SettingsToText.AppendLine(); SettingsToText.AppendLine("// Banks"); SettingsToText.AppendLine(String.Format("BC1 = {0}", BC1.Value)); SettingsToText.AppendLine(String.Format("BC2 = {0}", BC2.Value)); SettingsToText.AppendLine(String.Format("BC3 = {0}", BC3.Value)); SettingsToText.AppendLine(String.Format("BC4 = {0}", BC4.Value)); SettingsToText.AppendLine(String.Format("BC5 = {0}", BC5.Value)); SettingsToText.AppendLine(String.Format("BC6 = {0}", BC6.Value)); SettingsToText.AppendLine(String.Format("BC7 = {0}", BC7.Value)); SettingsToText.AppendLine(String.Format("BC8 = {0}", BC8.Value)); SettingsToText.AppendLine(String.Format("BC9 = {0}", BC9.Value)); SettingsToText.AppendLine(String.Format("BCD = {0}", BCD.Value)); SettingsToText.AppendLine(String.Format("BC11 = {0}", BC11.Value)); SettingsToText.AppendLine(String.Format("BC12 = {0}", BC12.Value)); SettingsToText.AppendLine(String.Format("BC13 = {0}", BC13.Value)); SettingsToText.AppendLine(String.Format("BC14 = {0}", BC14.Value)); SettingsToText.AppendLine(String.Format("BC15 = {0}", BC15.Value)); SettingsToText.AppendLine(String.Format("BC16 = {0}", BC16.Value)); SettingsToText.AppendLine(); SettingsToText.AppendLine("// Presets"); SettingsToText.AppendLine(String.Format("PC1 = {0}", PC1.Value)); SettingsToText.AppendLine(String.Format("PC2 = {0}", PC2.Value)); SettingsToText.AppendLine(String.Format("PC3 = {0}", PC3.Value)); SettingsToText.AppendLine(String.Format("PC4 = {0}", PC4.Value)); SettingsToText.AppendLine(String.Format("PC5 = {0}", PC5.Value)); SettingsToText.AppendLine(String.Format("PC6 = {0}", PC6.Value)); SettingsToText.AppendLine(String.Format("PC7 = {0}", PC7.Value)); SettingsToText.AppendLine(String.Format("PC8 = {0}", PC8.Value)); SettingsToText.AppendLine(String.Format("PC9 = {0}", PC9.Value)); SettingsToText.AppendLine(String.Format("PCD = {0}", PCD.Value)); SettingsToText.AppendLine(String.Format("PC11 = {0}", PC11.Value)); SettingsToText.AppendLine(String.Format("PC12 = {0}", PC12.Value)); SettingsToText.AppendLine(String.Format("PC13 = {0}", PC13.Value)); SettingsToText.AppendLine(String.Format("PC14 = {0}", PC14.Value)); SettingsToText.AppendLine(String.Format("PC15 = {0}", PC15.Value)); SettingsToText.AppendLine(String.Format("PC16 = {0}", PC16.Value)); File.WriteAllText(ExportDialog.FileName, SettingsToText.ToString()); MessageBox.Show( String.Format("The setting file \"{0}\" has been saved to:\n\n{1}", Path.GetFileNameWithoutExtension(ExportDialog.FileName), ExportDialog.FileName), "Keppy's Synthesizer - Export settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { // Something bad happened hehe MessageBox.Show( "Fatal error", String.Format("Fatal error during the execution of the program.\n\nPress OK to quit.\n\nException:\n{0}", ex.ToString()), MessageBoxButtons.OK, MessageBoxIcon.Error ); Application.Exit(); } }
public override async void Execute() { // make sure only one image is visible if (models.NumEnabled != 1) { models.Window.ShowErrorDialog("Exactly one image equation should be visible when exporting."); return; } // get active final image var id = models.GetFirstEnabledPipeline(); var tex = models.Pipelines[id].Image; if (tex == null) { return; // not yet computed? } float multiplier = 1.0f; // ReSharper disable once CompareOfFloatsByEqualityOperator if (models.Display.Multiplier != 1.0f) { if (models.Window.ShowYesNoDialog( $"Color multiplier is currently set to {models.Display.MultiplierString}. Do you want to include the multiplier in the export?", "Keep Color Multiplier?")) { multiplier = models.Display.Multiplier; } } // set proposed filename var firstImageId = models.Pipelines[id].Color.FirstImageId; var firstImage = models.Images.Images[firstImageId].Filename; var proposedFilename = System.IO.Path.GetFileNameWithoutExtension(firstImage); // set or keep export directory var exportDirectory = GetExportDirectory(firstImage); if (exportExtension == null) { exportExtension = System.IO.Path.GetExtension(firstImage); if (exportExtension != null && exportExtension.StartsWith(".")) { exportExtension = exportExtension.Substring(1); } } if (exportFormat == null) { exportFormat = models.Images.Images[firstImageId].OriginalFormat; } // open save file dialog Debug.Assert(exportDirectory != null); Debug.Assert(proposedFilename != null); var sfd = new SaveFileDialog { Filter = GetFilter(exportExtension, tex.Is3D), InitialDirectory = exportDirectory, FileName = proposedFilename }; if (sfd.ShowDialog(models.Window.TopmostWindow) != true) { return; } exportExtension = System.IO.Path.GetExtension(sfd.FileName).Substring(1); var exportFilename = System.IO.Path.GetFileNameWithoutExtension(sfd.FileName); exportDirectory = System.IO.Path.GetDirectoryName(sfd.FileName); SetExportDirectory(exportDirectory); var viewModel = new ExportViewModel(models, exportExtension, exportFormat.Value, sfd.FileName, tex.Is3D, models.Statistics[id].Stats); var dia = new ExportDialog(viewModel); if (models.Window.ShowDialog(dia) != true) { return; } var desc = new ExportDescription(tex, exportDirectory + "/" + exportFilename, exportExtension) { Multiplier = multiplier, Mipmap = models.ExportConfig.Mipmap, Layer = models.ExportConfig.Layer, UseCropping = models.ExportConfig.UseCropping, CropStart = models.ExportConfig.CropStart, CropEnd = models.ExportConfig.CropEnd, Overlay = models.Overlay.Overlay }; desc.TrySetFormat(viewModel.SelectedFormatValue); exportFormat = desc.FileFormat; models.Export.ExportAsync(desc); // export additional zoom boxes? if (viewModel.HasZoomBox && viewModel.ExportZoomBox) { for (int i = 0; i < models.ZoomBox.Boxes.Count; ++i) { var box = models.ZoomBox.Boxes[i]; var zdesc = new ExportDescription(tex, $"{exportDirectory}/{exportFilename}_zoom{i}", exportExtension) { Multiplier = multiplier, Mipmap = models.ExportConfig.Mipmap, Layer = models.ExportConfig.Layer, UseCropping = true, CropStart = new Float3(box.Start, 0.0f), CropEnd = new Float3(box.End, 1.0f), Overlay = viewModel.ZoomBorders ? models.Overlay.Overlay : null, Scale = viewModel.ZoomBoxScale }; zdesc.TrySetFormat(viewModel.SelectedFormatValue); await models.Progress.WaitForTaskAsync(); models.Export.ExportAsync(zdesc); } } }
// xml запись сцены в файл private void ExportScene_Click(object sender, EventArgs e) { if (ExportDialog.ShowDialog() == DialogResult.OK) { try { IFormatProvider format = new System.Globalization.CultureInfo("en-us"); XDocument document = new XDocument(); XElement scene = new XElement("scene"); scene.SetAttributeValue("ViewMode", Scene.Mode); var camera = Scene.Camera; XElement cameraElement = new XElement("camera"); cameraElement.SetElementValue("central-projection", camera.IsCentralProjection); XElement position = new XElement("position"); position.SetAttributeValue("x", string.Format(format, "{0:0.00}", camera.Position.X)); position.SetAttributeValue("y", string.Format(format, "{0:0.00}", camera.Position.Y)); position.SetAttributeValue("z", string.Format(format, "{0:0.00}", camera.Position.Z)); cameraElement.Add(position); XElement target = new XElement("target"); target.SetAttributeValue("x", string.Format(format, "{0:0.00}", camera.Target.X)); target.SetAttributeValue("y", string.Format(format, "{0:0.00}", camera.Target.Y)); target.SetAttributeValue("z", string.Format(format, "{0:0.00}", camera.Target.Z)); cameraElement.Add(target); XElement clippingplanes = new XElement("clipping-planes"); clippingplanes.SetAttributeValue("near", camera.NearClipZ); clippingplanes.SetAttributeValue("far", camera.FarClipZ); cameraElement.Add(clippingplanes); cameraElement.SetElementValue("fov", camera.FOV); scene.Add(cameraElement); var light = Scene.Light; XElement lightElement = new XElement("light"); XElement lightPosition = new XElement("position"); lightPosition.SetAttributeValue("x", string.Format(format, "{0:0.00}", light.X)); lightPosition.SetAttributeValue("y", string.Format(format, "{0:0.00}", light.Y)); lightPosition.SetAttributeValue("z", string.Format(format, "{0:0.00}", light.Z)); lightElement.Add(lightPosition); scene.Add(lightElement); XElement objects = new XElement("objects"); foreach (TelescopeObject radio in Scene.Objects) { XElement objectelement; objectelement = new XElement("Telescope"); objectelement.SetElementValue("Basis1CylinderRadius", string.Format(format, "{0:0.00}", radio.Basis1CylinderRadius)); objectelement.SetElementValue("PrimaryLegsLength", string.Format(format, "{0:0.00}", radio.PrimaryLegsLength)); objectelement.SetElementValue("Basis2CylinderRadius", string.Format(format, "{0:0.00}", radio.Basis2CylinderRadius)); objectelement.SetElementValue("Basis3CylinderRadius", string.Format(format, "{0:0.00}", radio.Basis3CylinderRadius)); objectelement.SetElementValue("LenseRadius", string.Format(format, "{0:0.00}", radio.LenseRadius)); objectelement.SetElementValue("SecondaryLegsLength", string.Format(format, "{0:0.00}", radio.SecondaryLegsLength)); objectelement.SetElementValue("PrimaryLegsCount", string.Format(format, "{0:0.00}", radio.PrimaryLegsCount)); objectelement.SetElementValue("SecondaryLegsCount", string.Format(format, "{0:0.00}", radio.SecondaryLegsCount)); objectelement.SetElementValue("HandsCount", radio.HandsCount); objectelement.SetElementValue("HandsRadius", radio.HandsRadius); objectelement.SetAttributeValue("name", radio.ObjectName); XElement objectposition = new XElement("position"); objectposition.SetAttributeValue("x", string.Format(format, "{0:0.00}", radio.BasePoint.X)); objectposition.SetAttributeValue("y", string.Format(format, "{0:0.00}", radio.BasePoint.Y)); objectposition.SetAttributeValue("z", string.Format(format, "{0:0.00}", radio.BasePoint.Z)); objectelement.Add(objectposition); XElement objectrotate = new XElement("rotate"); objectrotate.SetAttributeValue("x", radio.AngleX); objectrotate.SetAttributeValue("y", radio.AngleY); objectrotate.SetAttributeValue("z", radio.AngleZ); objectelement.Add(objectrotate); XElement objectscale = new XElement("scale"); objectscale.SetAttributeValue("x", string.Format(format, "{0:0.00}", radio.ScaleX)); objectscale.SetAttributeValue("y", string.Format(format, "{0:0.00}", radio.ScaleY)); objectscale.SetAttributeValue("z", string.Format(format, "{0:0.00}", radio.ScaleZ)); objectelement.Add(objectscale); objects.Add(objectelement); } scene.Add(objects); document.Add(scene); document.Save(ExportDialog.FileName); } catch (Exception) { MessageBox.Show("Не получается экспортировать сцену!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; DestinationPath = string.Empty; Documents = new List <string>(); Splash = string.Empty; Errors = new List <string[]>(); string date = DateTime.Now.ToString("dd/MM/yyyy"); int completed = 0; int failed = 0; ExportDialog exportdialog = new ExportDialog(); System.Windows.Forms.DialogResult dialog = exportdialog.ShowDialog(); if (dialog != System.Windows.Forms.DialogResult.OK) { return(Result.Cancelled); } WorksetConfiguration openconfig = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets); OpenOptions openoptions = new OpenOptions(); openoptions.SetOpenWorksetsConfiguration(openconfig); if (exportdialog.DiscardRadioButton.Checked) { openoptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets; } else { openoptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets; } SaveAsOptions worksharedsaveas = new SaveAsOptions(); WorksharingSaveAsOptions saveConfig = new WorksharingSaveAsOptions { SaveAsCentral = true }; worksharedsaveas.SetWorksharingOptions(saveConfig); worksharedsaveas.OverwriteExistingFile = true; SaveAsOptions regularsaveas = new SaveAsOptions { OverwriteExistingFile = true }; if (exportdialog.AuditCheckBox.Checked) { openoptions.Audit = true; } if (exportdialog.SafeNameTextbox.Text.Trim() != string.Empty) { Splash = exportdialog.SafeNameTextbox.Text.Trim(); } string customdate = exportdialog.DateTimePickerIssue.Value.ToString("yyyy/MM/dd"); string nameprefix = exportdialog.PrefixTextBox.Text.Trim(); string namesuffix = exportdialog.SuffixTextBox.Text.Trim(); bool samepath = false; List <string[]> results = new List <string[]>(); foreach (string path in Documents) { string destdoc = nameprefix + Path.GetFileNameWithoutExtension(path) + namesuffix + ".rvt"; if (File.Exists(DestinationPath + destdoc)) { samepath = true; break; } string pathonly = Path.GetDirectoryName(path) + "\\"; if (pathonly == DestinationPath) { samepath = true; break; } } if (samepath) { TaskDialog td = new TaskDialog("Export") { MainInstruction = "Some documents already exist in the destination path.", MainContent = "The files will be overritten, do you wish to continue?" }; td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Continue"); td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Cancel"); switch (td.Show()) { case TaskDialogResult.CommandLink1: break; case TaskDialogResult.CommandLink2: return(Result.Cancelled); default: return(Result.Cancelled); } } uiapp.DialogBoxShowing += new EventHandler <DialogBoxShowingEventArgs>(OnDialogBoxShowing); uiapp.Application.FailuresProcessing += FailureProcessor; DateTime start = DateTime.Now; foreach (string path in Documents) { string[] result = new string[6]; string resultmessage = string.Empty; if (!File.Exists(path)) { result[0] = Path.GetFileName(path); result[1] = "File Not Found"; result[2] = string.Empty; results.Add(result); failed++; continue; } DateTime s1 = DateTime.Now; Document doc = null; //try //{ doc = uiapp.Application.OpenDocumentFile(ModelPathUtils.ConvertUserVisiblePathToModelPath(path), openoptions); string docname = nameprefix + Path.GetFileNameWithoutExtension(path) + namesuffix; using (Transaction t = new Transaction(doc, "Export")) { t.Start(); if (exportdialog.AutoCheckBox.Checked) { doc.ProjectInformation.IssueDate = date; } else { doc.ProjectInformation.IssueDate = customdate; } if (exportdialog.RemoveCADLinksCheckBox.Checked) { DeleteCADLinks(doc); } if (exportdialog.RemoveCADImportsCheckBox.Checked) { DeleteCADImports(doc); } if (exportdialog.RemoveRVTLinksCheckBox.Checked) { DeleteRVTLinks(doc); } DeleteViewsAndSheets(doc, exportdialog.ViewsONSheetsCheckBox.Checked, exportdialog.ViewsNOTSheetsCheckBox.Checked, exportdialog.SheetsCheckBox.Checked, exportdialog.TemplatesCheckBox.Checked); if (exportdialog.RemoveSchedulesCheckBox.Checked) { DeleteSchedules(doc); } if (exportdialog.UngroupCheckBox.Checked) { UngroupGroups(doc); } if (exportdialog.PurgeCheckBox.Checked) { PurgeDocument(doc); } t.Commit(); } if (doc.IsWorkshared) { doc.SaveAs(DestinationPath + docname + ".rvt", worksharedsaveas); } else { doc.SaveAs(DestinationPath + docname + ".rvt", regularsaveas); } doc.Close(false); string backupfolder = DestinationPath + docname + "_backup"; string tempfolder = DestinationPath + "Revit_temp"; if (Directory.Exists(backupfolder)) { Directory.Delete(backupfolder, true); } if (Directory.Exists(tempfolder)) { Directory.Delete(tempfolder, true); } resultmessage = "Completed"; completed++; //} // catch (Exception e) //{ // try // { // doc.Close(false); // } // catch { } // resultmessage = e.Message; // failed++; //} DateTime e1 = DateTime.Now; int h = (e1 - s1).Hours; int m = (e1 - s1).Minutes; int s = (e1 - s1).Seconds; result[0] = Path.GetFileName(path); result[1] = resultmessage; result[2] = h.ToString() + ":" + m.ToString() + ":" + s.ToString(); results.Add(result); } uiapp.DialogBoxShowing -= OnDialogBoxShowing; uiapp.Application.FailuresProcessing -= FailureProcessor; DateTime end = DateTime.Now; int hours = (end - start).Hours; int minutes = (end - start).Minutes; int seconds = (end - start).Seconds; TaskDialog rd = new TaskDialog("Export") { MainInstruction = "Results", MainContent = "Exported to: " + DestinationPath + "\n" + "Completed: " + completed.ToString() + "\nFailed: " + failed.ToString() + "\nTotal Time: " + hours.ToString() + " h " + minutes.ToString() + " m " + seconds.ToString() + " s" }; rd.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Close"); rd.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Show Details"); switch (rd.Show()) { case TaskDialogResult.CommandLink1: return(Result.Succeeded); case TaskDialogResult.CommandLink2: ResultsDialog resultsdialog = new ResultsDialog(); foreach (string[] r in results) { var item = new System.Windows.Forms.ListViewItem(r); resultsdialog.ResultsView.Items.Add(item); } var rdialog = resultsdialog.ShowDialog(); return(Result.Succeeded); default: return(Result.Succeeded); } }
public void Execute(object parameter) { if (models.Images.NumImages == 0) { return; } // make sure only one image is visible if (models.Equations.NumVisible != 1) { App.ShowInfoDialog(models.App.Window, "Exactly one image equation should be visible when exporting."); return; } // get active final image var equationId = models.Equations.GetFirstVisible(); var firstImageId = models.Equations.Get(equationId).ColorFormula.FirstImageId; var proposedFilename = firstImageId < models.Images.NumImages ? System.IO.Path.GetFileNameWithoutExtension(models.Images.GetFilename(firstImageId)) : ""; // open save file dialog var sfd = new SaveFileDialog { Filter = "PNG (*.png)|*.png|BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|HDR (*.hdr)|*.hdr|Portable float map (*.pfm)|*.pfm|Khronos Texture (*.ktx)|*.ktx|Khronos Texture (*.ktx2)|*.ktx2|DirectDraw Surface (*.dds)|*.dds", InitialDirectory = Properties.Settings.Default.ExportPath, FileName = proposedFilename }; if (sfd.ShowDialog() != true) { return; } Properties.Settings.Default.ExportPath = System.IO.Path.GetDirectoryName(sfd.FileName); // obtain file format var format = ExportModel.FileFormat.Png; if (sfd.FileName.EndsWith(".bmp")) { format = ExportModel.FileFormat.Bmp; } else if (sfd.FileName.EndsWith(".hdr")) { format = ExportModel.FileFormat.Hdr; } else if (sfd.FileName.EndsWith(".pfm")) { format = ExportModel.FileFormat.Pfm; } else if (sfd.FileName.EndsWith(".jpg")) { format = ExportModel.FileFormat.Jpg; } else if (sfd.FileName.EndsWith(".ktx")) { format = ExportModel.FileFormat.Ktx; } else if (sfd.FileName.EndsWith(".ktx2")) { format = ExportModel.FileFormat.Ktx2; } else if (sfd.FileName.EndsWith(".dds")) { format = ExportModel.FileFormat.Dds; } var texFormat = new ImageLoader.ImageFormat(PixelFormat.Rgb, PixelType.UnsignedByte, true); switch (format) { case ExportModel.FileFormat.Png: case ExportModel.FileFormat.Bmp: case ExportModel.FileFormat.Jpg: if (models.Images.IsAlpha && format == ExportModel.FileFormat.Png) { texFormat.ExternalFormat = PixelFormat.Rgba; } if (models.Images.IsGrayscale) { texFormat.ExternalFormat = PixelFormat.Red; } break; case ExportModel.FileFormat.Hdr: case ExportModel.FileFormat.Pfm: texFormat = new ImageLoader.ImageFormat(PixelFormat.Rgb, PixelType.Float, false); if (models.Images.IsGrayscale) { texFormat.ExternalFormat = PixelFormat.Red; } break; case ExportModel.FileFormat.Ktx: case ExportModel.FileFormat.Ktx2: case ExportModel.FileFormat.Dds: // load default format from settings if (Enum.TryParse <GliFormat>(Properties.Settings.Default.GliFormat, out var fmt)) { texFormat = new ImageLoader.ImageFormat(fmt); } else { texFormat = new ImageLoader.ImageFormat(GliFormat.RGB8_SRGB_PACK8); } break; } models.Export.IsExporting = true; // open export dialog var dia = new ExportDialog(models, sfd.FileName, texFormat, format); dia.Owner = models.App.Window; dia.Closed += (sender, args) => { models.Export.IsExporting = false; // save gli format if present var fmt = models.Export.TexFormat.Format; if (fmt.HasGliFormat) { Properties.Settings.Default.GliFormat = fmt.GliFormat.ToString(); } if (!dia.ExportResult) { return; } var info = models.Export; models.GlContext.Enable(); try { // obtain data from gpu var texture = models.FinalImages.Get(equationId).Texture; if (texture == null) { throw new Exception("texture is not computed"); } if (info.FileType == ExportModel.FileFormat.Ktx || info.FileType == ExportModel.FileFormat.Ktx2 || info.FileType == ExportModel.FileFormat.Dds) { SaveMultipleLevel(info, texture); } else { SaveSingleLevel(info, texture); } } catch (Exception e) { App.ShowErrorDialog(models.App.Window, e.Message); } finally { models.GlContext.Disable(); } }; dia.Show(); }