diff --git a/EditorExtensions/Commands/Css/CssExtractToFileCommandTarget.cs b/EditorExtensions/Commands/Css/CssExtractToFileCommandTarget.cs index d203bc451..425887701 100644 --- a/EditorExtensions/Commands/Css/CssExtractToFileCommandTarget.cs +++ b/EditorExtensions/Commands/Css/CssExtractToFileCommandTarget.cs @@ -66,7 +66,7 @@ protected override bool Execute(uint commandId, uint nCmdexecopt, IntPtr pvaIn, } else { - MessageBox.Show("The file already exist", "Web Essentials", MessageBoxButton.OK, MessageBoxImage.Warning); + Logger.ShowMessage("The file already exists."); } } diff --git a/EditorExtensions/Logger.cs b/EditorExtensions/Logger.cs index 5eba26d35..d7ab830f2 100644 --- a/EditorExtensions/Logger.cs +++ b/EditorExtensions/Logger.cs @@ -1,4 +1,5 @@ -using Microsoft.VisualStudio; +using System.Windows.Forms; +using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell.Interop; using System; @@ -35,6 +36,21 @@ public static void Log(Exception ex) } } + public static void ShowMessage(string message, string title = "Web Essentials", + MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK, + MessageBoxIcon messageBoxIcon = MessageBoxIcon.Warning, + MessageBoxDefaultButton messageBoxDefaultButton = MessageBoxDefaultButton.Button1) + { + if (WESettings.GetBoolean(WESettings.Keys.AllMessagesToOutputWindow)) + { + Log(String.Format("{0}: {1}", title, message)); + } + else + { + MessageBox.Show(message, title, messageBoxButtons, messageBoxIcon, messageBoxDefaultButton); + } + } + private static bool EnsurePane() { if (pane == null) diff --git a/EditorExtensions/MenuItems/BundleFiles.cs b/EditorExtensions/MenuItems/BundleFiles.cs index e45cea926..d1f71be26 100644 --- a/EditorExtensions/MenuItems/BundleFiles.cs +++ b/EditorExtensions/MenuItems/BundleFiles.cs @@ -209,7 +209,7 @@ private static void CreateBundlefile(string extension) if (File.Exists(bundlePath)) { - MessageBox.Show("The bundle file already exists.", "Web Essentials", MessageBoxButton.OK, MessageBoxImage.Warning); + Logger.ShowMessage("The bundle file already exists."); } else { @@ -273,7 +273,7 @@ private static void WriteBundleFile(string filePath, XmlDocument doc) if (outputAttr != null && (outputAttr.InnerText.Contains("/") || outputAttr.InnerText.Contains("\\"))) { - MessageBox.Show("The 'output' attribute should contain a file name without a path; '" + outputAttr.InnerText + "' is not valid", "Web Essentials"); + Logger.ShowMessage(String.Format("The 'output' attribute should contain a file name without a path; '{0}' is not valid", outputAttr.InnerText)); return; } @@ -300,9 +300,10 @@ private static void WriteBundleFile(string filePath, XmlDocument doc) } else { - string error = string.Format("Bundle error: The file '{0}' doesn't exist", node.InnerText); _dte.ItemOperations.OpenFile(filePath); - MessageBox.Show(error, "Web Essentials"); + + Logger.ShowMessage(String.Format("Bundle error: The file '{0}' doesn't exist", node.InnerText)); + return; } } @@ -347,7 +348,7 @@ private static void WriteBundleFile(string filePath, XmlDocument doc) using (StreamWriter writer = new StreamWriter(bundlePath, false, new UTF8Encoding(true))) { writer.Write(sb.ToString().Trim()); - Logger.Log("Updating bundle: " + Path.GetFileName(bundlePath)); + Logger.Log("Web Essentials: Updating bundle: " + Path.GetFileName(bundlePath)); } MarginBase.AddFileToProject(filePath, bundlePath); } @@ -392,4 +393,4 @@ private static void WriteMinFile(string filePath, string bundlePath, string cont } } } -} \ No newline at end of file +} diff --git a/EditorExtensions/MenuItems/ReferenceJs.cs b/EditorExtensions/MenuItems/ReferenceJs.cs index ad315219d..2eb1336e0 100644 --- a/EditorExtensions/MenuItems/ReferenceJs.cs +++ b/EditorExtensions/MenuItems/ReferenceJs.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Windows; using EnvDTE80; using Microsoft.VisualStudio.Shell; @@ -74,7 +75,7 @@ private void Execute() } catch (IOException) { - System.Windows.Forms.MessageBox.Show("Can't write to the folder"); + Logger.ShowMessage("Can't write to the folder: " + _referencesJsPath); } } } diff --git a/EditorExtensions/Options/General.cs b/EditorExtensions/Options/General.cs index 0c221a3a0..80bae3fde 100644 --- a/EditorExtensions/Options/General.cs +++ b/EditorExtensions/Options/General.cs @@ -15,6 +15,7 @@ public override void SaveSettingsToStorage() Settings.SetValue(WESettings.Keys.KeepImportantComments, KeepImportantComments); Settings.SetValue(WESettings.Keys.EnableEnterFormat, EnableEnterFormat); Settings.SetValue(WESettings.Keys.EnableBrowserLinkMenu, EnableBrowserLinkMenu); + Settings.SetValue(WESettings.Keys.AllMessagesToOutputWindow, AllMessagesToOutputWindow); Settings.Save(); } @@ -24,6 +25,7 @@ public override void LoadSettingsFromStorage() KeepImportantComments = WESettings.GetBoolean(WESettings.Keys.KeepImportantComments); EnableEnterFormat = WESettings.GetBoolean(WESettings.Keys.EnableEnterFormat); EnableBrowserLinkMenu = WESettings.GetBoolean(WESettings.Keys.EnableBrowserLinkMenu); + AllMessagesToOutputWindow = WESettings.GetBoolean(WESettings.Keys.AllMessagesToOutputWindow); } // MISC @@ -41,5 +43,10 @@ public override void LoadSettingsFromStorage() [Description("Enable the menu that shows up in the browser. Requires restart.")] [Category("Browser Link")] public bool EnableBrowserLinkMenu { get; set; } + + [LocDisplayName("Redirect Messages to Output Window")] + [Description("Redirect messages/notifications to output window.")] + [Category("Messages")] + public bool AllMessagesToOutputWindow { get; set; } } } diff --git a/EditorExtensions/Options/WebEssentialsSettings.cs b/EditorExtensions/Options/WebEssentialsSettings.cs index 9c66ef2e5..63f52deca 100644 --- a/EditorExtensions/Options/WebEssentialsSettings.cs +++ b/EditorExtensions/Options/WebEssentialsSettings.cs @@ -9,6 +9,7 @@ public static class Keys public const string KeepImportantComments = "KeepImportantComments"; public const string EnableEnterFormat = "EnableEnterFormat"; public const string EnableBrowserLinkMenu = "EnableBrowserLinkMenu"; + public const string AllMessagesToOutputWindow = "AllMessagesToOutputWindow"; // LESS public const string GenerateCssFileFromLess = "LessGenerateCssFile"; diff --git a/EditorExtensions/SmartTags/CSS/Actions/ReverseEmbedSmartTagAction.cs b/EditorExtensions/SmartTags/CSS/Actions/ReverseEmbedSmartTagAction.cs index 74794b96e..553b70568 100644 --- a/EditorExtensions/SmartTags/CSS/Actions/ReverseEmbedSmartTagAction.cs +++ b/EditorExtensions/SmartTags/CSS/Actions/ReverseEmbedSmartTagAction.cs @@ -1,7 +1,6 @@ using System; using System.Globalization; using System.IO; -using System.Text; using System.Windows.Forms; using System.Windows.Media.Imaging; using Microsoft.CSS.Core; @@ -65,7 +64,7 @@ public static bool TrySaveFile(string base64, string filePath) } catch (Exception ex) { - MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); + Logger.ShowMessage(ex.Message, "Web Essentials " + ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } } diff --git a/EditorExtensions/SmartTags/CSS/Actions/UpdateEmbedSmartTagAction.cs b/EditorExtensions/SmartTags/CSS/Actions/UpdateEmbedSmartTagAction.cs index 131d3cdd5..5d8f9398a 100644 --- a/EditorExtensions/SmartTags/CSS/Actions/UpdateEmbedSmartTagAction.cs +++ b/EditorExtensions/SmartTags/CSS/Actions/UpdateEmbedSmartTagAction.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.Text; using System; using System.IO; -using System.Windows.Forms; using System.Windows.Media.Imaging; namespace MadsKristensen.EditorExtensions @@ -47,13 +46,14 @@ private void ApplyChanges(string filePath) } else { - MessageBox.Show("'" + _path + "' could not be resolved.", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Information); + Logger.ShowMessage(String.Format("'{0}' could not be resolved.", _path), "Web Essentials: File not found"); } } private void InsertEmbedString(ITextSnapshot snapshot, string dataUri) { EditorExtensionsPackage.DTE.UndoContext.Open(DisplayText); + // it's not used anywhere... Declaration dec = _url.FindType(); _span.TextBuffer.Replace(_span.GetSpan(snapshot), dataUri);