public void Initialize(BXCustomField currentField,BXCustomProperty value) { field = currentField; this.value = value; if (field == null) return; IBXCalendar cal = Calendar1 as IBXCalendar; valDate.Enabled = currentField.Mandatory; DateTime? dateTime = null; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); showTime = settings.ContainsKey("showTime") ? (bool)settings["showTime"] : true; if (value == null) { if (cal != null) { if (settings.ContainsKey("default")) dateTime = (DateTime)settings["default"]; if (settings.ContainsKey("current")) dateTime = DateTime.Now; } } else { if (value.Value is DateTime) dateTime = (DateTime)value.Value; } if (dateTime.HasValue) txtDate.Text = showTime ? dateTime.Value.ToString() : dateTime.Value.ToString("d"); }
public void SetSettings(BXParamsBag<object> settings) { DefaultValue.Text = settings.ContainsKey("DefaultValue") ? settings["DefaultValue"].ToString() : String.Empty; TextBoxSize.Text = settings.ContainsKey("TextBoxSize") ? settings["TextBoxSize"].ToString() : String.Empty; MinValue.Text = settings.ContainsKey("MinValue") ? settings["MinValue"].ToString() : String.Empty; MaxValue.Text = settings.ContainsKey("MaxValue") ? settings["MaxValue"].ToString() : String.Empty; }
public void SetSettings(BXParamsBag<object> settings) { Precision.Text = settings.ContainsKey("Precision") ? settings["Precision"].ToString() : String.Empty; DefaultValue.Text = settings.ContainsKey("DefaultValue") ? settings.Get<double>("DefaultValue").ToString(CultureInfo.InvariantCulture) : String.Empty; TextBoxSize.Text = settings.ContainsKey("TextBoxSize") ? settings["TextBoxSize"].ToString() : String.Empty; MinValue.Text = settings.ContainsKey("MinValue") ? settings["MinValue"].ToString().ToString(CultureInfo.InvariantCulture) : String.Empty; MaxValue.Text = settings.ContainsKey("MaxValue") ? settings["MaxValue"].ToString().ToString(CultureInfo.InvariantCulture) : String.Empty; }
public void SetSettings(BXParamsBag<object> settings) { TextBoxSize.Text = settings.ContainsKey("TextBoxSize") ? settings["TextBoxSize"].ToString() : String.Empty; if (settings.ContainsKey("IBlockId")) ddlIBlock.SelectedValue = settings["IBlockId"].ToString(); else ddlIBlock.SelectedIndex = 0; }
public void SetSettings(BXParamsBag<object> settings) { if (settings.ContainsKey("TextBoxSize")) TextBoxSize.Text = settings["TextBoxSize"].ToString(); if (settings.ContainsKey("MaxSize")) MaxSize.Text = settings["MaxSize"].ToString(); if (settings.ContainsKey("AllowedExtensions")) AllowedExtensions.Text = string.Join(" ", (string[])settings["AllowedExtensions"]); AddDescription.Checked = settings.GetBool("AddDescription"); }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueList.Rows = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 5; ValueList.SelectionMode = (currentField.Multiple ? ListSelectionMode.Multiple : ListSelectionMode.Single); List<string> selectedValues = new List<string>(); if (value != null) { foreach (object v in value.Values) selectedValues.Add(v.ToString()); } ValueList.Items.Clear(); int iblockId = 0; if (!settings.ContainsKey("IBlockId")) { BXInfoBlockCollectionOld c = BXInfoBlockManagerOld.GetList(null, null); if (c.Count > 0) iblockId = c[0].IBlockId; } else iblockId = (int)settings["IBlockId"]; BXInfoBlockSectionCollectionOld sectionCollection = BXInfoBlockSectionManagerOld.GetTree(iblockId, 0); foreach (BXInfoBlockSectionOld section in sectionCollection) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < section.DepthLevel; i++) sb.Append(" . "); sb.Append(section.Name); ListItem l = new ListItem(sb.ToString(), section.SectionId.ToString()); if (value != null && selectedValues.Contains(section.SectionId.ToString())) l.Selected = true; ValueList.Items.Add(l); } }
public void SetSettings(BXParamsBag<object> settings) { if (settings.ContainsKey("IBlockId")) ddlIBlock.SelectedValue = settings["IBlockId"].ToString(); else ddlIBlock.SelectedIndex = 0; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); //Инициализируем только текстбокс if (value != null && value.Value != null) { int elId; if (int.TryParse(value.Value.ToString(), out elId) && elId > 0) tbValue.Text = elId.ToString(); } BXParamsBag<object> settings = new BXParamsBag<object>(field.Settings); iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; }
public void SetSettings(BXParamsBag<object> settings) { if (settings.ContainsKey("default")) { rbCustom.Checked = true; IBXCalendar cal = Calendar1 as IBXCalendar; if (cal != null) cal.Date = (DateTime)settings["default"]; } showTime.Checked = settings.ContainsKey("showTime") ? (bool)settings["showTime"] : true; if (settings.ContainsKey("current")) rbCurrent.Checked = true; rbNone.Checked = true; }
public void Initialize(BXCustomField currentField,BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueTextBox.Columns = settings.ContainsKey("TextBoxSize") ? settings.GetInt("TextBoxSize") : 20; ValueMin.Enabled = ValueMax.Enabled = false; ValueType.ErrorMessage = ValueMax.ErrorMessage = ValueMin.ErrorMessage = GetMessageFormat("Error.DefaultRangeInvalid", fieldName); if (settings.ContainsKey("MinValue")) { double min = Convert.ToDouble(settings["MinValue"]);// is int ? (double)((int)settings["MinValue"]) : (double)settings["MinValue"]; ValueMin.ValueToCompare = min.ToString(); ValueMin.Enabled = true; } if (settings.ContainsKey("MaxValue")) { double max = Convert.ToDouble(settings["MaxValue"]); //is int ? (double)((int)settings["MaxValue"]) : (double)settings["MaxValue"]; ValueMax.ValueToCompare = max.ToString(); ValueMax.Enabled = true; } int precision = settings.ContainsKey("Precision") ? settings.GetInt("Precision") : 4; if (value != null) ValueTextBox.Text = string.Format("{0:F" + precision + "}", value.Value); else ValueTextBox.Text = settings.ContainsKey("DefaultValue") ? settings["DefaultValue"].ToString() : String.Empty; }
public void SetSettings(BXParamsBag<object> settings) { if (settings.ContainsKey("view")) { switch ((int)settings["view"]) { case 0: rbCheckbox.Checked = true; break; case 1: rbRadiobuttons.Checked = true; break; case 2: rbDropDown.Checked = true; break; } } if (settings.ContainsKey("default")) { DefaultValue.SelectedIndex = (int)settings["default"]; } }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueTextBox.Columns = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 20; ValueRange.Enabled = true; ValueRange.MinimumValue = int.MinValue.ToString(); ValueRange.MaximumValue = int.MaxValue.ToString(); ValueRange.ErrorMessage = GetMessageFormat("Error.DefaultRangeInvalid", fieldName); if (settings.ContainsKey("MinValue")) { int min = (int)settings["MinValue"]; ValueRange.MinimumValue = min.ToString(); } if (settings.ContainsKey("MaxValue")) { int max = (int)settings["MaxValue"]; ValueRange.MaximumValue = max.ToString(); } if (value != null) ValueTextBox.Text = string.Format("{0}", value.Value); else ValueTextBox.Text = settings.ContainsKey("DefaultValue") ? settings["DefaultValue"].ToString() : String.Empty; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(field.Settings); MultiView1.ActiveViewIndex = settings.ContainsKey("view") ? (int)settings["view"] : 0; //BIND VALUE if (value != null) { if (value.Value != null && value.Value is bool) { bool flag = (bool)value.Value; chValue.Checked = flag; ddValue.SelectedIndex = flag ? 0 : 1; No.Checked = !flag; Yes.Checked = flag; return; //Skip default setup } } //BIND DEFAULT int defVal; if(settings.TryGetInt("default", out defVal)) switch (defVal) { case 0: //True chValue.Checked = true; ddValue.SelectedIndex = 0; Yes.Checked = true; break; case 1: //False chValue.Checked = false; ddValue.SelectedIndex = 1; No.Checked = true; break; } }
public void SetSettings(BXParamsBag<object> settings) { string textType = (settings.GetString("TextType") ?? "").ToUpperInvariant(); if (string.Equals(textType, "PATTERN", StringComparison.InvariantCulture)) { PatternButton.Checked = true; PatternContainer.Style.Add(HtmlTextWriterStyle.Display, ""); } else if (string.Equals(textType, "HTML", StringComparison.InvariantCulture)) HtmlButton.Checked = true; else TextButton.Checked = true; Pattern.Text = settings.ContainsKey("Pattern") ? (string)settings["Pattern"] : String.Empty; DefaultValue.Text = settings.ContainsKey("DefaultValue") ? (string)settings["DefaultValue"] : String.Empty; TextBoxSize.Text = settings.ContainsKey("TextBoxSize") ? settings["TextBoxSize"].ToString() : String.Empty; RowsCount.Text = settings.ContainsKey("RowsCount") ? settings["RowsCount"].ToString() : String.Empty; MinLength.Text = settings.ContainsKey("MinLength") ? settings["MinLength"].ToString() : String.Empty; MaxLength.Text = settings.ContainsKey("MaxLength") ? settings["MaxLength"].ToString() : String.Empty; ValidationRegex.Text = settings.ContainsKey("ValidationRegex") ? (string)settings["ValidationRegex"] : String.Empty; }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey(deleteMenuItemChkBx.ID)) deleteMenuItemChkBx.Checked = Convert.ToBoolean(paramsBag[deleteMenuItemChkBx.ID]); }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey(tbxPageName.ID)) tbxPageName.Text = paramsBag[tbxPageName.ID]; if (paramsBag.ContainsKey(tbxTitle.ID)) tbxTitle.Text = paramsBag[tbxTitle.ID]; if (paramsBag.ContainsKey(chbxEditAfterSave.ID)) chbxEditAfterSave.Checked = Convert.ToBoolean(paramsBag[chbxEditAfterSave.ID]); if (paramsBag.ContainsKey(chbxAddToMenu.ID)) chbxAddToMenu.Checked = Convert.ToBoolean(paramsBag[chbxAddToMenu.ID]); if (!chbxAddToMenu.Checked && paramsBag.ContainsKey("checkForGrantMenuModification") && !string.IsNullOrEmpty(paramsBag["checkForGrantMenuModification"]) && BXUser.IsCanOperate(BXRoleOperation.Operations.MenuItemsEdit)) chbxAddToMenu.Checked = true; if (paramsBag.ContainsKey(tbxMenuName.ID)) tbxMenuName.Text = paramsBag[tbxMenuName.ID]; if (paramsBag.ContainsKey(ddlMenuTypes.ID)) { string text = paramsBag[ddlMenuTypes.ID]; if (!string.IsNullOrEmpty(text)) { ListItem li = ddlMenuTypes.Items.FindByValue(text); if (li != null) { int index = ddlMenuTypes.Items.IndexOf(li); if (ddlMenuTypes.SelectedIndex != index) { ddlMenuTypes.SelectedIndex = index; PrepareMenuItemsList(); } } } } if (paramsBag.ContainsKey(ddlMenuItems.ID)) { string text = paramsBag[ddlMenuItems.ID]; if (!string.IsNullOrEmpty(text)) { ListItem li = ddlMenuItems.Items.FindByValue(text); if (li != null) { int index = ddlMenuItems.Items.IndexOf(li); if (ddlMenuItems.SelectedIndex != index) ddlMenuItems.SelectedIndex = index; } } } foreach (KeyValuePair<string, Dictionary<string, string>> keywordPair in _keywords) { string paramKey = string.Format("keyword[{0}]", keywordPair.Key); if (!paramsBag.ContainsKey(paramKey)) continue; string keywordValue = paramsBag[paramKey]; if (keywordPair.Value.ContainsKey("value")) keywordPair.Value["value"] = keywordValue; else keywordPair.Value.Add("value", keywordValue); } }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); defaultValue = settings.GetInt("default", 1) != 1; view = settings.ContainsKey("view") ? (BooleanViewType)settings["view"] : BooleanViewType.Default; }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); BXPublicMenuItemCollection menuItemCollection = MenuItemCollection; if (!paramsBag.ContainsKey(menuItemCollection.ID)) return; menuItemCollection.Clear(); string menuItemCollectionAsStr = paramsBag[menuItemCollection.ID]; if (string.IsNullOrEmpty(menuItemCollectionAsStr)) return; string[] menuItemArr = menuItemCollectionAsStr.Split(';'); int menuItemsCount = menuItemArr.Length; for (int i = 0; i < menuItemsCount; i++) menuItemCollection.Add(Deserialize(menuItemArr[i])); }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey("content")) { string content = paramsBag["content"]; if (!string.IsNullOrEmpty(content)) { if (mMode == VisualPageEditorMode.Standard) { VisualEditor.AutoLoadContent = false; VisualEditor.Content = content; } else TextEditor.Text = content; } } }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); RequiredValidator.Enabled = currentField.Mandatory; if (RequiredValidator.Enabled) RequiredValidator.ErrorMessage = GetMessageFormat("Error.Required", field.EditFormLabel); SizeValidator.Enabled = settings.ContainsKey("MaxSize"); if (SizeValidator.Enabled) { maxSize = (int)settings["MaxSize"]; SizeValidator.ErrorMessage = GetMessageFormat("Error.IllegalSize", field.EditFormLabel, settings["MaxSize"]); } if (settings.ContainsKey("AllowedExtensions")) extensions = settings["AllowedExtensions"] as string[]; ExtensionValidator.Enabled = (extensions != null && extensions.Length > 0); if (ExtensionValidator.Enabled) ExtensionValidator.ErrorMessage = GetMessageFormat("Error.IllegalExtension", field.EditFormLabel, string.Join(", ", extensions)); value = currentValue; RequiredValidator.Enabled = field.Mandatory; if (RequiredValidator.Enabled) RequiredValidator.ErrorMessage = GetMessageFormat("Error.Required", field.EditFormLabel); addDescription = settings.GetBool("AddDescription"); DescriptionBlock.Visible = addDescription; BXFile f = null; if (currentValue != null && (currentValue.Value != null && (int)currentValue.Value != 0) && (f = BXFile.GetById((int)currentValue.Value, BXTextEncoder.EmptyTextEncoder)) != null) { currentFile = originalFile = f; StoredId.Value = "Y"; //DisplayName.Value = f.FileNameOriginal; //DisplaySize.Value = BXStringUtility.BytesToString(f.FileSize); //ContentType.Value = f.ContentType; if (addDescription) Description.Text = f.Description; } }
public void SetSettings(BXParamsBag<object> settings) { ListSize.Text = settings.ContainsKey("ListSize") ? settings["ListSize"].ToString() : "5"; rbList.Checked = settings.ContainsKey("ViewMode") ? true : false; rbFlags.Checked = !settings.ContainsKey("ViewMode") ? true : false; }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); required = field.Mandatory; multiple = field.Multiple; iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; textBoxSize = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 5; BXIBlockSectionCollection sections = BXIBlockSection.GetList( new BXFilter( new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"), new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId) ), new BXOrderBy( new BXOrderByPair(BXIBlockSection.Fields.LeftMargin, BXOrderByDirection.Asc) ), new BXSelect( BXIBlockSection.Fields.ID, BXIBlockSection.Fields.Name, BXIBlockSection.Fields.DepthLevel ), null, BXTextEncoder.HtmlTextEncoder ); int currentIndex = 0; int previousDepthLevel = 1; foreach (BXIBlockSection section in sections) { if (currentIndex > 0) ((SectionTreeItem)sectionTree[currentIndex - 1]).HasChildren = section.DepthLevel > previousDepthLevel; previousDepthLevel = section.DepthLevel; SectionTreeItem treeItem = new SectionTreeItem(); treeItem.Id = section.Id; treeItem.DepthLevel = section.DepthLevel; treeItem.Name = section.Name; sectionTree.Insert(currentIndex++, section.Id, treeItem); } }
/// <summary> /// InternalizeParameters /// Загрузить параметры /// </summary> /// <param name="paramsBag"></param> protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey(tbxNewTemplateName.ID)) tbxNewTemplateName.Text = paramsBag[tbxNewTemplateName.ID]; if (paramsBag.ContainsKey(rbtnDefaultSiteTemplate.ID)) { rbtnDefaultSiteTemplate.Checked = true; rbtnActiveSiteTemplate.Checked = false; rbtnAnotherSiteTemplate.Checked = false; ddlSiteTemplateName.Disabled = true; ddlSiteTemplateName.SelectedIndex = 0; } else if (paramsBag.ContainsKey(rbtnActiveSiteTemplate.ID)) { rbtnDefaultSiteTemplate.Checked = false; rbtnActiveSiteTemplate.Checked = true; rbtnAnotherSiteTemplate.Checked = false; ddlSiteTemplateName.Disabled = true; ddlSiteTemplateName.SelectedIndex = 0; } else if (paramsBag.ContainsKey(rbtnAnotherSiteTemplate.ID)) { rbtnDefaultSiteTemplate.Checked = false; rbtnActiveSiteTemplate.Checked = false; rbtnAnotherSiteTemplate.Checked = true; ddlSiteTemplateName.Disabled = false; if (paramsBag.ContainsKey(ddlSiteTemplateName.ID)) { string siteTemplateName = paramsBag[ddlSiteTemplateName.ID]; int siteTemplateNamesCount = ddlSiteTemplateName.Items.Count, siteTemplateNameIndex = -1; for (int i = 0; i < siteTemplateNamesCount; i++) { if (!string.Equals(ddlSiteTemplateName.Items[i].Value, siteTemplateName, StringComparison.InvariantCulture)) continue; siteTemplateNameIndex = i; break; } if (siteTemplateNameIndex >= 0) ddlSiteTemplateName.SelectedIndex = siteTemplateNameIndex; else if(siteTemplateNamesCount > 0) ddlSiteTemplateName.SelectedIndex = 0; } else if (ddlSiteTemplateName.Items.Count > 0) ddlSiteTemplateName.SelectedIndex = 0; } SetSiteTemplateNameForNewItemFromUserInput(); try { if (paramsBag.ContainsKey(chbxApply.ID)) chbxApply.Checked = Convert.ToBoolean(paramsBag[chbxApply.ID]); if (paramsBag.ContainsKey(chbxGo2Modification.ID)) chbxGo2Modification.Checked = Convert.ToBoolean(paramsBag[chbxGo2Modification.ID]); } catch (FormatException /*exc*/) { } //подавление исключений при конвертации }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey("pageTitle")) { string text = paramsBag["pageTitle"]; if(!string.IsNullOrEmpty(text)) mClientPageTitle = text; } foreach (KeyValuePair<string, Dictionary<string, string>> keywordPair in _keywords) { string paramKey = string.Format("keyword[{0}]", keywordPair.Key); if (!paramsBag.ContainsKey(paramKey)) continue; string keywordValue = paramsBag[paramKey]; if (keywordPair.Value.ContainsKey("value")) keywordPair.Value["value"] = keywordValue; else keywordPair.Value.Add("value", keywordValue); } }
protected void Page_LoadComplete(object sender, EventArgs e) { MasterTitle = GetMessage("MasterTitle"); if (bigError) return; keywords = keywords ?? BXPageManager.GetKeywords(curSite); BXSectionInfo inherited = !string.IsNullOrEmpty(curDir) ? BXSectionInfo.GetCumulativeSection(curDir) : null; if (!IsPostBack) { BXSectionInfo info = BXSectionInfo.GetSection(curPath); Name.Text = info.Name; foreach (string keyword in keywords.Keys) { Keyword k = new Keyword(); k.Name = keyword; info.Keywords.TryGetValue(keyword, out k.Value); state.Add(k); } foreach (KeyValuePair<string, string> kvp in info.Keywords) if (!keywords.ContainsKey(kvp.Key) && !string.IsNullOrEmpty(kvp.Value)) { Keyword k = new Keyword(); k.Name = kvp.Key; k.Value = kvp.Value; state.Add(k); } if (inherited != null) foreach (KeyValuePair<string, string> kvp in inherited.Keywords) if (!keywords.ContainsKey(kvp.Key) && (!info.Keywords.ContainsKey(kvp.Key) || string.IsNullOrEmpty(info.Keywords[kvp.Key])) && !string.IsNullOrEmpty(kvp.Value)) { Keyword k = new Keyword(); k.Name = kvp.Key; k.Value = null; state.Add(k); } for (int i = 0; i < 5; i++) state.Add(new Keyword()); } if (inherited != null) foreach(Keyword k in state) if (!string.IsNullOrEmpty(k.Name)) inherited.Keywords.TryGetValue(k.Name, out k.Inherited); PrepareResultMessage(); }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; settings = new BXParamsBag<object>(field.Settings); viewMode = settings.ContainsKey("ViewMode") && (string)settings["ViewMode"] == "list" ? ViewMode.List : ViewMode.Flag; valDDList.Enabled = false; valList.Enabled = false; valFlag.Enabled = false; valCheckbox.Enabled = false; ListControl list; int listCount = Math.Max(settings.GetInt("ListSize", 5), 1); if (viewMode == ViewMode.List) { if (field.Multiple) { View.ActiveViewIndex = 0; list = List; validator = valList; List.Rows = Math.Min(listCount, Enums.Count + (!field.Multiple && !field.Mandatory ? 1 : 0)); } else { View.ActiveViewIndex = 3; list = DDList; validator = valDDList; } } else { if (field.Multiple) { View.ActiveViewIndex = 2; list = ChBox; validator = valCheckbox; } else { View.ActiveViewIndex = 1; list = Flag; validator = valFlag; } } ListItem none = null; if (!field.Multiple && !field.Mandatory) { none = new ListItem(GetMessage("Option.NotSelected"), ""); none.Selected = true; list.Items.Add(none); } validator.Enabled = field.Mandatory; validator.ValidationGroup = ValidationGroup; foreach (BXCustomFieldEnum e in Enums) list.Items.Add(new ListItem(e.Value, e.Id.ToString())); if (value != null) { bool stop = false; foreach (ListItem item in list.Items) { foreach (int val in value.Values) if (item.Value == val.ToString()) { if (!field.Multiple) { if (none != null) none.Selected = false; stop = true; } item.Selected = true; break; } if (stop) break; } } else //BIND DEFAULT { bool stop = false; foreach (ListItem item in list.Items) { foreach (BXCustomFieldEnum val in Enums) if (item.Value == val.Id.ToString() && val.Default) { if (!field.Multiple) { if (none != null) none.Selected = false; stop = true; } item.Selected = true; break; } if (stop) break; } } }
public void Activate(BXParamsBag<object> state) { D.StartHidden = false; if (!dynamicsLoaded) InitStatics(); UserTypeIdTextBox.SelectedValue = state.Get("CustomTypeId", "Bitrix.System.Text"); DontEditInList.Checked = !state.Get("EditInList", true); FieldNameTextBox.Text = state.Get("FieldName", string.Empty); IsSearchable.Checked = state.Get("IsSearchable", false); Mandatory.Checked = state.Get("Mandatory", false); MultipleCheckBox.Checked = state.Get("Multiple", false); ShowFilter.SelectedValue = ((BXCustomFieldFilterVisibility)state.Get("ShowInFilter", (int)BXCustomFieldFilterVisibility.CompleteMatch)).ToString(); DontShowInList.Checked = !state.Get("ShowInList", true); Sort.Text = state.Get("Sort", string.Empty); XmlId.Text = state.Get("XmlId", string.Empty); foreach (KeyValuePair<string, Dictionary<string, TextBox>> l in locControls) { string key = "Loc." + l.Key; if (state.ContainsKey(key)) { string[] phrases = (string[])state[key]; l.Value["EditFormLabel"].Text = phrases[0]; l.Value["ErrorMessage"].Text = phrases[1]; l.Value["HelpMessage"].Text = phrases[2]; l.Value["ListColumnLabel"].Text = phrases[3]; l.Value["ListFilterLabel"].Text = phrases[4]; } } userTypeId = state.Get<string>("@CustomTypeId"); if (string.IsNullOrEmpty(userTypeId)) userTypeId = null; fieldName = state.Get<string>("@FieldName"); if (string.IsNullOrEmpty(fieldName)) fieldName = null; if (state.ContainsKey("@Multiple")) multiple = state.Get("@Multiple", false); else multiple = null; InstantiateSettings(); BXParamsBag<object> settingsState = state.Get<BXParamsBag<object>>("Settings"); if (settings != null && settingsState != null) settings.SetSettings(settingsState); object extrasState = state.Get("Extras", null); InstantiateExtraSettings(extrasState); StoredSender.Value = state.Get("@Sender", string.Empty); }
public void FillLocalization(BXCustomField field, BXParamsBag<object> state) { foreach (string lang in BXLoc.Locales) { string key = "Loc." + lang; BXCustomFieldLocalization l = field.Localization[lang]; if (l == null) { l = new BXCustomFieldLocalization(); field.Localization[lang] = l; } if (!state.ContainsKey(key)) continue; string[] phrases = state.Get<string[]>(key); l.EditFormLabel = phrases[0]; l.ErrorMessage = phrases[1]; l.HelpMessage = phrases[2]; l.ListColumnLabel = phrases[3]; l.ListFilterLabel = phrases[4]; } }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); required = field.Mandatory; iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; }
protected override void InternalizeParameters(BXParamsBag<string> paramsBag) { if (paramsBag == null) throw new ArgumentNullException("paramsBag"); if (paramsBag.ContainsKey(textEditor.ID)) { string text = paramsBag[textEditor.ID]; if (!string.IsNullOrEmpty(text)) textEditor.Text = text; } }