//public static string DisplayVotingMethodFor(Election currentElection, Person person) //{ // //p.VotingMethod.DefaultTo(VotingMethodEnum.InPerson) == VotingMethodEnum.InPerson ? null : p.EnvNum // var item = BaseItems.SingleOrDefault(i => i.Value == person.VotingMethod); // if (item == null) // { // // unknown! // return person.VotingMethod; // } // if (item == InPerson) // { // // don't show anything for In Person voters // return ""; // } // var envNum = person.EnvNum.AsInt(0); // var envNumText = envNum == 0 ? "?" : envNum.ToString(); // if (currentElection.MaskVotingMethod.AsBoolean()) // { // return "Envelope " + envNumText; // } // return string.Format("{1} <span>{0}</span> {2}", item.DisplayText, envNumText, " ".PadRight(envNumText.Length).Replace(" ", " ")); //} public static string MethodMap() { return(BaseItems .Select(l => "{0}:{1}".FilledWith(l.Value.QuotedForJavascript(), l.Text.QuotedForJavascript())) .JoinedAsString(", ") .SurroundContentWith("{", "}")); }
public static string TextFor(string electionType) { var item = BaseItems.SingleOrDefault(i => i.Value == electionType); return(item == null ? "" : item._blankForDisplay ? "" : item.DisplayText); }
public static string AsJsonObject() { return(BaseItems .Select(l => "{0}:{1}" .FilledWith(l.Value.ToString().QuotedForJavascript(), TextFor(l).QuotedForJavascript())) .JoinedAsString(", ") .SurroundContentWith("{", "}")); }
//public static string DisplayVotingMethodFor(Election currentElection, Person person) //{ // //p.VotingMethod.DefaultTo(VotingMethodEnum.InPerson) == VotingMethodEnum.InPerson ? null : p.EnvNum // var item = BaseItems.SingleOrDefault(i => i.Value == person.VotingMethod); // if (item == null) // { // // unknown! // return person.VotingMethod; // } // if (item == InPerson) // { // // don't show anything for In Person voters // return ""; // } // var envNum = person.EnvNum.AsInt(0); // var envNumText = envNum == 0 ? "?" : envNum.ToString(); // if (currentElection.MaskVotingMethod.AsBoolean()) // { // return "Envelope " + envNumText; // } // return string.Format("{1} <span>{0}</span> {2}", item.DisplayText, envNumText, " ".PadRight(envNumText.Length).Replace(" ", " ")); //} public static HtmlString ForHtmlSelect(string selected = "") { return (BaseItems .Select(bi => "<option value='{0}'{2}>{1}</option>" .FilledWith(bi.Value, TextFor(bi), bi.Value == selected ? " selected" : "")) .JoinedAsString() .AsRawHtml()); }
public static IneligibleReasonEnum GetFor(string description) { var item = BaseItems.SingleOrDefault(i => i.Description.Equals(description.Trim(), StringComparison.InvariantCultureIgnoreCase)); if (item == null) { return(null); } return(item); }
public static object ReasonNamesForImportPage() { return(BaseItems .Where(r => r.Group != GroupName.Unreadable && r.Group != GroupName.Unidentifiable) .Select(r => new { r.Group, r.Description })); }
public static HtmlString ForHtmlSelect(Location location) { var selected = location == null ? "" : location.TallyStatus; return (BaseItems .Select(bi => "<option value='{0}'{2}>{1}</option>" .FilledWith(bi.Value, bi.Text, bi.Value == selected ? " selected" : "")) .JoinedAsString() .AsRawHtml()); }
public static HtmlString ForHtmlList(string currentState = "", bool showAll = true) { const string liTemplate = "<span data-state='{0}' class='state Active_{2} {0}'>{1}</span>"; var mainList = BaseItems .Where(bi => bi.Visible) .Where(bi => showAll || ShowAsSelected(bi, currentState)) .Select(bi => liTemplate.FilledWith(bi.Value, bi.Text, ShowAsSelected(bi, currentState))) .JoinedAsString(); return(mainList.AsRawHtml()); }
public static string TextFor(string value, string defaultValue = "") { var item = BaseItems.SingleOrDefault(i => i.Value == value); if (item == null) { return(defaultValue ?? value); } return(TextFor(item)); }
private void SynchronizeSelection() { if (ItemsView.CurrentItem == null) { return; } Workspace.ActiveLister.View.ListView.SelectedItem = null; var selected = BaseItems.FirstOrDefault(i => i.Path == ((IItem)ItemsView.CurrentItem).Path); Workspace.ActiveLister.View.FocusItem(selected); }
public int IndexOf(T item) { try { var lvi = BaseItemsEnumerable.Where(x => x.Tag == item).First(); return(BaseItems.IndexOf(lvi)); } catch (Exception) { return(-1); } }
public static HtmlString ForHtmlSelect(string selected = "", Dictionary <string, string> extraAttribPerItem = null) { return (BaseItems .Select(bi => "<option value='{0}'{2}>{1}</option>" .FilledWith( bi.Value, bi.Text, (bi.Value == selected ? " selected" : "") + (extraAttribPerItem != null ? extraAttribPerItem.Where(kvp => kvp.Key == bi.Value).Select(kvp => kvp.Value).SingleOrDefault() : ""))) .JoinedAsString() .AsRawHtml()); }
public void Open(SettingItem settingItem, object baseObject) { _settingItem = settingItem; Title = PropertyName = settingItem.Path; BaseObject = baseObject; _propertyInfo = BaseObject.GetType().GetProperties().FirstOrDefault(p => p.Name == PropertyName); BaseItems = GetValues().ToList(); IsFreeText = !BaseItems.Any(); base.Open(); if (IsFreeText) { Text = _propertyInfo.GetValue(Options).ToString(); SelectAll(); } }
public override void DataBind() { base.DataBind(); RightListBox.DataTextField = this.DataTextField; RightListBox.DataValueField = this.DataValueField; RightListBox.DataBind(); BaseItems.Clear(); for (int index = 0; index < RightListBox.Items.Count; index++) { this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value)); if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim())) { BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim()); } } }
static async Task MainAsync(string[] args) { client.BaseAddress = new Uri("https://api.warframe.market/v1/items"); HttpResponseMessage httpResponse = client.GetAsync(client.BaseAddress).GetAwaiter().GetResult(); string jsonString = httpResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult(); BaseItems baseItems = BaseItems.FromJson(jsonString); baseItems.Payload.Items.En.OrderBy(e => e.ItemName); Console.Title = baseItems.Payload.Items.En.Where(c => c.UrlName.Contains("prime")).ToList().Count + "Items"; Dictionary <String, List <Order> > f**k = await TestMethod(baseItems.Payload.Items.En.Where(c => c.UrlName.Contains("prime"))); Console.ReadLine(); }
/// <summary> /// Focuses the next item. /// </summary> /// <param name="item">The current item.</param> /// <param name="forward">if set to <c>true</c>, moves to the next item, otherwise moves to the previous item.</param> /// <returns><c>true</c> on success, <c>false</c> otherwise.</returns> protected bool FocusNextItem(ButtonListItem <T> item, bool forward) { if (BaseItems.Count > 0) { var idx = -1; if (item != null && (idx = BaseItems.IndexOf(item)) == -1) { throw new ArgumentOutOfRangeException(nameof(item)); } idx = GetNextEnabledItemIndex(idx, forward); if (idx != -1) { SetFocused(idx); return(true); } } return(false); }
/// <summary> /// Creates new instance with "Default" as group name. /// </summary> /// <param name="fileNames">File path enumeration.</param> /// <param name="maximumCount">Maximum number of items to load or save.</param> /// <exception cref="ArgumentOutOfRangeException">Maximum count must be between 1 and 99.</exception> public RecentlyUsed(IEnumerable <string> fileNames, int maximumCount) { if ((maximumCount < 1) || (maximumCount > 99)) { throw new ArgumentOutOfRangeException(nameof(maximumCount), "Maximum count must be between 1 and 99."); } MaximumCount = maximumCount; if (fileNames != null) { foreach (var fileName in fileNames) { BaseItems.Add(new RecentlyUsedFile(fileName)); if (BaseItems.Count >= MaximumCount) { break; } } } }
// Reload list items from the data source. private void LoadItemsFromSource() { // Tell the control not to bother redrawing until we're done // adding new items - avoids flicker and speeds things up. BeginUpdate(); try { // We're about to rebuild the list, so get rid of the current // items. //Items.Clear(); BaseItems.Clear(); // m_bindingList won't be set if the data source doesn't // implement IBindingList, so always ask the CurrencyManager // for the IList. (IList is all we need to retrieve the rows.) IList items = m_currencyManager.List; // Add items to list. int nItems = items.Count; for (int i = 0; i < nItems; ++i) { //Items.Add(BuildItemForRow(items[i])); //BaseItems.Add(BuildItemForRow(items[i])); BuildItemForRow(items[i]); } int index = m_currencyManager.Position; if (index != -1) { SetSelectedIndex(index); } } finally { // In finally block just in case the data source does something // nasty to us - it feels like it might be bad to leave the // control in a state where we called BeginUpdate without a // corresponding EndUpdate. EndUpdate(); } }
public bool Remove(T item) { try { var lvi = BaseItemsEnumerable.Where(x => x.Tag == item).FirstOrDefault(); if (lvi != null) { BaseItems.Remove(lvi); return(true); } else { return(false); } } catch (Exception) { return(false); } }
public void ResetItems(bool clear) { ComboBox control = BaseValueControl as ComboBox; if (control == null) { return; } if (clear) { BaseItems.Clear(); } List <object> cbItems = new List <object>(); foreach (var item in Items) { cbItems.Add(string.Format("{0}", item)); } Form.SetComboBoxItems(control, Items.IndexOf(Value), cbItems.ToArray()); }
/// <summary> /// Get the reason matching this guid. If null or not matched, returns null. /// </summary> /// <param name="guid"></param> /// <returns></returns> public static IneligibleReasonEnum Get(Guid?guid) { return(guid.HasValue ? BaseItems.SingleOrDefault(i => i.Value == guid.Value) : null); }
public static bool Exists(string voteType) { return(BaseItems.Any(i => i.Value == voteType)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { for (int index = 0; index < RightListBox.Items.Count; index++) { this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value)); if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim())) { BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim()); } } } if (AddedBox.Value != null && AddedBox.Value != "") { string AddedString = AddedBox.Value.Substring(0, AddedBox.Value.Length - 1); string[] adds = AddedString.Split(";".ToCharArray()); //List<ListItem> LeftClears = new List<ListItem>(); RightListBox.Items.Clear(); for (int index = 0; index < adds.Length; index++) { string[] item = adds[index].Trim().Split(",".ToCharArray()); RightListBox.Items.Add(new ListItem(item[1], item[0])); //this.Items.Remove(this.Items.FindByValue(item[1])); } AddedBox.Value = ""; } //if (DeletedBox.Value != null && DeletedBox.Value != "") //{ // string DeletedString = DeletedBox.Value.Substring(0, DeletedBox.Value.Length - 1); // string[] dels = DeletedString.Split(";".ToCharArray()); // List<ListItem> RightClears = new List<ListItem>(); // for (int index = 0; index < dels.Length; index++) // { // string[] item = dels[index].Trim().Split(",".ToCharArray()); // this.Items.Add(new ListItem(item[0], item[1])); // RightListBox.Items.Remove(RightListBox.Items.FindByValue(item[1])); // } // DeletedBox.Value = ""; //} if (!Page.ClientScript.IsClientScriptBlockRegistered("MoveListBox")) { string clientscript = "function Add(Obj,Active,IsAll) " + "{ " + " var row=Obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; " + " var addedHidden=Obj.parentNode.parentNode.parentNode.parentNode.rows[4].cells[0].childNodes[0]; " + " var deletedHidden=Obj.parentNode.parentNode.parentNode.parentNode.rows[4].cells[0].childNodes[1]; " + " var FromSelect,ToSelect; " + " if(Active=='toRight') " + " {FromSelect=row.cells[0].childNodes[0];ToSelect=row.cells[2].childNodes[0];} " + " else " + " {FromSelect=row.cells[2].childNodes[0];ToSelect=row.cells[0].childNodes[0];} " + " var sss=new Array(),l=0; " + " if(IsAll) " + " { " + " for(var i=0;i<FromSelect.options.length;i++){sss[l]=FromSelect.options[i];l++;} " + " } " + " else " + " { " + " for(var i=0;i<FromSelect.options.length;i++) " + " { " + " if(FromSelect.options[i].selected) "+ " { "+ " sss[l]=FromSelect.options[i];l++; "+ " } "+ " } " + " } " + " " + " for(var i=0;i<sss.length;i++) " + " { " + " if(Active=='toRight') " + " { " + " if(!IsRightExist(sss[i].value,ToSelect)) "+ " { "+ " var oOption = document.createElement('OPTION'); " + " ToSelect.options.add(oOption); "+ " oOption.innerText=sss[i].innerText; "+ " oOption.value =sss[i].value; "+ " } "+ " } " + " else " + " { " + " FromSelect.removeChild(sss[i]); "+ " } " + " } " + " addedHidden.value = ''; " + " if(Active!='toRight') " + " { " + " for(var i=0;i<FromSelect.options.length;i++) " + " { " + " addedHidden.value += FromSelect.options[i].value+','+ FromSelect.options[i].innerText+';'; " + " } " + " } " + " else " + " { " + " for(var i=0;i<ToSelect.options.length;i++) " + " { " + " addedHidden.value += ToSelect.options[i].value+','+ ToSelect.options[i].innerText+';'; " + " } "+ " } " + " SetButton(Obj,'button'); " + "} " + "function IsRightExist(option,right) " + "{ " + " for(var i=0;i<right.options.length;i++) " + " { " + " if(right.options[i].value == option) "+ " return true; "+ " } " + " return false; " + "} " + "function SetButton(Obj,ctrlType) " + "{ " + " var LeftSelect,RightSelect,ToRightAdd,ToLeftAdd,ToLeftAll,ToRightAll,row,table; " + " if(ctrlType=='button') " + " { " + " table=Obj.parentNode.parentNode.parentNode.parentNode;row=table.parentNode.parentNode; "+ " } " + " else " + " { " + " row=Obj.parentNode.parentNode.parentNode.parentNode;table=row.rows[0].cells[1].childNodes[0];"+ " } " + " LeftSelect=row.cells[0].childNodes[0];RightSelect=row.cells[2].childNodes[0]; " + " ToRightAdd=table.rows[0].cells[0].childNodes[0];ToLeftAdd=table.rows[1].cells[0].childNodes[0]; " + " ToRightAll=table.rows[2].cells[0].childNodes[0];ToLeftAll=table.rows[3].cells[0].childNodes[0]; " + " if(LeftSelect.options.length<=0) " + " { " + " ToRightAdd.disabled='disabled';ToRightAll.disabled='disabled'; "+ " } " + " else " + " { " + " ToRightAll.disabled='';var ToRightAdddisabled='disabled'; "+ " for(var i=0;i<LeftSelect.options.length;i++) "+ " { "+ " if(LeftSelect.options[i].selected) "+ " { "+ " ToRightAdddisabled=''; "+ " break; "+ " } "+ " } "+ " ToRightAdd.disabled=ToRightAdddisabled; "+ " } " + " if(RightSelect.options.length<=0) " + " { " + " ToLeftAdd.disabled='disabled';ToLeftAll.disabled='disabled'; "+ " } " + " else " + " { " + " ToLeftAll.disabled='';var ToLeftAdddisabled='disabled'; "+ " for(var i=0;i<RightSelect.options.length;i++) "+ " { "+ " if(RightSelect.options[i].selected) "+ " { "+ " ToLeftAdddisabled=''; "+ " break; "+ " } "+ " } "+ " ToLeftAdd.disabled=ToLeftAdddisabled; "+ " } " + "} "; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MoveListBox", clientscript, true); } }
public static string TextFor(string status) { var item = BaseItems.SingleOrDefault(i => i.Value == status); return(item == null ? NotStarted : item.DisplayText); }
public static string TextFor(string value, string defaultValue = "") { var item = BaseItems.SingleOrDefault(i => i.Value == value); return(item == null ? (defaultValue ?? value) : item.DisplayText); }
public static string MessageTypeAFor(string value, string defaultValue = "") { var item = BaseItems.SingleOrDefault(i => i.Value == value); return(item == null ? (defaultValue ?? value) : item.MessageTypeA); }
protected new static void Add(IneligibleReasonEnum item) { item.IndexNum = _itemCount++; BaseItems.Add(item); }
/// <Summary>Find the status that matches this string. If not found, default to something... use Review needed.</Summary> public static BallotStatusEnum Parse(string code) { return(BaseItems.SingleOrDefault(i => i.Value == code) ?? Verify); }
private void bindingList_ListChanged(object sender, ListChangedEventArgs e) { switch (e.ListChangedType) { // Well, usually fine-grained... The whole list has changed // utterly, so reload it. case ListChangedType.Reset: LoadItemsFromSource(); break; // A single item has changed, so just rebuild that. case ListChangedType.ItemChanged: object changedRow = m_currencyManager.List[e.NewIndex]; BeginUpdate(); BaseItems[e.NewIndex] = BuildItemForRow(changedRow); EndUpdate(); break; // A new item has appeared, so add that. case ListChangedType.ItemAdded: object newRow = m_currencyManager.List[e.NewIndex]; // We get this event twice if certain grid controls // are used to add a new row to a datatable: once when // the editing of a new row begins, and once again when // that editing commits. (If the user cancels the creation // of the new row, we never see the second creation.) // We detect this by seeing if this is a view on a // row in a DataTable, and if it is, testing to see if // it's a new row under creation. DataRowView drv = newRow as DataRowView; if (drv == null || !drv.IsNew) { // Either we're not dealing with a view on a data // table, or this is the commit notification. Either // way, this is the final notification, so we want // to add the new row now! BeginUpdate(); //BaseItems.Insert(e.NewIndex, BuildItemForRow(newRow)); BuildItemForRow(newRow); EndUpdate(); } break; // An item has gone away. case ListChangedType.ItemDeleted: if (e.NewIndex < BaseItems.Count) { BaseItems.RemoveAt(e.NewIndex); } break; // An item has changed its index. case ListChangedType.ItemMoved: BeginUpdate(); object moving = BaseItems[e.OldIndex]; BaseItems.Insert(e.NewIndex, moving); EndUpdate(); break; // Something has changed in the metadata. (This control is // too lazy to deal with this in a fine-grained fashion, // mostly because the author has never seen this event // occur... So we deal with it the simple way: reload // everything.) case ListChangedType.PropertyDescriptorAdded: case ListChangedType.PropertyDescriptorChanged: case ListChangedType.PropertyDescriptorDeleted: //LoadColumnsFromSource(); LoadItemsFromSource(); break; } }
public static string DescriptionFor(Guid key) { var item = BaseItems.SingleOrDefault(i => i.Value == key); return(item == null ? "" : item.Description); }