Closed jmcouffin closed 1 month ago
Haven't tried it, for the SaveDialog https://github.com/pyrevitlabs/pyRevit/blob/edeeb3e7b824e3d52f57ba9c76ce594ae5062227/dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs#L837
private void Save_Contents_Button_Clicked(object sender, RoutedEventArgs e)
{
var saveDlg = new System.Windows.Forms.SaveFileDialog()
{
Title = "Save Output to:",
Filter = "HTML Files|*.html",
DefaultExt = "html",
AddExtension = true,
RestoreDirectory = true
};
if (saveDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(saveDlg.FileName))
{
try
{
using (var f = File.CreateText(saveDlg.FileName))
{
f.Write(GetFullHtml());
}
}
catch (Exception ex)
{
// Use WPF MessageBox instead of System.Windows.Forms.MessageBox
System.Windows.MessageBox.Show($"Error saving file: {ex.Message}", "Save Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
System.Windows.MessageBox.Show("File saving was canceled or an invalid file name was provided.", "Save Canceled", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
And the issue with the Process.Start() when opening the content of the html of the output window to the default Process
private void OpenButton_Click(object sender, RoutedEventArgs e)
{
try
{
var filePath = SaveContentsToTemp();
// Adjust for proper URI format
var uri = new Uri(filePath).AbsoluteUri;
// Use ProcessStartInfo to set UseShellExecute to true
var processInfo = new ProcessStartInfo()
{
FileName = uri,
UseShellExecute = true // Required in .NET Core to launch external processes
};
Process.Start(processInfo);
}
catch (Exception ex)
{
// Handle any exceptions and show an error message
System.Windows.MessageBox.Show($"Error opening file: {ex.Message}", "Open Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
Will try it tomorrow
✈ Pre-Flight checks
🐞 Describe the bug
Soft crash when using the following commands of the output window:
⌨ Error/Debug Message
♻️ To Reproduce
-
⏲️ Expected behavior
-
🖥️ Hardware and Software Setup (please complete the following information)
Additional context
@dosymep @sanzoghenzo