如何在cefSharp中实现文本搜索(How to implement Text Search in cefSharp)
我正在使用
cefSharp
构建和应用程序。 现在我需要像Google Chrome
一样为用户提供文本搜索功能。 任何人都可以帮助我在cefSharp
实现文本搜索。I'm building and application using
cefSharp
. Now i need to provide text search functionality to user just likeGoogle Chrome
has. Can any one help me with the implementation of text Search incefSharp
.
原文:https://stackoverflow.com/questions/35884540
最满意答案
我建议创建设置单例类,它将存储AppTheme状态并实现INotifyPropertyChanged接口
public class Settings : INotifyPropertyChanged { private static volatile Settings instance; private static readonly object SyncRoot = new object(); private ElementTheme appTheme; private Settings() { this.appTheme = ApplicationData.Current.LocalSettings.Values.ContainsKey("AppTheme") ? (ElementTheme)ApplicationData.Current.LocalSettings.Values["AppTheme"] : ElementTheme.Default; } public static Settings Instance { get { if (instance != null) { return instance; } lock (SyncRoot) { if (instance == null) { instance = new Settings(); } } return instance; } } public ElementTheme AppTheme { get { return this.appTheme; } set { ApplicationData.Current.LocalSettings.Values["AppTheme"] = (int)value; this.OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } }
然后,你可以在页面上创建属性设置,它将返回单例的值并将页面的RequestedTheme绑定到AppTheme属性
<Page x:Class="SamplePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" RequestedTheme="{x:Bind Settings.AppTheme, Mode=OneWay}">
I would suggest to create settings singleton class that will store AppTheme state and implements INotifyPropertyChanged interface
public class Settings : INotifyPropertyChanged { private static volatile Settings instance; private static readonly object SyncRoot = new object(); private ElementTheme appTheme; private Settings() { this.appTheme = ApplicationData.Current.LocalSettings.Values.ContainsKey("AppTheme") ? (ElementTheme)ApplicationData.Current.LocalSettings.Values["AppTheme"] : ElementTheme.Default; } public static Settings Instance { get { if (instance != null) { return instance; } lock (SyncRoot) { if (instance == null) { instance = new Settings(); } } return instance; } } public ElementTheme AppTheme { get { return this.appTheme; } set { ApplicationData.Current.LocalSettings.Values["AppTheme"] = (int)value; this.OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } }
Than, you can create Property Settings on page, that will return value of singleton and bind RequestedTheme of Page to AppTheme property
<Page x:Class="SamplePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" RequestedTheme="{x:Bind Settings.AppTheme, Mode=OneWay}">
相关问答
更多-
以下是VS可以构建哪些应用模型的摘要: VS2017 - UWP VS2015 - UWP,Win8.1 StoreApp,WP8 / 8.1 StoreApp VS2013 - Win8 / 8.1 StoreApp,WP8 / 8.1 StoreAp (假设开发系统是Win10并忽略Win32或其他) (注意 - 要使用最新的Win10 FallCU SDK,您需要使用VS2017) 有关详细信息,请参阅vs兼容性页面: VS2017 VS2015 VS2013 Here is a summary th ...
-
不,这不是必需的。 根据这篇文章 在Windows 8中,微软复制了Apple的iPad和iPhone型号,迫使您从微软的策划商店中获取应用程序。 Windows 10转变为更像PC的Android模型 - 您可以从任何您喜欢的地方获取应用程序。 据technet.microsoft.com 在Windows 10中,sideloading与早期版本的Windows不同: You can unlock a device for sideloading using an enterprise policy, ...
-
我建议创建设置单例类,它将存储AppTheme状态并实现INotifyPropertyChanged接口 public class Settings : INotifyPropertyChanged { private static volatile Settings instance; private static readonly object SyncRoot = new object(); private ElementTheme appTheme; private ...
-
好处 : 如果您将您的应用程序转换为UWP,请注意它不会是一个简单的端口,并且由于API的差异,您将再次编写大部分内容,顾名思义,您将拥有一个可在多个Windows设备平台上运行的应用程序家庭如平板电脑,手机,桌面等 否则 : 在你的情况下,如果你继续赢取窗体应用,你将不会受到伤害。 显然保证在Win 10上运行,这并不意外。 除非您需要前述的好处,否则我认为没有任何理由再次开展开发工作来创建UWP。 Benefit: If you convert your app to UWP, note that it ...
-
我可以看到你尝试使用VariableSizedWrapGrid作为ItemPanel ,正如我所说,默认它在UWP应用程序和ItemPanel应用程序中使用ItemsWrapGrid作为ItemPanel ,你可以在空白的uwp应用程序或空白的Windows 8.1应用程序中测试它。 刚刚在两个应用中测试了你的代码,当使用VariableSizedWrapGrid作为ItemPanel , GridView控制的布局与ItemPanel不同,因为它们在你的图片中。 所以我猜你可能在你的代码中的某个地方使用V ...
-
桌面应用程序转换器不适合此方案。 您需要更新appxmanifest和VS项目设置才能使其正常工作。 您可以在此处发布几个示例: https : //github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Systray https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Office%20Interop ...
-
在Win 8.1上更改方向后,MonoGame中的TouchPanel将重置(TouchPanel in MonoGame reset after orientation change on Win 8.1)[2022-05-10]
我无法找到这个问题的解决方案,我只是决定以不同的方式处理触摸输入; 而不是设置TouchPanel.DisplayWidth&Height,我决定使用一个简单的函数将触摸(和鼠标)位置转换为虚拟屏幕坐标: ScreenYScale = GraphicsDevice.PresentationParameters.BackBufferHeight / 1920.0f; public Vector2 TranslateCoords(Vector2 coords) { return new Vector2 ... -
使用WinPhone 8库为Win10 UWP开发,可以吗?(Develop for Win10 UWP using a library for WinPhone 8, Can I?)[2023-02-01]
只有当你不使用任何windows phone 8 API时,你才能使用它 You can use it, only if you dont use any of the windows phone 8 API's -
摘自开发Windows 10应用程序的官方要求 : Windows 8.1和Windows 7支持 如果您选择在Windows 10以外的平台上使用Visual Studio 2015开发通用Windows应用程序,则存在以下限制: - Windows 8.1 :您无法在本地运行应用程序(仅在远程Windows 10设备上)。 您可以在Visual Studio中使用模拟器,但不能使用模拟器。 - Windows 7:您无法在本地运行应用程序(仅在远程Windows 10设备上运行)。 您不能在Visual ...
-
我找到了解决问题的方法。 由于某些未知原因,项目(解决方案)需要在磁盘c:。 如果它在其他磁盘上(在我的情况下是d :),问题就出现了。 这是愚蠢的,但它仍然有效。 I have found the solution to my problem. For some unknown reason the project(solution) need to be on disk c:. If it were on other disk (in my case d:) the problem occurred. ...