public async Task <ulong> RequestRuleEphemeral(ContextMenuContext ctx) { List <DiscordSelectComponentOption> options = new List <DiscordSelectComponentOption>(); foreach (var item in RuleService.rules) { if (item.RuleNum == 0) { options.Add(new DiscordSelectComponentOption( $"OTHER", item.RuleNum.ToString())); continue; } var option = new DiscordSelectComponentOption( $"Rule {item.RuleNum}: {item.ShortDesc}", item.RuleNum.ToString(), item.RuleText.Length > 99 ? item.RuleText[..95] + "..." : item.RuleText); options.Add(option); } DiscordSelectComponent selectMenu = new DiscordSelectComponent("warnSelect", "Select a Rule!", options); var message = await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder() .AddComponents(selectMenu) .WithContent("") .AsEphemeral(true)); var reaction = await Interactivity.WaitForSelectAsync(message, Mod, "warnSelect", TimeSpan.FromMinutes(2)); Rule = RuleService.rules.Single(x => x.RuleNum.ToString() == reaction.Result.Values.First()); await reaction.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate); return(message.Id); }
public async Task UserInfoFromMessageCommand(ContextMenuContext ctx) { DiscordGuild guild = await ctx.Client.GetGuildAsync(Guilds.SBG); DiscordMember member = await guild.GetMemberAsync(ctx.TargetMessage.Author.Id); Permissions memberPerms = member.PermissionsIn(guild.GetChannel(ctx.Channel.Id)); DiscordEmbedBuilder userDetails = new DiscordEmbedBuilder { Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"ID: {member.Id} | isBot: {(member.IsBot ? "✔" : "✘")}", }, Color = new DiscordColor(95, 95, 95), Timestamp = DateTime.UtcNow, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = member.AvatarUrl, }, Title = $"**User Details for {ctx.Channel.Name}**", }; userDetails.WithDescription(this.BuildUserDetails(member)); userDetails.AddField("Guild Permissions", this.BuildPermissions(memberPerms, ctx)); await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(userDetails.Build()).AsEphemeral(true)); }
private string BuildUserEventsAsync(ulong discordId, ContextMenuContext ctx) { List <UserEvent> userEvents = this.userEventService.QueryEventReportAsync(discordId); StringBuilder discordUserEvents = new StringBuilder(); foreach (UserEvent events in userEvents) { if (events.Event == Event.Joined) { discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Join)} Joined - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n"); } if (events.Event == Event.Left) { discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Leave)} Left - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n"); } if (events.Event == Event.Banned) { discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Banned)} Banned - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n"); } if (events.Event == Event.Unbanned) { discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Edited)} Unbanned - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n"); } } return(discordUserEvents.ToString()); }
public async Task UserInfoFromUserMenu(ContextMenuContext ctx) { DiscordGuild guild = await ctx.Client.GetGuildAsync(Guilds.SBG); DiscordMember member = await guild.GetMemberAsync(ctx.TargetMember.Id); DiscordEmbedBuilder userDetails = new DiscordEmbedBuilder { Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"ID: {member.Id} | isBot: {(member.IsBot ? "✔" : "✘")}", }, Color = new DiscordColor(95, 95, 95), Timestamp = DateTime.UtcNow, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = member.AvatarUrl, }, Title = "**User Details**", }; userDetails.WithDescription(this.BuildUserDetails(member)); string userEvents = this.BuildUserEventsAsync(ctx.TargetMember.Id, ctx); if (!string.IsNullOrEmpty(userEvents)) { userDetails.AddField("User Server Events", userEvents); } await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(userDetails.Build()).AsEphemeral(true)); }
private string BuildPermissions(Permissions permissions, ContextMenuContext ctx) { string perms = $"**Add Reactions**: {(permissions.HasPermission(Permissions.AddReactions) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Administrator: {(permissions.HasPermission(Permissions.Administrator) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Attach Files**: {(permissions.HasPermission(Permissions.AttachFiles) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Ban Members: {(permissions.HasPermission(Permissions.BanMembers) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Change Nickname**: {(permissions.HasPermission(Permissions.ChangeNickname) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Connect: {(permissions.HasPermission(Permissions.UseVoice) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Create II: {(permissions.HasPermission(Permissions.CreateInstantInvite) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Embed Links**: {(permissions.HasPermission(Permissions.EmbedLinks) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Kick Members: {(permissions.HasPermission(Permissions.KickMembers) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Manage Channels**: {(permissions.HasPermission(Permissions.ManageChannels) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Manage Emojis: {(permissions.HasPermission(Permissions.ManageEmojis) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Manage Guild**: {(permissions.HasPermission(Permissions.ManageGuild) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Manage Messages: {(permissions.HasPermission(Permissions.ManageMessages) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Manage Nicknames**: {(permissions.HasPermission(Permissions.ManageNicknames) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Manage Roles: {(permissions.HasPermission(Permissions.ManageRoles) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Manage Webhooks**: {(permissions.HasPermission(Permissions.ManageWebhooks) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Mention Everyone: {(permissions.HasPermission(Permissions.MentionEveryone) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Move Members**: {(permissions.HasPermission(Permissions.MoveMembers) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Mute Members: {(permissions.HasPermission(Permissions.MuteMembers) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Read Message History**: {(permissions.HasPermission(Permissions.ReadMessageHistory) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Read Messages: {(permissions.HasPermission(Permissions.AccessChannels) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Send Messages**: {(permissions.HasPermission(Permissions.SendMessages) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Send TTS Messages: {(permissions.HasPermission(Permissions.SendTtsMessages) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Speak**: {(permissions.HasPermission(Permissions.Speak) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"Use External Emojis: {(permissions.HasPermission(Permissions.UseExternalEmojis) ? DiscordEmoji.FromName(ctx.Client, ":white_check_mark:") : DiscordEmoji.FromName(ctx.Client, ":x:"))}\n" + $"**Use VAD**: {(permissions.HasPermission(Permissions.UseVoiceDetection) ? "✔" : "✘")}\n"; return(perms); }
public async Task ContextAvatar(ContextMenuContext ctx) { string avatarUrl = ""; try { avatarUrl = await Helpers.UserOrMemberAvatarURL(ctx.TargetUser, ctx.Guild); } catch (ArgumentException e) { await ctx.RespondAsync($"{Program.cfgjson.Emoji.Xmark} {e.Message}", ephemeral : true); return; } DiscordEmbedBuilder embed = new DiscordEmbedBuilder() .WithColor(new DiscordColor(0xC63B68)) .WithTimestamp(DateTime.UtcNow) .WithFooter( $"Called by {ctx.User.Username}#{ctx.User.Discriminator} ({ctx.User.Id})", ctx.User.AvatarUrl ) .WithImageUrl(avatarUrl) .WithAuthor( $"Avatar for {ctx.TargetUser.Username} (Click to open in browser)", avatarUrl ); await ctx.RespondAsync(null, embed, ephemeral : true); }
/* H A N D L E C O N T E X T O P E N I N G */ /*---------------------------------------------------------------------------- * %%Function: HandleContextOpening * %%Qualified: AzLog.AzLogWindow.HandleContextOpening * %%Contact: rlittle * * This is going to get executed every time they go to open a context menu. * We want to know *where* they are invoking from, so we do some clever * hacker in HeaderSup.ColumnHeaderFromContextOpening(...) -- it figures out * (based on the client rects of the column header items) where they are * clicking and which column header is appropriate. * * NOTE: IF it locates a ColumnHeader and returns it to you, then * ColumnHeaderFromContextOpeneing CANCELS the context menu operation * from here from happening and assumes you are going to invoke the context * menu yourself (which is why we conly call m_ctxmHeader.Show() when * we get a columnheader back - this allows us to show our ContextMenu * for our Header columns instead of the context menu for the rest of the * listview) * * ALSO NOTE that we squirrel away the matched columnheader into the first * menu item in the context menu -- in our case, that's the * "Remove this column" menu item, so it follows that it needs to know * what "this" column is. (Other routings may choose to look here for this * information, so let's make sure to clear the Tag in times when we aren't * matched...) * ----------------------------------------------------------------------------*/ private void HandleContextOpening(object sender, CancelEventArgs e) { if (m_hs == null) { m_hs = new HeaderSupp(); } ColumnHeader ch = m_hs.ColumnHeaderFromContextOpening(m_lvLog, sender, e); if (ch != null) { m_ctxmHeader.Tag = ch; m_ctxmHeader.Items[0].Text = "Remove column " + ch.Text; m_ctxmHeader.Show(Control.MousePosition); } else { // we aren't in the column headers. now customize our context menu Point ptLocal = m_lvLog.PointToClient(Cursor.Position); ListViewItem lvi = m_lvLog.GetItemAt(ptLocal.X, ptLocal.Y); AzLogEntry azle = (AzLogEntry)lvi.Tag; ch = TCore.ListViewSupp.HeaderSupp.ColumnFromPoint(m_lvLog, ptLocal.X); AzLogViewSettings.AzLogViewColumn azlvc = m_azlvs.AzlvcFromName((string)ch.Tag); ContextMenuContext cmc = new ContextMenuContext(); cmc.azle = azle; cmc.lc = azlvc.DataColumn; m_ctxmListViewLog.Items[0].Tag = cmc; m_ctxmListViewLog.Items[0].Text = String.Format("Filter to this {0}", ch.Text); m_ctxmListViewLog.Items[1].Tag = cmc; m_ctxmListViewLog.Items[1].Text = String.Format("Filter out this {0}", ch.Text); m_ctxmListViewLog.Items[2].Tag = cmc; m_ctxmListViewLog.Items[2].Text = String.Format("Color this {0}", ch.Text); } }
internal ContextMenuEventArgs(ContextMenuContext context, nsIContextMenuInfo contextMenuInfo) { m_Context = context; m_DomEvent = DomEvent.Create(contextMenuInfo.MouseEvent); m_DomNode = DomNode.Create(contextMenuInfo.TargetNode); String associaledLink = XpcomStringHelper.Get(contextMenuInfo.GetAssociatedLink); Uri.TryCreate(associaledLink, UriKind.RelativeOrAbsolute, out m_AssociatedLink); }
/* F I L T E R T O C O N T E X T */ /*---------------------------------------------------------------------------- * %%Function: CreateFilterToContext * %%Qualified: AzLog.AzLogWindow.CreateFilterToContext * %%Contact: rlittle * * Grabt he ContextMenuContext that we stashed away when the context menu * was popping up and then make a filter for that. * * (we can't evaluate the context here because the mousemove that happened * to select the context menu item will screw up the context of *where* they * were when they right clicked for the context menu. * ----------------------------------------------------------------------------*/ private void CreateFilterToContext(object sender, EventArgs e) { ContextMenuContext cmc = (ContextMenuContext)((ToolStripMenuItem)sender).Tag; m_azlv.Filter.Add(new AzLogFilter.AzLogFilterCondition(AzLogFilter.AzLogFilterValue.ValueType.String, AzLogFilter.AzLogFilterValue.DataSource.Column, cmc.lc, AzLogFilter.AzLogFilterCondition.CmpOp.Eq, cmc.azle.GetColumn(cmc.lc))); m_azlv.Filter.Add(AzLogFilter.AzLogFilterOperation.OperationType.And); m_azlv.RebuildView(); }
public async Task DumpCommand(ContextMenuContext ctx) { await using var outStream = new MemoryStream(Encoding.UTF8.GetBytes(ctx.TargetMessage.Content)) { Position = 0 }; await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddFile("message.txt", outStream)); }
internal ShowControlContextMenuEventArgs( DockControl dockControl, System.Drawing.Point position, ContextMenuContext context) : base(dockControl) { this.x13d4cb8d1bd20347 = position; this.x0f7b23d1c393aed9 = context; }
public override async Task <bool> BeforeContextMenuExecutionAsync(ContextMenuContext ctx) { Ctx = ctx; // for now var res = await new RequireServerAdminOrOwnerSlashAttribute().ExecuteChecksAsync(ctx); if (!res) { throw new Exception("Checks failed"); } return(await base.BeforeContextMenuExecutionAsync(ctx)); }
/*---------------------------------------------------------------------------- * %%Function: CreateColorContext * %%Qualified: AzLog.AzLogWindow.CreateColorContext * * we're going to get called for the color item, so the parent of this item * should have our tag * ----------------------------------------------------------------------------*/ private void CreateColorContext(object sender, EventArgs e) { ToolStripMenuItem subMenuItem = (ToolStripMenuItem)sender; ToolStripMenuItem menuItem = colorThisToolStripMenuItem; ContextMenuContext cmc = (ContextMenuContext)(menuItem).Tag; AzLogFilter filter = new AzLogFilter(); filter.Add(new AzLogFilter.AzLogFilterCondition(AzLogFilter.AzLogFilterValue.ValueType.String, AzLogFilter.AzLogFilterValue.DataSource.Column, cmc.lc, AzLogFilter.AzLogFilterCondition.CmpOp.Eq, cmc.azle.GetColumn(cmc.lc))); m_azlv.AddColorFilter(filter, subMenuItem.BackColor, subMenuItem.ForeColor); m_azlv.RebuildView(); }
public override async Task <bool> ExecuteChecksAsync(ContextMenuContext ctx) { // SBG if (ctx.Guild.Id == 103933666417217536) { return(await Task.FromResult(ctx.Member?.Roles?.Any(r => r.Id == SBGRoles.Mod) ?? false)); } if (ctx.Guild.Id == 196820438398140417) { return(await Task.FromResult(true)); } return(await Task.FromResult(false)); }
public async Task WarnMessage(ContextMenuContext ctx) { await ctx.DeferAsync(true); if (!ctx.Member.Permissions.HasFlag(Permissions.KickMembers)) { await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("No you dumbass!")); return; } WarnBuilder warnBuilder = new WarnBuilder( ctx.Client, ctx.Guild.GetChannel(764251867135475713), ctx.Guild, ctx.Member, await ctx.Guild.GetMemberAsync(ctx.TargetMessage.Author.Id), ctx.TargetMessage); if (!await warnBuilder.PreExecutionChecks()) { return; } var id = await warnBuilder.RequestRuleEphemeral(ctx); var interaction = await warnBuilder.RequestPointsEphemeral(ctx, id); await warnBuilder.RequestReasonEphemeral(ctx, interaction); if (!await warnBuilder.WriteToDatabase()) { return; } if (!await warnBuilder.WriteAuditToDb()) { return; } await warnBuilder.ReadRemainingPoints(); await warnBuilder.SendWarnMessage(); await warnBuilder.LogMessage(); await warnBuilder.SendPunishMessageEphemeral(ctx, id); }
public async Task SetMessageContextMenuAsync(ContextMenuContext ctx) { string message = ctx.TargetMessage.Content; GuildBan?ban; if ((ban = await this._ban.GetBanAsync(ctx.Guild.Id)) is not null || (ban = await this._ban.GetBanAsync(ctx.Guild.OwnerId)) is not null) { await RespondError($"Your server is banned due to: {ban.Reason}\n\n" + $"Contact a staff member on the [support server](https://discord.gg/3SCTnhCMam) to learn more."); await ctx.Guild.LeaveAsync(); return; } if (string.IsNullOrWhiteSpace(message)) { await RespondError("The partner message can not be null or white space!"); return; } IReadOnlyList <string>?links = message.GetUrls(); foreach (string?l in links) { message = message.Remove(message.IndexOf(l), l.Length); } int drank = await this._donor.GetDonorRankAsync(ctx.Guild.OwnerId); (Partner?, string)res = await this._partners.UpdateOrAddPartnerAsync(ctx.Guild.Id, () => { PartnerUpdater dat = new() { Message = message, GuildIcon = ctx.Guild.IconUrl, GuildName = ctx.Guild.Name, UserCount = ctx.Guild.MemberCount, OwnerId = ctx.Guild.OwnerId, DonorRank = drank }; return(dat); });
public async Task <DiscordInteraction> RequestPointsEphemeral(ContextMenuContext ctx, ulong messageID) { DiscordWebhookBuilder webhook = new DiscordWebhookBuilder { Content = $"For this rule you can reduce the users chances by {Rule.MinPoints} - {Rule.MaxPoints}" }; for (int i = 0; i < 3; i++) { List <DiscordButtonComponent> buttons = new List <DiscordButtonComponent>(); for (int index = i * 5; index < (i * 5) + 5; index++) { buttons.Add(new DiscordButtonComponent ( ButtonStyle.Primary, (index + 1).ToString(), (index + 1).ToString(), (index + 1) < Rule.MinPoints || (index + 1) > Rule.MaxPoints) ); } webhook.AddComponents(buttons); } DiscordMessage pointsMessage = await ctx.EditFollowupAsync(messageID, webhook); var interactpointsMessage = await Interactivity.WaitForButtonAsync(pointsMessage, Mod, TimeSpan.FromMinutes(2)); PointsDeducted = int.Parse(interactpointsMessage.Result.Id); foreach (var item in webhook.Components) { foreach (DiscordButtonComponent button in item.Components) { button.Disable(); } } await ctx.EditFollowupAsync(messageID, webhook); return(interactpointsMessage.Result.Interaction); }
public async Task RequestRule(ContextMenuContext ctx = null) { List <DiscordSelectComponentOption> options = new List <DiscordSelectComponentOption>(); foreach (var item in RuleService.rules) { if (item.RuleNum == 0) { options.Add(new DiscordSelectComponentOption( $"OTHER", item.RuleNum.ToString())); continue; } var option = new DiscordSelectComponentOption( $"Rule {item.RuleNum}: {item.ShortDesc}", item.RuleNum.ToString(), item.RuleText.Length > 99 ? item.RuleText[..95] + "..." : item.RuleText); options.Add(option); } DiscordSelectComponent selectMenu = new DiscordSelectComponent("warnSelect", "Select a Rule!", options); DiscordMessageBuilder messageBuilder = new DiscordMessageBuilder() .AddComponents(selectMenu) .WithContent(""); DiscordMessage message = await WarnChannel.SendMessageAsync(messageBuilder); if (!(ctx is null)) { await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder { Content = message.JumpLink.ToString() }); } var reaction = await Interactivity.WaitForSelectAsync(message, Mod, "warnSelect", TimeSpan.FromMinutes(2)); Rule = RuleService.rules.Single(x => x.RuleNum.ToString() == reaction.Result.Values.First()); await message.DeleteAsync(); }
public async Task ContextHug(ContextMenuContext ctx) { await ctx.RespondAsync($"{Program.cfgjson.Emoji.BlobHug} {ctx.TargetUser.Mention} was given a tight hug by {ctx.User.Mention}!"); }
public async Task ContextPat(ContextMenuContext ctx) { await ctx.RespondAsync($"{Program.cfgjson.Emoji.BlobPats} {ctx.TargetUser.Mention} was given a big headpat by {ctx.User.Mention}!"); }
internal ShowControlContextMenuEventArgs(DockControl dockControl, Point position, ContextMenuContext context) : base(dockControl) { Position = position; Context = context; }
/* H A N D L E C O N T E X T O P E N I N G */ /*---------------------------------------------------------------------------- %%Function: HandleContextOpening %%Qualified: AzLog.AzLogWindow.HandleContextOpening %%Contact: rlittle This is going to get executed every time they go to open a context menu. We want to know *where* they are invoking from, so we do some clever hacker in HeaderSup.ColumnHeaderFromContextOpening(...) -- it figures out (based on the client rects of the column header items) where they are clicking and which column header is appropriate. NOTE: IF it locates a ColumnHeader and returns it to you, then ColumnHeaderFromContextOpeneing CANCELS the context menu operation from here from happening and assumes you are going to invoke the context menu yourself (which is why we conly call m_ctxmHeader.Show() when we get a columnheader back - this allows us to show our ContextMenu for our Header columns instead of the context menu for the rest of the listview) ALSO NOTE that we squirrel away the matched columnheader into the first menu item in the context menu -- in our case, that's the "Remove this column" menu item, so it follows that it needs to know what "this" column is. (Other routings may choose to look here for this information, so let's make sure to clear the Tag in times when we aren't matched...) ----------------------------------------------------------------------------*/ private void HandleContextOpening(object sender, CancelEventArgs e) { if (m_hs == null) m_hs = new HeaderSupp(); ColumnHeader ch = m_hs.ColumnHeaderFromContextOpening(m_lvLog, sender, e); if (ch != null) { m_ctxmHeader.Tag = ch; m_ctxmHeader.Items[0].Text = "Remove column " + ch.Text; m_ctxmHeader.Show(Control.MousePosition); } else { // we aren't in the collumn headers. now customize our context menu Point ptLocal = m_lvLog.PointToClient(Cursor.Position); ListViewItem lvi = m_lvLog.GetItemAt(ptLocal.X, ptLocal.Y); AzLogEntry azle = (AzLogEntry) lvi.Tag; ch = TCore.ListViewSupp.HeaderSupp.ColumnFromPoint(m_lvLog, ptLocal.X); AzLogViewSettings.AzLogViewColumn azlvc = m_azlvs.AzlvcFromName((string)ch.Tag); ContextMenuContext cmc = new ContextMenuContext(); cmc.azle = azle; cmc.lc = azlvc.DataColumn; m_ctxmListViewLog.Items[0].Tag = cmc; m_ctxmListViewLog.Items[0].Text = String.Format("Filter to this {0}", ch.Text); } }
public override List <MacroCommandDescriptor> GetMenuEntries(List <ObjectProxy> aSelectedObjects, ContextMenuContext aContext) { var result = new List <MacroCommandDescriptor>(); ExportManager = ExportManager ?? new ExportManager(Session); result.Add(new MacroCommandDescriptor() { CaptionLid = "Transfer to Unity", Execute = ConfigureTemplate }); var flow = Session.RunQuery("SELECT * FROM Flow WHERE ObjectType=FlowFragment"); var entitiesRoot = Session.GetSystemFolder(SystemFolderNames.Entities); var t = Session.GetSystemFolder(SystemFolderNames.Assets); foreach (var obj in flow.Rows) { var list = obj.GetChildren(); } switch (aContext) { case ContextMenuContext.Global: // entries for the "global" commands of the ribbon menu are requested return(result); default: // normal context menu when working in the content area, navigator, search return(result); } }
public override List <MacroCommandDescriptor> GetMenuEntries(List <ObjectProxy> aSelectedObjects, ContextMenuContext aContext) { var result = new List <MacroCommandDescriptor>(); switch (aContext) { case ContextMenuContext.Global: // entries for the "global" commands of the ribbon menu are requested return(result); default: // normal context menu when working in the content area, navigator, search return(result); } }
public Task UserMenu(ContextMenuContext ctx) { return(WhoIsTask(ctx, ctx.TargetMember)); }
public Task LookupContextAsync(ContextMenuContext ctx) => LookupAsync(ctx, ctx.TargetUser);
public static MenuFlyout GetTrackMenu(IAudio track, ContextMenuContext context) { var menu = new MenuFlyout(); if (context != ContextMenuContext.NowPlaying && context != ContextMenuContext.Player) { menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_Play"), Command = ViewModelLocator.Main.PlaySingleTrackCommand, CommandParameter = track }); menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_AddToNowPlaying"), Command = ViewModelLocator.Main.AddTrackToNowPlayingCommand, CommandParameter = track }); menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_PlayNext"), Command = ViewModelLocator.Main.PlayTrackNextCommand, CommandParameter = track }); menu.Items?.Add(new MenuFlyoutSeparator()); } if (context != ContextMenuContext.NowPlaying) { if (track is AudioVk) { var vkAudio = (AudioVk)track; if (vkAudio.IsAddedByCurrentUser) { if (context != ContextMenuContext.Player) { menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_Edit"), Command = ViewModelLocator.Main.EditTrackCommand, CommandParameter = track }); } menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_Remove"), Command = ViewModelLocator.Main.RemoveTrackFromMyMusicCommand, CommandParameter = track }); menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_AddToPlaylist"), Command = ViewModelLocator.Main.AddTrackToPlaylistCommand, CommandParameter = track }); } else { menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_AddToMyMusic"), Command = ViewModelLocator.Main.AddTrackToMyMusicCommand, CommandParameter = track }); } } } else { if (context != ContextMenuContext.Player) { menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_RemoveFromNowPlaying"), Command = ViewModelLocator.Main.RemoveTrackFromNowPlayingCommand, CommandParameter = track }); } } if (track is AudioVk) { menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_Lyrics"), Command = ViewModelLocator.Main.ShowTrackLyricsCommand, CommandParameter = track, IsEnabled = ((AudioVk)track).LyricsId != 0 }); } if (!(menu.Items?.LastOrDefault() is MenuFlyoutSeparator)) { menu.Items?.Add(new MenuFlyoutSeparator()); } menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_FindMore"), Command = ViewModelLocator.Main.FindMoreForTrackCommand, CommandParameter = track }); menu.Items?.Add(new MenuFlyoutItem() { Text = Resources.GetStringByKey("ContextMenu_CopyTitle"), Command = ViewModelLocator.Main.CopyTrackTitleCommand, CommandParameter = track }); return(menu); }
internal ContextMenuEventArgs(ContextMenuContext context, nsIDOMEvent domEvent, nsIDOMNode domNode) { m_Context = context; m_DomEvent = DomEvent.Create(domEvent); m_DomNode = DomNode.Create(domNode); }