Skip to content

Commit

Permalink
Merge pull request #2395 from pyrevitlabs/fix/2333
Browse files Browse the repository at this point in the history
Update ScriptConsole.cs
  • Loading branch information
jmcouffin committed Sep 10, 2024
2 parents 372cc6c + cae17c1 commit 5fcc710
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,17 +834,31 @@ private System.Windows.Shapes.Path GetAutoCollapseIcon(bool active) {
return MakeButtonPath("M19.92,12.08L12,20L4.08,12.08L5.5,10.67L11,16.17V2H13V16.17L18.5,10.66L19.92,12.08M12,20H2V22H22V20H12Z");
}

private void Save_Contents_Button_Clicked(object sender, RoutedEventArgs e) {
var saveDlg = new System.Windows.Forms.SaveFileDialog() {
private void Save_Contents_Button_Clicked(object sender, RoutedEventArgs e)
{
var saveDlg = new System.Windows.Forms.SaveFileDialog()
{
Title = "Save Output to:",
Filter = "HTML|*.html"
Filter = "HTML Files|*.html",
DefaultExt = "html",
AddExtension = true,
RestoreDirectory = true
};
saveDlg.ShowDialog();
var f = File.CreateText(saveDlg.FileName);
f.Write(GetFullHtml());
f.Close();
if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK || string.IsNullOrWhiteSpace(saveDlg.FileName))
{
return;
}
try
{
using (File.CreateText(saveDlg.FileName).Write(GetFullHtml())) { }

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.

Check failure on line 853 in dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs

View workflow job for this annotation

GitHub Actions / build

'void': type used in a using statement must be implicitly convertible to 'System.IDisposable'.
}
catch (Exception ex)
{
System.Windows.MessageBox.Show($"Error saving file: {ex.Message}", "Save Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}


private void PinButton_Click(object sender, RoutedEventArgs e) {
var button = e.Source as Button;
if (Topmost) {
Expand Down Expand Up @@ -901,8 +915,22 @@ private string SaveContentsToTemp() {
return tempHtml;
}

private void OpenButton_Click(object sender, RoutedEventArgs e) {
Process.Start(string.Format("file:///{0}", SaveContentsToTemp()));
private void OpenButton_Click(object sender, RoutedEventArgs e)
{
try
{
var uri = new Uri(SaveContentsToTemp()).AbsoluteUri;
var processInfo = new ProcessStartInfo()
{
FileName = uri,
UseShellExecute = true
};
Process.Start(processInfo);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show($"Error opening file: {ex.Message}", "Open Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}

private void PrintButton_Click(object sender, RoutedEventArgs e) {
Expand Down

0 comments on commit 5fcc710

Please sign in to comment.