private void textChanged(object sender, EventArgs e) { if (initialized) { IEditControl c = sender as IEditControl; if (c != null) { if (c.Changed) { if (isMultiple) { if (checkboxes.ContainsKey(c)) { checkboxes[c].Checked = true; } } Dirty = true; } if (!isMultiple) { updateColor(c, c.Changed); } } } }
private void ProcessControl(Control c, BusinessObject _obj) { IEditControl editControl = c as IEditControl; if (editControl != null) { string fieldName = editControl.FieldName; string ownFieldName = fieldName; string aggrFieldName = String.Empty; MetaField ownField = null; MetaField aggrField = null; if (ownFieldName.Contains(".")) { string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 1) { ownFieldName = mas[0]; aggrFieldName = mas[1]; string aggrClassName = _obj.Properties[ownFieldName].GetMetaType().Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString(); aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName); } } ownField = _obj.Properties[ownFieldName].GetMetaType(); object eValue = editControl.Value; bool makeChange = true; MetaField field = (aggrField == null) ? ownField : aggrField; if ((!field.IsNullable && eValue == null) || _obj.Properties[ownFieldName].IsReadOnly) { makeChange = false; } if (makeChange) { if (aggrField == null) { _obj[ownFieldName] = eValue; } else { //make aggregation MetaObject aggrObj = (MetaObject)_obj[ownFieldName]; aggrObj[aggrFieldName] = eValue; } } } BaseServiceEditControl bsc = c as BaseServiceEditControl; if (bsc != null) { bsc.Save(_obj); } }
private static void updateColor(IEditControl c, QCheckBox cb) { updateColor(c, cb.Checked); if (c is IWatermarkable) { (c as IWatermarkable).WatermarkEnabled = !cb.Checked; c.ForeColor = cb.Checked ? Color.Black : Styles.Watermark; } }
private void setTabIndex(IEditControl C, ref int TabIndex) { labels[C].TabIndex = TabIndex++; C.TabIndex = TabIndex++; if (checkboxes.ContainsKey(C)) { checkboxes[C].TabIndex = TabIndex++; } }
protected void Page_Load(object sender, EventArgs e) { int entityTypeValue = 0; Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue); if (Enum.IsDefined(typeof(EntityType), entityTypeValue)) { _selectedEntityType = (EntityType)entityTypeValue; _entityTypeDefined = true; } if (_entityTypeDefined) { // load edit control for given entity. Control controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); IEditControl editor = controlToAdd as IEditControl; if (editor != null) { editor.EditMode = FormViewMode.ReadOnly; phControls.Controls.Add(controlToAdd); controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); ISearchControl searcher = controlToAdd as ISearchControl; if (searcher != null) { if (Request.QueryString.Count > 1) { // get the filter based on the query string's PK fields. Use the search control for this, as it contains the logic for this. PredicateExpression filter = searcher.CreateFilter(Request.QueryString); editor.FilterToUse = filter; controlToAdd = Page.LoadControl("~/Controls/ViewRelatedTo" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); IViewRelatedControl relatedViewer = controlToAdd as IViewRelatedControl; if (relatedViewer != null) { relatedViewer.FilterToUse = filter; phRelatedEntities.Controls.Add(controlToAdd); } } } } } if (!Page.IsPostBack) { if (_entityTypeDefined) { this.Title += _selectedEntityType.ToString() + " instance"; lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType); } // check for user info if (SessionHelper.GetUserID() == string.Empty) { Response.Redirect("Login.aspx"); } } }
private void ProcessControl(Control c, MetaObject mo) { IEditControl fc = c as IEditControl; if (fc != null && !fc.ReadOnly) { string fieldName = fc.FieldName; if (fieldName.ToLower() == "title" && mo.Properties[fieldName] == null) { fieldName = mo.GetMetaType().TitleFieldName; } mo.Properties[fieldName].Value = fc.Value; } }
private void updateColor(object sender, EventArgs e) { if (isMultiple) { IEditControl c = checkboxes.First(kvp => kvp.Value.Equals(sender)).Key; QCheckBox cb = sender as QCheckBox; updateColor(c, cb); } else { IEditControl it = sender as IEditControl; it.Highlighted = it.Changed; } }
private int placeControl(IEditControl Control, int X, int Y, int Width) { bool checkbox = checkboxes.ContainsKey(Control); labels[Control].Location = new Point(X, Y); Control.Bounds = new Rectangle(X, labels[Control].Bottom, Width - (checkbox ? chkArt.Width : -MARGIN / 2), Control.Height); if (checkbox) { checkboxes[Control].Location = new Point(Control.Right + MARGIN / 3, Control.Top); } return(Control.Bottom); }
/// <summary> /// Processes the control. /// </summary> /// <param name="c">The c.</param> /// <param name="_obj">The _obj.</param> private void ProcessControl(Control c, BusinessObject obj) { IEditControl editControl = c as IEditControl; if (editControl != null) { string fieldName = editControl.FieldName; object eValue = editControl.Value; bool makeChange = true; if ((!obj.Properties[fieldName].GetMetaType().IsNullable&& eValue == null) || obj.Properties[fieldName].IsReadOnly) { makeChange = false; } if (makeChange) { obj.Properties[fieldName].Value = eValue; } } }
protected void Page_Load(object sender, EventArgs e) { int entityTypeValue = 0; Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue); if (Enum.IsDefined(typeof(EntityType), entityTypeValue)) { _selectedEntityType = (EntityType)entityTypeValue; _entityTypeDefined = true; } if (_entityTypeDefined) { // load edit control for given entity. Control controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); IEditControl editor = controlToAdd as IEditControl; if (editor != null) { editor.EditMode = FormViewMode.Insert; phControls.Controls.Add(controlToAdd); } } if (!Page.IsPostBack) { if (_entityTypeDefined) { this.Title += _selectedEntityType.ToString() + " instance"; lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType); } // check for user info if (SessionHelper.GetUserID() == string.Empty) { Response.Redirect("Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { int entityTypeValue = 0; Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue); if (Enum.IsDefined(typeof(EntityType), entityTypeValue)) { _selectedEntityType = (EntityType)entityTypeValue; _entityTypeDefined = true; } if (_entityTypeDefined) { // load edit control for given entity. Control controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); _editor = controlToAdd as IEditControl; if (_editor != null) { _editor.EditMode = FormViewMode.Edit; phEditControls.Controls.Add(controlToAdd); } phEditArea.Visible = false; // load search control controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx"); _searcher = controlToAdd as ISearchControl; if (_searcher != null) { if (Request.QueryString.Count == 1) { // just entitytype specified. _searcher.AllowSingleEntitySearches = true; _searcher.AllowMultiEntitySearches = false; _searcher.SearchClicked += new EventHandler(searcher_SearchClicked); phSearchControls.Controls.Add(controlToAdd); phSearchArea.Visible = true; } else { // get the filter based on the query string's PK fields. Use the search control for this, as it contains the logic for this. if (_editor != null) { _editor.FilterToUse = _searcher.CreateFilter(Request.QueryString); phSearchArea.Visible = false; phEditArea.Visible = true; } } } } if (!Page.IsPostBack) { if (_entityTypeDefined) { this.Title += _selectedEntityType.ToString() + " instance"; lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType); } // check for user info if (SessionHelper.GetUserID() == string.Empty) { Response.Redirect("Login.aspx"); } } }
private void ProcessControl(Control c, EntityObject _obj) { IEditControl editControl = c as IEditControl; if (editControl != null) { string fieldName = editControl.FieldName; #region MyRegion string ownFieldName = fieldName; string aggrFieldName = String.Empty; string aggrClassName = String.Empty; MetaField ownField = null; MetaField aggrField = null; MetaClass ownClass = MetaDataWrapper.GetMetaClassByName(ClassName); if (ownFieldName.Contains(".")) { string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 1) { ownFieldName = mas[0]; aggrFieldName = mas[1]; ownField = MetaDataWrapper.GetMetaFieldByName(ownClass, ownFieldName); aggrClassName = ownField.Attributes.GetValue <string>(McDataTypeAttribute.AggregationMetaClassName); aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName); } } if (ownField == null) { ownField = ownClass.Fields[ownFieldName]; } #endregion object eValue = editControl.Value; bool makeChange = true; MetaField field = (aggrField == null) ? ownField : aggrField; if (!field.IsNullable && eValue == null) { makeChange = false; } if (makeChange) { if (aggrField == null) { _obj[ownFieldName] = eValue; } else { EntityObject aggrObj = null; if (_obj[ownFieldName] != null) { aggrObj = (EntityObject)_obj[ownFieldName]; } else { aggrObj = BusinessManager.InitializeEntity(ClassName); } aggrObj[aggrFieldName] = eValue; } } } }
private void setupControl(IEditControl Control, string Caption, bool MakeCheckbox) { QLabel label = new QLabel(Caption, Styles.FontSmaller); this.Controls.Add(label); labels.Add(Control, label); label.ShowAccellerator(); if (MakeCheckbox) { QCheckBox cb = new QCheckBox(String.Empty, this.BackColor); cb.CheckedChanged += (s, e) => { updateColor(s, e); Dirty = true; }; this.Controls.Add(cb); checkboxes.Add(Control, cb); Control.ForeColor = Styles.Watermark; } this.Controls.Add(Control as Control); if (Control is QTextBox) { Control.TextChanged += textChanged; QTextBox tb = Control as QTextBox; tb.GotFocus += (s, e) => { Clock.DoOnMainThread(tb.SelectAll, 30); }; if (tb.Text == VARIES_TOKEN) { tb.EnableWatermark(this, MULTIPLE_VALUES, String.Empty); tb.Text = String.Empty; } editControls.Add(tb); } else if (Control is QComboBox) { QComboBox cb = Control as QComboBox; // need both, depends on editable vs. uneditable cb.TextChanged += textChanged; cb.SelectedIndexChanged += textChanged; if (cb.Text == VARIES_TOKEN) { cb.EnableWatermark(this, MULTIPLE_VALUES, String.Empty); cb.Text = String.Empty; } cb.DropDown += (s, e) => { if (isMultiple) { cb.ForeColor = Color.Black; } }; cb.DropDownClosed += (s, e) => { if (isMultiple) { updateColor(cb, checkboxes[cb]); } else { updateColor(cb, EventArgs.Empty); } }; editControls.Add(cb); } }
private bool write(IEditControl c) { return(!isMultiple || checkboxes[c].Checked); }
private static void updateColor(IEditControl c, bool Highlight) { c.Highlighted = Highlight; }