Exemplo n.º 1
0
        /// <summary>
        /// Make SimpleChannel from GuildChannel with overriden LastMessageId
        /// </summary>
        /// <param name="channel">GuildChannel</param>
        /// <param name="overridelastmessageid">New LastMessageId</param>
        /// <returns>SimpleChannel</returns>
        public static SimpleChannel MakeChannel(GuildChannel channel, string overridelastmessageid = null)
        {
            // Create basic SimpleChannel
            SimpleChannel sc = new SimpleChannel
            {
                Id   = channel.Id,
                Name = channel.Name,
                Type = channel.Type,
                Nsfw = channel.NSFW,
                // Override LastMessageId
                LastMessageId = overridelastmessageid ?? channel.LastMessageId,
                Position      = channel.Position,
                ParentId      = channel.ParentId,
                Icon          = channel.Icon
            };

            // Determine if has permission
            sc.HavePermissions =
                LocalState.Guilds[App.CurrentGuildId].channels[sc.Id].permissions.ReadMessages ||
                App.CurrentGuildId == sc.Id;

            // Determine if SimpleChannel should be displayed
            if (!(sc.IsMuted && Storage.Settings.HideMutedChannels) && (sc.HavePermissions || Storage.Settings.ShowNoPermissionChannels))
            {
                return(sc);
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Make flyout for Category
        /// </summary>
        /// <param name="category">Category control</param>
        /// <param name="parentId">Guild Id</param>
        /// <returns>A MenuFlyout item to display</returns>
        public static MenuFlyout MakeCategoryMenu(GuildChannel category, string parentId)
        {
            MenuFlyout menu = new MenuFlyout();

            menu.MenuFlyoutPresenterStyle = (Style)App.Current.Resources["MenuFlyoutPresenterStyle1"];

            // Add "Mark As Read" button
            MenuFlyoutItem markasread = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/MarkAsRead"),
                Icon = new SymbolIcon(Symbol.View),
                Tag  = new Tuple <string, string>(category.Id, parentId)
            };

            markasread.Click += FlyoutManager.MarkCategoryAsRead;
            menu.Items.Add(markasread);

            return(menu);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create GuildChannel from API model with missing guildId
 /// </summary>
 /// <param name="channel">API model</param>
 /// <param name="guildId">Guild ID</param>
 public GuildChannel(DiscordAPI.SharedModels.GuildChannel channel, string guildId)
 {
     raw         = channel;
     raw.GuildId = guildId;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create GuildChannel object from API model
 /// </summary>
 /// <param name="channel">API model</param>
 public GuildChannel(DiscordAPI.SharedModels.GuildChannel channel)
 {
     raw = channel;
 }