void InitView()
        {
            var scrollView = new ScrollView()
            {
                //Padding = new Thickness(10, 20)
            };
            //Dictionary<string, int> hours = new Dictionary<string, int>();
            //for (int i = 0; i <= 23; i++)
            //{
            //    hours.Add(i + "小时", i);
            //}
            Dictionary<string, int> minutes = new Dictionary<string, int>();
            for (int i = 0; i <= 59; i++)
            {
                minutes.Add(i + "分钟", i);
            }
            Dictionary<string, int> seconds = new Dictionary<string, int>();
            for (int i = 0; i <= 60; i++)
            {
                seconds.Add(i + "秒钟", i);
            }
            Dictionary<string, int> readySeconds = new Dictionary<string, int>();
            for (int i = 1; i <= 5; i++)
            {
                readySeconds.Add(i + "秒钟", i);
            }
            //Picker hourPicker = new Picker()
            //{
            //    Title = "小时",
            //    HorizontalOptions = LayoutOptions.FillAndExpand
            //};
            //foreach (var hour in hours)
            //{
            //    hourPicker.Items.Add(hour.Key);
            //}
            //hourPicker.SelectedIndexChanged += delegate
            //{
            //    if (hourPicker.SelectedIndex == -1)
            //    {
            //        Hours = 0;
            //    }
            //    else
            //    {
            //        Hours = hours.ToArray()[hourPicker.SelectedIndex].Value;
            //    }
            //};
            Picker minutePicker = new Picker()
            {
                Title = "分钟",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var minute in minutes)
            {
                minutePicker.Items.Add(minute.Key);
            }

            minutePicker.SelectedIndexChanged += delegate
            {
                if (minutePicker.SelectedIndex == -1)
                {
                    Minutes = 0;
                }
                else
                {
                    Minutes = minutes.ToArray()[minutePicker.SelectedIndex].Value;
                }
            };
            Picker secondPicker = new Picker()
            {
                Title = "秒钟",
                HorizontalOptions = LayoutOptions.FillAndExpand

            };
            foreach (var second in seconds)
            {
                secondPicker.Items.Add(second.Key);
            }
            secondPicker.SelectedIndexChanged += delegate
            {
                if (secondPicker.SelectedIndex == -1)
                {
                    Seconds = 0;
                }
                else
                {
                    Seconds = seconds.ToArray()[secondPicker.SelectedIndex].Value;
                }
            };

            Picker readySecondPicker = new Picker()
            {
                Title = "秒钟",
                IsEnabled = false
            };
            foreach (var second in readySeconds)
            {
                readySecondPicker.Items.Add(second.Key);
            }
            readySecondPicker.SelectedIndex = readySeconds.ToList().FindIndex(w => w.Value == ViewModel.VoiceInterval);
            readySecondPicker.SelectedIndexChanged += delegate
            {
                if (readySecondPicker.SelectedIndex == -1)
                {
                    VoiceInterval = readySeconds.ToArray()[0].Value; ;
                }
                else
                {
                    VoiceInterval = readySeconds.ToArray()[readySecondPicker.SelectedIndex].Value;
                }
                //ViewModel.VoiceInterval = VoiceInterval;
            };

            PanelView panelView1 = new PanelView()
            {
                Text = "阶段时间点",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal,
                    Children =
                    {
                        //hourPicker,
                        minutePicker, secondPicker
                    }
                }
            };
            PanelView panelView2 = new PanelView()
            {
                Text = "播报间隔时间",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = readySecondPicker
            };

            Button saveButton = new Button()
            {

                HeightRequest = 40,
                Text = "确定",
                BackgroundColor = Consts.ThemeColor,
                TextColor = Color.White,
            };
            saveButton.Clicked += saveButton_Clicked;
            LineView line0 = new LineView()
            {
                HeightRequest = 10,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line1 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line2 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            //LineView line3 = new LineView()
            //{
            //    HeightRequest = 10,
            //    HorizontalOptions = LayoutOptions.FillAndExpand,
            //    BackgroundColor = Color.FromHex("#f7f7f7")
            //};
            scrollView.Content = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Children = {line0, panelView1, line1, panelView2, line2, new StackLayout()
                {
                    Padding = 10,
                    Children = {saveButton}
                } }
            };
            Content = scrollView;
        }
        void InitView()
        {
            var scrollView = new ScrollView()
            {
                //Padding = new Thickness(10, 20)

            };
            entry = new Entry() { Placeholder = "请输入名称" };
            entry.SetBinding(Entry.TextProperty, "Name");
            PanelView panelView1 = new PanelView()
            {
                Text = "名称",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = entry
            };

            Dictionary<string, int> hours = new Dictionary<string, int>();
            for (int i = 0; i <= 2; i++)
            {
                hours.Add(i + "小时", i);
            }
            Dictionary<string, int> minutes = new Dictionary<string, int>();
            for (int i = 0; i <= 59; i++)
            {
                minutes.Add(i + "分钟", i);
            }
            Dictionary<string, int> seconds = new Dictionary<string, int>();
            for (int i = 0; i <= 60; i++)
            {
                seconds.Add(i + "秒钟", i);
            }
            Dictionary<string, int> readySeconds = new Dictionary<string, int>();
            readySeconds.Add("无",0);
            for (int i = 3; i <= 10; i++)
            {
                readySeconds.Add(i + "秒钟", i);
            }
            Picker hourPicker = new Picker()
            {
                Title = "小时",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var hour in hours)
            {
                hourPicker.Items.Add(hour.Key);
            }
            hourPicker.SelectedIndex = hours.ToList().FindIndex(w => w.Value == Hours);
            hourPicker.SelectedIndexChanged += delegate
            {
                if (hourPicker.SelectedIndex == -1)
                {
                    Hours = 0;
                }
                else
                {
                    Hours = hours.ToArray()[hourPicker.SelectedIndex].Value;
                }
                ViewModel.Duration = ComputeDuration();
            };
            Picker minutePicker = new Picker()
            {
                Title = "分钟",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var minute in minutes)
            {
                minutePicker.Items.Add(minute.Key);
            }
            minutePicker.SelectedIndex = minutes.ToList().FindIndex(w => w.Value == Minutes);
            minutePicker.SelectedIndexChanged += delegate
            {
                if (minutePicker.SelectedIndex == -1)
                {
                    Minutes = 0;
                }
                else
                {
                    Minutes = minutes.ToArray()[minutePicker.SelectedIndex].Value;
                }
                ViewModel.Duration = ComputeDuration();
            };
            Picker secondPicker = new Picker()
            {
                Title = "秒钟",
                HorizontalOptions = LayoutOptions.FillAndExpand

            };
            foreach (var second in seconds)
            {
                secondPicker.Items.Add(second.Key);
            }
            secondPicker.SelectedIndex = seconds.ToList().FindIndex(w => w.Value == Seconds);
            secondPicker.SelectedIndexChanged += delegate
            {
                if (secondPicker.SelectedIndex == -1)
                {
                    Seconds = 0;
                }
                else
                {
                    Seconds = seconds.ToArray()[secondPicker.SelectedIndex].Value;
                }
                ViewModel.Duration = ComputeDuration();
            };

            Picker readySecondPicker = new Picker()
            {
                Title = "准备时间",

            };
            foreach (var second in readySeconds)
            {
                readySecondPicker.Items.Add(second.Key);
            }
            readySecondPicker.SelectedIndex = readySeconds.ToList().FindIndex(w => w.Value == ViewModel.SecendsToReady);
            readySecondPicker.SelectedIndexChanged += delegate
            {
                if (readySecondPicker.SelectedIndex == -1)
                {
                    ReadySeconds = 0;
                }
                else
                {
                    ReadySeconds = readySeconds.ToArray()[readySecondPicker.SelectedIndex].Value;
                }
                ViewModel.SecendsToReady = ReadySeconds;
            };

            PanelView panelView2 = new PanelView()
            {
                Text = "方案时长",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = { hourPicker, minutePicker, secondPicker }
                }
            };
            PanelView panelView3 = new PanelView()
            {
                Text = "准备时间",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = readySecondPicker
            };

            //text to speak engines
            var textToSpeak = DependencyService.Get<ITextToSpeech>().New().Init();
            //textToSpeak.NoEngine += delegate
            //{
            //    DependencyService.Get<Acr.XamForms.UserDialogs.IUserDialogService>().Toast("您的设备上没安装TTS引擎",2);
            //};
            PanelView engineView = null;
            if (textToSpeak.GetEngines().Count == 0)
            {

                var btn = new Button()
                {
                    Text = "无语音引擎 点击看详情",
                    TextColor = Color.White,
                    BackgroundColor = Consts.ThemeColor
                };

                btn.Clicked += delegate
                {
                    var uds = DependencyService.Get<Acr.XamForms.UserDialogs.IUserDialogService>();
                    uds.ActionSheet(new ActionSheetConfig()
                    {
                        Title = "安装语音引擎",
                        Options =
                        {
                            new ActionSheetOption("下载安装讯飞语音+", () =>
                            {
                                var url = "http://zhushou.360.cn/detail/index/soft_id/676960";
                                Device.OpenUri(new Uri(url));
                            }),
                            new ActionSheetOption("下载安装灵犀语音助手", () =>
                            {
                                var url = "http://zhushou.360.cn/detail/index/soft_id/194066";
                                Device.OpenUri(new Uri(url));
                                
                            }),
                            new ActionSheetOption("下载安装Google文字转语音 非汉语", () =>
                            {
                                var url = "http://zhushou.360.cn/detail/index/soft_id/885077";
                                Device.OpenUri(new Uri(url));
                                
                            }),
                        }
                    });
                };
                engineView = new PanelView()
                {
                    Text = "语音引擎",
                    TextColor = Color.FromHex("999"),
                    UnderLineColor = Color.FromHex("999"),
                    Content = btn
                };
            }
            else
            {

                Dictionary<string, string> engines = new Dictionary<string, string>();
                foreach (var engine in textToSpeak.GetEngines())
                {
                    engines.Add(engine.Label, engine.Name);
                }
                Picker enginePicker = new Picker()
                {
                    Title = "选择TTS语音引擎",
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };
                foreach (var engine in engines)
                {
                    enginePicker.Items.Add(engine.Key);
                }
                enginePicker.SelectedIndex = engines.ToList().FindIndex(w => w.Value == ViewModel.VoiceEngine);
                enginePicker.SelectedIndexChanged += delegate
                {
                    if (enginePicker.SelectedIndex == -1)
                    {
                        ViewModel.VoiceEngine = engines.ToArray()[0].Value;
                    }
                    else
                    {
                        ViewModel.VoiceEngine = engines.ToArray()[enginePicker.SelectedIndex].Value;
                    }

                };
                engineView = new PanelView()
                {
                    Text = "语音引擎",
                    TextColor = Color.FromHex("999"),
                    UnderLineColor = Color.FromHex("999"),
                    Content = enginePicker
                };
            }
            textToSpeak.Dispose();
            stageListView = new ListView();
            var addStageBtn = new Button()
            {
                WidthRequest = 140,
                HeightRequest = 40,
                HorizontalOptions = LayoutOptions.Center,
                Text = "普通阶段",
                BackgroundColor = Consts.ThemeColor,
                TextColor = Color.White,
                Image = "ic_add_white_24dp.png"
            };
            addStageBtn.Clicked += addStageBtn_Clicked;
            var addFinalStageBtn = new Button()
            {
                WidthRequest = 140,
                HeightRequest = 40,
                HorizontalOptions = LayoutOptions.Center,
                Text = "冲刺阶段",
                BackgroundColor = Consts.ThemeColor,
                TextColor = Color.White,
                Image = "ic_add_white_24dp.png"
            };
            addFinalStageBtn.IsEnabled = !ViewModel.HasFinalStage;
            ViewModel.ObservableStages.CollectionChanged += delegate
            {
                addFinalStageBtn.IsEnabled = !ViewModel.HasFinalStage;
            };
            addFinalStageBtn.Clicked += addFinalStageBtn_Clicked;
            stageListView.Header = new StackLayout()
            {
                Padding = 10,
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children = { addStageBtn, addFinalStageBtn }
            };
            stageListView.SetBinding(ListView.ItemsSourceProperty, "ObservableStages");
            stageListView.ItemTemplate = new DataTemplate(typeof(StagesViewCell));
            stageListView.HeightRequest = ViewModel.ObservableStages.Count * 45 + 70;
            stageListView.ItemTapped += stageListView_ItemTapped;
            PanelView panelView5 = new PanelView()
            {
                Text = "播报阶段设置",
                TextColor = Color.FromHex("999"),
                UnderLineColor = Color.FromHex("999"),
                Content = stageListView
            };

            Button saveButton = new Button()
            {

                HeightRequest = 40,
                Text = "保存",
                BackgroundColor = Consts.ThemeColor,
                TextColor = Color.White,
            };
            saveButton.Clicked += saveButton_Clicked;
            LineView line0 = new LineView()
            {
                HeightRequest = 10,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line1 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line2 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line3 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line4 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            LineView line5 = new LineView()
            {
                HeightRequest = 8,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.FromHex("#f7f7f7")
            };
            scrollView.Content = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Children = {line0, panelView1, line1, panelView2, line2, panelView3, line3, engineView, line4, panelView5, //line5, 
                    new StackLayout()
                    {
                        Padding = new Thickness(10,20),
                        Children = {saveButton}
                    }
                }
            };
            Content = scrollView;
            ViewModel.ObservableStages.CollectionChanged += ObservableStages_CollectionChanged;

        }