Exemplo n.º 1
0
    /// <summary>
    /// 保存广播信息 应该是还未来得及显示的
    /// </summary>
    public void M_saveRadioMsg(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return;
        }
        string         saveContent = string.Empty;
        RadioInfo      radioInfo   = radioInfoDic [radioType];
        Queue <string> msgCache    = radioInfo.msgCache;

        while (msgCache.Count > 0)
        {
            saveContent += ("#" + msgCache.Dequeue());
        }
        if (saveContent == string.Empty)
        {
            return;
        }
        string       path     = ConfigGlobal.CONFIG_FOLDER + "/" + ConfigGlobal.CONFIG_RADIO_MSG;
        string       holePath = PathKit.GetOSDataPath(path) + SUFFIX;
        FileStream   fs       = new FileStream(holePath, FileMode.OpenOrCreate, FileAccess.Write);
        StreamWriter sw       = new StreamWriter(fs);

        sw.Flush();
        sw.BaseStream.Seek(0, SeekOrigin.Begin);
        sw.Write(saveContent);
        sw.Close();
    }
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(TitleEdit.Text))
            {
                MessageBox.Show("Radio title cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (String.IsNullOrEmpty(StreamUrlEdit.Text))
            {
                MessageBox.Show("Stream url cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            RadioInfo radioInfo = new RadioInfo()
            {
                Title      = TitleEdit.Text,
                CategoryId = CategoryList.SelectedIndex + 1,
                HomePage   = HomeEdit.Text,
                StreamUrl  = StreamUrlEdit.Text,
                Active     = true,
                Faved      = false
            };

            _radioDb.Add(radioInfo);
            this.Close();
        }
Exemplo n.º 3
0
 public RadioCaster(RadioInfo radioInfo)
 {
     RadioInfo    = radioInfo;
     RadioClients = new LinkedList <IRadioClient>();
     Tracks       = new LinkedList <IAudioSource>();
     NewTrackPossiblyAvailable = new ManualResetEvent(false);
 }
Exemplo n.º 4
0
 public async void SetStationInfo()
 {
     await Task.Factory.StartNew(() =>
     {
         Dispatcher.Invoke(() => RadioName.BeginAnimation(Label.OpacityProperty, AnimDown));          //NOT WORKING
         Dispatcher.Invoke(() => RadioArtist.BeginAnimation(Label.OpacityProperty, AnimDown));        //NOT WORKING
         Dispatcher.Invoke(() => RadioSongName.BeginAnimation(Label.OpacityProperty, AnimDown));      //NOT WORKING
         Dispatcher.Invoke(() => RadioInfo.BeginAnimation(Label.OpacityProperty, AnimDown));          //NOT WORKING
         Dispatcher.Invoke(() => RadioLogo.BeginAnimation(Image.OpacityProperty, AnimDown));          //NOT WORKING
     })
     .ContinueWith((prevTask) =>
     {
         prevTask.Wait();
         Dispatcher.Invoke(() => ClearStationInfo());
         Dispatcher.Invoke(() => RadioName.Content     = StationToPlay.StationName);
         Dispatcher.Invoke(() => RadioArtist.Content   = StationToPlay.TrackArtist);
         Dispatcher.Invoke(() => RadioSongName.Content = StationToPlay.TrackName);
         Dispatcher.Invoke(() => RadioInfo.Content     = StationToPlay.ChannelInfo);
         Dispatcher.Invoke(() => RadioLogo.Source      = StationToPlay.TrackPicture);
     })
     .ContinueWith((prevTask) =>
     {
         prevTask.Wait();
         Dispatcher.Invoke(() => RadioName.BeginAnimation(Label.OpacityProperty, AnimHigh));
         Dispatcher.Invoke(() => RadioArtist.BeginAnimation(Label.OpacityProperty, AnimHigh));
         Dispatcher.Invoke(() => RadioSongName.BeginAnimation(Label.OpacityProperty, AnimHigh));
         Dispatcher.Invoke(() => RadioInfo.BeginAnimation(Label.OpacityProperty, AnimHigh));
         Dispatcher.Invoke(() => RadioLogo.BeginAnimation(Image.OpacityProperty, AnimHigh));
     });
 }
Exemplo n.º 5
0
        /// <summary>
        /// plays given radio index
        /// only called from search form
        /// </summary>
        /// <param name="index">index of the radio station to be placed</param>
        public void PlayFromSearchForm(int index)
        {
            RadioInfo radioInfo = _radioInfos[index];

            if (radioInfo != null)
            {
                // update the last played station for that radio category
                _radioCategories[CategoryList.SelectedIndex].LastPlayedStationIndex = index;
                if (_currentRadioIndex > -1)
                {
                    StationsList.Items[_currentRadioIndex].Selected = false;
                }
                _currentRadioIndex = index;
                _activeCategory    = CategoryList.SelectedIndex;
                // make sure list focuses on the station
                StationsList.Items[index].EnsureVisible();
                StationsList.Items[index].Selected = true;
                StationsList.Refresh();

                // play the radio
                PlayUrl(radioInfo.StreamUrl);
            }
            else
            {
                // todo: report this by showing the log
            }
        }
Exemplo n.º 6
0
    /** 初始化主界面广播信息对象 */
    private RadioInfo initMainRadioInfo()
    {
        int[]     customIds = new int[] { 1, 6 };
        RadioInfo radioInfo = new RadioInfo(10, false, customIds);

        return(radioInfo);
    }
Exemplo n.º 7
0
        private void UpdateRadioInfoTextBoxes(RadioInfo radioInfo)
        {
            textBoxRadioName.Text = radioInfo?.RadioName;
            textBoxFrequency.Text = radioInfo?.Frequency.ToString();
            textBoxMode.Text      = radioInfo?.Mode;

            this.Update();
        }
Exemplo n.º 8
0
        private RadioInfo GetRadioInfoFromFlRig()
        {
            FLRigAPI.FLRigClient flRigClient = new FLRigAPI.FLRigClient();

            RadioInfo radioInfo = flRigClient.GetRadioInfo();

            return(radioInfo);
        }
Exemplo n.º 9
0
        private RadioInfo readOpenGD77RadioInfo()
        {
            /*
             * String gd77CommPort = SetupDiWrap.ComPortNameFromFriendlyNamePrefix("OpenGD77");
             * try
             * {
             *      _port = new SerialPort(gd77CommPort, 115200, Parity.None, 8, StopBits.One);
             *      _port.ReadTimeout = 1000;
             *      _port.Open();
             * }
             * catch (Exception)
             * {
             *      _port = null;
             *      MessageBox.Show("Failed to open comm port", "Error");
             *      return;
             * }*/


            sendCommand(0);
            sendCommand(1);
            sendCommand(2, 0, 0, 3, 1, 0, "CPS");
            sendCommand(2, 0, 16, 3, 1, 0, "Read");
            sendCommand(2, 0, 32, 3, 1, 0, "Radio");
            sendCommand(2, 0, 48, 3, 1, 0, "Info");
            sendCommand(3);
            sendCommand(6, 4);            // flash red LED

            OpenGD77CommsTransferData dataObjRead = new OpenGD77CommsTransferData(OpenGD77CommsTransferData.CommsAction.NONE);

            dataObjRead.mode = OpenGD77CommsTransferData.CommsDataMode.DataModeReadRadioInfo;
            dataObjRead.localDataBufferStartPosition = 0;
            dataObjRead.transferLength = 0;
            dataObjRead.dataBuff       = new byte[128];

            RadioInfo radioInfo = new RadioInfo();

            if (ReadRadioInfo(dataObjRead))
            {
                radioInfo = ByteArrayToRadioInfo(dataObjRead.dataBuff);
            }

            sendCommand(5);

            /*
             * if (_port != null)
             * {
             *      try
             *      {
             *              _port.Close();
             *      }
             *      catch (Exception)
             *      {
             *              MessageBox.Show("Failed to close OpenGD77 comm port", "Warning");
             *      }
             * }
             */
            return(radioInfo);
        }
Exemplo n.º 10
0
        private void ProcessRedcode(string redcode)
        {
            RadioInfo r     = RadioInfo.ParseRedcode(redcode);
            bool      hiRes = (File.Exists(r.getGifName(true)));

            pictureBox1.Image = Image.FromFile(r.getGifName(hiRes));
            pictureBox1.BringToFront();
            ProcessImage(pictureBox1);
        }
Exemplo n.º 11
0
    ///加入一条播报
    public void addRadio(string info, Color color)
    {
        if (null == color)
        {
            color = Color.gray;
        }
        RadioInfo radio = new RadioInfo(info, color);

        this.radiolist.Add(radio);
    }
Exemplo n.º 12
0
    public void Clear()
    {
        this.radiolist.Clear();
        this.ClearTween();
        this.canvasGroup.alpha = 0f;

        this.currentRadio     = null;
        this.currentRadioTime = 0;
        this.isSwitch         = false;
    }
Exemplo n.º 13
0
    public void clear()
    {
        radiolist.Clear();
        clearTween();
        canvasGroup.alpha = 0f;

        currentRadio     = null;
        currentRadioTime = 0;
        isSwitch         = false;
    }
Exemplo n.º 14
0
        public Contact(string spotMessage)
        {
            XElement element = XElement.Parse(spotMessage);

            Call            = element.Element("call").Value;
            Frequency       = double.Parse(element.Element("rxfreq").Value) / 100d;
            OffsetTimestamp = DateTimeOffset.Parse($"{element.Element("timestamp").Value} -00:00");

            Band = RadioInfo.DetermineBand(Frequency);
        }
Exemplo n.º 15
0
    /** 清理指定类型的广播 */
    public void clearByType(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return;
        }
        RadioInfo radioInfo = radioInfoDic [radioType];

        radioInfo.clear();
        radioInfo = null;
    }
Exemplo n.º 16
0
    /// <summary>
    /// 获取一条循环的广播
    /// </summary>
    /// <returns>The last radio message.</returns>
    public string M_getLastRadioTipMsg(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return(null);
        }
        RadioInfo radioInfo = radioInfoDic [radioType];
        string    msg       = radioInfo.getTipCacheMessage();

        return(msg);
    }
Exemplo n.º 17
0
        private RadioInfo GetCustomRadioInfo()
        {
            int frequency = GetCustomFrequency();

            RadioInfo radioInfo = new RadioInfo()
            {
                RadioName = textBoxCustomRadioName.Text.Trim(),
                Frequency = frequency,
                Mode      = textBoxCustomMode.Text.Trim()
            };

            return(radioInfo);
        }
Exemplo n.º 18
0
    ///弹出并显示一条播报
    public void PopRadio()
    {
        this.ClearTween();
        if (this.radiolist.Count > 0)
        {
            LTDescr ltd;

            this.currentRadio = this.radiolist [0];
            this.radiolist.RemoveAt(0);
            this.currentRadioTime = 0;

            //首阶段显现时间
            float timeApper = 0.1f;
            //次阶段缓动动画时间
            float timeEnter = 0.1f;
            //第三阶段缓动动画时间
            float timeNext = 0.1f;

            this.radioTextOutline.effectColor = this.currentRadio.color;
            this.radioText.text = this.currentRadio.info;
            //文字缩放
            float   scale1 = 1.5f;
            float   scale2 = 1.2f;
            Vector3 v3_1   = new Vector3(scale1, scale1, scale1);
            Vector3 v3_2   = new Vector3(scale2, scale2, scale2);

            this.radioText.transform.localScale = v3_1;

            ltd            = LeanTween.scale(this.radioText.gameObject, v3_2, timeEnter);
            ltd.delay      = timeApper * 0.5f;
            ltd.onComplete = () => {
                LTDescr ltd_ = LeanTween.scale(this.radioText.gameObject, this.textLocalScale, timeNext);
                ltd_.tweenType = LeanTweenType.easeOutBack;
            };

            //整体透明显现
            ltd = LeanTween.value(this.gameObject, (float value) =>
            {
                this.canvasGroup.alpha = value;
            },
                                  this.canvasGroup.alpha,
                                  1,
                                  timeApper
                                  );
            ltd.onComplete = () => {
                this.isSwitch = false;
            };
        }
    }
Exemplo n.º 19
0
    /** 获取指定类型的广播消息缓存列表 */
    public string[] getCacheListByType(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return(null);
        }
        RadioInfo radioInfo = radioInfoDic [radioType];

        string[] tipMsgCache = radioInfo.tipCache.ToArray();
        string[] msgCache    = radioInfo.msgCache.ToArray();
        string[] messages    = new string[msgCache.Length + tipMsgCache.Length];
        System.Array.Copy(tipMsgCache, 0, messages, 0, tipMsgCache.Length);
        System.Array.Copy(msgCache, 0, messages, tipMsgCache.Length, msgCache.Length);
        return(messages);
    }
Exemplo n.º 20
0
    /// <summary>
    /// 返回一条小贴士
    /// </summary>
    /// <returns>The random tip.</returns>
    public string M_getRandomTip(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return("");
        }
        RadioInfo radioInfo = radioInfoDic [radioType];

        int[] randomValues = radioInfo.customIds;
        if (randomValues != null)
        {
            string msg = RandomTipMessage(randomValues[0], randomValues[1]);
            return(msg);
        }
        return("");
    }
Exemplo n.º 21
0
        private void StationsList_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            // virtual mode
            if (e.ItemIndex < _radioInfos.Count)
            {
                ListViewItem listViewItem = new ListViewItem();
                RadioInfo    radioInfo    = _radioInfos[e.ItemIndex];
                if (radioInfo != null)
                {
                    listViewItem.Text = radioInfo.Title;
                    listViewItem.SubItems.Add(radioInfo.Faved ? "Yes" : "No");
                    listViewItem.Font = new Font(listViewItem.Font, e.ItemIndex == _currentRadioIndex && _playerState != PlayerState.Stopped && _activeCategory == CategoryList.SelectedIndex ? FontStyle.Bold : FontStyle.Regular);

                    e.Item = listViewItem;
                }
            }
        }
Exemplo n.º 22
0
    ///隐藏当前播报
    public void HideRadio()
    {
//		ClearTween ();
        this.isSwitch = true;
        LTDescr ltd = LeanTween.value(this.gameObject, (float value) =>
        {
            this.canvasGroup.alpha = value;
        },
                                      this.canvasGroup.alpha,
                                      0,
                                      0.2f
                                      );

        ltd.onComplete = () => {
            this.isSwitch     = false;
            this.currentRadio = null;
        };
    }
Exemplo n.º 23
0
        private void StationsList_DoubleClick_1(object sender, EventArgs e)
        {
            // start playing selected station
            if (StationsList.SelectedIndices.Count > 0)
            {
                // get radio that will be played
                RadioInfo radioInfo = _radioInfos[StationsList.SelectedIndices[0]];

                // update the last played station for that radio category
                _radioCategories[CategoryList.SelectedIndex].LastPlayedStationIndex = StationsList.SelectedIndices[0];
                _currentRadioIndex = StationsList.SelectedIndices[0];
                _activeCategory    = CategoryList.SelectedIndex;
                StationsList.Refresh();

                // play the radio
                // todo: check links first
                PlayUrl(radioInfo.StreamUrl);
            }
        }
Exemplo n.º 24
0
    /// <summary>
    /// 返回一条最新的广播消息
    /// </summary>
    /// <returns>The last radio message.</returns>
    public string M_getLastRadioMsg(int radioType)
    {
        if (!radioInfoDic.ContainsKey(radioType))
        {
            return(null);
        }
        RadioInfo radioInfo = radioInfoDic [radioType];
        string    msg       = null;

        if (radioInfo.msgCache.Count > 0)
        {
            msg = radioInfo.msgCache.Dequeue();
            if (radioInfo.isAutoAddTip)
            {
                M_addTipMsg(radioType, msg);
            }
        }
        return(msg);
    }
Exemplo n.º 25
0
        public Spot(string contactMessage, bool minInfo = false)
        {
            XElement element = XElement.Parse(contactMessage);

            Call            = element.Element("dxcall").Value;
            Frequency       = double.Parse(element.Element("frequency").Value);
            Band            = RadioInfo.DetermineBand(Frequency);
            OffsetTimestamp = DateTimeOffset.Parse($"{element.Element("timestamp").Value} -00:00");
            CountryZone     = MainForm.CallParser.CheckCall(Call);

            if (!minInfo)
            {
                Action      = element.Element("action").Value;
                SpotterCall = element.Element("spottercall").Value;
                Comment     = element.Element("comment").Value;
                Status      = element.Element("status").Value;
                Mode        = RadioInfo.DetermineMode(Comment);

                ValueModel = new SpotValueModel(Call, CountryZone, Band, Multiplier);
            }
        }
Exemplo n.º 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
            }
            pictureBox1.Image = null;
            Downloader d = new Downloader();

            var r = RadioInfo.ParseRedcode(textBox1.Text);

            r.SaveToTmp = true;

            FraccionInfo fraccion = new FraccionInfo(r.Prov, r.Dpto, r.Fraccion);

            if (d.getFraccionInfo(fraccion))
            {
                d.getMapaRadio(r, fraccion.Extents);
                pictureBox1.Image = Bitmap.FromFile(r.getGifName());
            }
        }
Exemplo n.º 27
0
        private void SearchBtn_Click(object sender, EventArgs e)
        {
            // show search form
            SearchForm searchForm = new SearchForm(this);

            for (int i = 0; i < _radioInfos.Count; i++)
            {
                RadioInfo radioInfo = _radioInfos[i];
                if (radioInfo.Active)
                {
                    searchForm.RadioInfos.Add(new SearchItem()
                    {
                        Title      = radioInfo.Title,
                        Index      = i,
                        TitleLower = radioInfo.Title.ToLower()
                    });
                }
            }
            searchForm.Show();
            this.SendToBack();
            searchForm.BringToFront();
        }
Exemplo n.º 28
0
        private void ProcessCheckUncheck(object sender, bool bChecked)
        {
            CheckBox cb = sender as CheckBox;

            if (cb == null || cb.Tag == null)
            {
                return;
            }
            RadioInfo rc = cb.Tag as RadioInfo;

            if (rc == null)
            {
                return;
            }
            if (bChecked && !lbRadios.SelectedItems.Contains(cb.Tag))
            {
                lbRadios.SelectedItems.Add(cb.Tag);
            }
            else if (!bChecked && lbRadios.SelectedItems.Contains(cb.Tag))
            {
                lbRadios.SelectedItems.Remove(cb.Tag);
            }
        }
Exemplo n.º 29
0
        public void HandleRadioSignal(RadioSignalingItem sigItem, EmergencyState emerState = EmergencyState.NonEmergency)
        {
            if (!_firegroundEnabled)
            {
                return;
            }
            if (sigItem == null)
            {
                return;
            }
            RadioInfo rInfo = RadioInfoLookupHelper.Instance.GetRadioInfoFromSignalingItem(sigItem);

            if (rInfo == null || rInfo.ExcludeFromRollCall)
            {
                return;
            }

            RollCallItem rci = GetItemFromLookupKey(rInfo.SignalingLookupKey);

            if (rci == null)
            {
                rci = new RollCallItem(rInfo, emerState);
            }
            else
            {
                rci.EmergencyState = emerState;
            }
            if (_rollCallActive)
            {
                AddToGoodList(rci);
            }
            else
            {
                AddToWaitingList(rci);
            }
        }
Exemplo n.º 30
0
    /** 初始化广播信息对象 */
    private RadioInfo initRadioInfo(int radioType)
    {
        RadioInfo radioInfo = null;

        switch (radioType)
        {
        case RADIO_MAIN_TYPE:
            radioInfo = initMainRadioInfo();
            break;

        case RADIO_LUCKY_CARD_TYPE:
            radioInfo = initLuckCardRadioInfo();
            break;

        case RADIO_LUCKY_EQUIP_TYPE:
            radioInfo = initLuckEquipRadioInfo();
            break;

        case RADIO_LUCKY_STARSOUL_TYPE:
            radioInfo = initLuckLiehunRadioInfo();
            break;
        }
        return(radioInfo);
    }