public override void ExtendedPropertiesDeserialize(System.Xml.XmlNode extendedPropertiesXml) { base.ExtendedPropertiesDeserialize(extendedPropertiesXml); // foreach (System.Xml.XmlNode currentPropertyNode in extendedPropertiesXml.SelectNodes ("./Property")) { foreach (System.Xml.XmlNode currentPropertyNode in extendedPropertiesXml.ChildNodes) { switch (currentPropertyNode.Attributes["Name"].InnerText) { case "SelectionType": selectionType = (Mercury.Server.Core.Forms.Enumerations.FormControlSelectionType)Convert.ToInt32(currentPropertyNode.InnerText); break; case "ReferenceSource": referenceSource = (Mercury.Server.Core.Forms.Enumerations.FormControlSelectionReferenceSource)Convert.ToInt32(currentPropertyNode.InnerText); break; case "Columns": columns = Convert.ToInt32(currentPropertyNode.InnerText); break; case "Rows": rows = Convert.ToInt32(currentPropertyNode.InnerText); break; case "SelectionDirection": direction = (Mercury.Server.Core.Forms.Enumerations.FormControlSelectionDirection)Convert.ToInt32(currentPropertyNode.InnerText); break; case "Wrap": wrap = Convert.ToBoolean(currentPropertyNode.InnerText); break; case "MaxLength": maxLength = Convert.ToInt32(currentPropertyNode.InnerText); break; case "SelectionMode": selectionMode = (Mercury.Server.Core.Forms.Enumerations.FormControlSelectionMode)Convert.ToInt32(currentPropertyNode.InnerText); break; case "DataSource": dataSource = (Mercury.Server.Core.Forms.Enumerations.FormControlDataSource)Convert.ToInt32(currentPropertyNode.InnerText); break; case "AllowCustomText": allowCustomText = Convert.ToBoolean(currentPropertyNode.InnerText); break; case "CustomText": customText = currentPropertyNode.InnerText; break; case "Items": foreach (System.Xml.XmlNode currentItemNode in currentPropertyNode.ChildNodes) { Structures.SelectionItem selectionItem = new Mercury.Server.Core.Forms.Structures.SelectionItem(); selectionItem.SelectionControl = this; selectionItem.Text = currentItemNode.Attributes ["Text"].Value; selectionItem.Value = currentItemNode.Attributes ["Value"].Value; selectionItem.Enabled = Convert.ToBoolean(currentItemNode.Attributes ["Enabled"].Value); selectionItem.Selected = Convert.ToBoolean(currentItemNode.Attributes["Selected"].Value); Items.Add(selectionItem); } break; } } return; }
public Boolean ItemSelected(String value) { Boolean itemSelected = false; for (Int32 currentItemIndex = 0; currentItemIndex < Items.Count; currentItemIndex++) { Mercury.Server.Core.Forms.Structures.SelectionItem currentitem = Items[currentItemIndex]; if (currentitem.Value == value) { itemSelected = currentitem.Selected; break; } } return(itemSelected); }
public override void OnDataSourceChanged(Control dataSourceControl, Boolean propogate) { String dataValue = String.Empty; base.OnDataSourceChanged(dataSourceControl, propogate); foreach (Mercury.Server.Core.Forms.Structures.DataBinding currentBinding in GetDataBindings(dataSourceControl.ControlId)) { if (currentBinding.BoundProperty.Replace("Id", "") == referenceSource.ToString()) { dataValue = dataSourceControl.EvaluateDataBinding(currentBinding); if ((selectionType == Mercury.Server.Core.Forms.Enumerations.FormControlSelectionType.DropDownList) && (dataSource == Mercury.Server.Core.Forms.Enumerations.FormControlDataSource.Reference)) { Items.Clear(); switch (referenceSource) { case Mercury.Server.Core.Forms.Enumerations.FormControlSelectionReferenceSource.Ethnicity: Int64 ethnicityId; if (Int64.TryParse(dataValue, out ethnicityId)) { String ethnicityName = application.CoreObjectGetNameById("Ethnicity", ethnicityId); if (!String.IsNullOrEmpty(ethnicityName)) { Forms.Structures.SelectionItem item = new Mercury.Server.Core.Forms.Structures.SelectionItem(); item.SelectionControl = this; item.Text = ethnicityName; item.Value = ethnicityId.ToString(); item.Selected = true; Items.Add(item); } } break; case Mercury.Server.Core.Forms.Enumerations.FormControlSelectionReferenceSource.Language: Int64 languageId; if (Int64.TryParse(dataValue, out languageId)) { String languageName = application.CoreObjectGetNameById("Language", languageId); if (!String.IsNullOrEmpty(languageName)) { Forms.Structures.SelectionItem item = new Mercury.Server.Core.Forms.Structures.SelectionItem(); item.SelectionControl = this; item.Text = languageName; item.Value = languageId.ToString(); item.Selected = true; Items.Add(item); } } break; } } else { foreach (Forms.Structures.SelectionItem currentItem in Items) { currentItem.Selected = (currentItem.Value == dataValue); currentItem.SelectionControl = this; } } } } return; }