1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-09 06:15:49 +02:00

Make dev tools work in release if devtools_resources.pak is present

This commit is contained in:
chylex 2017-05-19 15:14:46 +02:00
parent b5e58db242
commit 5447afc3f5
3 changed files with 14 additions and 18 deletions

View File

@ -10,6 +10,7 @@
namespace TweetDuck.Core.Handling{
abstract class ContextMenuBase : IContextMenuHandler{
private static readonly Regex RegexTwitterAccount = new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled);
protected static readonly bool HasDevTools = File.Exists(Path.Combine(Program.ProgramPath, "devtools_resources.pak"));
private const int MenuOpenLinkUrl = 26500;
private const int MenuCopyLinkUrl = 26501;
@ -17,15 +18,8 @@ abstract class ContextMenuBase : IContextMenuHandler{
private const int MenuOpenImage = 26503;
private const int MenuSaveImage = 26504;
private const int MenuCopyImageUrl = 26505;
#if DEBUG
private const int MenuOpenDevTools = 26599;
protected void AddDebugMenuItems(IMenuModel model){
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
}
#endif
private readonly Form form;
protected ContextMenuBase(Form form){
@ -100,12 +94,10 @@ public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser br
Match match = RegexTwitterAccount.Match(parameters.UnfilteredLinkUrl);
SetClipboardText(match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl);
break;
#if DEBUG
case MenuOpenDevTools:
browserControl.ShowDevTools();
break;
#endif
}
return false;
@ -120,6 +112,10 @@ public virtual bool RunContextMenu(IWebBrowser browserControl, IBrowser browser,
protected void SetClipboardText(string text){
form.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
}
protected void AddDebugMenuItems(IMenuModel model){
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
}
protected static void RemoveSeparatorIfLast(IMenuModel model){
if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){

View File

@ -82,10 +82,10 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins);
globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram);
#if DEBUG
globalMenu.AddSeparator();
AddDebugMenuItems(globalMenu);
#endif
if (HasDevTools){
globalMenu.AddSeparator();
AddDebugMenuItems(globalMenu);
}
}
RemoveSeparatorIfLast(model);

View File

@ -43,10 +43,10 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
model.AddSeparator();
}
}
#if DEBUG
AddDebugMenuItems(model);
#endif
if (HasDevTools){
AddDebugMenuItems(model);
}
RemoveSeparatorIfLast(model);