예제 #1
0
        private void AddRoom()
        {
            var match = UrlToRoomidRegex.Match(AddRoomidTextBox.Text);

            if (match.Success)
            {
                if (int.TryParse(match.Groups["roomid"].Value, out int roomid))
                {
                    Add(roomid);
                }
                else
                {
                    logger.Warn("添加房间时发生了不应该出现的错误");
                }
            }
            else if (int.TryParse(AddRoomidTextBox.Text, out int roomid))
            {
                Add(roomid);
            }
            else
            {
                logger.Info("房间号是数字!");
            }
            AddRoomidTextBox.Text = string.Empty;

            void Add(int roomid)
            {
                if (roomid > 0)
                {
                    if (Recorder.Any(x => x.RoomId == roomid || x.ShortRoomId == roomid))
                    {
                        logger.Info("该直播间已经添加过了");
                    }
                    else
                    {
                        Recorder.AddRoom(roomid);
                        Recorder.SaveConfigToFile();
                    }
                }
                else
                {
                    logger.Info("房间号是大于0的数字!");
                }
            }
        }