コード例 #1
0
        public void StartHeartbeat()
        {
            ChromecastChannel channel;

            if (!Channels.Any(ie => ie.Namespace == DialConstants.DialHeartbeatUrn))
            {
                channel = CreateChannel(DialConstants.DialHeartbeatUrn);
            }
            else
            {
                channel = Channels.FirstOrDefault(i => i.Namespace == DialConstants.DialHeartbeatUrn);
            }
            if (channel != null && _hearbeatRunning == false)
            {
                _hearbeatRunning = true;

                Task.Run(async() =>
                {
                    while (_hearbeatRunning)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(5));
                        channel.Write(MessageFactory.Ping());
                    }
                });
            }
        }
コード例 #2
0
ファイル: ChannelContext.cs プロジェクト: Otradaa/imagination
        public ChannelContext(DbContextOptions <ChannelContext> options)
            : base(options)
        {
            Database.EnsureCreated();
            if (!Channels.Any())
            {
                Channels.Add(new Channel {
                    Name = "Great New Channel", UserId = 1, Date = DateTime.Now, Description = "Great and New"
                });
                Channels.Add(new Channel {
                    Name = "Not great Channel", UserId = 1, Date = DateTime.Now, Description = "not great at all"
                });

                SaveChanges();
            }

            if (!Subscriptions.Any())
            {
                Subscriptions.Add(new Subscription {
                    UserId = 2, ChannelId = 1
                });
                SaveChanges();
            }

            if (!ChannelImages.Any())
            {
                ChannelImages.Add(new ChannelImage {
                    ChannelId = 1, Description = "Hey guys, it's a great new channel", Date = DateTime.Now, ImageId = 1
                });
                SaveChanges();
            }
        }
コード例 #3
0
        public async Task Initialize()
        {
            Channels = await apiGateway.Get <List <ChannelModel> >("Channels").ConfigureAwait(false);

            if (Channels == null)
            {
                return;
            }

            await suspensionsHub.StartAsync().ConfigureAwait(false);

            if (!Channels.Any(x => string.Equals(x.ChannelName, userService.CurrentUserTwitchUsername, StringComparison.OrdinalIgnoreCase)))
            {
                if (Channels.Count > 0)
                {
                    await FetchSuspensionForChannel(Channels[0].ChannelName).ConfigureAwait(false);
                    await FetchSeenUsersForChannel(Channels[0].ChannelName).ConfigureAwait(false);
                }
            }
            else
            {
                await FetchSuspensionForChannel(userService.CurrentUserTwitchUsername).ConfigureAwait(false);
                await FetchSeenUsersForChannel(userService.CurrentUserTwitchUsername).ConfigureAwait(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// Starts the streaming of channel data.
        /// </summary>
        public void StartStreaming()
        {
            if (Parent.Session == null)
            {
                LogSessionClientError();
                return;
            }

            // If no channels were selected display a warning message
            if (!Channels.Any(c => c.IsChecked))
            {
                Runtime.ShowWarning(string.Format(NoChannelsSelectedMessage, "Streaming Start"));
                return;
            }

            try
            {
                Parent.EtpExtender.ChannelStreamingStart(Channels, GetStreamingStartValue());
            }
            catch (OverflowException ex)
            {
                Runtime.ShowError(UnscaledIndexMessage, ex);
            }
            catch (Exception ex)
            {
                Runtime.ShowError(ErrorSettingIndexMessage, ex);
            }
        }
コード例 #5
0
        private async Task RefreshChannels(bool force = false)
        {
            if (!force && Channels.Any())
            {
                return;
            }

            if (BusyStart != null)
            {
                BusyStart();
            }

            Channels.Clear();

            var channels = await _slackClient.GetChannels(new ChannelQuery { IncludeArchived = false, MyChannelsOnly = true });

            foreach (var c in channels)
            {
                Channels.Add(
                    new SlackItem(c.id, "#{0}".FormatWith(c.name), c.purpose.value, "#{0}".FormatWith(c.name)));
            }

            if (BusyStop != null)
            {
                BusyStop();
            }
        }
コード例 #6
0
ファイル: Character.cs プロジェクト: zoukidev/SilverDofus
 public void RemoveChannel(Channel.ChannelHeader header)
 {
     if (Channels.Any(x => x.Header == header))
     {
         Channels.RemoveAll(x => x.Header == header);
     }
 }
コード例 #7
0
        private void OnChannelMetadata(object sender, ProtocolEventArgs <ChannelMetadata> e)
        {
            if (!e.Message.Channels.Any())
            {
                Parent.Details.Append(Environment.NewLine + "// No channels were described");
                return;
            }

            // add to channel metadata collection
            e.Message.Channels.ForEach(x =>
            {
                if (Channels.Any(c => c.ChannelUri.EqualsIgnoreCase(x.ChannelUri)))
                {
                    return;
                }

                Channels.Add(x);
                ChannelStreamingInfos.Add(ToChannelStreamingInfo(x));
            });

            if (e.Header.MessageFlags != (int)MessageFlags.MultiPart)
            {
                LogChannelMetadata(Channels);
            }
        }
コード例 #8
0
 public void ChangeChannelState(char head, bool state)
 {
     if (Channels.Any(x => x.Head == head))
     {
         Channels.First(x => x.Head == head).On = state;
         Client.NClient.Send(string.Format("cC{0}{1}", (state ? "+" : "-"), head.ToString()));
     }
 }
コード例 #9
0
ファイル: AvediaServer.cs プロジェクト: uxav/lib2-devices
        public void Initialize()
        {
            if (_timer != null)
            {
                return;
            }

            _refreshCount = 60;

            CrestronEnvironment.ProgramStatusEventHandler += type =>
            {
                _programStopping = type == eProgramStatusEventType.Stopping;
                if (_programStopping)
                {
                    RequestQueue.Enqueue(null);
                }
            };

            _timer = new CTimer(specific =>
            {
                _refreshCount = _refreshCount - 1;

                try
                {
                    if (_refreshCount == 0 || !Receivers.Any())
                    {
                        Receivers.Discover();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting receiver collection from AvediaServer, {0}", e.Message);
                }

                try
                {
                    if (_refreshCount == 0 || !Channels.Any())
                    {
                        Channels.UpdateChannels();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting channel collection from AvediaServer, {0}", e.Message);
                }

                if (!_initialized)
                {
                    _initialized = true;
                    OnHasInitialized(this);
                }

                if (_refreshCount == 0)
                {
                    _refreshCount = 60;
                }
            }, null, 1000, (long)TimeSpan.FromMinutes(1).TotalMilliseconds);
        }
コード例 #10
0
 public bool Exists(string name)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     lock (Sync)
         return(Channels.Any(c => c.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)));
 }
コード例 #11
0
 public bool Exists(IChannel channel)
 {
     if (channel == null)
     {
         throw new ArgumentNullException(nameof(channel));
     }
     lock (Sync)
         return(Channels.Any(c => c.Equals(channel)));
 }
コード例 #12
0
 void _join(string channel)
 {
     if (!Channels.Any(x => x.ChannelName == channel))
     {
         var vm = new Controls.ChannelViewModel(_irc, channel);
         vm.Parted += OnParted;
         Channels.Add(vm);
         CurrentChannel = vm;
     }
 }
コード例 #13
0
        private async Task ChannelsHubSignalRClient_ChannelJoined(object _, ChannelJoinedEventArgs e)
        {
            if (!Channels.Any(x => x.ChannelName == e.ChannelName))
            {
                await FetchChannels().ConfigureAwait(false);
            }
            else
            {
                UpdateConnectedStateForChannels(e.ChannelName, true);
            }

            NotifyStateChanged();
        }
コード例 #14
0
ファイル: ChannelPool.cs プロジェクト: younes21/abp
    public void Dispose()
    {
        if (IsDisposed)
        {
            return;
        }

        IsDisposed = true;

        if (!Channels.Any())
        {
            Logger.LogDebug($"Disposed channel pool with no channels in the pool.");
            return;
        }

        var poolDisposeStopwatch = Stopwatch.StartNew();

        Logger.LogInformation($"Disposing channel pool ({Channels.Count} channels).");

        var remainingWaitDuration = TotalDisposeWaitDuration;

        foreach (var poolItem in Channels.Values)
        {
            var poolItemDisposeStopwatch = Stopwatch.StartNew();

            try
            {
                poolItem.WaitIfInUse(remainingWaitDuration);
                poolItem.Dispose();
            }
            catch
            { }

            poolItemDisposeStopwatch.Stop();

            remainingWaitDuration = remainingWaitDuration > poolItemDisposeStopwatch.Elapsed
                ? remainingWaitDuration.Subtract(poolItemDisposeStopwatch.Elapsed)
                : TimeSpan.Zero;
        }

        poolDisposeStopwatch.Stop();

        Logger.LogInformation($"Disposed RabbitMQ Channel Pool ({Channels.Count} channels in {poolDisposeStopwatch.Elapsed.TotalMilliseconds:0.00} ms).");

        if (poolDisposeStopwatch.Elapsed.TotalSeconds > 5.0)
        {
            Logger.LogWarning($"Disposing RabbitMQ Channel Pool got time greather than expected: {poolDisposeStopwatch.Elapsed.TotalMilliseconds:0.00} ms.");
        }

        Channels.Clear();
    }
コード例 #15
0
        public byte CreateChannelValue()
        {
            if (channelValue >= byte.MaxValue)
            {
                throw new NotSupportedException("Too many channels specified.");
            }

            while (Channels.Any(c => c.Value == channelValue))
            {
                ++channelValue;
            }

            return((byte)channelValue);
        }
コード例 #16
0
        public GuitarChordConfig(int[] frets, int[] channels,
                                 bool isSlide, bool isSlideReverse,
                                 bool isHammeron,
                                 ChordStrum strumMode,
                                 GuitarChordRootNoteConfig rootNoteConfig)
            : this()
        {
            this.RootNoteConfig = rootNoteConfig;
            if (frets != null)
            {
                Frets = frets.ToArray();
            }

            if (channels != null)
            {
                Channels = channels.ToArray();

                if (Frets != null)
                {
                    for (int x = 0; x < Frets.Count(); x++)
                    {
                        if (Frets[x].IsNotNull() && Channels[x].IsNull())
                        {
                            Channels[x] = Utility.ChannelDefault;
                        }
                        else if (Frets[x].IsNull() && Channels[x].IsNotNull())
                        {
                            Channels[x] = Int32.MinValue;
                        }
                    }
                }

                if (Channels.Any(x => x == Utility.ChannelX))
                {
                    for (int x = 0; x < Channels.Count(); x++)
                    {
                        if (Channels[x].IsNotNull())
                        {
                            Channels[x] = Utility.ChannelX;
                        }
                    }
                }
            }
            IsSlide        = isSlide | isSlideReverse;
            IsSlideReverse = isSlideReverse;
            IsHammeron     = isHammeron;
            StrumMode      = strumMode;
        }
        async Task IPermissionConfig.AddNewGuild(IGuild guild)
        {
            var users = await guild.GetUsersAsync(CacheMode.AllowDownload);

            var cUsers = new List <TUser>();

            foreach (var user in users)
            {
                if (!Users.Any(u => u.UserId == user.Id))
                {
                    cUsers.Add(await AddUserInternal(user));
                }
            }

            var tChannels = await guild.GetTextChannelsAsync();

            var cChannels = new List <TChannel>();

            foreach (var chan in tChannels)
            {
                if (!Channels.Any(c => c.ChannelId == chan.Id))
                {
                    cChannels.Add(await AddChannelInternal(chan));
                }
            }

            var cGuild = Guilds.SingleOrDefault(g => g.GuildId == guild.Id);

            if (cGuild == null)
            {
                Guilds.Add(await AddGuildInternal(guild, cChannels, cUsers));
            }
            else
            {
                foreach (var user in cUsers)
                {
                    cGuild.Users.Add(user);
                }
                foreach (var chan in cChannels)
                {
                    cGuild.Channels.Add(chan);
                }
            }
        }
コード例 #18
0
        protected async override Task InternalJoinChannel(Channel channel)
        {
            var channelName = channel.Name.ToLower();

            // Check channel.Name as lowercase string
            if (Channels.Any(c => c.Name == channelName))
            {
                OnError(new ChatErrorEventArgs(
                            $"The attempt to connect to the same channel - {channel} in chat.",
                            ChatError.ConnectionToSameChannel));
            }
            else
            {
                var reqJoin = new IRCMessage(
                    command: "JOIN",
                    middle: new[] { $"#{channelName}" });

                await SendAsync(reqJoin).ConfigureAwait(false);
            }
        }
コード例 #19
0
        /// <summary>
        /// Starts the streaming of channel data.
        /// </summary>
        public void SubscribeChannels()
        {
            if (Parent.Session == null)
            {
                LogSessionClientError();
                return;
            }

            // If no channels were selected display a warning message
            if (!Channels.Any(c => c.IsChecked))
            {
                Runtime.ShowWarning(string.Format(NoChannelsSelectedMessage, "Subscribe Channels"));
                return;
            }

            // TODO: Add input controls to view, similar to Data Load tab
            object lastIndex   = null;
            var    infill      = false;
            var    dataChanges = false;

            Parent.EtpExtender.SubscribeChannels(Channels, lastIndex, infill, dataChanges);
        }
コード例 #20
0
        protected virtual void OnChannelMetadata(IMessageHeader header, IList <IChannelMetadataRecord> channels)
        {
            if (!channels.Any())
            {
                Parent.Details.Append(Environment.NewLine + "// No channels were described");
                return;
            }

            // add to channel metadata collection
            channels.ForEach(x =>
            {
                if (Channels.Any(c => c.Record.ChannelUri.EqualsIgnoreCase(x.ChannelUri)))
                {
                    return;
                }

                Channels.Add(new ChannelMetadataViewModel(x));
            });

            if (header.MessageFlags != (int)MessageFlags.MultiPart)
            {
                LogChannelMetadata(Channels.Select(c => c.Record).ToArray());
            }
        }
コード例 #21
0
ファイル: Service.cs プロジェクト: PDFer/TGRaidBot
        private Raid ParseRaid(EventData data)
        {
            if (data == null || !Channels.Any(ch => ch.Gyms.Any(gym => gym.Contains(data.Gym))))
            {
                return(null);
            }

            if (!data.Start.HasValue && !data.End.HasValue)
            {
                Console.WriteLine("No Start or End time.");
                return(null);
            }

            DateTime start = DateTimeOffset.FromUnixTimeSeconds(data.Start.GetValueOrDefault()).LocalDateTime;
            DateTime end   = DateTimeOffset.FromUnixTimeSeconds(data.End.GetValueOrDefault()).LocalDateTime;

            if (data.Start.HasValue && !data.End.HasValue)
            {
                end = start + new TimeSpan(0, 45, 0);
            }
            else if (!data.Start.HasValue)
            {
                start = end - new TimeSpan(0, 45, 0);
            }

            if (end < DateTime.Now)
            {
                return(null);
            }

            var raid = Raids.FirstOrDefault(r => r.Id == data.Raid);

            if (raid != null)
            {
                raid.Pokemon   = data.Pokemon;
                raid.Tier      = data.Tier.GetValueOrDefault();
                raid.StartTime = start;
                raid.EndTime   = end;
            }
            else
            {
                raid = new Raid(data.Raid, data.Gym)
                {
                    Pokemon   = data.Pokemon,
                    Tier      = data.Tier.GetValueOrDefault(),
                    StartTime = start,
                    EndTime   = end
                };
                Raids.Add(raid);
            }

            var raidToRemove       = Raids.FirstOrDefault(r => r.EndTime < DateTime.Now);
            var currentRaidRemoved = false;

            while (raidToRemove != null)
            {
                Raids.Remove(raidToRemove);
                if (raidToRemove == raid)
                {
                    currentRaidRemoved = true;
                }
                raidToRemove = Raids.FirstOrDefault(r => r.EndTime < DateTime.Now);
            }

            if (currentRaidRemoved)
            {
                return(null);
            }

            return(raid);
        }
コード例 #22
0
        private async void NewMessageHandler(NewMessageNotification obj)
        {
            var message = new Message(obj);

            if (message.Attachments != null && message.Attachments.Length != 0 && message.Attachments[0].IsImage)
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    message.Attachments[0].ImagePreview = await message.Attachments[0].Base64ToBitmapImage(message.Attachments[0].ImagePreviewString);
                    message.Attachments[0].ImagePreview = await rocketChatRest.GetImage(message.Attachments[0].ImageUrl);
                });
            }
            message.User = Users.FirstOrDefault(x => x.Id == message.User.Id);
            if (SelectedChannel != null && SelectedChannel.Id == obj.fields.args[0].rid)
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    Messages.Add(message);
                });
            }
            else
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (Channels.Any(x => x.Id == message.RoomId))
                    {
                        Channels.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true;
                        Channels.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight   = FontWeights.Bold;
                        if (message.Attachments != null && message.Attachments[0].IsImage)
                        {
                            notificationService.ShowNewMessageToastNotification(message, Channels.FirstOrDefault(x => x.Id == message.RoomId), true);
                        }
                        else
                        {
                            notificationService.ShowNewMessageToastNotification(message, Channels.FirstOrDefault(x => x.Id == message.RoomId));
                        }
                    }
                    if (Discussions.Any(x => x.Id == message.RoomId))
                    {
                        Discussions.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true;
                        Discussions.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight   = FontWeights.Bold;
                        if (obj.fields.args[0].t == null || obj.fields.args[0].t != "discussion-created")
                        {
                            if (message.Attachments != null && message.Attachments[0].IsImage)
                            {
                                notificationService.ShowNewMessageToastNotification(message, Discussions.FirstOrDefault(x => x.Id == message.RoomId), true);
                            }
                            else
                            {
                                notificationService.ShowNewMessageToastNotification(message, Discussions.FirstOrDefault(x => x.Id == message.RoomId));
                            }
                        }
                    }
                    if (DirectConversations.Any(x => x.Id == message.RoomId))
                    {
                        DirectConversations.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true;
                        DirectConversations.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight   = FontWeights.Bold;
                        if (message.Attachments != null && message.Attachments[0].IsImage)
                        {
                            notificationService.ShowNewMessageToastNotification(message, DirectConversations.FirstOrDefault(x => x.Id == message.RoomId), true);
                        }
                        else
                        {
                            notificationService.ShowNewMessageToastNotification(message, DirectConversations.FirstOrDefault(x => x.Id == message.RoomId));
                        }
                    }
                    if (PrivateGroups.Any(x => x.Id == message.RoomId))
                    {
                        PrivateGroups.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true;
                        PrivateGroups.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight   = FontWeights.Bold;
                    }
                });
            }
        }
コード例 #23
0
        public MainWindowViewModel()
        {
            var listenEndPoint    = new IPEndPoint(IPAddress.Any, 8167);
            var broadcastEndPoint = new IPEndPoint(IPAddress.Parse("192.168.0.255"), 8167);

            _messenger = new QCMessenger(listenEndPoint, broadcastEndPoint);

            Nickname     = $"Guest_{new Random().Next()%1000}";
            _OldNickname = Nickname;
            Topic        = "Unset";

            SendMessageCommand = new DelegateCommand(async() =>
            {
                if (MessageText == "")
                {
                    return;
                }
                if (SelectedChannel.ChannelType == ChannelType.Public || SelectedChannel.ChannelType == ChannelType.Const)
                {
                    await _messenger.SendAsync(new PublicMessage(SelectedChannel.Id, String.IsNullOrWhiteSpace(SnoopName) ? Nickname : SnoopName, MessageText));
                }
                else
                {
                    await _messenger.SendAsync(new PrivateMessage(String.IsNullOrWhiteSpace(SnoopName) ? Nickname : SnoopName, SelectedChannel.Id, MessageText));
                }
                MessageText = string.Empty;
            });
            AddChannelCommand = new DelegateCommand(async() =>
            {
                if (NewChannelName == "" || Channels.Any(channel => channel.Id == NewChannelName))
                {
                    return;
                }
                Channels.Add(new ChannelViewModel(NewChannelName, ChannelType.Public));
                SelectedChannel = Channels.Last();
                await _messenger.SendAsync(new ConnectMessage(NewChannelName, Nickname));
                NewChannelName = string.Empty;
            });
            RemoveChannelCommand = new DelegateCommand <ChannelViewModel>(async ch =>
            {
                if (ch.Id == "#Main")
                {
                    return;
                }
                SelectedChannel = Channels.First();
                Channels.Remove(ch);
                await _messenger.SendAsync(new ExitMessage(ch.Id, Nickname));
            });
            ChangeTopicCommand = new DelegateCommand(async() => await _messenger.SendAsync(new TopicMessage(Topic, Nickname)));
            ChangeNameCommand  = new DelegateCommand(async() =>
            {
                await _messenger.SendAsync(new RenameMessage(_OldNickname, Nickname));
                _OldNickname = Nickname;
            });
            AddPrivateChatCommand = new DelegateCommand <User>(u =>
            {
                if (Channels.Any(ch => ch.Id == u.Name))
                {
                    return;
                }
                Channels.Add(new ChannelViewModel(u.Name, ChannelType.Private));
            });
        }
コード例 #24
0
        public bool Analyse()
        {
            bool bRetVal = false;

            /* Go through all the symbols of the system definition and get all the processes under optional parallelism */
            foreach (var symb in systemDefinition.Symbols)
            {
                if (symb.Type == Symbol.enSymbolType.Operator)
                {
                    if (symb.Value.Contains("[||"))
                    {
                        /* Here we have a optional parallel operator */
                        /* Get the name of the process before and after the operator */
                        int iLeftIndex  = systemDefinition.Symbols.IndexOf(symb) - 1;
                        int iRightIndex = iLeftIndex + 2;

                        /* Names of the processes */
                        String leftName  = systemDefinition.Symbols[iLeftIndex].Value;
                        String rightName = systemDefinition.Symbols[iRightIndex].Value;

                        /* Definition of the processes */
                        Process leftProc  = processList.First(p => p.Name == leftName);
                        Process rightProc = processList.First(p => p.Name == rightName);

                        /* Get the syncronisation set */
                        String   sSyncSetRaw = symb.Value.Trim(new char[] { '|', '[', ']', '{', '}' });
                        String[] SyncSet     = sSyncSetRaw.Split(new char[] { ',' });

                        /* Generate an output definition */
                        /* Rename the traces which are equal to the sync set */
                        /* Add a channel definition */
                        foreach (String syncTrace in SyncSet)
                        {
                            /* Add the processes to the process list if the do not already exist */
                            if (!Processes.Any(p => p.Name == leftProc.Name))
                            {
                                Processes.Add(leftProc);
                            }

                            if (!Processes.Any(p => p.Name == rightProc.Name))
                            {
                                Processes.Add(rightProc);
                            }

                            /* We have the two processes and the name of the sync trace between the processes */

                            if (leftProc.Symbols.Any(p => (p.Type == Symbol.enSymbolType.Trace) && (GetTrace(p.Value) == syncTrace)))
                            {
                                /* Only add a channel to the process if it does not already have a channel for the sync trace */
                                if (!leftProc.Channels.Any(p => p.PublicTrace == syncTrace))
                                {
                                    /* Create a channel for the left process */
                                    Channel chanLeft = new Channel(leftProc, syncTrace);
                                    /* Add the channel to the left process */
                                    leftProc.AddChannel(chanLeft);

                                    /* Add the channels to the channel list */
                                    if (!Channels.Any(p => p.Name == chanLeft.Name))
                                    {
                                        Channels.Add(chanLeft);
                                    }
                                }
                            }

                            if (rightProc.Symbols.Any(p => (p.Type == Symbol.enSymbolType.Trace) && (GetTrace(p.Value) == syncTrace)))
                            {
                                /* Only add a channel to the process if it does not already have a channel for the sync trace */
                                if (!rightProc.Channels.Any(p => p.PublicTrace == syncTrace))
                                {
                                    /* Create a channel for the right process */
                                    Channel chanRight = new Channel(rightProc, syncTrace);
                                    /* Add a channel to the right process */
                                    rightProc.AddChannel(chanRight);

                                    if (!Channels.Any(p => p.Name == chanRight.Name))
                                    {
                                        Channels.Add(chanRight);
                                    }
                                }
                            }
                        }

                        bRetVal = true;
                    }
                }
            }

            return(bRetVal);
        }
コード例 #25
0
 public bool IsForChannel(SocketMessage msg) =>
 IsGlobal ||
 Channels.Any(c => c.Channel.IsMonitored && c.Channel.DiscordId == msg.Channel.Id);
コード例 #26
0
        internal ChannelEx GetContentItemChannel(ContentItem item)
        {
            if ((item != null) && !string.IsNullOrEmpty(item.ID) && (Channels != null) && Channels.Any())
            {
                string[] idParts = item.ID.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
                if (idParts.Length > 0)
                {
                    return(Channels.Cast <ChannelEx>().FirstOrDefault(c => c.ID == idParts[0]));
                }
            }

            return(null);
        }
コード例 #27
0
 public StreamInfoReply(string name, string value) : base(name, value)
 {
     Channels         = StreamChannel.ParseChannels(value).ToList().AsReadOnly();
     IsWaitingForData = Channels.Any(c => c.IsNoData);
 }
コード例 #28
0
        private void Import(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(asset.Name) ||
                Channels.Count == 0 ||
                Channels.Any(c => string.IsNullOrEmpty(c.Filename)) ||
                string.IsNullOrEmpty(asset.Description))
            {
                MessageBox.Show("All fields must be filled");
                return;
            }

            asset.ChannelMappings = Channels.ToList();
            asset.SourceFilenames = asset.ChannelMappings.Select(c => c.Filename).Distinct().Where(s => s != "null").ToList();

            var texturesPath = Path.GetFullPath(Path.Combine(Properties.Settings.Default.ImportedAssetsPath, "Textures"));

            texturesPath += new DirectoryInfo(asset.SourceFilenames[0]).Parent.Name;
            var outputName = Path.Combine(texturesPath, Path.ChangeExtension(asset.Name, "dds"));

            if (!Directory.Exists(texturesPath))
            {
                Directory.CreateDirectory(texturesPath);
            }

            asset.ImportedFilename = System.IO.Path.GetFullPath(outputName);

            if (!isEditMode && File.Exists(asset.ImportedFilename))
            {
                MessageBox.Show("An imported texture with the same name already exists, stopping");
                return;
            }

            var result = import(asset.Format, asset.ChannelMappings, asset.ImportedFilename);

            if (!string.IsNullOrEmpty(result))
            {
                status.Text = result;
            }
            else
            {
                asset.LastUpdated     = DateTime.Now;
                asset.ImporterVersion = ImporterVersion;

                using (var stream = File.OpenRead(asset.ImportedFilename))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        reader.BaseStream.Position = 12;

                        asset.Height = reader.ReadInt32().ToString();
                        asset.Width  = reader.ReadInt32().ToString();

                        reader.BaseStream.Position = 128;
                        asset.Format = (DXGI_FORMAT)reader.ReadInt32();
                    }
                }

                this.DialogResult = true;
                this.Close();
            }
        }
コード例 #29
0
        }                                                    // does there need to be a more explicit way of assigning this?

        public void UpdateChannels()
        {
            lock (Sync) {
                string[] channelNames = ChannelNames;

                foreach (IChannel channel in Channels)
                {
                    if (channelNames.Contains(channel.Name))
                    {
                        using IConfig config = Config.ScopeTo($@"channels:{channel.Name}");
                        bool   autoJoin    = config.ReadValue(@"autoJoin", DefaultChannel == null || DefaultChannel == channel);
                        string password    = null;
                        int?   minRank     = null;
                        uint?  maxCapacity = null;

                        if (!autoJoin)
                        {
                            password = config.ReadValue(@"password", string.Empty);
                            if (string.IsNullOrEmpty(password))
                            {
                                password = null;
                            }

                            minRank     = config.SafeReadValue(@"minRank", 0);
                            maxCapacity = config.SafeReadValue(@"maxCapacity", 0u);
                        }

                        Update(channel, null, false, minRank, password, autoJoin, maxCapacity);
                    }
                    else if (!channel.IsTemporary)  // Not in config == temporary
                    {
                        Update(channel, temporary: true);
                    }
                }

                foreach (string channelName in channelNames)
                {
                    if (Channels.Any(x => x.Name == channelName))
                    {
                        continue;
                    }
                    using IConfig config = Config.ScopeTo($@"channels:{channelName}");
                    bool   autoJoin    = config.ReadValue(@"autoJoin", DefaultChannel == null || DefaultChannel.Name == channelName);
                    string password    = null;
                    int    minRank     = 0;
                    uint   maxCapacity = 0;

                    if (!autoJoin)
                    {
                        password = config.ReadValue(@"password", string.Empty);
                        if (string.IsNullOrEmpty(password))
                        {
                            password = null;
                        }

                        minRank     = config.SafeReadValue(@"minRank", 0);
                        maxCapacity = config.SafeReadValue(@"maxCapacity", 0u);
                    }

                    Create(Bot, channelName, false, minRank, password, autoJoin, maxCapacity);
                }

                if (DefaultChannel == null || DefaultChannel.IsTemporary || !channelNames.Contains(DefaultChannel.Name))
                {
                    DefaultChannel = Channels.FirstOrDefault(c => !c.IsTemporary && c.AutoJoin);
                }
            }
        }