Skip to content

Commit 86dc296

Browse files
committed
Merge branch 'JsBinding_WIP' into JsBinding/Wip2
2 parents dd2ee32 + 122e97c commit 86dc296

16 files changed

+166
-115
lines changed

CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
4242
</PropertyGroup>
4343
<ItemGroup>
44-
<Reference Include="nunit.framework, Version=2.6.0.12035, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
45-
<SpecificVersion>False</SpecificVersion>
46-
<HintPath>..\nunit\nunit.framework.dll</HintPath>
47-
</Reference>
4844
<Reference Include="System" />
4945
<Reference Include="System.Core">
5046
<RequiredTargetFramework>3.5</RequiredTargetFramework>

CefSharp.WinForms/ChromiumWebBrowser.cs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class ChromiumWebBrowser : Control, IWebBrowserInternal, IWinFormsWebBrow
1616

1717
public BrowserSettings BrowserSettings { get; set; }
1818
public string Title { get; set; }
19-
public bool IsLoading { get; set; }
20-
public string TooltipText { get; set; }
19+
public bool IsLoading { get; private set; }
20+
public string TooltipText { get; private set; }
2121
public string Address { get; set; }
2222

2323
public IDialogHandler DialogHandler { get; set; }
@@ -73,6 +73,13 @@ protected override void Dispose(bool disposing)
7373
void IWebBrowserInternal.OnInitialized()
7474
{
7575
IsBrowserInitialized = true;
76+
77+
var handler = IsBrowserInitializedChanged;
78+
79+
if (handler != null)
80+
{
81+
handler(this, new IsBrowserInitializedChangedEventArgs(IsBrowserInitialized));
82+
}
7683
}
7784

7885
public void Load(String url)
@@ -105,14 +112,16 @@ public Task<JavascriptResponse> EvaluateScriptAsync(string script, TimeSpan? tim
105112
return managedCefBrowserAdapter.EvaluateScriptAsync(script, timeout);
106113
}
107114

108-
public event LoadErrorEventHandler LoadError;
109-
public event FrameLoadStartEventHandler FrameLoadStart;
110-
public event FrameLoadEndEventHandler FrameLoadEnd;
111-
public event NavStateChangedEventHandler NavStateChanged;
112-
public event ConsoleMessageEventHandler ConsoleMessage;
113-
public event StatusMessageEventHandler StatusMessage;
114-
public event AddressChangedEventHandler AddressChanged;
115-
public event TitleChangedEventHandler TitleChanged;
115+
public event EventHandler<LoadErrorEventArgs> LoadError;
116+
public event EventHandler<FrameLoadStartEventArgs> FrameLoadStart;
117+
public event EventHandler<FrameLoadEndEventArgs> FrameLoadEnd;
118+
public event EventHandler<NavStateChangedEventArgs> NavStateChanged;
119+
public event EventHandler<ConsoleMessageEventArgs> ConsoleMessage;
120+
public event EventHandler<StatusMessageEventArgs> StatusMessage;
121+
public event EventHandler<AddressChangedEventArgs> AddressChanged;
122+
public event EventHandler<TitleChangedEventArgs> TitleChanged;
123+
public event EventHandler<IsBrowserInitializedChangedEventArgs> IsBrowserInitializedChanged;
124+
public event EventHandler<IsLoadingChangedEventArgs> IsLoadingChanged;
116125

117126
protected override void OnHandleCreated(EventArgs e)
118127
{
@@ -143,6 +152,12 @@ void IWebBrowserInternal.SetAddress(string address)
143152
void IWebBrowserInternal.SetIsLoading(bool isLoading)
144153
{
145154
IsLoading = isLoading;
155+
156+
var handler = IsLoadingChanged;
157+
if (handler != null)
158+
{
159+
handler(this, new IsLoadingChangedEventArgs(isLoading));
160+
}
146161
}
147162

148163
void IWebBrowserInternal.SetNavState(bool canGoBack, bool canGoForward, bool canReload)

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public class ChromiumWebBrowser : ContentControl, IRenderWebBrowser, IWpfWebBrow
5050
public IDownloadHandler DownloadHandler { get; set; }
5151
public ILifeSpanHandler LifeSpanHandler { get; set; }
5252

53-
public event ConsoleMessageEventHandler ConsoleMessage;
54-
public event StatusMessageEventHandler StatusMessage;
55-
public event FrameLoadStartEventHandler FrameLoadStart;
56-
public event FrameLoadEndEventHandler FrameLoadEnd;
57-
public event LoadErrorEventHandler LoadError;
53+
public event EventHandler<ConsoleMessageEventArgs> ConsoleMessage;
54+
public event EventHandler<StatusMessageEventArgs> StatusMessage;
55+
public event EventHandler<FrameLoadStartEventArgs> FrameLoadStart;
56+
public event EventHandler<FrameLoadEndEventArgs> FrameLoadEnd;
57+
public event EventHandler<LoadErrorEventArgs> LoadError;
5858

5959
public ICommand BackCommand { get; private set; }
6060
public ICommand ForwardCommand { get; private set; }
@@ -72,7 +72,6 @@ public class ChromiumWebBrowser : ContentControl, IRenderWebBrowser, IWpfWebBrow
7272
public bool CanGoBack
7373
{
7474
get { return (bool)GetValue(CanGoBackProperty); }
75-
private set { SetValue(CanGoBackProperty, value); }
7675
}
7776

7877
public static DependencyProperty CanGoBackProperty = DependencyProperty.Register("CanGoBack", typeof (bool), typeof (ChromiumWebBrowser));
@@ -84,7 +83,6 @@ public bool CanGoBack
8483
public bool CanGoForward
8584
{
8685
get { return (bool)GetValue(CanGoForwardProperty); }
87-
private set { SetValue(CanGoForwardProperty, value); }
8886
}
8987

9088
public static DependencyProperty CanGoForwardProperty = DependencyProperty.Register("CanGoForward", typeof (bool), typeof (ChromiumWebBrowser));
@@ -96,7 +94,6 @@ public bool CanGoForward
9694
public bool CanReload
9795
{
9896
get { return (bool)GetValue(CanReloadProperty); }
99-
private set { SetValue(CanReloadProperty, value); }
10097
}
10198

10299
public static DependencyProperty CanReloadProperty = DependencyProperty.Register("CanReload", typeof (bool), typeof (ChromiumWebBrowser));
@@ -165,7 +162,7 @@ protected virtual void OnAddressChanged(string oldValue, string newValue)
165162
Dispatcher
166163
);
167164

168-
managedCefBrowserAdapter.LoadUrl(Address);
165+
managedCefBrowserAdapter.LoadUrl(newValue);
169166
}
170167

171168
#endregion Address dependency property
@@ -175,7 +172,6 @@ protected virtual void OnAddressChanged(string oldValue, string newValue)
175172
public bool IsLoading
176173
{
177174
get { return (bool)GetValue(IsLoadingProperty); }
178-
set { SetValue(IsLoadingProperty, value); }
179175
}
180176

181177
public static readonly DependencyProperty IsLoadingProperty =
@@ -188,19 +184,18 @@ public bool IsLoading
188184
public bool IsBrowserInitialized
189185
{
190186
get { return (bool)GetValue(IsBrowserInitializedProperty); }
191-
set { SetValue(IsBrowserInitializedProperty, value); }
192187
}
193188

194189
public static readonly DependencyProperty IsBrowserInitializedProperty =
195-
DependencyProperty.Register("IsBrowserInitialized", typeof(bool), typeof(ChromiumWebBrowser), new PropertyMetadata(false, OnIsBrowserInitializedChanged ));
190+
DependencyProperty.Register("IsBrowserInitialized", typeof(bool), typeof(ChromiumWebBrowser), new PropertyMetadata(false, OnIsBrowserInitializedChanged));
196191

197192
public event DependencyPropertyChangedEventHandler IsBrowserInitializedChanged;
198193

199194
private static void OnIsBrowserInitializedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
200195
{
201196
var owner = (ChromiumWebBrowser)d;
202-
bool oldValue = (bool)e.OldValue;
203-
bool newValue = (bool)e.NewValue;
197+
var oldValue = (bool)e.OldValue;
198+
var newValue = (bool)e.NewValue;
204199

205200
owner.OnIsBrowserInitializedChanged(oldValue, newValue);
206201

@@ -339,6 +334,14 @@ public void Dispose()
339334

340335
protected virtual void Dispose(bool isdisposing)
341336
{
337+
Loaded -= OnLoaded;
338+
Unloaded -= OnUnloaded;
339+
340+
GotKeyboardFocus -= OnGotKeyboardFocus;
341+
LostKeyboardFocus -= OnLostKeyboardFocus;
342+
343+
IsVisibleChanged -= OnIsVisibleChanged;
344+
342345
Cef.RemoveDisposable(this);
343346

344347
RemoveSourceHook();
@@ -364,7 +367,6 @@ protected virtual void Dispose(bool isdisposing)
364367
public string TooltipText
365368
{
366369
get { return (string)GetValue(TooltipTextProperty); }
367-
set { SetValue(TooltipTextProperty, value); }
368370
}
369371

370372
public static readonly DependencyProperty TooltipTextProperty =
@@ -658,9 +660,9 @@ void IWebBrowserInternal.SetNavState(bool canGoBack, bool canGoForward, bool can
658660
{
659661
UiThreadRunAsync(() =>
660662
{
661-
CanGoBack = canGoBack;
662-
CanGoForward = canGoForward;
663-
CanReload = canReload;
663+
SetCurrentValue(CanGoBackProperty, canGoBack);
664+
SetCurrentValue(CanGoForwardProperty, canGoForward);
665+
SetCurrentValue(CanReloadProperty, canReload);
664666

665667
RaiseCommandsCanExecuteChanged();
666668
});
@@ -937,10 +939,7 @@ private void OnMouseButton(MouseButtonEventArgs e)
937939

938940
void IWebBrowserInternal.OnInitialized()
939941
{
940-
UiThreadRunAsync(() =>
941-
{
942-
SetCurrentValue(IsBrowserInitializedProperty, true);
943-
});
942+
UiThreadRunAsync(() => SetCurrentValue(IsBrowserInitializedProperty, true));
944943
}
945944

946945
public void Load(string url)
@@ -993,12 +992,12 @@ public void Stop()
993992
managedCefBrowserAdapter.Stop();
994993
}
995994

996-
private void Back()
995+
public void Back()
997996
{
998997
managedCefBrowserAdapter.GoBack();
999998
}
1000999

1001-
private void Forward()
1000+
public void Forward()
10021001
{
10031002
managedCefBrowserAdapter.GoForward();
10041003
}
@@ -1013,7 +1012,7 @@ public void Reload(bool ignoreCache)
10131012
managedCefBrowserAdapter.Reload(ignoreCache);
10141013
}
10151014

1016-
private void Print()
1015+
public void Print()
10171016
{
10181017
managedCefBrowserAdapter.Print();
10191018
}

CefSharp/AddressChangedEventArgs.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,5 @@ public AddressChangedEventArgs(string address)
1717
{
1818
Address = address;
1919
}
20-
};
21-
22-
/// <summary>
23-
/// A delegate type used to listen to AddressChanged events.
24-
/// </summary>
25-
/// <param name="sender">The object that raised the event.</param>
26-
/// <param name="e">The event arguments.</param>
27-
public delegate void AddressChangedEventHandler(object sender, AddressChangedEventArgs args);
20+
}
2821
}

CefSharp/CefSharp.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
</ItemGroup>
8888
<ItemGroup>
8989
<Compile Include="CefFileDialogMode.cs" />
90+
<Compile Include="IsBrowserInitializedChangedEventArgs.cs" />
9091
<Compile Include="CefTerminationStatus.cs" />
9192
<Compile Include="IDialogHandler.cs" />
9293
<Compile Include="AddressChangedEventArgs.cs" />
@@ -95,6 +96,7 @@
9596
<Compile Include="Internals\BrowserProcessResponse.cs" />
9697
<Compile Include="Internals\JavascriptRootObject.cs" />
9798
<Compile Include="Internals\TaskExtensions.cs" />
99+
<Compile Include="IsLoadingChangedEventArgs.cs" />
98100
<Compile Include="IStringVisitor.cs" />
99101
<Compile Include="JavascriptResponse.cs" />
100102
<Compile Include="LoadErrorEventArgs.cs" />
@@ -103,7 +105,6 @@
103105
<Compile Include="Internals\BrowserProcessServiceHost.cs" />
104106
<Compile Include="Internals\WCFExtensions.cs" />
105107
<Compile Include="KeyType.cs" />
106-
<Compile Include="LoadErrorEventHandler.cs" />
107108
<Compile Include="NavStateChangedEventArgs.cs" />
108109
<Compile Include="ICompletionHandler.cs" />
109110
<Compile Include="Internals\BitmapInfo.cs" />

CefSharp/ConsoleMessageEventArgs.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,4 @@ public ConsoleMessageEventArgs(string message, string source, int line)
3333
/// </summary>
3434
public int Line { get; private set; }
3535
}
36-
37-
/// <summary>
38-
/// A delegate type used to listen to ConsoleMessage events.
39-
/// </summary>
40-
/// <param name="sender">The object that raised the event.</param>
41-
/// <param name="e">The event arguments.</param>
42-
public delegate void ConsoleMessageEventHandler(object sender, ConsoleMessageEventArgs e);
4336
}

CefSharp/FrameLoadEndEventArgs.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,5 @@ public FrameLoadEndEventArgs(string url, bool isMainFrame, int httpStatusCode)
3232
/// Http Status Code
3333
/// </summary>
3434
public int HttpStatusCode { get; set; }
35-
};
36-
37-
/// <summary>
38-
/// A delegate type used to listen to FrameLoadEnd events.
39-
/// </summary>
40-
/// <param name="sender">The object that raised the event.</param>
41-
/// <param name="e">The event arguments.</param>
42-
public delegate void FrameLoadEndEventHandler(object sender, FrameLoadEndEventArgs url);
35+
}
4336
}

CefSharp/FrameLoadStartEventArgs.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,5 @@ public FrameLoadStartEventArgs(string url, bool isMainFrame)
2626
/// Is this the Main Frame
2727
/// </summary>
2828
public bool IsMainFrame { get; private set; }
29-
};
30-
31-
/// <summary>
32-
/// A delegate type used to listen to FrameLoadStart events.
33-
/// </summary>
34-
/// <param name="sender">The object that raised the event.</param>
35-
/// <param name="e">The event arguments.</param>
36-
public delegate void FrameLoadStartEventHandler(object sender, FrameLoadStartEventArgs args);
29+
}
3730
}

0 commit comments

Comments
 (0)