public static void FillComboFromEnumType(ComboBox comboBox, Type Etype, List <object> values = null) { comboBox.Items.Clear(); comboBox.SelectedValuePath = "Value"; if (values == null) { // Get all possible enum vals foreach (object item in Enum.GetValues(Etype)) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = GetEnumValueDescription(Etype, item); CEI.Value = item; comboBox.Items.Add(CEI); } } else { // get only subset from selected enum vals - used in Edit Action locate by to limit to valid values foreach (object item in values) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = GetEnumValueDescription(Etype, item); CEI.Value = item; comboBox.Items.Add(CEI); } } // Get the combo to be sorted comboBox.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("text", System.ComponentModel.ListSortDirection.Ascending)); }
private List <ComboEnumItem> GetPlatformLocatByList() { List <ComboEnumItem> locateByComboItemList = new List <ComboEnumItem>(); var targetPlatform = WorkSpace.Instance.Solution.GetTargetApplicationPlatform(mPOM.TargetApplicationKey); if (!targetPlatform.Equals(ePlatformType.NA)) { PlatformInfoBase platformInfoBase = PlatformInfoBase.GetPlatformImpl(targetPlatform); List <eLocateBy> platformLocateByList = platformInfoBase.GetPlatformUIElementLocatorsList(); foreach (var locateBy in platformLocateByList) { if (!locateBy.Equals(eLocateBy.POMElement)) { ComboEnumItem comboEnumItem = new ComboEnumItem(); comboEnumItem.text = GingerCore.General.GetEnumValueDescription(typeof(eLocateBy), locateBy); comboEnumItem.Value = locateBy; locateByComboItemList.Add(comboEnumItem); } } } return(locateByComboItemList); }
private void SetLocatorsGridView() { GridViewDef defView = new GridViewDef(GridViewDef.DefaultViewName); defView.GridColsView = new ObservableList <GridColView>(); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.Active), WidthWeight = 8, MaxWidth = 50, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, StyleType = GridColView.eGridColStyleType.CheckBox }); List <ComboEnumItem> locateByList = GingerCore.General.GetEnumValuesForCombo(typeof(eLocateBy)); ComboEnumItem comboItem = locateByList.Where(x => ((eLocateBy)x.Value) == eLocateBy.POMElement).FirstOrDefault(); if (comboItem != null) { locateByList.Remove(comboItem); } defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.LocateBy), Header = "Locate By", WidthWeight = 25, StyleType = GridColView.eGridColStyleType.ComboBox, CellValuesList = locateByList, }); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.LocateValue), Header = "Locate Value", WidthWeight = 65 }); defView.GridColsView.Add(new GridColView() { Field = "...", WidthWeight = 5, MaxWidth = 30, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xLocateValueVETemplate"] }); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.Help), WidthWeight = 25 }); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.IsAutoLearned), Header = "Auto Learned", WidthWeight = 10, MaxWidth = 100, ReadOnly = true }); defView.GridColsView.Add(new GridColView() { Field = "Test", WidthWeight = 10, MaxWidth = 100, AllowSorting = true, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xTestElementButtonTemplate"] }); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.StatusIcon), Header = "Status", WidthWeight = 10, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xTestStatusIconTemplate"] }); xLocatorsGrid.SetAllColumnsDefaultView(defView); xLocatorsGrid.InitViewItems(); xLocatorsGrid.SetTitleStyle((Style)TryFindResource("@ucTitleStyle_4")); xLocatorsGrid.AddToolbarTool(eImageType.Run, "Test All Elements Locators", new RoutedEventHandler(TestAllElementsLocators)); xLocatorsGrid.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddLocatorButtonClicked)); xLocatorsGrid.SetbtnDeleteHandler(new RoutedEventHandler(DeleteLocatorClicked)); xLocatorsGrid.grdMain.PreparingCellForEdit += LocatorsGrid_PreparingCellForEdit; xLocatorsGrid.PasteItemEvent += PasteLocatorEvent; }
private void SetDeltaLocatorsGridView() { GridViewDef defView = new GridViewDef(GridViewDef.DefaultViewName); defView.GridColsView = new ObservableList <GridColView>(); defView.GridColsView.Add(new GridColView() { Field = nameof(ElementLocator.Active), WidthWeight = 50, MaxWidth = 50, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, StyleType = GridColView.eGridColStyleType.CheckBox, ReadOnly = true, BindingMode = BindingMode.OneWay }); List <ComboEnumItem> locateByList = GingerCore.General.GetEnumValuesForCombo(typeof(eLocateBy)); ComboEnumItem comboItem = locateByList.Where(x => ((eLocateBy)x.Value) == eLocateBy.POMElement).FirstOrDefault(); if (comboItem != null) { locateByList.Remove(comboItem); } defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.LocateBy), Header = "Locate By", WidthWeight = 150, StyleType = GridColView.eGridColStyleType.ComboBox, CellValuesList = locateByList, ReadOnly = true, BindingMode = BindingMode.OneWay }); defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.LocateValue), Header = "Locate Value", WidthWeight = 200, ReadOnly = true, BindingMode = BindingMode.OneWay }); defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.IsAutoLearned), Header = "Auto Learned", WidthWeight = 100, ReadOnly = true, BindingMode = BindingMode.OneWay }); defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.DeltaStatusIcon), Header = "Comparison Status", WidthWeight = 150, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xDeltaStatusIconTemplate"] }); defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.DeltaExtraDetails), Header = "Comparison Details", WidthWeight = 300, AllowSorting = true, ReadOnly = true, BindingMode = BindingMode.OneWay }); defView.GridColsView.Add(new GridColView() { Field = "Test", WidthWeight = 50, MaxWidth = 100, AllowSorting = true, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xTestElementButtonTemplate"] }); defView.GridColsView.Add(new GridColView() { Field = nameof(DeltaElementLocator.StatusIcon), Header = "Identification Status", WidthWeight = 100, StyleType = GridColView.eGridColStyleType.Template, CellTemplate = (DataTemplate)this.PageGrid.Resources["xTestStatusIconTemplate"] }); xLocatorsGrid.SetAllColumnsDefaultView(defView); xLocatorsGrid.InitViewItems(); xLocatorsGrid.SetTitleStyle((Style)TryFindResource("@ucTitleStyle_4")); xLocatorsGrid.ShowCopy = Visibility.Collapsed; xLocatorsGrid.ShowPaste = Visibility.Collapsed; xLocatorsGrid.ShowAdd = Visibility.Collapsed; xLocatorsGrid.ShowDelete = Visibility.Collapsed; xLocatorsGrid.ShowUpDown = Visibility.Collapsed; xLocatorsGrid.AddToolbarTool(eImageType.Run, "Test All Elements Locators", new RoutedEventHandler(TestAllElementsLocators)); }
/// <summary> /// /// </summary> /// <param name="comboBox"></param> /// <param name="EnumObj"></param> /// <param name="values"> leave values empty will take all possible vals, or pass a list to limit selection </param> public static void FillComboFromEnumObj(ComboBox comboBox, Object EnumObj, List <object> values = null, bool sortValues = true, ListCollectionView valuesCollView = null) { comboBox.SelectedValuePath = "Value"; Type Etype = EnumObj.GetType(); if ((values == null) && (valuesCollView == null)) { comboBox.Items.Clear(); // Get all possible enum vals foreach (object item in Enum.GetValues(Etype)) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = GetEnumValueDescription(Etype, item); CEI.Value = item; comboBox.Items.Add(CEI); } } else { if ((values == null) && (valuesCollView != null)) { comboBox.ItemsSource = valuesCollView; } else { comboBox.Items.Clear(); // get only subset from selected enum vals - used in Edit Action locate by to limit to valid values foreach (object item in values) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = GetEnumValueDescription(Etype, item); CEI.Value = item; comboBox.Items.Add(CEI); } } } if (sortValues) { // Get the combo to be sorted comboBox.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("text", System.ComponentModel.ListSortDirection.Ascending)); } //if ((values == null) && (valuesCollView != null)) //{ comboBox.SelectedItem = EnumObj; //} //else //{ // comboBox.SelectedValue = EnumObj; //} }
public static List <ComboEnumItem> GetEnumValuesForComboFromList(Type Etype, List <Object> Items) { List <ComboEnumItem> list = new List <ComboEnumItem>(); foreach (object item in Items) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = GingerCore.General.GetEnumValueDescription(Etype, item); CEI.Value = item; list.Add(CEI); } return(list); }
public static void FillComboFromList(ComboBox comboBox, List <string> ls) { comboBox.Items.Clear(); if (ls == null) { return; } foreach (var item in ls) { ComboEnumItem CEI = new ComboEnumItem(); CEI.text = item.ToString(); CEI.Value = item; comboBox.Items.Add(CEI); } }
/// <summary> /// Set the selected item of combo box /// </summary> /// <param name="obj"></param> public void SelectValue(object obj) { Execute(() => { ComboBox combo = (ComboBox)dependencyObject; foreach (var x in combo.Items) { ComboEnumItem item = (ComboEnumItem)x; //TODO: Not working check why //if (item.Value == obj) //{ //} // Meanwhile use toString which works if (item.Value.ToString() == obj.ToString()) { combo.SelectedValue = item; } } // TODO: fail back to find by string if not found by obj so use the .ToString in 2nd option }); }
public static void AddComboItem(ComboBox comboBox, object itemtoadd) { string itemText = itemtoadd.ToString(); if (itemtoadd.GetType().BaseType.Name == "Enum") { itemText = GetEnumValueDescription(itemtoadd.GetType(), itemtoadd); } foreach (var item in comboBox.Items) { if (item.ToString() == itemText) { return; } } ComboEnumItem CEI = new ComboEnumItem(); CEI.text = itemText; CEI.Value = itemtoadd; comboBox.Items.Add(CEI); }
private List <ComboEnumItem> GetPlatformLocatByList() { List <ComboEnumItem> locateByComboItemList = new List <ComboEnumItem>(); if (Platform == null) { Platform = PlatformInfoBase.GetPlatformImpl(Context.Platform); // ((Agent)ApplicationAgent.Agent).Platform); } List <eLocateBy> platformLocateByList = Platform.GetPlatformUIElementLocatorsList(); foreach (var locateBy in platformLocateByList) { if (!locateBy.Equals(eLocateBy.POMElement)) { ComboEnumItem comboEnumItem = new ComboEnumItem(); comboEnumItem.text = GingerCore.General.GetEnumValueDescription(typeof(eLocateBy), locateBy); comboEnumItem.Value = locateBy; locateByComboItemList.Add(comboEnumItem); } } return(locateByComboItemList); }
private void GroupFilter_SelectionChanged(object sender, SelectionChangedEventArgs e) { mCurrentGroupByFilter = (ComboEnumItem)e.AddedItems[0];// ((ComboBox)sender).SelectedItem; FilterListByFiltersCreteria(); }
private void ComperisonStatusFilter_SelectionChanged(object sender, SelectionChangedEventArgs e) { mCurrentDeltaStatusFilter = (ComboEnumItem)e.AddedItems[0]; FilterListByFiltersCreteria(); }