Example #1
0
 public Channel(ChannelType type, int width, int height, long size)
 {
     this.type = type;
     this.width = width;
     this.height = height;
     this.size = size;
 }
        public static Server.GatewayRef CreateGateway(ActorSystem system, ChannelType type, string name, IPEndPoint endPoint,
                                                      XunitOutputLogger.Source outputSource,
                                                      Action<Server.GatewayInitiator> clientInitiatorSetup = null)
        {
            // initialize gateway initiator

            var initiator = new Server.GatewayInitiator()
            {
                GatewayLogger = new XunitOutputLogger($"Gateway({name})", outputSource),
                ListenEndPoint = endPoint,
                ConnectEndPoint = endPoint,
                TokenRequired = false,
                CreateChannelLogger = (_, o) => new XunitOutputLogger($"ServerChannel({name})", outputSource),
                CheckCreateChannel = (_, o) => true,
                ConnectionSettings = new Server.TcpConnectionSettings { PacketSerializer = s_serverSerializer },
                PacketSerializer = s_serverSerializer,
            };

            clientInitiatorSetup?.Invoke(initiator);

            // create gateway and start it

            var gateway = (type == ChannelType.Tcp)
                ? system.ActorOf(Props.Create(() => new Server.TcpGateway(initiator))).Cast<Server.GatewayRef>()
                : system.ActorOf(Props.Create(() => new Server.UdpGateway(initiator))).Cast<Server.GatewayRef>();
            gateway.Start().Wait();

            return gateway;
        }
Example #3
0
        /// <summary>
        /// Constructor (initiated by server)
        /// </summary>
        public SSH2ChannelBase(
                IPacketSender<SSH2Packet> packetSender,
                SSHConnectionParameter param,
                SSHProtocolEventManager protocolEventManager,
                uint localChannel,
                uint remoteChannel,
                ChannelType channelType,
                string channelTypeString,
                uint serverWindowSize,
                uint serverMaxPacketSize)
        {
            _packetSender = packetSender;
            _protocolEventManager = protocolEventManager;
            LocalChannel = localChannel;
            RemoteChannel = remoteChannel;
            ChannelType = channelType;
            ChannelTypeString = channelTypeString;

            _localMaxPacketSize = param.MaxPacketSize;
            _localWindowSize = _localWindowSizeLeft = param.WindowSize;
            _serverMaxPacketSize = serverMaxPacketSize;
            _serverWindowSizeLeft = serverWindowSize;

            _state = State.InitiatedByServer; // SendOpenConfirmation() will change state to "Opened"
        }
Example #4
0
        /// <summary>
        /// Setup constructor
		/// </summary>
		/// <param name="policyType">Associated policy type</param>
        /// <param name="name">Policy type display name</param>
        /// <param name="channels">Policy type channels</param>
        /// <param name="available">If policy type is available to be used in the designer</param>
		public PolicyTypeInfo(PolicyType policyType, IPolicyLanguageItem name, ChannelType[] channels, bool available)
		{
			m_PolicyType = policyType;
            m_Name = name;
            m_Channels = channels;
            m_Available = available;
        }
Example #5
0
    /// <summary>
    /// Play the specified audioClip on specified channel type. This function is meant to be used for single sound occurences.
    /// Use default level will set the attenuation to its default level.
    /// </summary>
    /// <param name="audioClip">Audio clip.</param>
    /// <param name="clipName">Clip name.</param>
    /// <param name="channeltype">Channeltype.</param>
    public void Play(AudioClip audioClip, ChannelType channeltype, AudioClipInfo clipInfo)
    {
        GameObject go = new GameObject("GameSound");
        go.tag = channeltype.ToString();
        go.transform.SetParent(gameObject.transform, false);
        AudioSource source = go.AddComponent<AudioSource>();
        source.playOnAwake = false;

        source.clip = audioClip;

        float lvl = 0.0f;
        ChannelInfo chInfo = null;
        channelInfos.TryGetValue(channeltype.ToString(), out chInfo);

        if(chInfo != null)
        {
            lvl = clipInfo.useDefaultDBLevel ? chInfo.defaultDBLevel : chInfo.settedDBLevel;
        }
        else
        {
            Debug.LogError("Channel info not found");
        }

        audioMixer.SetFloat(channeltype.ToString(),lvl);
        source.outputAudioMixerGroup = chInfo.audioMixerGroup;

        source.loop = clipInfo.isLoop;

        source.PlayDelayed(clipInfo.delayAtStart);
        playingList.Add(go);
    }
Example #6
0
        public static DoubleMatrix GetChannel(this MatrixBase<YCbCrColor> matrix,  ChannelType channelType)
        {
            var ret = new DoubleMatrix(matrix.RowCount, matrix.ColumnCount);

            for (int i = 0; i < matrix.RowCount; i++)
            {
                for (int j = 0; j < matrix.ColumnCount; j++)
                {
                    switch (channelType)
                    {
                        case ChannelType.Y:
                            ret[i, j] = matrix[i, j].Y;
                            break;
                        case ChannelType.Cr:
                            ret[i, j] = matrix[i, j].Cr;
                            break;
                        case ChannelType.Cb:
                            ret[i, j] = matrix[i, j].Cb;
                            break;
                        default:
                            throw new ArgumentOutOfRangeException("channelType");
                    }
                }
            }

            return ret;
        }
Example #7
0
 protected SSHChannel(SSHConnection con, ChannelType type, int local_id)
 {
     con.RegisterChannel(local_id, this);
     _connection = con;
     _type = type;
     _localID = local_id;
 }
Example #8
0
        public void ChangeChannelType(ChannelType channelType)
        {
            _model.ChannelType = channelType;
            _model.ChannelGroups.Clear();
            _model.ChannelGroups.AddRange(Proxies.SchedulerService.GetAllChannelGroups(channelType, true).Result);
            _model.ChannelGroups.Add(new ChannelGroup()
            {
                ChannelGroupId = channelType == ChannelType.Television ? ChannelGroup.AllTvChannelsGroupId : ChannelGroup.AllRadioChannelsGroupId,
                ChannelType = channelType,
                GroupName = _model.AllChannelsGroupName,
                VisibleInGuide = true
            });

            if (_model.GuideDateTime == DateTime.MinValue)
            {
                GotoNow();
                _model.CurrentChannelGroupId = _model.ChannelGroups[0].ChannelGroupId;
            }
            else
            {
                bool currentIsOk = false;
                foreach (ChannelGroup channelGroup in _model.ChannelGroups)
                {
                    if (channelGroup.ChannelGroupId == _model.CurrentChannelGroupId)
                    {
                        currentIsOk = true;
                        break;
                    }
                }
                if (!currentIsOk)
                {
                    _model.CurrentChannelGroupId = _model.ChannelGroups[0].ChannelGroupId;
                }
            }
        }
Example #9
0
 public void Initialize(ChannelType channelType, int epgHours, int epgHoursOffset, string allChannelsGroupName)
 {
     _model.EpgHours = epgHours;
     _model.EpgHoursOffset = epgHoursOffset;
     _model.AllChannelsGroupName = allChannelsGroupName;
     ChangeChannelType(channelType);
 }
 /// <summary>
 /// </summary>
 /// <param name="flags">
 /// </param>
 /// <param name="type">
 /// </param>
 /// <param name="id">
 /// </param>
 /// <param name="name">
 /// </param>
 public ChannelBase(ChannelFlags flags, ChannelType type, uint id, string name = "")
 {
     this.channelFlags = flags;
     this.channelType = type;
     this.ChannelId = id;
     this.ChannelName = name;
 }
        private static GatewayRef StartGateway(ActorSystem system, ChannelType type, int port)
        {
            var serializer = PacketSerializer.CreatePacketSerializer();

            var initiator = new GatewayInitiator
            {
                ListenEndPoint = new IPEndPoint(IPAddress.Any, port),
                GatewayLogger = LogManager.GetLogger("Gateway"),
                CreateChannelLogger = (ep, _) => LogManager.GetLogger($"Channel({ep}"),
                ConnectionSettings = new TcpConnectionSettings { PacketSerializer = serializer },
                PacketSerializer = serializer,
                CreateInitialActors = (context, connection) => new[]
                {
                    Tuple.Create(context.ActorOf(Props.Create(() => new EntryActor(context.Self.Cast<ActorBoundChannelRef>()))),
                                 new TaggedType[] { typeof(IEntry) },
                                 (ActorBindingFlags)0)
                }
            };

            var gateway = (type == ChannelType.Tcp)
                ? system.ActorOf(Props.Create(() => new TcpGateway(initiator))).Cast<GatewayRef>()
                : system.ActorOf(Props.Create(() => new UdpGateway(initiator))).Cast<GatewayRef>();
            gateway.Start().Wait();
            return gateway;
        }
        public ImportChannelsContext(ChannelType channelType)
        {
            _channelType = channelType;

            List<TreeNode> nodes = new List<TreeNode>();

            if (channelType == ChannelType.Television)
            {
                List<TvDatabase.ChannelGroup> groups = Utility.GetAllGroups<TvDatabase.ChannelGroup>();
                groups.Add(new TvDatabase.ChannelGroup(-1, "All Channels"));
                foreach (TvDatabase.ChannelGroup group in groups)
                {
                    TreeNode groupNode = new TreeNode(group.GroupName);
                    groupNode.Tag = group;
                    nodes.Add(groupNode);
                    groupNode.Nodes.Add(String.Empty);
                }
            }
            else
            {
                List<TvDatabase.RadioChannelGroup> groups = Utility.GetAllGroups<TvDatabase.RadioChannelGroup>();
                groups.Add(new TvDatabase.RadioChannelGroup(-1, "All Channels"));
                foreach (TvDatabase.RadioChannelGroup group in groups)
                {
                    TreeNode groupNode = new TreeNode(group.GroupName);
                    groupNode.Tag = group;
                    nodes.Add(groupNode);
                    groupNode.Nodes.Add(String.Empty);
                }
            }

            _channelNodes = nodes.ToArray();
        }
Example #13
0
 protected SSHChannel(SSHConnection con, ChannelType type, int localID)
 {
     con.ChannelCollection.RegisterChannel(localID, this);
     _connection = con;
     _type = type;
     _localID = localID;
 }
 public Dictionary<string, string> GetLogos(List<string> channelsNames, ChannelType type, string regionCode)
 {
     var result = new Dictionary<string, string>();
     using (var ctx = new EF.RepositoryContext("LogoDB"))
     {
         foreach (var channelName in channelsNames)
         {
             var aliases = ctx.Aliases.Include("Channel").Include("Channel.Logos").Include("Channel.Logos.Suggestion").Where(a => a.Name == channelName && a.Channel.Type == type);
             if (aliases.Any())
             {
                 if (!string.IsNullOrWhiteSpace(regionCode))
                 {
                     // find best matching by RegionCode
                     var matchedByRegion = aliases.FirstOrDefault(a => a.Channel.RegionCode == regionCode);
                     if (matchedByRegion != null)
                     {
                         result.Add(channelName, matchedByRegion.Channel.Logos.First(l => l.Suggestion == null).Id.ToString());
                         continue;
                     }
                 }
                 // simply use first one
                 result.Add(channelName, aliases.First().Channel.Logos.First(l => l.Suggestion == null).Id.ToString());
             }
         }
     }
     return result;
 }
        public async Task SlimClientFailedToConnectToSlimServer(ChannelType type)
        {
            // Act
            var exception = await Record.ExceptionAsync(() => CreatePrimaryClientChannelAsync(type));

            // Assert
            Assert.NotNull(exception);
        }
Example #16
0
 public ChannelLink(ChannelType channelType, Guid channelId, string channelName, int mpChannelId, string mpChannelName)
 {
     this.ChannelType = channelType;
     this.ChannelId = channelId;
     this.ChannelName = channelName;
     this.MPChannelId = mpChannelId;
     this.MPChannelName = mpChannelName;
 }
 /// <summary>
 /// Erzeugt eine Instanz von der Klasse Event.
 /// </summary>
 /// <param name="id">Die eindeutige Id des Events.</param>
 /// <param name="name">Der Name des Events.</param>
 /// <param name="description">Die Beschreibung des Events.</param>
 /// <param name="type">Der Typ des Kanals, hier Event.</param>
 /// <param name="creationDate">Das Erstellungsdatum des Events.</param>
 /// <param name="modiciationDate">Das Datum der letzten Änderung.</param>
 /// <param name="term">Das zugeordnete Semester.</param>
 /// <param name="locations">Ort, an dem das Event stattfindet.</param>
 /// <param name="dates">Termin, an dem das Event stattfindet.</param>
 /// <param name="contacts">Kontaktdaten von verantwortlichen Personen.</param>
 /// <param name="website">Ein oder mehrere Links auf Webseiten.</param>
 /// <param name="deleted">Gibt an, ob das Event als gelöscht markiert wurde.</param>
 /// <param name="cost">Die dem Event zugeordneten Kosten.</param>
 /// <param name="organizer">Der Veranstalter des Events.</param>
 public Event(int id, string name, string description, ChannelType type, DateTimeOffset creationDate, 
     DateTimeOffset modiciationDate, string term, string locations, string dates, string contacts, 
     string website, bool deleted, string cost, string organizer)
     : base(id, name, description, type, creationDate, modiciationDate, term, locations, dates, contacts, website, deleted)
 {
     this.cost = cost;
     this.organizer = organizer;
 }
 public Sports(int id, string name, string description, ChannelType type, DateTimeOffset creationDate,
     DateTimeOffset modificationDate, string term, string locations, string dates, string contacts, string website,
     bool deleted, string cost, string numberOfParticipants)
     : base(id, name, description, type, creationDate, modificationDate, term, locations, dates, contacts, website, deleted)
 {
     this.cost = cost;
     this.numberOfParticipants = numberOfParticipants;
 }
 /// <summary>
 /// Get all channels.
 /// </summary>
 /// <param name="channelType">The channel type of the channels to retrieve.</param>
 /// <param name="visibleOnly">Set to true to only receive channels that are marked visible.</param>
 /// <returns>A list containing zero or more channels.</returns>
 public async Task<List<Channel>> GetAllChannels(ChannelType channelType, bool visibleOnly = true)
 {
     var request = NewRequest(HttpMethod.Get, "Channels/{0}", channelType);
     if (!visibleOnly)
     {
         request.AddParameter("visibleOnly", false);
     }
     return await ExecuteAsync<List<Channel>>(request).ConfigureAwait(false);
 }
 public FileTransferChannelInfo(ChannelType type, 
                        HandleType target, 
                        string content_type, 
                        string description)
     : base(type, target)
 {
     ContentType = content_type;
     Description = description;
 }
Example #21
0
 public static Schedule CreateRecordOnceSchedule(ChannelType channelType, Guid channelId, Guid guideProgramId)
 {
     GuideProgram guideProgram = Proxies.GuideService.GetProgramById(guideProgramId).Result;
     if (guideProgram != null)
     {
         return CreateRecordOnceSchedule(channelType, channelId, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay, guideProgram.StartTime);
     }
     return null;
 }
Example #22
0
 public static Schedule CreateRecordRepeatingSchedule(RepeatingType repeatingType, ChannelType channelType, Guid channelId, Guid guideProgramId, string titleSuffix = null)
 {
     GuideProgram guideProgram = Proxies.GuideService.GetProgramById(guideProgramId).Result;
     if (guideProgram != null)
     {
         return CreateRecordRepeatingSchedule(repeatingType, channelType, channelId, guideProgram.Title, guideProgram.StartTime, titleSuffix);
     }
     return null;
 }
Example #23
0
 public SSH2Channel(SSHConnection con, ChannelType type, int local_id, int remote_id, int maxpacketsize)
     : base(con, type, local_id)
 {
     _windowSize = _leftWindowSize = con.Param.WindowSize;
     Debug.Assert(type==ChannelType.ForwardedRemoteToLocal);
     _remoteID = remote_id;
     _serverMaxPacketSize = maxpacketsize;
     _negotiationStatus = 0;
 }
Example #24
0
 public static Schedule CreateRecordRepeatingSchedule(ISchedulerService tvSchedulerAgent, IGuideService tvGuideAgent,
     RepeatingType repeatingType, ChannelType channelType, Guid channelId, Guid guideProgramId, string titleSuffix = null)
 {
     GuideProgram guideProgram = tvGuideAgent.GetProgramById(guideProgramId);
     if (guideProgram != null)
     {
         return CreateRecordRepeatingSchedule(tvSchedulerAgent, repeatingType, channelType, channelId, guideProgram.Title, guideProgram.StartTime, titleSuffix);
     }
     return null;
 }
Example #25
0
        public UserWorker(ClusterNodeContext context, Config config)
        {
            _context = context;
            _channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
            _listenEndPoint = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));

            var connectAddress = config.GetString("connect-address");
            var connectPort = config.GetInt("connect-port", _listenEndPoint.Port);
            _connectEndPoint = new IPEndPoint(connectAddress != null ? IPAddress.Parse(connectAddress) : IPAddress.Loopback, connectPort);
        }
Example #26
0
 public SSH2Channel(SSH2Connection con, ChannelType type, int local_id, string command)
     : base(con, type, local_id)
 {
     _command = command;
     if (type == ChannelType.ExecCommand || type == ChannelType.Subsystem)
         Debug.Assert(command != null); //'command' is required for ChannelType.ExecCommand
     _connection = con;
     _windowSize = _leftWindowSize = con.Param.WindowSize;
     _negotiationStatus = NegotiationStatus.WaitingChannelConfirmation;
 }
 void IMessageNotifier.RaiseMessageForwarded(ChannelType from, ChannelType to, TransportMessage message)
 {
     if (MessageForwarded != null)
         MessageForwarded(this, new MessageForwardingArgs
                                    {
                                        FromChannel = from,
                                        ToChannel = to,
                                        Message = message
                                    });
 }
    private Dictionary<int, ListViewItem> _listViewCache; //A list of allready created listviewitems

    /// <summary>
    /// Creates a new ChannelListView Handler
    /// </summary>
    /// <param name="listView"></param>
    /// <param name="channels"></param>
    /// <param name="allCards"></param>
    /// <param name="textBox"></param>
    internal ChannelListViewHandler(ListView listView, IList<Channel> channels, Dictionary<int, CardType> allCards,
                                    TextBox textBox, ChannelType type)
    {
      _listView = listView;
      _allChannels = channels;
      _allCards = allCards;
      _currentText = textBox;
      _type = type;
      _listViewCache = new Dictionary<int, ListViewItem>();
    }
Example #29
0
 public NxPolicySet(IPolicySet policySet, ChannelType channelType)
 {
     m_ChannelType = channelType;
     NxSet policies = new NxSet("Policies");            
     List<NxParameter> parameters = NxUtils.GetAttributes(policySet);
     parameters.Add(new NxParameter("Name", policySet));            
     policies.Append(new NxEvaluate("BeforePolicy", parameters));
     policies.Append(new NxInvokeSet("C1C0D5EA-5B82-4607-AE41-D52739AA6AB1"));
     policies.Append(new NxEvaluate("AfterPolicy", parameters));
     AppendSet(policies);
 }
 public Lecture(int id, string name, string description, ChannelType type, DateTimeOffset creationDate, 
     DateTimeOffset modificationDate, string term, string locations, string dates, string contacts,
     string website, bool deleted, Faculty faculty, string startDate, string endDate, string lecturer, string assistant)
     : base(id, name, description, type, creationDate, modificationDate, term, locations, dates, contacts, website, deleted)
 {
     this.faculty = faculty;
     this.startDate = startDate;
     this.endDate = endDate;
     this.lecturer = lecturer;
     this.assistant = assistant;
 }
Example #31
0
        public static async Task <Channel> FindChannel(this DiscordClient client, CommandEventArgs e, string name, ChannelType type = null)
        {
            var channels = e.Server.FindChannels(name, type);

            int count = channels.Count();

            if (count == 0)
            {
                await client.ReplyError(e, "Channel was not found.");

                return(null);
            }
            else if (count > 1)
            {
                await client.ReplyError(e, "Multiple channels were found with that name.");

                return(null);
            }
            return(channels.FirstOrDefault());
        }
Example #32
0
 /// <summary>
 /// 获得渠道商提供的Sdk配置
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public GameChannel GetChannelSetting(ChannelType type)
 {
     return(_sdkChannelDict.ContainsKey(type) ? _sdkChannelDict[type] : null);
 }
Example #33
0
    public void JoinChannel(string channelName, bool IsAudio, bool IsText, bool switchTransmission, ChannelType channelType)
    {
        ChannelId channelId = new ChannelId(issuer, channelName, domain, channelType);

        channelSession = loginSession.GetChannelSession(channelId);
        Bind_Channel_Callback_Listeners(true, channelSession);

        channelSession.BeginConnect(IsAudio, IsText, switchTransmission, channelSession.GetConnectToken(tokenKey, timeSpan), ar =>
        {
            try
            {
                channelSession.EndConnect(ar);
            }
            catch (Exception e)
            {
                Bind_Channel_Callback_Listeners(false, channelSession);
                Debug.Log(e.Message);
            }
        });
    }
Example #34
0
        static void Main(string[] args)
        {
            const int       NoiseSilencerEffect = 10;
            ChannelType     channelType         = ChannelType.Null;
            AudioFileReader audioStream         = null;
            long            currentBaseOffset   = 0;

            float[]             buffer = null;
            int                 bufferPointer = 0;
            long                peakCount = 0;
            TextWriter          outRawWriter = null;
            string              outputDirectory = null;
            float               upperPeak, lowerPeak;
            Tuple <float, long> peak           = new Tuple <float, long>(0, 0);
            long                lastPeakOffset = 0;
            bool                upper          = true;
            Speeds              speed          = Speeds.s600bps;
            int                 OnePeaks;
            int                 ZeroPeaks;
            int                 ThresholdPeakCount;
            int                 TypicalOneCount;
            int                 TypicalZeroCount;
            int                 peakCount1 = 0;
            int                 peakCount0 = 0;

            bool?[]    shiftRegister   = new bool?[11];
            DetectMode currentMode     = DetectMode.WaitHeader;
            int        valueCounter    = 0;
            string     currentFileName = "";

            byte[] currentFileImage     = new byte[32767];
            int    currentFileImageSize = 0;
            bool   bitsInPeakLog        = true;
            int    tryingBits           = 0;

#if DEBUG
            var waveRecorder   = new List <Tuple <float, long> >();
            var peakRecorder   = new List <Tuple <float, long> >();
            var waveLogEnabled = false;
#endif

            if (args.Length == 0)
            {
                Console.Error.WriteLine("Soft CMT Interface by autumn");
                Console.Error.WriteLine("usage: softcmtif INPUT_FILE_NAME [--verbose] [--300|--600|--1200] [--right|--left|--average|--maximum] [--peaklog FILE_NAME] [--bitsinpeaklog] [--outraw FILE_NAME] [--outdir PATH]");
                return;
            }
            bool bVerbose       = false;
            bool peaklogWaiting = false;
            bool outRawWaiting  = false;
            bool outDirWaiting  = false;
            foreach (var item in args.Skip(1))
            {
                if (peaklogWaiting)
                {
                    peaklogWriter  = File.CreateText(item);
                    peaklogWaiting = false;
                }
                else if (outRawWaiting)
                {
                    outRawWriter  = File.CreateText(item);
                    outRawWaiting = false;
                }
                else if (outDirWaiting)
                {
                    outputDirectory = item;
                    outDirWaiting   = false;
                }
                else if (item == "--verbose")
                {
                    bVerbose = true;
                }
                else if (item == "--right")
                {
                    channelType = ChannelType.Right;
                }
                else if (item == "--left")
                {
                    channelType = ChannelType.Left;
                }
                else if (item == "--average")
                {
                    channelType = ChannelType.Average;
                }
                else if (item == "--maximum")
                {
                    channelType = ChannelType.Maximum;
                }
                else if (item == "--bitsinpeaklog")
                {
                    bitsInPeakLog = true;
                }
                else if (item == "--peaklog")
                {
                    peaklogWaiting = true;
                }
                else if (item == "--outraw")
                {
                    outRawWaiting = true;
                }
                else if (item == "--outdir")
                {
                    outDirWaiting = true;
                }
                else if (item == "--300")
                {
                    speed = Speeds.s300bps;
                }
                else if (item == "--600")
                {
                    speed = Speeds.s600bps;
                }
                else if (item == "--1200")
                {
                    speed = Speeds.s1200bps;
                }
                else
                {
                    Console.WriteLine($"Unknwon option {item}");
                    return;
                }
            }
            if (bVerbose)
            {
                Console.WriteLine($"File Length: {new FileInfo(args[0]).Length}");
            }
            using (audioStream = new AudioFileReader(args[0]))
            {
                audioStream.Position = 0;
                setSpeed();
                clearShiftRegister();
                if (bVerbose)
                {
                    Console.WriteLine($"Audio Stream Length: {audioStream.Length}");
                    Console.WriteLine($"BlockAlign: {audioStream.BlockAlign}");
                    Console.WriteLine($"Channels: {audioStream.WaveFormat.Channels}");
                    Console.WriteLine($"BitsPerSample: {audioStream.WaveFormat.BitsPerSample}");
                    Console.WriteLine($"Encoding: {audioStream.WaveFormat.Encoding}");
                    Console.WriteLine($"ExtraSize: {audioStream.WaveFormat.ExtraSize}");
                    Console.WriteLine($"SampleRate: {audioStream.WaveFormat.SampleRate}");
                }
                if (audioStream.WaveFormat.Channels == 1)
                {
                    if (channelType != ChannelType.Null)
                    {
                        Console.WriteLine("Mono file not support --right|--left|--average");
                        return;
                    }
                }
                else if (audioStream.WaveFormat.Channels == 2)
                {
                    if (channelType == ChannelType.Null)
                    {
                        channelType = ChannelType.Maximum;
                    }
                }
                else
                {
                    Console.WriteLine($"Not supported channels {audioStream.WaveFormat.Channels}");
                    return;
                }
                if (bVerbose)
                {
                    Console.WriteLine($"Channel selected: ChannelType:{channelType}");
                }

                // detect upper peak and lower peak
                audioStream.Position = 0;
                upperAndLowerPeak();

                // detect wave peaks
                audioStream.Position = 0;
                peakCount1           = 0;
                peakCount0           = 0;
                currentBaseOffset    = 0;
#if DEBUG
                waveLogEnabled = true;
#endif
                for (; ;)
                {
                    var d = readUnit();
                    if (d == null)
                    {
                        break;
                    }

                    //if (peaklogWriter != null) peaklogWriter.WriteLine($"[{d.Item1} {d.Item2}]");
                    if (upper)
                    {
                        if (d.Item1 > peak.Item1)
                        {
                            peak = d;
                        }
                        else if (d.Item1 < 0.0f)
                        {
                            setPeak(d, false);
                        }
                    }
                    else
                    {
                        if (d.Item1 < peak.Item1)
                        {
                            peak = d;
                        }
                        else if (d.Item1 > 0.0f)
                        {
                            setPeak(d, true);
                        }
                    }
                }

                //float[] samples = new float[audioStream.Length / audioStream.BlockAlign * audioStream.WaveFormat.Channels];
                //audioStream.Read(samples, 0, samples.Length);



                // playback
                //var outputDevice = new WaveOutEvent();
                //outputDevice.Init(audioStream);
                //outputDevice.Play();
                //await Task.Delay(10000);

                if (bVerbose)
                {
                    Console.WriteLine($"Detected: {peakCount} peaks.");
                }
            }
            if (peaklogWriter != null)
            {
                peaklogWriter.Close();
            }
            if (outRawWriter != null)
            {
                outRawWriter.Close();
            }
            Console.WriteLine("Done");

#if DEBUG
            void waveLogSaver()
            {
                //Console.WriteLine($"waveRecorder.Count()=={waveRecorder.Count()}");
                //Console.WriteLine($"waveRecorder[0].Item2=={waveRecorder[0].Item2}");
                //Console.WriteLine($"waveRecorder[1].Item2=={waveRecorder[1].Item2}");
                using (var w = File.CreateText("wavelog1.csv"))
                {
                    //var waves = waveRecorder.TakeLast(300);
                    var waves = waveRecorder;
                    foreach (var item in waves)
                    {
                        w.WriteLine($"{item.Item2},{item.Item1}");
                    }
                }
                using (var w = File.CreateText("peaklog1.csv"))
                {
                    foreach (var item in peakRecorder.TakeLast(100))
                    {
                        w.WriteLine($"{item.Item2},{item.Item1}");
                    }
                }
                Console.WriteLine("Fatal Exit");
                if (peaklogWriter != null)
                {
                    peaklogWriter.Close();
                }
                if (outRawWriter != null)
                {
                    outRawWriter.Close();
                }
                Environment.Exit(0);
            }
#endif

            void saveFile()
            {
                if (outputDirectory == null)
                {
                    Console.WriteLine("If you want to save this file, use --outdir option");
                    return;
                }
                var fullpath = Path.Combine(outputDirectory, DateTime.Now.ToString("yyyyMMddHHmmss") + " " + currentFileName + ".bin");

                using (var stream = File.Create(fullpath))
                {
                    stream.Write(currentFileImage, 0, currentFileImageSize - 9 + 2);
                }
                Console.WriteLine($"{fullpath} saved");
            }

            void fileDetector(int value)
            {
                if (currentMode == DetectMode.WaitHeader)
                {
                    if (value == 0xd3)
                    {
                        valueCounter++;
                        if (valueCounter >= 10)
                        {
                            valueCounter    = 0;
                            currentFileName = "";
                            currentMode     = DetectMode.GettingFileName;
                        }
                    }
                    else
                    {
                        valueCounter = 0;
                    }
                }
                else if (currentMode == DetectMode.GettingFileName)
                {
                    if (value != 0)
                    {
                        currentFileName += (char)value;
                    }
                    valueCounter++;
                    if (valueCounter >= 6)
                    {
                        Console.WriteLine($"Found: {currentFileName} (N-BASIC Binary Image)");
                        valueCounter         = 0;
                        currentMode          = DetectMode.GettingBody;
                        currentFileImageSize = 0;
                        goToCarrierDetectMode();
                    }
                }
                else if (currentMode == DetectMode.GettingBody)
                {
                    currentFileImage[currentFileImageSize++] = (byte)value;
                    if (value == 0)
                    {
                        valueCounter++;
                        if (valueCounter == 12)
                        {
                            saveFile();
                            valueCounter = 0;
                            currentMode  = DetectMode.WaitHeader;
                            goToCarrierDetectMode();
                        }
                    }
                    else
                    {
                        valueCounter = 0;
                    }
                }
            }

            void notifyByte(int value)
            {
                if (peaklogWriter != null)
                {
                    peaklogWriter.WriteLine($"BYTE {value:X2}");
                }
                if (outRawWriter != null)
                {
                    outRawWriter.Write((char)value);
                }

                fileDetector(value);

                // TBW
            }

            void clearShiftRegister()
            {
                for (int i = 0; i < shiftRegister.Length; i++)
                {
                    shiftRegister[i] = true;
                }
            }

            void tapeReadError()
            {
                Console.WriteLine($"Tape Read Error [offset:{currentBaseOffset + bufferPointer}]");
                //Environment.Exit(0);
                waveLogSaver();
            }

            void notifyBit(bool?bit)
            {
                tryingBits++;
                if (bitsInPeakLog && peaklogWriter != null)
                {
                    peaklogWriter.WriteLine($"[{bit} {peakCount0} {peakCount1}]");
                }
                for (int i = 0; i < shiftRegister.Length - 1; i++)
                {
                    shiftRegister[i] = shiftRegister[i + 1];
                }
                shiftRegister[shiftRegister.Length - 1] = bit;
                // check start bit and two stop bit
                if (shiftRegister[0] == false && shiftRegister[9] == true && shiftRegister[10] == true)
                {
                    // found frame
                    var val = 0;
                    for (int j = 0; j < 8; j++)
                    {
                        val >>= 1;
                        if (shiftRegister[j + 1] == true)
                        {
                            val |= 0x80;
                        }
                        else if (shiftRegister[j + 1] == null)
                        {
                            if (carrierDetectMode == CDMode.TryingFirstByte)
                            {
                                carrierDetectMode = CDMode.TransferMode;
                                return;
                            }
                            tapeReadError();
                            return;
                        }
                    }
                    notifyByte(val);
                    if (carrierDetectMode == CDMode.TryingFirstByte)
                    {
                        carrierDetectMode = CDMode.TransferMode;
                    }
                    clearShiftRegister();
                }
                else if (tryingBits == 10)
                {
                    if (carrierDetectMode == CDMode.TryingFirstByte)
                    {
                        carrierDetectMode = CDMode.CarrierDetecting;
                    }
                }
            }

            void setPeak(Tuple <float, long> d, bool upperValue)
            {
#if DEBUG
                if (waveLogEnabled)
                {
                    peakRecorder.Add(d);
                }
#endif
                var timeOffset = (peak.Item2 - lastPeakOffset) / audioStream.WaveFormat.Channels;
                notifyPeak(timeOffset);
                //if (peaklogWriter != null) peaklogWriter.WriteLine($"PEAK {timeOffset} {peak.Item2}");
                lastPeakOffset = peak.Item2;
                peak           = d;
                upper          = upperValue;
            }

            void goToCarrierDetectMode()
            {
                carrierDetectMode = CDMode.CarrierDetecting;
            }

            void notifyPeak(long timeOffset)
            {
                peakCount++;
                //if (bVerbose && peakCount < 20) Console.Write($"{timeOffset},");
                var b = timeOffset < ThresholdPeakCount;

                //if (peaklogWriter != null) peaklogWriter.WriteLine($"[{(b ? 1 : 0)}]");

                if (carrierDetectMode == CDMode.CarrierDetecting)
                {
                    if (b == false)
                    {
                        return;
                    }
                    carrierDetectMode = CDMode.CarrierDetected;
                    return;
                }
                else if (carrierDetectMode == CDMode.CarrierDetected)
                {
                    if (b == true)
                    {
                        return;
                    }
                    carrierDetectMode = CDMode.TryingFirstByte;
                    clearShiftRegister();
                    tryingBits = 0;
                    peakCount1 = 0;
                    peakCount0 = 1;
                    return;
                }

                if (b)
                {
                    peakCount1++;
                }
                else
                {
                    peakCount0++;
                }
                if (peakCount1 == OnePeaks && peakCount0 == 0)
                {
                    notifyBit(true);
                    peakCount1 = 0;
                    peakCount0 = 0;
                }
                else if (peakCount1 == 0 && peakCount0 == ZeroPeaks)
                {
                    notifyBit(false);
                    peakCount1 = 0;
                    peakCount0 = 0;
                }
                else if (peakCount1 + peakCount0 * 2 >= OnePeaks)
                {
#if DEBUG
                    if (bufferPointer + currentBaseOffset == 5380)
                    {
                        waveLogSaver();
                    }
#endif
                    notifyBit(null);
                    peakCount1 = 0;
                    peakCount0 = 0;
                    if (carrierDetectMode == CDMode.TryingFirstByte)
                    {
                        carrierDetectMode = CDMode.CarrierDetecting;
                    }
                }
            }

            float[] readBlock()
            {
                var buf   = new float[256];
                var bytes = audioStream.Read(buf, 0, buf.Length);

                if (bytes == 0)
                {
                    return(null);
                }
                return(buf);
            }

            Tuple <float, long> readRawUnit()
            {
                if (buffer == null || bufferPointer >= buffer.Length)
                {
                    buffer = readBlock();
                    if (buffer == null)
                    {
                        return(null);
                    }
                    //currentBaseOffset = audioStream.Position;
                    currentBaseOffset += bufferPointer;
                    bufferPointer      = 0;
                }
                var v = buffer[bufferPointer];

#if NOISE_SILENCER_ENABLE
                // noise silencer
                if (v > 0 && v < upperPeak / NoiseSilencerEffect)
                {
                    v = 0;
                    //if (peaklogWriter != null) peaklogWriter.WriteLine("Detect upper cancel");
                }
                if (v < 0 && v > lowerPeak / NoiseSilencerEffect)
                {
                    v = 0;
                    //if (peaklogWriter != null) peaklogWriter.WriteLine("Detect lower cancel");
                }
#endif

                var r = new Tuple <float, long>(v, bufferPointer + currentBaseOffset);
                bufferPointer++;
                return(r);
            }

            Tuple <float, long> readUnit()
            {
                Tuple <float, long> t = null;
                var l = readRawUnit();

                if (l == null)
                {
                    return(null);
                }
                if (audioStream.WaveFormat.Channels == 1)
                {
                    t = l;
                }
                else
                {
                    var r = readRawUnit();
                    if (r == null)
                    {
                        return(null);
                    }
                    switch (channelType)
                    {
                    case ChannelType.Left:
                        t = l;
                        break;

                    case ChannelType.Right:
                        t = r;
                        break;

                    case ChannelType.Maximum:
                        if (r.Item1 >= 0 && l.Item1 >= 0)
                        {
                            t = new Tuple <float, long>(Math.Max(r.Item1, l.Item1), l.Item2);
                        }
                        else
                        {
                            t = new Tuple <float, long>(Math.Min(r.Item1, l.Item1), l.Item2);
                        }
                        break;

                    default:
                        t = new Tuple <float, long>((r.Item1 + l.Item1) / 2, l.Item2);
                        break;
                    }
                }
#if DEBUG
                if (waveLogEnabled)
                {
                    waveRecorder.Add(t);
                }
#endif
                return(t);
            }

            void setSpeed()
            {
                TypicalZeroCount   = (int)(1.0 / 1200 / 2 * audioStream.WaveFormat.SampleRate);
                TypicalOneCount    = (int)(1.0 / 2400 / 2 * audioStream.WaveFormat.SampleRate);
                ThresholdPeakCount = (TypicalZeroCount + TypicalOneCount) / 2;
                if (bVerbose)
                {
                    Console.WriteLine($"TypicalZeroCount:{TypicalZeroCount} TypicalOneCount:{TypicalOneCount} ThresholdPeakCount:{ThresholdPeakCount}");
                }

                switch (speed)
                {
                case Speeds.s300bps:
                    OnePeaks  = 8 * 2;
                    ZeroPeaks = 4 * 2;
                    break;

                case Speeds.s600bps:
                    OnePeaks  = 4 * 2;
                    ZeroPeaks = 2 * 2;
                    break;

                default:
                    OnePeaks  = 2 * 2;
                    ZeroPeaks = 1 * 2;
                    break;
                }
            }

            void upperAndLowerPeak()
            {
                upperPeak = 0.0f;
                lowerPeak = 0.0f;
                for (; ;)
                {
                    var pair = readUnit();
                    if (pair == null)
                    {
                        break;
                    }
                    if (upperPeak < pair.Item1)
                    {
                        upperPeak = pair.Item1;
                    }
                    if (lowerPeak > pair.Item1)
                    {
                        lowerPeak = pair.Item1;
                    }
                }
                if (bVerbose)
                {
                    Console.WriteLine($"Detect upperPeak/lowerPeak: {upperPeak}/{lowerPeak}");
                }
            }
        }
Example #35
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (ChatServiceSid != null)
            {
                p.Add(new KeyValuePair <string, string>("ChatServiceSid", ChatServiceSid.ToString()));
            }

            if (ChannelType != null)
            {
                p.Add(new KeyValuePair <string, string>("ChannelType", ChannelType.ToString()));
            }

            if (ContactIdentity != null)
            {
                p.Add(new KeyValuePair <string, string>("ContactIdentity", ContactIdentity));
            }

            if (Enabled != null)
            {
                p.Add(new KeyValuePair <string, string>("Enabled", Enabled.Value.ToString().ToLower()));
            }

            if (IntegrationType != null)
            {
                p.Add(new KeyValuePair <string, string>("IntegrationType", IntegrationType.ToString()));
            }

            if (IntegrationFlowSid != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.FlowSid", IntegrationFlowSid.ToString()));
            }

            if (IntegrationUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.Url", Serializers.Url(IntegrationUrl)));
            }

            if (IntegrationWorkspaceSid != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.WorkspaceSid", IntegrationWorkspaceSid.ToString()));
            }

            if (IntegrationWorkflowSid != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.WorkflowSid", IntegrationWorkflowSid.ToString()));
            }

            if (IntegrationChannel != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.Channel", IntegrationChannel));
            }

            if (IntegrationTimeout != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.Timeout", IntegrationTimeout.ToString()));
            }

            if (IntegrationPriority != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.Priority", IntegrationPriority.ToString()));
            }

            if (IntegrationCreationOnMessage != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.CreationOnMessage", IntegrationCreationOnMessage.Value.ToString().ToLower()));
            }

            if (LongLived != null)
            {
                p.Add(new KeyValuePair <string, string>("LongLived", LongLived.Value.ToString().ToLower()));
            }

            if (JanitorEnabled != null)
            {
                p.Add(new KeyValuePair <string, string>("JanitorEnabled", JanitorEnabled.Value.ToString().ToLower()));
            }

            if (IntegrationRetryCount != null)
            {
                p.Add(new KeyValuePair <string, string>("Integration.RetryCount", IntegrationRetryCount.ToString()));
            }

            return(p);
        }
Example #36
0
 /// <summary>
 /// Create a private messaging channel with the specified user.
 /// </summary>
 /// <param name="user">The user to create the private conversation with.</param>
 public Channel(APIUser user)
 {
     Type = ChannelType.PM;
     Users.Add(user);
     Name = user.Username;
 }
Example #37
0
        public static Bitmap ColorComponentSelector(Bitmap image, ChannelType R, ChannelType G, ChannelType B, ChannelType A)
        {
            BitmapExtension.ColorSwapFilter color = new BitmapExtension.ColorSwapFilter();
            if (R == ChannelType.Red)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.Red;
            }
            if (R == ChannelType.Green)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.Green;
            }
            if (R == ChannelType.Blue)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.Blue;
            }
            if (R == ChannelType.Alpha)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.Alpha;
            }
            if (R == ChannelType.One)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.One;
            }
            if (R == ChannelType.Zero)
            {
                color.CompRed = BitmapExtension.ColorSwapFilter.Red.Zero;
            }

            if (G == ChannelType.Red)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.Red;
            }
            if (G == ChannelType.Green)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.Green;
            }
            if (G == ChannelType.Blue)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.Blue;
            }
            if (G == ChannelType.Alpha)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.Alpha;
            }
            if (G == ChannelType.One)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.One;
            }
            if (G == ChannelType.Zero)
            {
                color.CompGreen = BitmapExtension.ColorSwapFilter.Green.Zero;
            }

            if (B == ChannelType.Red)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.Red;
            }
            if (B == ChannelType.Green)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.Green;
            }
            if (B == ChannelType.Blue)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.Blue;
            }
            if (B == ChannelType.Alpha)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.Alpha;
            }
            if (B == ChannelType.One)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.One;
            }
            if (B == ChannelType.Zero)
            {
                color.CompBlue = BitmapExtension.ColorSwapFilter.Blue.Zero;
            }

            if (A == ChannelType.Red)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.Red;
            }
            if (A == ChannelType.Green)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.Green;
            }
            if (A == ChannelType.Blue)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.Blue;
            }
            if (A == ChannelType.Alpha)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.Alpha;
            }
            if (A == ChannelType.One)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.One;
            }
            if (A == ChannelType.Zero)
            {
                color.CompAlpha = BitmapExtension.ColorSwapFilter.Alpha.Zero;
            }

            return(BitmapExtension.SwapRGB(image, color));
        }
Example #38
0
 public SubscribeChannel(ChannelType name)
 {
     Name = name;
 }
Example #39
0
 public Channel(ChannelType name, string instrument) : this(name)
 {
     Instrument = instrument;
 }
Example #40
0
 public Channel(ChannelType name)
 {
     Name = name;
 }
Example #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextureCoordinateChannel"/> class.
 /// </summary>
 public TextureCoordinateChannel(ChannelType channelType)
 {
     frames           = new Vector2[0];
     this.channelType = channelType;
 }
Example #42
0
 public TcpChannel(TcpService connectService, Socket socket, ChannelType channelType) : base(connectService, channelType)
 {
     Init(socket);
 }
Example #43
0
 public NetTypeAttribute(ChannelType channelType)
 {
     ChannelType = channelType;
 }
Example #44
0
        void OnGUI()
        {
            EditorGUILayout.LabelField("\n Warning: Erases Current Canvas", EditorStyles.wordWrappedLabel);
            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Width");
            m_Width = EditorGUILayout.IntField(m_Width);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Height");
            m_Height = EditorGUILayout.IntField(m_Height);
            EditorGUILayout.EndHorizontal();
            m_PixelDepth = (ChannelType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Pixel Depth", "bytes Per pixel/accuracy"), m_PixelDepth, GUILayout.MaxWidth(300));

            EditorGUILayout.Separator();
            m_CreateUnityTex    = EditorGUILayout.Toggle("Create UnityTextureOutput nodes and textures", m_CreateUnityTex);
            m_LoadTestCubeScene = EditorGUILayout.Toggle("Throw Away current Scene and load test cube",
                                                         m_LoadTestCubeScene);
            GUI.enabled      = m_CreateUnityTex;
            m_CreateMaterial = EditorGUILayout.BeginToggleGroup("Create new material ", m_CreateMaterial);
            EditorGUI.indentLevel++;
            var text = new string[] { "Create new standard Unity material with new textures", "Create new tesselated dx11 material with new textures" };

            m_CreateMaterialType = GUILayout.SelectionGrid(m_CreateMaterialType, text, 1, EditorStyles.radioButton);
            EditorGUI.indentLevel--;
            //m_CreateUnityMaterial = EditorGUILayout.Toggle("Create new standard Unity material with new textures",m_CreateUnityMaterial);
            //m_CreateTesselatedMaterial = EditorGUILayout.Toggle("Create new tesselated dx11 material with new textures", m_CreateTesselatedMaterial);
            EditorGUILayout.EndToggleGroup();



            m_Path = EditorGUILayout.TextField(m_Path);
            if (GUILayout.Button(new GUIContent("Browse Output Path", "Path to Output Textures to")))
            {
                m_Path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "", "png", "", m_Path);
            }
            GUI.enabled = true;
            EditorGUILayout.Separator();



            //            m_Height = EditorGUILayout.IntField(m_Height);
            //            m_Noise = EditorGUILayout.FloatField(m_Noise);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            if (GUILayout.Button("Create"))
            {
                m_Parent.NewNodeCanvas(m_Width, m_Height);
                if (m_CreateUnityTex)
                {
                    if (m_Path.EndsWith("_albedo.png"))
                    {
                        m_Path = m_Path.Replace("_albedo.png", ".png");
                    }
                    if (m_Path.EndsWith("_normal.png"))
                    {
                        m_Path = m_Path.Replace("_albedo.png", ".png");
                    }
                    if (m_Path.EndsWith("_MetalAndRoughness.png"))
                    {
                        m_Path = m_Path.Replace("_MetalAndRoughness.png", ".png");
                    }
                    if (m_Path.EndsWith("_height.png"))
                    {
                        m_Path = m_Path.Replace("_height.png", ".png");
                    }
                    if (m_Path.EndsWith("_occlusion.png"))
                    {
                        m_Path = m_Path.Replace("_occlusion.png", ".png");
                    }

                    if (m_LoadTestCubeScene)
                    {
                        if (m_CreateMaterial && m_CreateMaterialType == 1)
                        {
                            EditorSceneManager.OpenScene("Assets/TextureWang/Scenes/DoNotEdit/testplaneTesselated.unity");
                        }
                        else
                        {
                            EditorSceneManager.OpenScene("Assets/TextureWang/Scenes/DoNotEdit/testcube.unity");
                        }
                    }
                    //Sigh, unity destroys scriptable objects when you call OpenScene, and you cant use dontdestroyonload
                    NodeEditor.ReInit(true);
                    m_Parent.NewNodeCanvas(m_Width, m_Height, m_PixelDepth);

                    //required to add nodes to canvas
                    NodeEditor.curNodeCanvas = NodeEditorTWWindow.canvasCache.nodeCanvas;

                    float yOffset = 200;
                    var   albedo  = MakeTextureNodeAndTexture("_albedo", new Vector2(0, 0));
                    var   norms   = MakeTextureNodeAndTexture("_normal", new Vector2(0, 1 * yOffset), true);

                    var       height = MakeTextureNodeAndTexture("_height", new Vector2(0, 2 * yOffset));
                    var       metal  = MakeTextureNodeAndTexture("_MetalAndRoughness", new Vector2(0, 3 * yOffset), false, "OutputMetalicAndRoughness");
                    Texture2D occ    = null;
                    if (m_CreateMaterialType == 0 || !m_CreateMaterial)
                    {
                        occ = MakeTextureNodeAndTexture("_occlusion", new Vector2(0, 4 * yOffset));
                    }
                    if (m_CreateMaterial)
                    {
                        if (m_CreateMaterialType == 0)
                        {
                            var m = new Material(Shader.Find("Standard"));
                            m.mainTexture = albedo;
                            m.SetTexture("_BumpMap", norms);
                            m.SetTexture("_ParallaxMap", height);
                            m.SetTexture("_MetallicGlossMap", metal);
                            m.SetTexture("_OcclusionMap", occ);
                            AssetDatabase.CreateAsset(m, m_Path.Replace(".png", "_material.mat"));

                            var mr = FindObjectOfType <MeshRenderer>();
                            if (mr != null)
                            {
                                mr.material = m;
                            }
                        }
                        else //if (m_CreateTesselatedMaterial)
                        {
                            var m = new Material(Shader.Find("Tessellation/Standard Fixed"));
                            if (m != null)
                            {
                                m.mainTexture = albedo;
                                m.SetTexture("_NormalMap", norms);
                                m.SetTexture("_DispTex", height);
                                m.SetTexture("_MOS", metal);
                                m.SetFloat("_Metallic", 1.0f);
                                m.SetFloat("_Glossiness", 1.0f);
                                m.SetFloat("_Tess", 100.0f);
                                AssetDatabase.CreateAsset(m, m_Path.Replace(".png", "_material.mat"));

                                var mr = FindObjectOfType <MeshRenderer>();
                                if (mr != null)
                                {
                                    mr.material = m;
                                }
                            }
                        }
                    }
                }

                m_Parent.Repaint();
                this.Close();
            }
            GUILayout.EndHorizontal();
        }
Example #45
0
 /// <summary>
 /// Creates a new instance of the <see cref="Channel"/> class.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="type"></param>
 internal Channel(int id, ChannelType type)
     : this(id, type, string.Empty)
 {
 }
        public override AccountCompletionResultView OnCompleteAccount(int cmid, string name, ChannelType channelType, string locale, string machineId)
        {
            var member = Context.Users.GetMember(cmid);

            if (member == null)
            {
                Log.Error("An unidentified CMID was passed.");
                return(null);
            }

            var itemsAttributed = new Dictionary <int, int>();

            for (int i = 0; i < member.MemberItems.Count; i++) // The client seem to ignore the value of the dictionary.
            {
                itemsAttributed.Add(member.MemberItems[i], 0);
            }

            member.PublicProfile.Name = name;
            // Set email status to complete so we don't ask for the player name again.
            member.PublicProfile.EmailAddressStatus = EmailAddressStatus.Verified;
            // Save the profile since we modified it.
            Context.Users.Db.Profiles.Save(member.PublicProfile);

            /*
             * result:
             * 1 -> Success
             * 2 -> GetNonDuplicateNames?
             * 3 -> Load menu for show?
             * 4 -> Invalid characters in name
             * 5 -> Account banned
             */
            var view = new AccountCompletionResultView(
                1,
                itemsAttributed,
                null
                );

            return(view);
        }
Example #47
0
 public FpgaChannel(string name, ChannelType dataType)
 {
     ChannelName = name;
     DataType    = dataType;
 }
        private void AddToLog(DateTime LogTime, ChannelType Type, string Message)
        {
            Message = Message.Replace('\n', '\t');
            string Hash = "";

            if (Type == ChannelType.Guild)
            {
                if (!IsGuildChatEnabled)
                {
                    return;
                }

                if (string.IsNullOrEmpty(LoginName))
                {
                    return;
                }

                if (Message.StartsWith("(SYSTEM)") || Message.StartsWith("-SYSTEM-"))
                {
                    if (Message[Message.Length - 1] == '"')
                    {
                        Message = Message.Substring(0, Message.Length - 1);
                    }

                    string PasswordPattern = "PgMessenger:";
                    int    PasswordStart   = Message.IndexOf(PasswordPattern);

                    if (PasswordStart >= 0)
                    {
                        int i = PasswordStart + PasswordPattern.Length;
                        while (i < Message.Length && char.IsWhiteSpace(Message[i]))
                        {
                            i++;
                        }

                        string Password = "";
                        while (i < Message.Length && !char.IsWhiteSpace(Message[i]) && i != '\r' && i != '\n')
                        {
                            Password += Message[i++].ToString();
                        }

                        UpdatePassword(LoginName, Password);
                    }

                    return;
                }
                else
                {
                    string Password = GetPasswordByLoginName(LoginName);
                    if (Password == null)
                    {
                        return;
                    }

                    try
                    {
                        Hash    = MD5Hash.GetHashString(Message);
                        Message = Encryption.AESThenHMAC.SimpleEncryptWithPassword(Message, Password, new byte[0]);
                    }
                    catch
                    {
                        Message = null;
                    }

                    if (Message == null)
                    {
                        return;
                    }
                }
            }
            else if (Type == ChannelType.Global)
            {
                if (Message.StartsWith("(SYSTEM) [Announcement]: Updating your character") ||
                    Message.StartsWith("(SYSTEM) [Announcement]: Done upgrading your character"))
                {
                    return;
                }
            }

            if (Type == ChannelType.Global || Type == ChannelType.Help || Type == ChannelType.Trade || Type == ChannelType.Guild)
            {
                UploadLog(LoginName != null ? LoginName : "", Type.ToString(), Message, Hash);
            }
        }
Example #49
0
 protected AChannel(AService service, ChannelType channelType)
 {
     this.ChannelType = channelType;
     this.service     = service;
 }
Example #50
0
        public PacketFlags ChannelTypeToPacketFlag(ChannelType type)
        {
            switch (type)
            {
            case ChannelType.Unreliable:
            {
                return(PacketFlags.Unsequenced | PacketFlags.UnreliableFragment);
            }

            case ChannelType.UnreliableFragmented:
            {
                return(PacketFlags.Unsequenced | PacketFlags.UnreliableFragment);
            }

            case ChannelType.UnreliableSequenced:
            {
                return(PacketFlags.UnreliableFragment);
            }

            case ChannelType.Reliable:
            {
                return(PacketFlags.Reliable | PacketFlags.Unsequenced);
            }

            case ChannelType.ReliableFragmented:
            {
                return(PacketFlags.Reliable | PacketFlags.Unsequenced);
            }

            case ChannelType.ReliableSequenced:
            {
                return(PacketFlags.Reliable);
            }

            case ChannelType.StateUpdate:
            {
                return(PacketFlags.None);
            }

            case ChannelType.ReliableStateUpdate:
            {
                return(PacketFlags.Reliable);
            }

            case ChannelType.AllCostDelivery:
            {
                return(PacketFlags.Reliable);
            }

            case ChannelType.UnreliableFragmentedSequenced:
            {
                return(PacketFlags.UnreliableFragment);
            }

            case ChannelType.ReliableFragmentedSequenced:
            {
                return(PacketFlags.Reliable);
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
            }
        }
Example #51
0
 public async Task TestCreateChannel_BadType()
 {
     string name = $"#test_{_random.Next()}";
     await _testServer.CreateChannel($"", ChannelType.FromString("badtype"));
 }
        public bool ParseMessageInfo(string Line, bool HideSpoilers, bool DisplayGlobal, bool DisplayHelp, bool DisplayTrade, string GuildName, out LogEntry LogEntry)
        {
            LogEntry = null;

            string[] Parts = Line.Split('/');
            if (Parts.Length < 9)
            {
                return(false);
            }

            int LineIndex;

            if (!int.TryParse(Parts[0], out LineIndex))
            {
                return(false);
            }

            if (LastReadIndex <= LineIndex)
            {
                LastReadIndex = LineIndex + 1;
            }

            int Year, Month, Day, Hour, Minute, Second;

            if (!int.TryParse(Parts[1], out Year) ||
                !int.TryParse(Parts[2], out Month) ||
                !int.TryParse(Parts[3], out Day) ||
                !int.TryParse(Parts[4], out Hour) ||
                !int.TryParse(Parts[5], out Minute) ||
                !int.TryParse(Parts[6], out Second))
            {
                return(false);
            }

            DateTime LogTime = new DateTime(Year, Month, Day, Hour, Minute, Second, DateTimeKind.Utc);

            LogTime = LogTime.ToLocalTime();

            string Channel = Parts[7];

            if (Channel.Length < 2)
            {
                return(false);
            }

            Channel = Channel[0].ToString().ToUpper() + Channel.Substring(1);
            ChannelType LogType = StringToChannelType(Channel);

            if (LogType == ChannelType.Other ||
                (LogType == ChannelType.Global && !DisplayGlobal) ||
                (LogType == ChannelType.Help && !DisplayHelp) ||
                (LogType == ChannelType.Trade && !DisplayTrade))
            {
                return(false);
            }

            string Message = "";

            for (int j = 8; j < Parts.Length; j++)
            {
                if (j > 8)
                {
                    Message += "/";
                }
                Message += Parts[j];
            }

            if (LogType == ChannelType.Guild)
            {
                string Password = GetPasswordByGuildName(GuildName);
                if (Password == null)
                {
                    return(false);
                }

                try
                {
                    Message = Encryption.AESThenHMAC.SimpleDecryptWithPassword(Message, Password);
                }
                catch
                {
                    Message = null;
                }

                if (Message == null)
                {
                    return(false);
                }
            }

            string Author;
            int    AuthorIndex = Message.IndexOf(':');

            if (AuthorIndex >= 0)
            {
                Author  = Message.Substring(0, AuthorIndex);
                Message = Message.Substring(AuthorIndex + 1);
            }
            else
            {
                Author = "";
            }

            List <string> ItemList = new List <string>();

            int ItemIndex = Message.IndexOf('\t');

            if (ItemIndex >= 0)
            {
                string MessageEnd = Message.Substring(ItemIndex + 1);
                Message = Message.Substring(0, ItemIndex);

                for (; ;)
                {
                    if (MessageEnd.Length < 3 || MessageEnd[0] != '[')
                    {
                        break;
                    }

                    int ItemEndIndex = MessageEnd.IndexOf(']');
                    if (ItemEndIndex < 0)
                    {
                        break;
                    }

                    string ItemName = MessageEnd.Substring(1, ItemEndIndex - 1);
                    ItemList.Add("[" + ItemName + "]");

                    MessageEnd = MessageEnd.Substring(ItemEndIndex + 1).Trim();
                }
            }

            if (HideSpoilers)
            {
                for (; ;)
                {
                    int SpoilerStartIndex = Message.IndexOf("[[[");
                    if (SpoilerStartIndex < 0)
                    {
                        break;
                    }

                    int SpoilerEndIndex = Message.IndexOf("]]]", SpoilerStartIndex);
                    if (SpoilerEndIndex < 0)
                    {
                        break;
                    }

                    Message = Message.Substring(0, SpoilerStartIndex) + "\t" + Message.Substring(SpoilerEndIndex + 3);
                }

                Message = Message.Replace("\t", "[[[Spoiler]]]");
            }

            LogEntry = new LogEntry(LogTime, LogType, Author, Message, ItemList);
            //Debug.Print("Entry added: " + LogTime + ", " + LogType + ", " + Message);
            return(true);
        }
Example #53
0
        public static PvrTexture Create(byte[] data, uint width, uint height, uint depth, PixelFormat format, ChannelType channelType, ColorSpace colorSpace)
        {
            var attributes = new PvrCreateParams
            {
                pixelFormat     = format,
                width           = width,
                height          = height,
                depth           = depth,
                numMipMaps      = 1,
                numArrayMembers = 1,
                numFaces        = 1,
                colorSpace      = colorSpace,
                channelType     = channelType,
                preMultiplied   = false
            };
            var header = new PvrHeader(attributes);

            return(new PvrTexture(header, data));
        }
 public ChannelHandle(string fileName, int handle, ChannelType type)
 {
     FileName = fileName;
     Handle   = handle;
     Type     = type;
 }
Example #55
0
        private void RedrawSampleViewHelper(Graphics graphics, ChannelType channel, Rectangle bounds)
        {
            int YMin = bounds.Y;
            int YMax = bounds.Y + bounds.Height;

            if (YMax <= YMin)
            {
                return;
            }

            int NumSampleFrames = sampleObject.SampleData.NumFrames;

            const int OffscreenStripWidth = 16;

            using (Bitmap offscreenBitmap = new Bitmap(OffscreenStripWidth, YMax - YMin, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
            {
                int prevIndex = -1;
                for (int XX = bounds.Left; XX < bounds.Left + bounds.Width + (OffscreenStripWidth - 1); XX += OffscreenStripWidth)
                {
                    int Limit = Math.Min(XX + OffscreenStripWidth, bounds.Left + bounds.Width);

                    using (Graphics offscreenGraphics = Graphics.FromImage(offscreenBitmap))
                    {
                        for (int X = XX; X < Limit; X++)
                        {
                            int Index     = (int)((X + horizontalIndex) * xScale);
                            int IndexNext = (int)((X + 1 + horizontalIndex) * xScale);
                            if (IndexNext > NumSampleFrames)
                            {
                                IndexNext = NumSampleFrames;
                            }
                            if (IndexNext < Index + 1)
                            {
                                IndexNext = Index + 1;
                            }

                            Brush DotColor;
                            Brush BackgroundColor;
                            if ((Index >= selectionStart) && (Index < selectionEnd))
                            {
                                DotColor        = Focused ? selectedForeBrush : selectedForeBrushInactive;
                                BackgroundColor = Focused ? selectedBackBrush : selectedBackBrushInactive;
                            }
                            else if ((selectionStart == selectionEnd) && (selectionStart >= Index) && (SelectionStart < IndexNext))
                            {
                                DotColor        = foreBrush;
                                BackgroundColor = insertionPointBrush;
                            }
                            else
                            {
                                DotColor        = foreBrush;
                                BackgroundColor = backBrush;
                            }

                            if ((Index >= 0) && (Index < NumSampleFrames))
                            {
                                /* draw left line */
                                float ValMin = 1;
                                float ValMax = -1;
                                for (int i = Index; i < IndexNext; i++)
                                {
                                    float Value;

                                    switch (channel)
                                    {
                                    default:
                                        throw new ArgumentException();

                                    case ChannelType.eMonoChannel:
                                        Value = sampleObject.SampleData.Buffer[i];
                                        break;

                                    case ChannelType.eLeftChannel:
                                        Value = sampleObject.SampleData.Buffer[2 * i + 0];
                                        break;

                                    case ChannelType.eRightChannel:
                                        Value = sampleObject.SampleData.Buffer[2 * i + 1];
                                        break;
                                    }
                                    if (Value < ValMin)
                                    {
                                        ValMin = Value;
                                    }
                                    if (Value > ValMax)
                                    {
                                        ValMax = Value;
                                    }
                                }
                                int PositionMin = (int)(((1 - ValMin) / 2) * (YMax - YMin - 1));
                                int PositionMax = (int)(((1 - ValMax) / 2) * (YMax - YMin - 1));
                                /* zero point:  displace very nearly zero points away from the */
                                /* origin line so you can see they aren't zero */
                                if (PositionMin == (YMax - YMin - 1) / 2)
                                {
                                    if (ValMin < 0)
                                    {
                                        PositionMin += 1;
                                    }
                                    else if (ValMin > 0)
                                    {
                                        PositionMin -= 1;
                                    }
                                }
                                if (PositionMax == (YMax - YMin - 1) / 2)
                                {
                                    if (ValMax < 0)
                                    {
                                        PositionMax += 1;
                                    }
                                    else if (ValMax > 0)
                                    {
                                        PositionMax -= 1;
                                    }
                                }
                                offscreenGraphics.FillRectangle(
                                    BackgroundColor,
                                    X - XX,
                                    YMin - YMin,
                                    1,
                                    YMax - YMin - 1 + 1);
                                offscreenGraphics.FillRectangle(
                                    DotColor,
                                    X - XX,
                                    YMin - YMin + PositionMax,
                                    1,
                                    PositionMin - PositionMax + 1);

                                /* draw separating line */
                                if (((int)(Index / xScale)) % 8 == 0)
                                {
                                    offscreenGraphics.FillRectangle(
                                        DotColor,
                                        X - XX,
                                        YMin - YMin + (YMax - YMin - 1) / 2,
                                        1,
                                        1);
                                }

                                // draw descending overline if needed
                                if ((prevIndex != Index) &&
                                    (((origin >= Index) && (origin < IndexNext)) ||
                                     ((loopStart >= Index) && (loopStart < IndexNext)) ||
                                     ((loopEnd >= Index) && (loopEnd < IndexNext))))
                                {
                                    offscreenGraphics.DrawLine(
                                        forePen,
                                        X - XX,
                                        2 * OVERLINEHEIGHT - YMin,
                                        X - XX,
                                        Height - YMin);
                                }
                            }
                            else
                            {
                                offscreenGraphics.FillRectangle(
                                    afterEndBrush,
                                    X - XX,
                                    YMin - YMin,
                                    1,
                                    YMax - YMin - 1 + 1);
                            }

                            prevIndex = Index;
                        }
                    }

                    graphics.SetClip(new Rectangle(XX, YMin, Math.Min(OffscreenStripWidth, Limit - XX), YMax - YMin));
                    graphics.DrawImage(offscreenBitmap, XX, YMin, OffscreenStripWidth, YMax - YMin);
                }
            }
        }
Example #56
0
 protected AChannel(AService service, ChannelType channelType)
 {
     this.Id          = IdGenerater.GenerateId();
     this.ChannelType = channelType;
     this.Service     = service;
 }
Example #57
0
 public SubscribeChannel(ChannelType name, string[] instruments) : this(name)
 {
     Instruments = instruments;
 }
 /// <summary>
 /// </summary>
 /// <param name="flags">
 /// </param>
 /// <param name="type">
 /// </param>
 /// <param name="id">
 /// </param>
 /// <param name="name">
 /// </param>
 public RaidChannel(ChannelFlags flags, ChannelType type, uint id, string name = "")
     : base(flags, type, id, name)
 {
 }
Example #59
0
 public ImageFormat(ChannelOrder channelOrder, ChannelType channelDataType)
 {
     ChannelOrder    = channelOrder;
     ChannelDataType = channelDataType;
 }
Example #60
0
 private void ParseSdkSetting(XmlNode sdkChannel)
 {
     _sdkChannelDict.Clear();
     foreach (XmlElement childNode in sdkChannel.ChildNodes)
     {
         ChannelType channelType = MathUtils.ToEnum <ChannelType>(childNode.Name);
         GameChannel gameChannel = new GameChannel(channelType);
         string      url         = childNode.GetAttribute("url");
         if (!string.IsNullOrEmpty(url))
         {
             gameChannel.Url = url;
         }
         string service = childNode.GetAttribute("service");
         if (!string.IsNullOrEmpty(service))
         {
             gameChannel.Service = service;
         }
         string version = childNode.GetAttribute("version");
         if (!string.IsNullOrEmpty(version))
         {
             gameChannel.Version = version;
         }
         string tokenUrl = childNode.GetAttribute("token_url");
         if (!string.IsNullOrEmpty(tokenUrl))
         {
             gameChannel.TokenUrl = tokenUrl;
         }
         string ctype = childNode.GetAttribute("type");
         if (!string.IsNullOrEmpty(ctype))
         {
             gameChannel.CType = ctype;
         }
         string channelId = childNode.GetAttribute("channelId");
         if (!string.IsNullOrEmpty(channelId))
         {
             gameChannel.ChannelId = channelId;
         }
         foreach (XmlElement item in childNode.ChildNodes)
         {
             var setting = new GameSdkSetting();
             setting.RetailId = item.GetAttribute("name");
             if (channelType == ChannelType.channelUC)
             {
                 setting.AppId  = item.GetAttribute("cpId");
                 setting.AppKey = item.GetAttribute("apiKey");
             }
             else
             {
                 setting.AppId  = item.GetAttribute("appId");
                 setting.AppKey = item.GetAttribute("appKey");
             }
             setting.AppSecret = item.GetAttribute("appSecret");
             setting.GameId    = item.GetAttribute("gameId");
             setting.ServerId  = item.GetAttribute("serverId");
             gameChannel.Add(setting);
         }
         if (!_sdkChannelDict.ContainsKey(gameChannel.ChannelType))
         {
             _sdkChannelDict.Add(gameChannel.ChannelType, gameChannel);
         }
     }
 }