mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-20 02:34:09 +02:00
Add FormBrowser.InvokeSafe and use it for CEF callbacks
This commit is contained in:
parent
f74a7c8ed3
commit
b9c93bfe20
@ -81,6 +81,15 @@ private void FormBrowser_WindowStateChanged(object sender, EventArgs e){
|
|||||||
|
|
||||||
// callback handlers
|
// callback handlers
|
||||||
|
|
||||||
|
public void InvokeSafe(Action func){
|
||||||
|
if (InvokeRequired){
|
||||||
|
Invoke(func);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenSettings(){
|
public void OpenSettings(){
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CefSharp;
|
using CefSharp;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace TweetDick.Core.Handling{
|
namespace TweetDick.Core.Handling{
|
||||||
class ContextMenuHandler : IContextMenuHandler{
|
class ContextMenuHandler : IContextMenuHandler{
|
||||||
@ -31,11 +32,17 @@ public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IF
|
|||||||
public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
||||||
switch((int)commandId){
|
switch((int)commandId){
|
||||||
case MenuSettings:
|
case MenuSettings:
|
||||||
form.OpenSettings();
|
form.InvokeSafe(() => {
|
||||||
|
form.OpenSettings();
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuAbout:
|
case MenuAbout:
|
||||||
form.OpenAbout();
|
form.InvokeSafe(() => {
|
||||||
|
form.OpenAbout();
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ public TweetDeckBridge(FormBrowser form){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void OpenSettingsMenu(){
|
public void OpenSettingsMenu(){
|
||||||
form.OpenSettings();
|
form.InvokeSafe(() => {
|
||||||
|
form.OpenSettings();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log(string data){
|
public void Log(string data){
|
||||||
|
Loading…
Reference in New Issue
Block a user