public string PropertyDisplayStr(string property_name) { switch (_api_doc.PropertyType(property_name)) { case GlDoc.ValueType.DOCUMENT: List <GlDoc> docrefs = _api_doc.GetDocs(property_name); if (docrefs == null) { return(FindDocName(_api_doc.GetDoc(property_name))); } else { switch (docrefs.Count) { case 0: return("(empty list)"); case 1: return(DocWrapper.FindDocName(docrefs[0])); default: return(DocWrapper.FindDocName(docrefs[0]) + ", " + DocWrapper.FindDocName(docrefs[1]) + ", ..."); } } case GlDoc.ValueType.STRING: List <string> multivals = _api_doc.GetStrings(property_name); if (multivals == null) { return(_api_doc.GetString(property_name)); } else { switch (multivals.Count) { case 0: return("empty list"); case 1: return(multivals[0]); default: return(multivals[0] + ", " + multivals[1] + ", ..."); } } default: return(""); } }
private void DisplayValues() { labelPropVal.Visible = false; panelMulti.Visible = false; string chosen_prop = ChosenPropStr(); if (chosen_prop == "") { return; } switch (chosen_prop) { case "Address": case "Favorite color": labelPropVal.Visible = true; labelPropVal.Text = CurrentDoc.GetString(chosen_prop); break; case "Spouse": labelPropVal.Visible = true; GlDoc target_doc = CurrentDoc.GetDoc(chosen_prop); if (target_doc == null) { labelPropVal.Text = ""; } else { labelPropVal.Text = DocWrapper.FindDocName(target_doc); } break; case "Children": panelMulti.Visible = true; List <DocWrapper> children = new List <DocWrapper>(); foreach (GlDoc child_doc in CurrentDoc.GetDocs(chosen_prop)) { children.Add(new DocWrapper(child_doc)); } listPropVals.DisplayMember = "DocName"; listPropVals.DataSource = new BindingList <DocWrapper>(children); break; case "Favorite foods": panelMulti.Visible = true; List <string> yum = CurrentDoc.GetStrings(chosen_prop); listPropVals.DisplayMember = ""; try { listPropVals.DataSource = new BindingList <string>(yum); // ? } catch { } break; default: MessageBox.Show("oops"); break; } buttonEdit.Visible = labelPropVal.Visible; //buttonClear.Visible = labelPropVal.Visible; }