public ProgramPage()
        {
            InitializeComponent();

            foreach (var programInfo in ((ProgramPageViewModel)DataContext).ProgramInfoCollection)
            {
                var btn = new SoundImageButton()
                {
                    Stretch = Stretch.Uniform
                };
                if (programInfo.IsEnabled)
                {
                    btn.NormalImage  = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/ProgramPage/Button_{programInfo.Program}_Normal.png", UriKind.RelativeOrAbsolute));
                    btn.PressedImage = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/ProgramPage/Button_{programInfo.Program}_Pressed.png", UriKind.RelativeOrAbsolute));
                    btn.SetBinding(ButtonBase.CommandProperty, new Binding("SelectProgramCommand"));
                    btn.CommandParameter = programInfo;
                }
                else
                {
                    btn.IsEnabled     = false;
                    btn.DisabledImage = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/ProgramPage/Button_{programInfo.Program}_Disabled.png", UriKind.RelativeOrAbsolute));
                }

                ButtonContainer.Children.Add(btn);
            }
        }
示例#2
0
        public override void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.NavigationType != NavigationType.Back)
            {
                ButtonContainer.Children.Clear();

                if (e.Parameter is ProgramInfo programInfo)
                {
                    foreach (var scene in programInfo.SceneInfoCollection)
                    {
                        var btn = new SoundImageButton()
                        {
                            Stretch = Stretch.Uniform
                        };
                        if (scene.IsEnabled)
                        {
                            btn.NormalImage  = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/SelectScenePage/Button_{scene.Scene}_Normal.png", UriKind.RelativeOrAbsolute));
                            btn.PressedImage = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/SelectScenePage/Button_{scene.Scene}_Pressed.png", UriKind.RelativeOrAbsolute));
                            btn.SetBinding(ButtonBase.CommandProperty, new Binding("SelectSceneCommand"));
                            btn.CommandParameter = new Tuple <string, string, int>(programInfo.Program, scene.Scene, scene.RoadTypeCount);
                        }
                        else
                        {
                            btn.IsEnabled     = false;
                            btn.DisabledImage = new BitmapImage(new Uri($"/RidingSystem.Assets;component/Assets/Image/SelectScenePage/Button_{scene.Scene}_Disabled.png", UriKind.RelativeOrAbsolute));
                        }

                        ButtonContainer.Children.Add(btn);
                    }
                }
            }
            else
            {
                MainWindow.Current.PlayBackgroundMusic();
            }
        }