Exemplo n.º 1
0
        private void MediatorContext_OnEarthquake(object sender, EPSPQuakeEventArgs e)
        {
            if (e.InformationType == QuakeInformationType.Unknown)
            {
                return;
            }

            var earthquakeNotification = configuration.EarthquakeNotification;

            if (!earthquakeNotification.Enabled)
            {
                return;
            }

            var scale = e.InformationType == QuakeInformationType.Destination ? 30 : ScaleConverter.Str2Int(e.Scale);

            if (scale < earthquakeNotification.MinScale)
            {
                return;
            }

            if (!earthquakeNotification.Show)
            {
                Select("quake", e.ReceivedAt.ToString());
                return;
            }
            Activate("quake", e.ReceivedAt.ToString());
        }
Exemplo n.º 2
0
        private void MediatorContext_OnEarthquake(object sender, EPSPQuakeEventArgs e)
        {
            if (e.InformationType == QuakeInformationType.Unknown)
            {
                return;
            }

            var earthquakeNotification = configuration.EarthquakeNotification;

            if (!earthquakeNotification.Enabled)
            {
                return;
            }
            if (!earthquakeNotification.Sound)
            {
                return;
            }

            if (e.OccuredTime == lastEarthquakeOccuredTime)
            {
                return;
            }
            lastEarthquakeOccuredTime = e.OccuredTime;

            var scale = e.InformationType == QuakeInformationType.Destination ? 30 : ScaleConverter.Str2Int(e.Scale);

            if (scale < earthquakeNotification.MinScale)
            {
                return;
            }

            if (e.InformationType == QuakeInformationType.Destination)
            {
                PlaySound(SoundType.P2PQ_Snd0);
                return;
            }

            if (scale >= 55)
            {
                PlaySound(SoundType.P2PQ_Snd4);
            }
            else if (scale >= 45)
            {
                PlaySound(SoundType.P2PQ_Snd3);
            }
            else if (scale >= 30)
            {
                PlaySound(SoundType.P2PQ_Snd2);
            }
            else
            {
                PlaySound(SoundType.P2PQ_Snd1);
            }
        }
Exemplo n.º 3
0
        public void MediatorContext_OnEarthquake(object sender, Client.Peer.EPSPQuakeEventArgs e)
        {
            if (e.InformationType == QuakeInformationType.Unknown)
            {
                return;
            }

            var earthquakeNotification = configuration.EarthquakeNotification;

            if (!earthquakeNotification.Enabled)
            {
                return;
            }
            if (!earthquakeNotification.Notice)
            {
                return;
            }

            // 震源情報は震度 3 以上で発表されるため、震度 3 とみなす
            var scale =
                e.InformationType == QuakeInformationType.Destination ?
                30 :
                ScaleConverter.Str2Int(e.Scale);

            if (scale < earthquakeNotification.MinScale)
            {
                return;
            }

            var builder = new ToastContentBuilder();

            // タイトル行
            var type = e.InformationType switch
            {
                QuakeInformationType.ScalePrompt => "震度速報",
                QuakeInformationType.Destination => "震源情報",
                QuakeInformationType.ScaleAndDestination => "震源・震度情報",
                QuakeInformationType.Detail => "地震情報",
                QuakeInformationType.Foreign => "遠地(海外)地震情報",
                _ => "地震情報",
            };

            if (e.InformationType == QuakeInformationType.Foreign || e.InformationType == QuakeInformationType.Destination)
            {
                builder.AddText($"{type} ({e.OccuredTime})");
            }
            else
            {
                builder.AddText($"{type} ({e.OccuredTime} 震度{e.Scale})");
            }

            if (e.InformationType == QuakeInformationType.ScalePrompt)
            {
                var maxScaleGroup = e.PointList.OrderBy(e => e.ScaleInt).Reverse().GroupBy(e => e.Scale).First();
                builder.AddText($"震度{maxScaleGroup.Key}: {string.Join('、', maxScaleGroup.Select(e => e.Name))}");
            }
            else
            {
                var tsunamiDescription = e.TsunamiType switch
                {
                    DomesticTsunamiType.None => "津波の心配なし",
                    DomesticTsunamiType.Checking => "津波の有無調査中",
                    DomesticTsunamiType.Effective => "津波予報 発表中",
                    _ => "津波の有無不明",
                };
                builder.AddText($"{e.Destination} (深さ{e.Depth}, {e.Magnitude}) {tsunamiDescription}");
            }

            builder.AddArgument("type", "quake").AddArgument("receivedAt", e.ReceivedAt.ToString());
            builder.Show();
        }