public void Stop() { foreach (var item in this.ChannelList) { item.Stop(); } ChannelList.Clear(); timer.Dispose(); }
private async Task GetChannels() { var channelGroupList = await _channelSerivce.GetAppChannels(); if (channelGroupList != null) { ChannelList.Clear(); foreach (var group in channelGroupList.Groups) { foreach (var channel in group.Channels) { ChannelList.Add(channel); } } } this.CurrentChannel = ChannelList.FirstOrDefault(); }
private void PopulateChannelList() { ChannelList.Clear(); if (selectedGuildId == 0L) { return; } var server = LocatorService.DiscordSocketClient.GetGuild(selectedGuildId); foreach (var channel in server.TextChannels.OrderBy(x => x.Position)) { string temp = $"# {channel.Name}"; ChannelList.Add(new ChannelListModel { ChannelId = channel.Id, ChannelName = temp, }); } }
public async void GetPage() { Owner.Status = "フォローチャンネルを取得中"; var list = await FollowInstance.GetFollowedChannelAsync(CurrentPage); if (list == null) { return; } ChannelList.Clear(); foreach (var entry in list) { ChannelList.Add(new FollowChannelEntryViewModel(entry)); } IsActive = false; Owner.Status = ""; }
public void loadConfig() { { XmlDocument xd = new XmlDocument(); xd.Load(Path.Combine(Application.StartupPath, "config/channelList.xml")); XmlNodeList xnList = xd.SelectNodes("config/channelList/channel"); ChannelList.Clear(); foreach (XmlNode xn in xnList) { ChannelItem item = new ChannelItem(); item.ChannelName = xn.SelectSingleNode("channelName").InnerText; item.ChannelId = xn.SelectSingleNode("channelId").InnerText; ChannelList.Add(item); } } { XmlDocument xd = new XmlDocument(); xd.Load(Path.Combine(Application.StartupPath, "config/packageList.xml")); XmlNodeList xnList = xd.SelectNodes("config/packageList/package"); PackageList.Clear(); foreach (XmlNode xn in xnList) { PackageItem item = new PackageItem(); item.Title = xn.SelectSingleNode("pkgTitle").InnerText; item.PackageName = xn.SelectSingleNode("pkgName").InnerText; item.AppName = xn.SelectSingleNode("AppName").InnerText; item.ResourceDelete = xn.SelectSingleNode("ResourceDelete").InnerText; item.ResourceEncrypt = xn.SelectSingleNode("ResourceEncrypt").InnerText; item.ResourceNormal = xn.SelectSingleNode("ResourceNormal").InnerText; item.WinPhoneDescription = xn.SelectSingleNode("WinPhoneDescription").InnerText; item.WinPhoneProductID = xn.SelectSingleNode("WinPhoneProductID").InnerText; XmlNodeList metaDataList = xn.SelectNodes("metaData/item"); foreach (XmlNode metaData in metaDataList) { string k = metaData.Attributes["name"].Value; string v = metaData.Attributes["value"].Value; item.MetaData.Add(k, v); } PackageList.Add(item); } } { XmlDocument xd = new XmlDocument(); xd.Load(Path.Combine(Application.StartupPath, "config/enableList.xml")); XmlNodeList xnList = xd.SelectNodes("config/enableList/item"); foreach (XmlNode xn in xnList) { switch (xn.Attributes["name"].Value) { case "EnableMM": EnableMM = xn.Attributes["value"].Value.Equals("true"); break; case "EnableCopyFile": EnableCopyFile = xn.Attributes["value"].Value.Equals("true"); break; case "DeleteTemp": DeleteTemp = xn.Attributes["value"].Value.Equals("true"); break; default: break; } } xnList = xd.SelectNodes("config/encryptConfig/item"); foreach (XmlNode xn in xnList) { switch (xn.Attributes["name"].Value) { case "AllExts": { EncryptCfg.AllExts.Clear(); string attrValue = xn.Attributes["value"].Value; string[] strArr = attrValue.Split(';'); foreach (string item in strArr) { EncryptCfg.AllExts.Add("." + item); } } break; case "PartExts": { EncryptCfg.PartExts.Clear(); string attrValue = xn.Attributes["value"].Value; string[] strArr = attrValue.Split(';'); foreach (string item in strArr) { EncryptCfg.PartExts.Add("." + item); } } break; case "PartLength": EncryptCfg.PartLength = Convert.ToInt32(xn.Attributes["value"].Value); break; default: break; } } CopyFileList.Clear(); xnList = xd.SelectNodes("config/copyFileList/item"); foreach (XmlNode xn in xnList) { CopyFileList.Add(xn.Attributes["name"].Value); } ResourceFileList.Clear(); xnList = xd.SelectNodes("config/resourceFileList/item"); foreach (XmlNode xn in xnList) { ResourceFileList.Add(xn.Attributes["name"].Value); } WinPhoneFileList.Clear(); xnList = xd.SelectNodes("config/winPhoneFileList/item"); foreach (XmlNode xn in xnList) { WinPhoneFileList.Add(xn.Attributes["name"].Value); } } }
public ServerViewModel() { typingThrottler.Action += (sender, e) => { DispatcherHelper.CheckBeginInvokeOnUI(async() => { await(LocatorService.DiscordSocketClient.GetChannel(channelId) as SocketTextChannel).TriggerTypingAsync(); }); }; LocatorService.DiscordSocketClient.MessageReceived += DiscordClient_MessageReceived; LocatorService.DiscordSocketClient.MessageUpdated += DiscordClient_MessageUpdated; LocatorService.DiscordSocketClient.MessageDeleted += DiscordClient_MessageDeleted; LocatorService.DiscordSocketClient.UserUpdated += DiscordClient_UserUpdated; this.LoadJoinedServersList = new DelegateCommand(() => { ServerListModelList.Clear(); var servers = LocatorService.DiscordSocketClient.Guilds; foreach (var server in servers) { ServerListModelList.Add(new ServerListModel { ServerId = server.Id, ServerName = server.Name, ServerImageUri = server.IconUrl, }); } }); this.LoadCurrentUserAvatar = new DelegateCommand(() => { CurrentUserAvatarUrl = LocatorService.DiscordSocketClient.CurrentUser.GetAvatarUrlOrDefault(); }); this.SendMessageToCurrentChannel = new DelegateCommand(async() => { var message = currentChatMessage; if (String.IsNullOrEmpty(message)) { return; } if (channelId == 0) { return; } var channel = LocatorService.DiscordSocketClient.GetChannel(channelId) as SocketTextChannel; await channel.SendMessageAsync(message); CurrentChatMessage = String.Empty; }); this.ToggleUserListCommand = new DelegateCommand(() => { ShowUserList = !ShowUserList; }); this.UserClick = new DelegateCommand <ulong>((userId) => { // 0 for now should mean its the role header if (userId != 0) { LocatorService.NavigationService.NavigateTo("userProfile", userId); } }); this.ServerListToggle = new DelegateCommand(() => { ShowServerPane = !ShowServerPane; }); this.PinnedMessagesCommand = new DelegateCommand(() => { LocatorService.NavigationService.NavigateTo("pinnedMessages", new PinnedMessagesNavData { ChannelId = channelId, GuildId = selectedGuildId, }); }); this.LinkClickCommand = new DelegateCommand <LinkClickedEventArgs>(async(args) => { // todo: rest of these if (args.Link.StartsWith("http")) { await Windows.System.Launcher.LaunchUriAsync(new Uri(args.Link)); } }); this.OpenDMCommand = new DelegateCommand(() => { ChannelList.Clear(); selectedGuildId = 0L; foreach (var channel in LocatorService.DiscordSocketClient.DMChannels) { string temp = channel.Recipient.Username; ChannelList.Add(new ChannelListModel { ChannelId = channel.Id, ChannelName = temp, }); } }); }