From 94c06d6797eb86f1cbe9e04f3457dbfefeaad825 Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Tue, 21 Sep 2021 09:27:03 +1000 Subject: [PATCH] WinForms/WPF - Add Debug/Release build to Window Title --- CefSharp.MinimalExample.WinForms/BrowserForm.cs | 10 ++++++++-- .../Converter/TitleConverter.cs | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CefSharp.MinimalExample.WinForms/BrowserForm.cs b/CefSharp.MinimalExample.WinForms/BrowserForm.cs index d3e458e..f68b90e 100644 --- a/CefSharp.MinimalExample.WinForms/BrowserForm.cs +++ b/CefSharp.MinimalExample.WinForms/BrowserForm.cs @@ -11,13 +11,19 @@ namespace CefSharp.MinimalExample.WinForms { public partial class BrowserForm : Form { +#if DEBUG + private const string Build = "Debug"; +#else + private const string Build = "Release"; +#endif + private string title = "CefSharp.MinimalExample.WinForms (" + Build + ")"; private readonly ChromiumWebBrowser browser; public BrowserForm() { InitializeComponent(); - Text = "CefSharp"; + Text = title; WindowState = FormWindowState.Maximized; browser = new ChromiumWebBrowser("www.google.com"); @@ -74,7 +80,7 @@ namespace CefSharp.MinimalExample.WinForms private void OnBrowserTitleChanged(object sender, TitleChangedEventArgs args) { - this.InvokeOnUiThreadIfRequired(() => Text = args.Title); + this.InvokeOnUiThreadIfRequired(() => Text = title + " - " + args.Title); } private void OnBrowserAddressChanged(object sender, AddressChangedEventArgs args) diff --git a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs index 2a3e147..10f9b8a 100644 --- a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs +++ b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs @@ -6,9 +6,14 @@ namespace CefSharp.MinimalExample.Wpf.Converter { public class TitleConverter : IValueConverter { +#if DEBUG + private const string Build = "Debug"; +#else + private const string Build = "Release"; +#endif object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return "CefSharp.MinimalExample.Wpf - " + (value ?? "No Title Specified"); + return "CefSharp.MinimalExample.Wpf (" + Build + ") - " + (value ?? "No Title Specified"); } object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)