mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
Move the first set of frame related method (Cut/Copy/Paste, etc) into a set of Extension methods
This commit is contained in:
@@ -401,76 +401,6 @@ void ManagedCefBrowserAdapter::GetText(IStringVisitor^ visitor)
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Cut()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Cut();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Copy()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Copy();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Paste()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Paste();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Delete()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::SelectAll()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Undo()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Undo();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::Redo()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetFocusedFrame()->Redo();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedCefBrowserAdapter::ExecuteScriptAsync(String^ script)
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
@@ -110,13 +110,6 @@ namespace CefSharp
|
||||
void ViewSource();
|
||||
void GetSource(IStringVisitor^ visitor);
|
||||
void GetText(IStringVisitor^ visitor);
|
||||
void Cut();
|
||||
void Copy();
|
||||
void Paste();
|
||||
void Delete();
|
||||
void SelectAll();
|
||||
void Undo();
|
||||
void Redo();
|
||||
void ExecuteScriptAsync(String^ script);
|
||||
virtual Task<JavascriptResponse^>^ EvaluateScriptAsync(int browserId, Int64 frameId, String^ script, Nullable<TimeSpan> timeout);
|
||||
virtual Task<JavascriptResponse^>^ EvaluateScriptAsync(String^ script, Nullable<TimeSpan> timeout);
|
||||
|
||||
@@ -367,48 +367,6 @@ namespace CefSharp.WinForms
|
||||
managedCefBrowserAdapter.Reload(ignoreCache);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Undo()
|
||||
{
|
||||
managedCefBrowserAdapter.Undo();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Redo()
|
||||
{
|
||||
managedCefBrowserAdapter.Redo();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Cut()
|
||||
{
|
||||
managedCefBrowserAdapter.Cut();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Copy()
|
||||
{
|
||||
managedCefBrowserAdapter.Copy();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Paste()
|
||||
{
|
||||
managedCefBrowserAdapter.Paste();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void Delete()
|
||||
{
|
||||
managedCefBrowserAdapter.Delete();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public void SelectAll()
|
||||
{
|
||||
managedCefBrowserAdapter.SelectAll();
|
||||
}
|
||||
|
||||
public void Print()
|
||||
{
|
||||
managedCefBrowserAdapter.Print();
|
||||
|
||||
@@ -135,12 +135,12 @@ namespace CefSharp.Wpf
|
||||
ViewSourceCommand = new DelegateCommand(ViewSource);
|
||||
CleanupCommand = new DelegateCommand(Dispose);
|
||||
StopCommand = new DelegateCommand(Stop);
|
||||
CutCommand = new DelegateCommand(Cut);
|
||||
CopyCommand = new DelegateCommand(Copy);
|
||||
PasteCommand = new DelegateCommand(Paste);
|
||||
SelectAllCommand = new DelegateCommand(SelectAll);
|
||||
UndoCommand = new DelegateCommand(Undo);
|
||||
RedoCommand = new DelegateCommand(Redo);
|
||||
CutCommand = new DelegateCommand(this.Cut);
|
||||
CopyCommand = new DelegateCommand(this.Copy);
|
||||
PasteCommand = new DelegateCommand(this.Paste);
|
||||
SelectAllCommand = new DelegateCommand(this.SelectAll);
|
||||
UndoCommand = new DelegateCommand(this.Undo);
|
||||
RedoCommand = new DelegateCommand(this.Redo);
|
||||
|
||||
imageTransform = new ScaleTransform();
|
||||
managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
|
||||
@@ -1281,40 +1281,7 @@ namespace CefSharp.Wpf
|
||||
Load(url);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
managedCefBrowserAdapter.Undo();
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
managedCefBrowserAdapter.Redo();
|
||||
}
|
||||
|
||||
public void Cut()
|
||||
{
|
||||
managedCefBrowserAdapter.Cut();
|
||||
}
|
||||
|
||||
public void Copy()
|
||||
{
|
||||
managedCefBrowserAdapter.Copy();
|
||||
}
|
||||
|
||||
public void Paste()
|
||||
{
|
||||
managedCefBrowserAdapter.Paste();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
managedCefBrowserAdapter.Delete();
|
||||
}
|
||||
|
||||
public void SelectAll()
|
||||
{
|
||||
managedCefBrowserAdapter.SelectAll();
|
||||
}
|
||||
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
|
||||
@@ -2,18 +2,78 @@
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public static class WebBrowserExtensions
|
||||
{
|
||||
//public static void Cut(this IWebBrowser browser)
|
||||
//{
|
||||
// browser.get
|
||||
//}
|
||||
public static void Undo(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if(frame != null)
|
||||
{
|
||||
frame.Undo();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Redo(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.Redo();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Cut(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.Cut();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Copy(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.Copy();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Paste(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.Paste();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Delete(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SelectAll(this IWebBrowser browser)
|
||||
{
|
||||
var frame = browser.GetFocusedFrame();
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
frame.SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user