Exemple #1
0
    /// <summary> WARNING: This save OVERWRITES ANY PREVIOUSLY STORED DATA </summary>
    public void SaveStreamerData(StreamerData streamerData, bool isTotal)
    {
        string savePath      = GetFilePath(isTotal);
        string saveDirectory = GetDirectoryPath(isTotal, false);

        if (!Directory.Exists(saveDirectory))
        {
            //if it doesn't, create it
            Directory.CreateDirectory(saveDirectory);
        }

        /*
         * //Serialize Method
         * BinaryFormatter binaryFormatter = new BinaryFormatter();
         * using (FileStream fileStream = File.Create(savePath))
         * {
         *  binaryFormatter.Serialize(fileStream, streamerData);
         * }
         */

        //JSON Method
        string output = JsonUtility.ToJson(streamerData, true);

        using (StreamWriter newTask = new StreamWriter(savePath, false))
        {
            newTask.WriteLine(output);
        }
    }
 public void AddNewStreamer(StreamerData streamer)
 {
     if (!CheckNotifyLimit())
     {
         streamer.UseNotify = false;
     }
     Streamers.Add(streamer);
 }
        public void InitWithStreamerData(StreamerData data)
        {
            this.data = data;
            file      = new AudioFileReader(data.NotifySoundPath);
            device.Init(file);
            device.Play();
            device.PlaybackStopped += Device_PlaybackStopped;

            ContentTextBlock.Text = $"{data.DisplayName}님의 방송이 켜졌습니다!";
        }
Exemple #4
0
 public void OnBroadcastStartup(StreamerData data)
 {
     handler.Post(() =>
     {
         AlarmActivity.alarmTarget = data;
         var intent = new Intent(this, typeof(AlarmActivity));
         intent.AddFlags(ActivityFlags.NewTask);
         StartActivity(intent);
     });
 }
Exemple #5
0
 private void StreamerListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         selectedData = (StreamerData)StreamerListBox.SelectedItem;
         LoadSelectedIntoUI();
     }
     catch
     {
     }
 }
Exemple #6
0
        protected override void OnDestroy()
        {
            streamerData = null;
            try
            {
                previewPlayer.Dispose();
            }
            catch
            {
            }

            base.OnDestroy();
        }
        public void SaveStreamer(StreamerData streamer)
        {
            if (!Streamers.Contains(streamer))
            {
                throw new Exception("Tried to save streamer data that not managed in detector!");
            }
            var path = Path.Combine(PlatformUtils.Instance.GetConfigBasePath(), "Streamers");

            PlatformUtils.Instance.EnsureDirectory(path);

            path = Path.Combine(path, streamer.Id + ".json");
            PlatformUtils.Instance.WriteAllBytes(path, streamer.SaveToBytes());
        }
Exemple #8
0
    public StreamerData DefaultStreamerData()
    {
        StreamerData streamerData = new StreamerData();

        streamerData.dataVersion = currentDataVersion;

        streamerData.gamesPlayed = 0;
        streamerData.totalJoins  = 0;
        streamerData.uniqueJoins = 0;

        streamerData.longestGame     = 0;
        streamerData.shortestGame    = 0;
        streamerData.totalGameLength = 0;
        return(streamerData);
    }
Exemple #9
0
        public void FireAlarm(StreamerData data)
        {
            if (lastAlarmWindow != null && !lastAlarmWindow.IsClosed)
            {
                return;
            }

            lastAlarmWindow = new AlarmWindow();
            lastAlarmWindow.InitWithStreamerData(data);
            if (data.PreventPopup || (PreventPopupAllCheckBox.IsChecked.HasValue && PreventPopupAllCheckBox.IsChecked.Value))
            {
                return;
            }
            lastAlarmWindow.Show();
        }
 public void LoadStreamers()
 {
     Streamers.Clear();
     try
     {
         var basePath = Path.Combine(PlatformUtils.Instance.GetConfigBasePath(), "Streamers");
         foreach (var path in PlatformUtils.Instance.GetFiles(basePath))
         {
             Streamers.Add(StreamerData.LoadFromBytes(PlatformUtils.Instance.ReadAllBytes(Path.Combine(basePath, path))));
         }
     }
     catch
     {
     }
 }
Exemple #11
0
    public void LoadStreamerData()
    {
        streamerSessionData = fileWriter.LoadStreamerData(false);
        streamerTotalData   = fileWriter.LoadStreamerData(true);

        if (streamerSessionData == null)
        {
            streamerSessionData = DefaultStreamerData();
            Debug.LogWarning("No streamer session data loaded! Created a fresh set");
        }

        if (streamerTotalData == null)
        {
            streamerTotalData = DefaultStreamerData();
            Debug.LogWarning("No streamer total data loaded! Created a fresh set");
        }
    }
Exemple #12
0
        private void AddStreamerButton_Click(object sender, RoutedEventArgs e)
        {
            var streamer = new StreamerData();

            streamer.Id = new InputBox("아이디를 정하세요", "트위치 알람", "").ShowDialog();
            if (streamer.Id.Trim() == "")
            {
                MessageBox.Show("스트리머 아이디는 공백일 수 없습니다", "트위치 알림");
                return;
            }
            try
            {
                streamer.InternalId = detector.Twitch.V5.Users.GetUserByNameAsync(streamer.Id).Result.Matches[0].Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show("대상 아이디의 정보를 트위치에서 가져올 수 없었습니다", "트위치 알림");
                return;
            }
            detector.AddNewStreamer(streamer);
            detector.SaveStreamer(streamer);
            RefreshFilteredList();
        }
Exemple #13
0
 public void OnBroadcastStartup(StreamerData data)
 {
     FireAlarm(data);
 }
Exemple #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.activity_edit);

            idEditText   = FindViewById <EditText>(Resource.Id.streamerIdEditText);
            nameEditText = FindViewById <EditText>(Resource.Id.streamerNameEditText);

            var random = (new Random().Next(ID_AND_NAME_SAMPLES.Length / 2) * 2) - 2;

            if (random < 0)
            {
                random = 0;
            }
            idEditText.Hint   = ID_AND_NAME_SAMPLES[random + 1];
            nameEditText.Hint = ID_AND_NAME_SAMPLES[random];

            notifyRepeatCountEditText = FindViewById <EditText>(Resource.Id.streamerNotifyRepeatCountEditText);

            selectAudioFileButton   = FindViewById <Button>(Resource.Id.selectAudioFileButton);
            previewAlarmAudioButton = FindViewById <Button>(Resource.Id.previewAudioFileButton);
            saveButton         = FindViewById <Button>(Resource.Id.saveButton);
            previewAlarmButton = FindViewById <Button>(Resource.Id.previewAlarmButton);

            useNotifyCheckBox    = FindViewById <CheckBox>(Resource.Id.streamerUseNotifyCheckBox);
            preventPopupCheckBox = FindViewById <CheckBox>(Resource.Id.streamerPreventPopupCheckBox);

            if (streamerData == null)
            {
                isAdd        = true;
                streamerData = new StreamerData();
                Title        = GetString(Resource.String.add_title);
            }
            else
            {
                idEditText.Enabled = false;
                Title = GetString(Resource.String.edit_title);
            }
            idEditText.Text   = streamerData.Id;
            nameEditText.Text = streamerData.DisplayName;
            if (streamerData.NotifySoundRepeatCount == -1)
            {
                notifyRepeatCountEditText.Text = "무한";
            }
            else
            {
                notifyRepeatCountEditText.Text = streamerData.NotifySoundRepeatCount.ToString();
            }

            useNotifyCheckBox.Checked    = streamerData.UseNotify;
            preventPopupCheckBox.Checked = streamerData.PreventPopup;

            selectAudioFileButton.Click   += SelectAudioFileButton_Click;
            previewAlarmAudioButton.Click += PreviewAlarmAudioButton_Click;
            saveButton.Click         += SaveButton_Click;
            previewAlarmButton.Click += PreviewAlarmButton_Click;

            useNotifyCheckBox.CheckedChange += UseNotifyCheckBox_CheckedChange;
        }