private bool uncheckThis() { // check if any other entry is checked instead? if (ParentEntry != null) { var siblings = ParentEntry.GetChildEntryList(); if (siblings != null) { foreach (var sibling in siblings) { if ( sibling != null && sibling != this && sibling is DialogEntry && ((DialogEntry)sibling).Type == DialogEntryType.RadioButton && ((DialogEntry)sibling).Status.HasFlag(DialogEntryStatus.Checked) ) { // one other sibling was found that is checked, .. so we can uncheck this _status &= ~DialogEntryStatus.Checked; _status |= DialogEntryStatus.Unchecked; return(true); } } } } return(false); }
private void checkThis() { _status &= ~DialogEntryStatus.Unchecked; _status |= DialogEntryStatus.Checked; // TODO: // - disable the others in this group [✓] // - or dialog [?] --> RadieoButtons must be within a group! if (ParentEntry != null) { var siblings = ParentEntry.GetChildEntryList(); if (siblings != null) { foreach (var sibling in siblings) { if (sibling != null && sibling != this && sibling is DialogEntry && ((DialogEntry)sibling).Type == DialogEntryType.RadioButton) { ((DialogEntry)sibling).Status |= DialogEntryStatus.Unchecked; } } } } }
protected bool AddSharedObject(INotifyPropertyChanged addedObj, int index, out ObjectEntry objectEntry) { // First determine if the added object is being tracked by the SharedObjects System // if it is then we don't need to send the objects content payload, just // the insertion information to put this object into this collection. this.client.ObjectsManager.TryAdd(addedObj, out objectEntry); Debug.Assert(objectEntry != null); if (objectEntry.IgnoreChanges) { // Avoid feedback loop from applying incoming insertions return(false); } this.MasterCollection.VerifyConnected(); var parent = new ParentEntry() { Index = index, Id = this.Id }; objectEntry.AddParent(parent); this.Items.Add(objectEntry.Id, objectEntry); return(true); }
public ActionResult getParentResponses(ParentEntry parentinfo) { Parent parent = new Parent { FirstName = parentinfo.firstName, LastName = parentinfo.lastname, PhoneNumber = parentinfo.phonenumber, Email = parentinfo.email, NumberOfStudents = parentinfo.numberofstudents, StudentGradesArray = parentinfo.studentgradesarray, PaymentPreference = parentinfo.paymentpreference, Date = parentinfo.date }; try { ParentClient tableStorage = new ParentClient(); tableStorage.Add(parent); return(Content("ok")); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, ex.Message)); } }
public void AddParent(ParentEntry entry) { if (Parents.ContainsKey(entry.Id)) { throw new ObjectAlreadyExistsException("Object is already parented by this parent"); } Parents.Add(entry.Id, entry); }
public bool ResetValue() { if (IsResetable) { object[] owners = this.PropertyOwners; PropertyDescriptor[] properties = PropertyDescriptors; for (int i = 0; i < owners.Length; i++) { properties[i].ResetValue(owners[i]); if (IsValueType(this.ParentEntry)) { string error = null; if (!ParentEntry.SetValueCore(owners[i], out error) && error != null) { property_grid.ShowError(error); } } } property_grid.OnPropertyValueChangedInternal(this, this.Value); return(true); } return(false); }
protected virtual bool SetValueCore(object value, out string error) { error = null; TypeConverter converter = GetConverter(); Type valueType = value != null?value.GetType() : null; // if the new value is not of the same type try to convert it if (valueType != null && this.PropertyDescriptor.PropertyType != null && !this.PropertyDescriptor.PropertyType.IsAssignableFrom(valueType)) { bool conversionError = false; try { if (converter != null && converter.CanConvertFrom((ITypeDescriptorContext)this, valueType)) { value = converter.ConvertFrom((ITypeDescriptorContext)this, CultureInfo.CurrentCulture, value); } } catch (Exception e) { error = e.Message; conversionError = true; } if (conversionError) { string valueText = ConvertToString(value); string errorShortDescription = null; if (valueText != null) { errorShortDescription = "Property value '" + valueText + "' of '" + PropertyDescriptor.Name + "' is not convertible to type '" + this.PropertyDescriptor.PropertyType.Name + "'"; } else { errorShortDescription = "Property value of '" + PropertyDescriptor.Name + "' is not convertible to type '" + this.PropertyDescriptor.PropertyType.Name + "'"; } error = errorShortDescription + Environment.NewLine + Environment.NewLine + error; return(false); } } bool changed = false; bool current_changed = false; object[] propertyOwners = this.PropertyOwners; PropertyDescriptor[] properties = PropertyDescriptors; for (int i = 0; i < propertyOwners.Length; i++) { object currentVal = properties[i].GetValue(propertyOwners[i]); current_changed = false; if (!Object.Equals(currentVal, value)) { if (this.ShouldCreateParentInstance) { Hashtable updatedParentProperties = new Hashtable(); PropertyDescriptorCollection parentProperties = TypeDescriptor.GetProperties(propertyOwners[i]); foreach (PropertyDescriptor property in parentProperties) { if (property.Name == properties[i].Name) { updatedParentProperties[property.Name] = value; } else { updatedParentProperties[property.Name] = property.GetValue(propertyOwners[i]); } } object updatedParentValue = this.ParentEntry.PropertyDescriptor.Converter.CreateInstance( (ITypeDescriptorContext)this, updatedParentProperties); if (updatedParentValue != null) { current_changed = this.ParentEntry.SetValueCore(updatedParentValue, out error); } } else { try { properties[i].SetValue(propertyOwners[i], value); } catch { // MS seems to swallow this // // string valueText = ConvertToString (value); // if (valueText != null) // error = "Property value '" + valueText + "' of '" + properties[i].Name + "' is invalid."; // else // error = "Property value of '" + properties[i].Name + "' is invalid."; return(false); } if (IsValueType(this.ParentEntry)) { current_changed = ParentEntry.SetValueCore(propertyOwners[i], out error); } else { current_changed = true; } } } if (current_changed) { changed = true; } } return(changed); }
protected virtual bool SetValueCore(object value, out string error) { error = null; bool changed = false; bool current_changed = false; object[] propertyOwners = this.PropertyOwners; PropertyDescriptor[] properties = PropertyDescriptors; for (int i = 0; i < propertyOwners.Length; i++) { object currentVal = properties[i].GetValue(propertyOwners[i]); current_changed = false; if (!Object.Equals(currentVal, value)) { if (this.ShouldCreateParentInstance) { Hashtable updatedParentProperties = new Hashtable(); PropertyDescriptorCollection parentProperties = TypeDescriptor.GetProperties(propertyOwners[i]); foreach (PropertyDescriptor property in parentProperties) { if (property.Name == properties[i].Name) { updatedParentProperties[property.Name] = value; } else { updatedParentProperties[property.Name] = property.GetValue(propertyOwners[i]); } } object updatedParentValue = this.ParentEntry.PropertyDescriptor.Converter.CreateInstance( (ITypeDescriptorContext)this, updatedParentProperties); if (updatedParentValue != null) { current_changed = this.ParentEntry.SetValueCore(updatedParentValue, out error); } } else { try { properties[i].SetValue(propertyOwners[i], value); } catch { // MS seems to swallow this // // string valueText = ConvertToString (value); // if (valueText != null) // error = "Property value '" + valueText + "' of '" + properties[i].Name + "' is invalid."; // else // error = "Property value of '" + properties[i].Name + "' is invalid."; return(false); } if (IsValueType(this.ParentEntry)) { current_changed = ParentEntry.SetValueCore(propertyOwners[i], out error); } else { current_changed = Object.Equals(properties[i].GetValue(propertyOwners[i]), value); } } } if (current_changed) { changed = true; } } return(changed); }