// Max players private void SetupMaxPlayerSelector(int i_StadiumId) { SelectorData selectorData = new SelectorData(); tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(i_StadiumId); if (stadiumData != null) { int minPlayers = 2 * stadiumData.onlineTeamSize.min; int maxPlayers = 2 * stadiumData.onlineTeamSize.max; int localPartySize; PhotonUtils.TryGetPlayerCustomProperty <int>(PhotonNetwork.player, PhotonPropertyKey.s_PlayerCustomPropertyKey_LocalPartySize, out localPartySize); for (int numPlayers = minPlayers; numPlayers <= maxPlayers; numPlayers += 2) { if (numPlayers <= localPartySize) { continue; } SelectorItem selectorItem = new SelectorItem(numPlayers, numPlayers.ToString(), "", null); selectorData.AddItem(selectorItem); } } if (viewInstance != null) { viewInstance.SetMaxPlayersSelectorData(selectorData); } RefreshMaxPlayers(); }
// EVENTS private void OnSelectedGameModeChanged(SelectorItem i_SelectorItem) { if (i_SelectorItem == null) { return; } int gameModeId = i_SelectorItem.id; if (Hash.IsNullOrEmpty(gameModeId)) { return; } //tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId); //if (gameModeData != null) //{ // tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId); // if (gameModeConfig != null) // { // SelectMatchDuration(gameModeConfig.matchDurationOption); // SelectReferee(gameModeConfig.refereeOption); // SelectGoldenGoal(gameModeConfig.goldenGoalOption); // } //} // Refresh stadium selector. SetupStadiumSelector(gameModeId); }
// Ball private void SetupBallSelector() { SelectorData selectorData = new SelectorData(); List <int> ballKeys = tnGameData.GetBallsKeysMain(); if (ballKeys != null) { for (int index = 0; index < ballKeys.Count; ++index) { int key = ballKeys[index]; if (Hash.IsNullOrEmpty(key)) { continue; } tnBallData ballData = tnGameData.GetBallDataMain(key); if (ballData == null) { continue; } SelectorItem selectorItem = new SelectorItem(key, ballData.name, "", ballData.icon); selectorData.AddItem(selectorItem); } } if (viewInstance != null) { viewInstance.SetBallSelectorData(selectorData); } }
// Referee private void SetupRefereeSelector() { SelectorData selectorData = new SelectorData(); List <int> refereeOptionKeys = tnGameData.GetRefereeOptionKeysMain(); if (refereeOptionKeys != null) { for (int index = 0; index < refereeOptionKeys.Count; ++index) { int key = refereeOptionKeys[index]; string value; if (tnGameData.TryGetRefereeValueMain(key, out value)) { SelectorItem selectorItem = new SelectorItem(key, value, "", null); selectorData.AddItem(selectorItem); } } } if (viewInstance != null) { viewInstance.SetRefereeSelectorData(selectorData); } }
// Duration private void SetupMatchDurationSelector() { SelectorData selectorData = new SelectorData(); List <int> matchDurationKeys = tnGameData.GetMatchDurationOptionKeysMain(); if (matchDurationKeys != null) { for (int index = 0; index < matchDurationKeys.Count; ++index) { int key = matchDurationKeys[index]; float value; if (tnGameData.TryGetMatchDurationValueMain(key, out value)) { string time = TimeUtils.TimeToString(value, true, true); SelectorItem selectorItem = new SelectorItem(key, time, "", null); selectorData.AddItem(selectorItem); } } } if (viewInstance != null) { viewInstance.SetMatchDurationSelectorData(selectorData); } }
private void OnSelectedStadiumChanged(SelectorItem i_SelectorItem) { if (i_SelectorItem == null) { return; } int stadiumId = i_SelectorItem.id; if (Hash.IsNullOrEmpty(stadiumId)) { return; } // Refrsh max players selector. SetupMaxPlayerSelector(stadiumId); // Refresh proceed trigger status. bool locked = i_SelectorItem.locked; if (viewInstance != null) { viewInstance.SetProceedTriggerCanSend(!locked); } }
// EVENTS private void OnGameModeSelectedChanged(SelectorItem i_SelectorItem) { if (gameModeSelectedChangedEvent != null) { gameModeSelectedChangedEvent(i_SelectorItem); } }
/// <summary> /// Sets the selected state for the provided item. /// </summary> /// <param name="item">The item to alter selection</param> /// <param name="view">An optional view associated with the item being selected</param> /// <param name="selected">The new selection state</param> public void SetItemSelection(object item, SelectorItem view, bool selected) { if (selected) { _selectedItems.Add(item); } else { _selectedItems.Remove(item); } if (view == null) { // A single item may be mapped multiple times because of the recycling, and // we may not be able to know which one is actually displayed. _allocatedViews .OfType <SelectorItem>() .Where(p => p.DataContext == item) .ForEach(s => s.IsSelected = selected); } else { view.IsSelected = selected; } }
private static void TriStateValuesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { System.Diagnostics.Debug.WriteLine("TriStateValues Changed"); IList triState = (IList)e.NewValue; SelectorItem selectorItem = (SelectorItem)d; selectorItem.PreviewMouseUp += (s, me) => { System.Diagnostics.Debug.WriteLine("PreviewMouseUp"); if (selectorItem.IsSelected == null) { //CheckComboBox check = FindParent<CheckComboBox>(selectorItem); GetSelectedValues(d).Add(selectorItem.DataContext); me.Handled = true; } }; INotifyCollectionChanged notifyCol = triState as INotifyCollectionChanged; notifyCol.CollectionChanged += (sender, colArgs) => { if (colArgs.Action == NotifyCollectionChangedAction.Add) { RefreshTriState(selectorItem, triState); } }; RefreshTriState(selectorItem, triState); }
protected override void OnDoubleTapped(SelectorItem selector) { if (selector.ContentTemplateRoot is FrameworkElement root && root.Tag is MessageViewModel message) { ViewModel.ReplyToMessage(message); } }
private void OnStadiumSelectedChanged(SelectorItem i_SelectorItem) { if (stadiumSelectedChangedEvent != null) { stadiumSelectedChangedEvent(i_SelectorItem); } }
public async Task When_NoItemTemplate() { var SUT = new ListView() { ItemContainerStyle = BasicContainerStyle, ItemTemplate = null, ItemTemplateSelector = null, }; WindowHelper.WindowContent = SUT; await WindowHelper.WaitForIdle(); var source = new[] { "Item 1" }; SUT.ItemsSource = source; SelectorItem si = null; await WindowHelper.WaitFor(() => (si = SUT.ContainerFromItem(source[0]) as SelectorItem) != null); Assert.AreEqual("Item 1", si.Content); #if !NETFX_CORE // On iOS and Android (others not tested), ContentTemplateRoot is null, and TemplatedRoot is a ContentPresenter containing an ImplicitTextBlock return; #endif Assert.IsInstanceOfType(si.ContentTemplateRoot, typeof(TextBlock)); Assert.AreEqual("Item 1", (si.ContentTemplateRoot as TextBlock).Text); }
/// <summary> /// Sets the selected state for the provided item. /// </summary> /// <param name="item">The item to alter selection</param> /// <param name="view">An optional view associated with the item being selected</param> /// <param name="selected">The new selection state</param> public void SetItemSelection(object item, SelectorItem view, bool selected) { if (selected) { _selectedItems.Add(item); } else { _selectedItems.Remove(item); } if (view == null) { // A single item may be mapped multiple times because of the recycling, and // we may not be able to know which one is actually displayed. SecondaryPool?.GetAllViews() .OfType <ItemContainerHolder>() .Select(i => i.Child as SelectorItem) .Trim() .Where(p => p.DataContext.SafeEquals(item)) .ForEach(s => s.IsSelected = selected); } else { view.IsSelected = selected; } }
public async Task When_ContainerSet_Then_ContentShouldBeSet() { var resources = new TestsResources(); var SUT = new ListView { ItemContainerStyle = BasicContainerStyle, ItemTemplate = TextBlockItemTemplate }; WindowHelper.WindowContent = SUT; await WindowHelper.WaitForIdle(); var source = new[] { "item 0", }; SUT.ItemsSource = source; Assert.AreEqual(-1, SUT.SelectedIndex); SelectorItem si = null; await WindowHelper.WaitFor(() => (si = SUT.ContainerFromItem(source[0]) as SelectorItem) != null); var tb = si.FindFirstChild <TextBlock>(); Assert.AreEqual("item 0", tb?.Text); }
public void SelectorExtensionsAdd() { tlog.Debug(tag, $"SelectorExtensionsAdd START"); Selector <Color> colors = new Selector <Color>(); IList <SelectorItem <Color> > list = new List <SelectorItem <Color> >(); var item = new SelectorItem <Color>() { Value = Color.Cyan, State = ControlState.All }; item.ToString(); list.Add(item); try { SelectorExtensions.Add(list, ControlState.All, Color.White); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } tlog.Debug(tag, $"SelectorExtensionsAdd END (OK)"); }
public void SelectorCopyTo() { tlog.Debug(tag, $"SelectorCopyTo START"); var testingTarget = new Selector <Color>(Color.Cyan); Assert.IsNotNull(testingTarget, "Can't create success object RenderTask."); Assert.IsInstanceOf <Selector <Color> >(testingTarget, "Should return Selector<Color> instance."); SelectorItem <Color>[] item = new SelectorItem <Color> [2]; item[0] = new SelectorItem <Color>(); item[0].Value = Color.Cyan; item[0].State = ControlState.All; item[1] = new SelectorItem <Color>(); item[1].Value = Color.Yellow; item[1].State = ControlState.Normal; try { testingTarget.CopyTo(item, 0); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!" ); } tlog.Debug(tag, $"SelectorCopyTo END (OK)"); }
public EventMessage() { InitializeComponent(); Loaded += (s, e) => { SelectorItem selector = null; DependencyObject dp = this; while ((dp = VisualTreeHelper.GetParent(dp)) != null) { var i = dp as SelectorItem; if (i == null) { continue; } selector = i; break; } SetBinding(IsSelectedProperty, new Binding { Path = new PropertyPath("IsSelected"), Source = selector, Mode = BindingMode.TwoWay }); }; }
internal override void OnSelectorItemIsSelectedChanged(SelectorItem container, bool oldIsSelected, bool newIsSelected) { if (!_modifyingSelectionInternally) { var item = ItemFromContainer(container); if (!newIsSelected) { SelectedItems.Remove(item); } else { if (!SelectedItems.Contains(item)) { if (!IsSelectionMultiple && SelectedItems.FirstOrDefault() is object selectedItem) { SelectedItems.Remove(selectedItem); } SelectedItems.Add(item); } } } }
private void SelectedObjectChanged(SelectorItem selectorItem, bool force = false) { if (force || selectorItem != lastSelectedItem) { OnObjectSelectedChangedEvent.Invoke(this, new InteractiveObjectEventArgs(selectorItem == null ? null : selectorItem.InteractiveObject)); lastSelectedItem = selectorItem; } }
internal override void ContainerPreparedForItem(object item, SelectorItem itemContainer, int itemIndex) { base.ContainerPreparedForItem(item, itemContainer, itemIndex); PrepareContainerForDragDrop(itemContainer); ContainerContentChanging?.Invoke(this, new ContainerContentChangingEventArgs(item, itemContainer, itemIndex)); }
void OnEnable() { // Refresh Game mode selector. SetupGameModeSelector(); // Reset selectors to default values (specified into each tnGameModeConfig). SelectGameModeIndex(0); if (m_GameModeSelector != null) { SelectorItem currentGameMode = m_GameModeSelector.currentItem; if (currentGameMode != null) { int gameModeId = currentGameMode.id; tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId); if (gameModeData != null) { tnGameModeConfig gameModeConfig = tnGameData.GetConfigDataMain(gameModeData.optionsConfigId); if (gameModeConfig != null) { SelectMatchDuration(gameModeConfig.matchDurationOption); SelectReferee(gameModeConfig.refereeOption); SelectGoldenGoal(gameModeConfig.goldenGoalOption); } } SetupStadiumSelector(gameModeId); } } SelectBallIndex(0); SelectFirstUnlockedStadium(); SetupAILevelSelector(); SelectAILevel(tnGameData.aiLevelCountMain / 2); int aiCount = GetAICount(); if (m_AILevelSelector != null) { m_AILevelSelector.interactable = (aiCount > 0); } // Adjust navigation. AdjustAISelectorNavigation(aiCount); // Register on events. if (m_GameModeSelector != null) { m_GameModeSelector.onChangeSelection.AddListener(OnGameModeSelectedChanged); } }
// UTILS private SelectorItem GetSelectedItem(UISelector i_Selector) { if (i_Selector == null) { return(null); } SelectorItem item = i_Selector.currentItem; return(item); }
public static async Task ScrollToItem(this ScrollViewer scrollViewer, SelectorItem selectorItem) { // calculate the position object in order to know how much to scroll to var transform = selectorItem.TransformToVisual((UIElement)scrollViewer.Content); var position = transform.TransformPoint(new Point(-scrollViewer.ViewportWidth / 2.0, 0)); // touch selection works without animation so the workaround is needed await Task.Delay(1); scrollViewer.ChangeView(position.X, position.Y, null); }
private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { SelectorItem container = (SelectorItem)d; if (container.ParentSelector != null) { container.ParentSelector.NotifyIsSelectedChanged(container, (bool)e.NewValue); } container.UpdateVisualStates(); }
/// <summary> /// Set appropriate visual state from MultiSelectStates group. (https://msdn.microsoft.com/en-us/library/windows/apps/mt299136.aspx?f=255&MSPPError=-2147217396) /// </summary> /// <param name="selectorItem"></param> internal void ApplyMultiSelectState(SelectorItem selectorItem) { if (IsSelectionMultiple) { VisualStateManager.GoToState(selectorItem, "MultiSelectEnabled", useTransitions: true); } else { VisualStateManager.GoToState(selectorItem, "MultiSelectDisabled", useTransitions: true); } }
private void OnPopupOpened(object sender, EventArgs e) { if (SelectedItem != null && _selectedItemContainer == null) { _selectedItemContainer = base.ItemContainerGenerator.ContainerFromItem(SelectedItem) as SelectorItem; if (_selectedItemContainer != null) { _selectedItemContainer.IsSelected = true; _selectedItemContainer.UpdateVisualStates(); } } }
// CALLBACK private void OnEvent(SelectorItem i_EventData) { if (i_EventData == null) { return; } FsmEventData fsmEventData = new FsmEventData(); fsmEventData.IntData = i_EventData.id; FireEvent(fsmEventData); }
private static void SelectorItemSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { System.Diagnostics.Debug.WriteLine("SelectorItemSelectedChanged"); SelectorItem selectorItem = (SelectorItem)d; IList triState = GetTriStateValues(d); if (triState == null) { return; } RefreshTriState(selectorItem, triState); }
public void Add(SelectorItem <T> selectorItem) { // To prevent a state from having multiple values, remove existing state-value pair. int index = SelectorItems.FindIndex(x => x.State == selectorItem.State); if (index != -1) { SelectorItems.RemoveAt(index); } SelectorItems.Add(selectorItem); }
/// <summary> /// Deals with populating images(screenshots) in the App-Details Page. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void ShowImages(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.Phase != 1) { throw new Exception("Not in phase 1."); } SelectorItem itemContainer = (SelectorItem)args.ItemContainer; StackPanel templateRoot = (StackPanel)itemContainer.ContentTemplateRoot; Image appImage = (Image)templateRoot.FindName("appScreenshots"); appImage.Source = new BitmapImage(new Uri(args.Item.ToString())); appImage.Opacity = 1; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public ItemHierarchy() { vHistory = new Stack<IItemGroup>(); NavigateBackItem = new SelectorItem(); NavigateBackItem.Id = NavigateBackItemId; NavigateBackItem.IsEnabled = true; NavigateBackItem.IsVisible = true; NavigateBackItem.NavigateBackUponSelect = true; NavigateBackItem.Label = "Back"; NavigateBackItem.OnSelected += HandleNavigateBackItemSelected; OnLevelChange += (d => {}); OnItemSelection += ((l,i) => {}); }