mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-10-29 03:24:22 +01:00
Configuration
Core
Bridge
Controls
Handling
General
ContextMenuBase.cs
ContextMenuBrowser.cs
ContextMenuGuide.cs
ContextMenuNotification.cs
DragHandlerBrowser.cs
KeyboardHandlerBrowser.cs
KeyboardHandlerNotification.cs
RequestHandlerBase.cs
RequestHandlerBrowser.cs
ResourceHandlerNotification.cs
Management
Notification
Other
Utils
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
FormManager.cs
TweetDeckBrowser.cs
Data
Plugins
Properties
Resources
Updates
bld
lib
subprocess
tests
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
packages.config
99 lines
3.8 KiB
C#
99 lines
3.8 KiB
C#
using CefSharp;
|
|
using TweetDuck.Core.Controls;
|
|
using TweetDuck.Core.Notification;
|
|
|
|
namespace TweetDuck.Core.Handling{
|
|
sealed class ContextMenuNotification : ContextMenuBase{
|
|
private const CefMenuCommand MenuViewDetail = (CefMenuCommand)26600;
|
|
private const CefMenuCommand MenuSkipTweet = (CefMenuCommand)26601;
|
|
private const CefMenuCommand MenuFreeze = (CefMenuCommand)26602;
|
|
private const CefMenuCommand MenuCopyTweetUrl = (CefMenuCommand)26603;
|
|
private const CefMenuCommand MenuCopyQuotedTweetUrl = (CefMenuCommand)26604;
|
|
|
|
private readonly FormNotificationBase form;
|
|
private readonly bool enableCustomMenu;
|
|
|
|
public ContextMenuNotification(FormNotificationBase form, bool enableCustomMenu) : base(form){
|
|
this.form = form;
|
|
this.enableCustomMenu = enableCustomMenu;
|
|
}
|
|
|
|
public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
|
model.Clear();
|
|
|
|
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection)){
|
|
model.AddItem(CefMenuCommand.Copy, "Copy");
|
|
model.AddSeparator();
|
|
}
|
|
|
|
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
|
|
|
if (enableCustomMenu){
|
|
if (form.CanViewDetail){
|
|
model.AddItem(MenuViewDetail, "View detail");
|
|
}
|
|
|
|
model.AddItem(MenuSkipTweet, "Skip tweet");
|
|
model.AddCheckItem(MenuFreeze, "Freeze");
|
|
model.SetChecked(MenuFreeze, form.FreezeTimer);
|
|
|
|
if (!string.IsNullOrEmpty(form.CurrentTweetUrl)){
|
|
model.AddSeparator();
|
|
model.AddItem(MenuCopyTweetUrl, "Copy tweet address");
|
|
|
|
if (!string.IsNullOrEmpty(form.CurrentQuoteUrl)){
|
|
model.AddItem(MenuCopyQuotedTweetUrl, "Copy quoted tweet address");
|
|
}
|
|
}
|
|
}
|
|
|
|
if (HasDevTools){
|
|
AddSeparator(model);
|
|
AddDebugMenuItems(model);
|
|
}
|
|
|
|
RemoveSeparatorIfLast(model);
|
|
|
|
form.InvokeAsyncSafe(() => {
|
|
form.ContextMenuOpen = true;
|
|
form.AnalyticsFile.NotificationContextMenus.Trigger();
|
|
});
|
|
}
|
|
|
|
public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
|
if (base.OnContextMenuCommand(browserControl, browser, frame, parameters, commandId, eventFlags)){
|
|
return true;
|
|
}
|
|
|
|
switch(commandId){
|
|
case MenuSkipTweet:
|
|
form.InvokeAsyncSafe(form.FinishCurrentNotification);
|
|
return true;
|
|
|
|
case MenuFreeze:
|
|
form.InvokeAsyncSafe(() => form.FreezeTimer = !form.FreezeTimer);
|
|
return true;
|
|
|
|
case MenuViewDetail:
|
|
form.InvokeSafe(form.ShowTweetDetail);
|
|
return true;
|
|
|
|
case MenuCopyTweetUrl:
|
|
SetClipboardText(form, form.CurrentTweetUrl);
|
|
return true;
|
|
|
|
case MenuCopyQuotedTweetUrl:
|
|
SetClipboardText(form, form.CurrentQuoteUrl);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame){
|
|
base.OnContextMenuDismissed(browserControl, browser, frame);
|
|
form.InvokeAsyncSafe(() => form.ContextMenuOpen = false);
|
|
}
|
|
}
|
|
}
|