Files
cefsharp/CefSharp.WinForms.Example/Minimal/TabulationDemoForm.cs
T
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00

78 lines
2.4 KiB
C#

// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace CefSharp.WinForms.Example.Minimal
{
public partial class TabulationDemoForm : Form
{
private readonly ChromiumWebBrowser chromiumWebBrowser;
private readonly Color focusColor = Color.Yellow;
private readonly Color nonFocusColor = Color.White;
public TabulationDemoForm()
{
InitializeComponent();
chromiumWebBrowser = new ChromiumWebBrowser(txtURL.Text) { Dock = DockStyle.Fill };
var userControl = new UserControl { Dock = DockStyle.Fill };
userControl.Enter += UserControlEnter;
userControl.Leave += UserControlLeave;
userControl.Controls.Add(chromiumWebBrowser);
txtURL.GotFocus += TxtUrlGotFocus;
txtURL.LostFocus += TxtUrlLostFocus;
grpBrowser.Controls.Add(userControl);
}
private void TxtUrlLostFocus(object sender, EventArgs e)
{
// Uncomment this if you want the address bar to go white
// during deactivation:
//UpdateUrlColor(nonFocusColor);
}
private void TxtUrlGotFocus(object sender, EventArgs e)
{
// Ensure the control turns yellow on form
// activation (since Enter events don't fire then)
UpdateUrlColor(focusColor);
}
private void UpdateUrlColor(Color color)
{
if (txtURL.BackColor != color)
{
txtURL.BackColor = color;
}
}
private void UserControlLeave(object sender, EventArgs e)
{
txtDummy.Text = "UserControl OnLeave";
}
private void UserControlEnter(object sender, EventArgs e)
{
txtDummy.Text = "UserControl OnEnter";
}
private void BtnGoClick(object sender, EventArgs e)
{
chromiumWebBrowser.Load(txtURL.Text);
}
private void TxtUrlLeave(object sender, EventArgs e)
{
UpdateUrlColor(nonFocusColor);
}
private void TxtUrlEnter(object sender, EventArgs e)
{
UpdateUrlColor(focusColor);
}
}
}