陈嘉乐
2020-06-05 f432344ed815e5b6b88ab42bcee50b45e664472e
HDL_ON/UI/Music/View/DialogView.cs
@@ -1136,6 +1136,204 @@
                return a31player.Name;
            }
        }
        /// <summary>
        /// 播放器音量的界面
        /// </summary>
        /// <param name="a31player">主播放器</param>
       public  void PlayerVolumeView(A31MusicModel a31player)
        {
            #region
            //主控件
            Dialog dialog = new Dialog()
            {
                //BackgroundColor = Color.PopupBackgroundColor,
            };
            dialog.Show();
            //父控件
            FrameLayout frame = new FrameLayout { };
            dialog.AddChidren(frame);
            frame.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
            };
            //白色快父控件
            FrameLayout dialogFra = new FrameLayout()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(397),
                Width = Application.GetRealWidth(344),
                Height = Application.GetRealHeight(250),
                BackgroundColor = Color.WhiteColor,
                Radius = (uint)Application.GetRealHeight(12),
            };
            frame.AddChidren(dialogFra);
            //显示头部信息父控件
            FrameLayout topFra = new FrameLayout()
            {
                Width = Application.GetRealWidth(344),
                Height = Application.GetRealHeight(58),
            };
            dialogFra.AddChidren(topFra);
            //取消控件
            Button cancelnBtn = new Button
            {
                X = Application.GetRealWidth(20),
                Y = Application.GetRealHeight(15),
                Width = Application.GetRealWidth(60),
                Height = Application.GetRealHeight(20),
                TextID = StringId.cancelMusic,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = Color.MusicNoTxetColor,
                TextSize = TextSize.Text14,
            };
            topFra.AddChidren(cancelnBtn);
            cancelnBtn.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
            };
            //标题控件
            Button txetBtn = new Button
            {
                X = cancelnBtn.Right + Application.GetRealWidth(20),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(152),
                Height = Application.GetRealHeight(22),
                TextColor = Color.TextColor,
                TextSize = TextSize.Text16,
                TextAlignment = TextAlignment.Center,
                //TextID = StringId.readyPlay,
                Text="调节音量",
                IsBold = true,
            };
            topFra.AddChidren(txetBtn);
            //确认控件
            Button confirmBtn = new Button
            {
                X = Application.GetRealWidth(344 - 60 - 20),
                Y = Application.GetRealHeight(15),
                Width = Application.GetRealWidth(60),
                Height = Application.GetRealHeight(20),
                TextID = StringId.confirmMusic,
                TextAlignment = TextAlignment.CenterRight,
                TextColor = Color.SelectedColor,
                TextSize = TextSize.Text14,
            };
            topFra.AddChidren(confirmBtn);
            confirmBtn.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
            };
            VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
            {
                Y = Application.GetRealHeight(58),
                Height = dialogFra.Height - Application.GetRealHeight(58),
                Width = Application.GetRealWidth(343),
            };
            dialogFra.AddChidren(verticalScrolViewLayout);
            var playList = new List<A31MusicModel>();
            for (int i = 0; i < a31player.Slave.slave_list.Count; i++)
            {
                var slave = a31player.Slave.slave_list[i];
                var music_If = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == slave.uuid.Replace("uuid:", ""));
                if (music_If != null)
                {
                    music_If.ServerClientType = -1;
                    music_If.A31PlayStatus.vol = slave.volume;
                    playList.Add(music_If);
                }
            }
            playList.Add(a31player);
            for (int i = 0; i < playList.Count; i++)
            {
                var player = playList[i];
                FrameLayout volumeFra = new FrameLayout
                {
                    Height = Application.GetRealHeight(64),
                };
                verticalScrolViewLayout.AddChidren(volumeFra);
                Button volumeTextBtn = new Button
                {
                    X = Application.GetRealWidth(28),
                    Y = Application.GetRealHeight(8),
                    Width = Application.GetRealWidth(200),
                    Height = Application.GetRealHeight(14),
                    TextColor = Color.MusicNoTxetColor,
                    TextSize = TextSize.Text10,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                volumeFra.AddChidren(volumeTextBtn);
                if (player.ServerClientType == -1)
                {
                    volumeTextBtn.Text = player.Name + "音量";
                }
                else if (player.ServerClientType == 1)
                {
                    volumeTextBtn.Text = "总音量";
                }
                DiyImageSeekBar volSeekBar = new DiyImageSeekBar
                {
                    Y = Application.GetRealHeight(12),
                    X = Application.GetRealWidth(28),
                    Width = Application.GetRealWidth(240),
                    Height = Application.GetRealHeight(54),//进度条父控件背景高度
                    IsProgressTextShow = false,//显示百分比
                    IsClickable = true,//进度条是否滑动
                    ProgressBarColor = Color.SelectedColor,//选中进度条颜色
                    ThumbImagePath = "MusicIcon/progressIcon.png",//进度条按钮图标
                    ThumbImageHeight = Application.GetMinRealAverage(54),//进度条按钮图标的高度(默认正方形:宽和高一样)
                    SeekBarViewHeight = Application.GetMinRealAverage(8),//进度条的高度
                    Progress=int.Parse(player.A31PlayStatus.vol),
                    //ProgressChangeDelayTime=
                };
                volumeFra.AddChidren(volSeekBar);
                Button valueBtn = new Button
                {
                    X = Application.GetRealWidth(289),
                    Y = Application.GetRealHeight(31),
                    Width = Application.GetRealWidth(26),
                    Height = Application.GetRealHeight(17),
                    TextColor = Color.MusicNoTxetColor,
                    TextSize = TextSize.Text12,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = player.A31PlayStatus.vol + "%",
                };
                volumeFra.AddChidren(valueBtn);
                ///音量进度条点击事件
                EventHandler<int> progressClick = (sender, e) =>
                {
                    if (player.ServerClientType == -1)
                    {
                        valueBtn.Text = volSeekBar.Progress + "%";
                        SendMethod.ControlVolume(volSeekBar.Progress, player);
                    }
                    else if (player.ServerClientType == 1)
                    {
                        for (int j = 0; j < playList.Count; j++)
                        {
                            var music = playList[j];
                            var frameLayout = (FrameLayout)verticalScrolViewLayout.GetChildren(j);
                            var diyImageSeekBar = (DiyImageSeekBar)frameLayout.GetChildren(1);
                            var button = (Button)frameLayout.GetChildren(2);
                            diyImageSeekBar.Progress = volSeekBar.Progress;
                            button.Text = volSeekBar.Progress + "%";
                            SendMethod.ControlVolume(volSeekBar.Progress, music);
                        }
                    }
                };
                volSeekBar.OnProgressChangedEvent += progressClick;
                volSeekBar.OnStopTrackingTouchEvent += progressClick;
            }
            #endregion
        }
       
    }
    [System.Serializable]