WinForms/WPF - Add Debug/Release build to Window Title

This commit is contained in:
Alex Maitland 2021-09-21 09:27:03 +10:00
parent bc856b0297
commit 94c06d6797
2 changed files with 14 additions and 3 deletions

View File

@ -11,13 +11,19 @@ namespace CefSharp.MinimalExample.WinForms
{ {
public partial class BrowserForm : Form 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; private readonly ChromiumWebBrowser browser;
public BrowserForm() public BrowserForm()
{ {
InitializeComponent(); InitializeComponent();
Text = "CefSharp"; Text = title;
WindowState = FormWindowState.Maximized; WindowState = FormWindowState.Maximized;
browser = new ChromiumWebBrowser("www.google.com"); browser = new ChromiumWebBrowser("www.google.com");
@ -74,7 +80,7 @@ namespace CefSharp.MinimalExample.WinForms
private void OnBrowserTitleChanged(object sender, TitleChangedEventArgs args) 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) private void OnBrowserAddressChanged(object sender, AddressChangedEventArgs args)

View File

@ -6,9 +6,14 @@ namespace CefSharp.MinimalExample.Wpf.Converter
{ {
public class TitleConverter : IValueConverter 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) 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) object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)