void HandleStartButt() { if (selected_butt == ButtonSelected.Button_None) { EventSystem.current.SetSelectedGameObject(start.gameObject); selected_butt = ButtonSelected.Button_Start; } }
private void ShowMessage(ButtonSelected buttonSelected) { MessageText = string.Format(TextResources.MessageNoWorkoutVideoFound, ButtonSelected.Beginner == buttonSelected ? TextResources.HealthyPlan : ButtonSelected.Moderate == buttonSelected ? TextResources.ActivePlan : ButtonSelected.Advanced == buttonSelected ? TextResources.ElitePlan : string.Empty); MessageVisible = MessageText != null && MessageText.Trim().Length > 0; }
private void ShowMessage(ButtonSelected buttonSelected) { MessageText = string.Format(TextResources.MessageNoWorkoutVideoFound, ButtonSelected.Beginner == buttonSelected ? TextResources.HealthyPlan : ButtonSelected.Moderate == buttonSelected ? TextResources.ActivePlan : ButtonSelected.Advanced == buttonSelected ? TextResources.ElitePlan : string.Empty); MessageVisible = !string.IsNullOrEmpty(MessageText); }
// Den används i Unity inspectorn public void SelectMenuButton() { if (!Selectable) { return; } ButtonSelected?.Invoke(); buttonSelected.Invoke(); button.Select(); menuButtonController.Index = index; }
void ReleaseDesignerOutlets() { if (LabelFilePath != null) { LabelFilePath.Dispose(); LabelFilePath = null; } if (ButtonSelected != null) { ButtonSelected.Dispose(); ButtonSelected = null; } }
public void ReloadData(string filePath, bool fileOrFolder) { char[] seperater = { '/' }; string[] filePathTemp = filePath.Split(seperater); LabelFilePath.Text = filePathTemp[filePathTemp.Length - 1]; if (fileOrFolder == true) { ButtonSelected.SetTitle("File", UIControlState.Normal); } else { ButtonSelected.SetTitle("Path", UIControlState.Normal); } }
public async Task UpdateButtonSelected(ButtonSelected buttonSelected = ButtonSelected.None) { if (ButtonSelectedPreviously != ButtonSelected.None && ButtonSelectedPreviously == buttonSelected) { return; } BeginnerStyle = LabelStyleDefault; ModerateStyle = LabelStyleDefault; AdvancedStyle = LabelStyleDefault; var imageSize = App.Configuration.GetImageSizeByID(ImageIdentity.WORKOUT_OPTIONS_IMAGE); if (imageSize == null) { imageSize = new ImageSize(); } BeginnerImage = ImageResizer.ResizeImage(TextResources.icon_meal_healthy_dark, imageSize); ModerateImage = ImageResizer.ResizeImage(TextResources.icon_meal_active_dark, imageSize); AdvancedImage = ImageResizer.ResizeImage(TextResources.icon_meal_elite_dark, imageSize); switch (buttonSelected) { case ButtonSelected.Beginner: BeginnerStyle = LabelStyleSelected; BeginnerImage = ImageResizer.ResizeImage(TextResources.icon_meal_healthy, imageSize); break; case ButtonSelected.Moderate: ModerateStyle = LabelStyleSelected; ModerateImage = ImageResizer.ResizeImage(TextResources.icon_meal_active, imageSize); break; case ButtonSelected.Advanced: AdvancedStyle = LabelStyleSelected; AdvancedImage = ImageResizer.ResizeImage(TextResources.icon_meal_elite, imageSize); break; } ButtonSelectedPreviously = buttonSelected; await GetData(buttonSelected); }
private async Task <List <AccordionExtendedSource> > GetData(ButtonSelected buttonSelected) { if (buttonSelected == ButtonSelected.None) { return(new List <AccordionExtendedSource>()); } var listWorkoutLevel = (await GetAsync()).FirstOrDefault(l => (l.LevelDisplay.ToString().ToLower() ?? "") == buttonSelected.ToString().ToLower()); var accordionSources = new List <AccordionExtendedSource>(); var listWorkoutWeeks = listWorkoutLevel?.WorkoutWeeks ?? new List <mediaFile.WorkoutWeek>(); var imageSize = App.Configuration.GetImageSizeByID(ImageIdentity.VIDEO_PLAYER_PAGE_COMMAND_IMAGE); //var imageSizeExpand = App.Configuration.GetImageSizeByID(ImageIdentity.WORKOUT_EXPAND_COLLAPSE_IMAGE); //var imageSizePlayIcon = App.Configuration.GetImageSizeByID(ImageIdentity.WORKOUT_PLAY_ICON); foreach (var week in listWorkoutWeeks) { var accordionSourceItems = new List <AccordionExtendedSourceItem>(); foreach (var day in week.WorkoutDays) { var list = new List <mediaFile.MediaContentDetail>(); foreach (var media in day.MediaContentDetails) { media.IsHeader = false; media.TextStyle = (Style)App.CurrentApp.Resources["labelAccordionStyleItem"]; list.Add(media); } var mediaContentDetails = (from m in list orderby m.IsHeader descending, m.WorkoutWeek, m.WorkoutDay, m.ID select m).ToList(); var contentListView = new ListView() { // Source of data items. ItemsSource = mediaContentDetails, Header = new StackLayout { VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(5, 0, 5, 0), Children = { new Grid() { RowDefinitions = { new RowDefinition() { Height = GridLength.Star } }, HorizontalOptions = LayoutOptions.FillAndExpand, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition() { Width = GridLength.Auto } }, Children = { new Label() { LineBreakMode = LineBreakMode.TailTruncation, VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.StartAndExpand, Style = (Style)App.CurrentApp.Resources["labelAccordionStyleItemHeader"], Text = TextResources.Header_Exercise }, new StackLayout() { WidthRequest = 1 }, new Label() { LineBreakMode = LineBreakMode.TailTruncation, VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.EndAndExpand, Style = (Style)App.CurrentApp.Resources["labelAccordionStyleItemHeader"], Text = TextResources.Header_SetsAndRepeats, Margin = new Thickness(10, 0, 0, 0) } } } } }, // Define template for displaying each item. (Argument of DataTemplate // constructor is called for each item; it must return a Cell derivative.) ItemTemplate = new DataTemplate(() => { // Create views with bindings for displaying each property. Label titleLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, VerticalOptions = LayoutOptions.Center, Style = (Style)App.CurrentApp.Resources["labelAccordionStyleItem"] }; titleLabel.SetBinding(Label.TextProperty, new Binding("MediaTitle", BindingMode.OneWay, null, null, "{0}")); Image image = new Image() { Style = (Style)App.CurrentApp.Resources["imageIconMenuItem"], Source = ImageResizer.ResizeImage(TextResources.icon_play, imageSize), VerticalOptions = LayoutOptions.Center }; image.SetBinding(VisualElement.IsVisibleProperty, new Binding("IsHeaderReverse", BindingMode.OneWay, null, null, "{0}")); Label setsAndRepeatsLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, Style = (Style)App.CurrentApp.Resources["labelAccordionStyleItem"] }; setsAndRepeatsLabel.SetBinding(Label.TextProperty, new Binding("SetsAndRepeats", BindingMode.OneWay, null, null, "{0}")); var grid = new Grid() { RowDefinitions = { new RowDefinition() { Height = GridLength.Star } }, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition() { Width = GridLength.Auto } }, HorizontalOptions = LayoutOptions.FillAndExpand, }; var stackLayoutColumnTitle = new StackLayout { VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new StackLayout() { HeightRequest = .5, BackgroundColor = Palette._FooterTexts, HorizontalOptions = LayoutOptions.FillAndExpand, }, new StackLayout { VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { image, titleLabel } } } }; var stackLayoutColumnSets = new StackLayout { VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new StackLayout() { HeightRequest = .5, BackgroundColor = Palette._FooterTexts, HorizontalOptions = LayoutOptions.FillAndExpand, }, setsAndRepeatsLabel } }; grid.Children.Add(stackLayoutColumnTitle, 0, 0); grid.Children.Add(new StackLayout() { WidthRequest = 1 }, 1, 0); grid.Children.Add(stackLayoutColumnSets, 2, 0); // Return an assembled ViewCell. return(new ViewCell { View = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(5, 0, 5, 20), Children = { grid }, }, }); }), SeparatorVisibility = SeparatorVisibility.None, Margin = new Thickness(0, 6, 0, 3), VerticalOptions = LayoutOptions.Start, RowHeight = 30, BackgroundColor = Color.Transparent }; contentListView.HeightRequest = (contentListView.RowHeight * (mediaContentDetails.Count)) + 20; //contentListView.ItemSelected += ContentListView_ItemSelected; contentListView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { if (e.SelectedItem != null) { CurrentMediaContent = (mediaFile.MediaContentDetail)e.SelectedItem; if (!CurrentMediaContent?.IsHeader ?? true) { PopupActionCommand(); } contentListView.SelectedItem = null; } }; accordionSourceItems.Add(new AccordionExtendedSourceItem() { HeaderImage = TextResources.icon_plus_gray, HeaderImageStyle = (Style)App.CurrentApp.Resources["imageExpandPlus"], HeaderImageSelected = TextResources.icon_plus, HeaderText = day.DayDisplay ?? "", HeaderTextStyle = (Style)App.CurrentApp.Resources["labelStyleInfoHeading"], HeaderTextSelectedStyle = (Style)App.CurrentApp.Resources["labelStyleInfoHighlight"], HeaderNotePart1 = TextResources.NoteTapOn, HeaderNotePart2 = TextResources.icon_play_gray, HeaderNotePart3 = TextResources.NoteToWatchTheVideos, HeaderNoteStyle = (Style)App.CurrentApp.Resources["labelStyleTextTitleIntern"], HeaderNotePart2Style = (Style)App.CurrentApp.Resources["imageIconMenuItem"], ContentItems = contentListView }); } accordionSources.Add(new AccordionExtendedSource() { Title = week.WeekDisplay ?? "", TitleStyle = (Style)App.CurrentApp.Resources["buttonStyleGray"], TitleSelectedStyle = (Style)App.CurrentApp.Resources["buttonStyle"], AccordionExtendedSourceItems = accordionSourceItems }); } if (accordionSources.Count == 0) { ShowMessage(buttonSelected); } AccordionSources = accordionSources; return(AccordionSources); }
void OnSelectedButtonChanged() { ButtonSelected.Invoke(this, new SelectedButtonChangedEventArgs(SelectedButton)); }
// Update is called once per frame void Update() { if (!playerIndexSet || !prevState.IsConnected) { for (int i = 0; i < 4; ++i) { PlayerIndex testPlayerIndex = (PlayerIndex)i; GamePadState testState = GamePad.GetState(testPlayerIndex); if (testState.IsConnected) { Debug.Log(string.Format("GamePad found {0}", testPlayerIndex)); playerIndex = testPlayerIndex; playerIndexSet = true; } } } prevState = state; state = GamePad.GetState(playerIndex); state = GamePad.GetState((PlayerIndex)0); if (state.ThumbSticks.Left.X > 0.95f) //Right { if (screen == Screen.Screen_Start) { HandleStartButt(); } else if (screen == Screen.Screen_Finish) { EventSystem.current.SetSelectedGameObject(exit.gameObject); selected_butt = ButtonSelected.Button_Exit; } } if (state.ThumbSticks.Left.X < -0.95f) //Left { if (screen == Screen.Screen_Start) { HandleStartButt(); } else if (screen == Screen.Screen_Finish) { EventSystem.current.SetSelectedGameObject(rematch.gameObject); selected_butt = ButtonSelected.Button_Rematch; } } if (state.Buttons.A == ButtonState.Pressed) { if (gameSceneManage) { switch (selected_butt) { case ButtonSelected.Button_Start: gameSceneManage.LoadStoryScene(); break; case ButtonSelected.Button_Rematch: gameSceneManage.LoadMainScene(); break; case ButtonSelected.Button_Exit: gameSceneManage.QuitApplication(); break; } } } }
private void InitUI() { //declare ui element //khai báo 1 cái label để hiển thị fps Label label_fps = new Label(" ", new Point(0, 0), new Vector2(100, 50), CONTENT_MANAGER.defaultfont); label_fps.foregroundColor = Color.DarkBlue; label_fps.IsVisible = false; //TODO make button for main menu Button button_Campaign = new Button(ModeSelectDark, null, new Point(100, 275), 2); Button button_MapEditor = new Button(ModeSelectDark, null, new Point(300, 275), 2); Button button_OtherGamemode = new Button(ModeSelectDark, null, new Point(500, 275), 2); //bind action to ui event button_Campaign.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.Campaign) { selectedbutton = ButtonSelected.Campaign; button_Campaign.Sprite = ModeSelectLight; button_MapEditor.Sprite = ModeSelectDark; button_OtherGamemode.Sprite = ModeSelectDark; } else { SCREEN_MANAGER.goto_screen("SetupScreen"); } }; button_MapEditor.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.MapEditor) { selectedbutton = ButtonSelected.MapEditor; button_Campaign.Sprite = ModeSelectDark; button_MapEditor.Sprite = ModeSelectLight; button_OtherGamemode.Sprite = ModeSelectDark; } else { SCREEN_MANAGER.goto_screen("EditorScreen"); } }; button_OtherGamemode.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.Other) { selectedbutton = ButtonSelected.Other; button_Campaign.Sprite = ModeSelectDark; button_MapEditor.Sprite = ModeSelectDark; button_OtherGamemode.Sprite = ModeSelectLight; } else { //SCREEN_MANAGER.goto_screen("OtherGamemode"); } }; //add ui element to canvas canvas.AddElement("label_fps", label_fps); canvas.AddElement("button_Campaign", button_Campaign); canvas.AddElement("button_MapEditor", button_MapEditor); canvas.AddElement("button_OtherGameMode", button_OtherGamemode); }