public static void Initialise() { try { if (_initialized) { return; } var resourceType = FindResourceType(); var styleable = resourceType.GetNestedType("Styleable"); LinearDialogScrollViewStylableGroupId = (int[])SafeGetFieldValue(styleable, "LinearDialogScrollView", new int[0]); LinearDialogScrollViewDivider = (int)SafeGetFieldValue(styleable, "LinearDialogScrollView_divider", -1); LinearDialogScrollViewShowDividers = (int)SafeGetFieldValue(styleable, "LinearDialogScrollView_showDividers", -1); LinearDialogScrollDividerPadding = (int)SafeGetFieldValue(styleable, "LinearDialogScrollView_dividerPadding", -1); LinearDialogScrollDividerHeight = (int)SafeGetFieldValue(styleable, "LinearDialogScrollView_dividerHeight", -1); LinearDialogScrollItemBackgroundDrawable = (int)SafeGetFieldValue(styleable, "LinearDialogScrollView_itemBackgroundDrawable", -1); } catch (Exception exception) { DialogTrace.WriteLine("Warning - Error finding resource ids for LinearDialog"); DialogTrace.WriteLine(exception.Message); } _initialized = true; }
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Add: ParentAddedElements(args); break; case NotifyCollectionChangedAction.Remove: OrphanRemovedElements(args); break; case NotifyCollectionChangedAction.Replace: OrphanRemovedElements(args); ParentAddedElements(args); break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Reset: #warning should we throw an exception here? DialogTrace.WriteLine("Warning - Reset seen - not expecting this - our dialog may go very wrong now!"); break; default: throw new ArgumentOutOfRangeException(); } HandleElementsChangedEvent(this, args); ActOnCurrentAttachedCell(UpdateDetailDisplay); }
public object Build(Type interfaceType, KeyedDescription description) { DialogTrace.WriteLine("Building {0} for {1}", interfaceType.Name, description.Key ?? "-empty-"); if (!ShouldBuildDescription(description)) { DialogTrace.WriteLine("Skipping - not for this platform"); return(null); } TypedUserInterfaceBuilder typeBuilder; if (!_builderRegistry.TryGetValue(interfaceType, out typeBuilder)) { DialogTrace.WriteLine("No builder found for that {0}", interfaceType.Name); return(null); } var userInterfaceInstance = typeBuilder.Build(description); if (userInterfaceInstance == null) { DialogTrace.WriteLine("Builder returned NULL for {0}", interfaceType.Name); return(null); } FillProperties(userInterfaceInstance, description.Properties); FillBuildableProperties(description, userInterfaceInstance); return(userInterfaceInstance); }
public TypedUserInterfaceBuilder(Type type, string conventionalEnding, string defaultKey) { DialogTrace.WriteLine("Creating typeduserinterfacebuilder for {0}", type.Name); Type = type; DefaultKey = defaultKey; ConventionalEnding = conventionalEnding; KnownKeys = new Dictionary <string, Type>(); }
public DateTimeElement(string caption = null, DateTime?date = null, string layoutName = null) : base(caption, date, layoutName ?? "dialog_multiline_labelfieldbelow") { Click = delegate { EditDate(); }; DateTimeFormat = "G"; if (Value.HasValue && Value.Value.Kind != DateTimeKind.Utc) { DialogTrace.WriteLine("Warning - non Utc datetmie used within DateTimeElement - can lead to unpredictable results"); } }
public DateTimeElement(string caption, DateTime?date) : base(caption, date) { if (date.HasValue && date.Value.Kind != DateTimeKind.Utc) { DialogTrace.WriteLine("Warning - it's safest to use Utc time with DateTimeElement"); } BackgroundColor = (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) ? UIColor.White : UIColor.Black; DateTimeFormat = "G"; }
private void FillList( PropertyInfo descriptionPropertyInfo, object descriptionPropertyValue, PropertyInfo userInterfacePropertyInfo, object userInterfaceInstance) { var descriptionValueType = CheckListAndGetValueType( descriptionPropertyInfo, typeof(KeyedDescription)); var userInterfaceValueType = CheckListAndGetValueType( userInterfacePropertyInfo, typeof(IBuildable)); var descriptionList = (IList)descriptionPropertyValue; if (descriptionList == null) { // nothing to do - the description is empty return; } var instanceList = (IList)userInterfacePropertyInfo.GetValue(userInterfaceInstance, null); if (instanceList == null) { throw new Exception("The UserInterfaceElement must be constructed with a valid Dictionary for " + userInterfacePropertyInfo.Name); } foreach (KeyedDescription description in descriptionList) { // now we can finally do the actual build of items... var builtUserInterfaceElement = Build(userInterfaceValueType, description); // so now need to insert the value into the target... if (builtUserInterfaceElement == null) { throw new Exception("Failed to build description " + description.Key + " as " + userInterfaceValueType.Name); } FixParent(builtUserInterfaceElement, userInterfaceInstance); try { instanceList.Add(builtUserInterfaceElement); } catch (Exception e) { DialogTrace.WriteLine("Problem adding to list {0} {1}", e.GetType().Name, e.Message); } } }
private void FillBuildableProperty(KeyedDescription description, object userInterfaceInstance, PropertyInfo buildablePropertyInfo) { var buildablePropertyValue = buildablePropertyInfo.GetValue(description, null); var userInterfacePropertyInfo = userInterfaceInstance.GetType().GetProperty(buildablePropertyInfo.Name); if (userInterfacePropertyInfo == null) { var props = userInterfaceInstance.GetType().GetProperties().Select(p => p.Name); var available = string.Join("'", props); DialogTrace.WriteLine("No User Interface member for description property {0} on {1}", buildablePropertyInfo.Name, available); return; } if (buildablePropertyInfo.PropertyType.GetTypeInfo().IsGenericType) { var genericPropertyType = buildablePropertyInfo.PropertyType.GetGenericTypeDefinition(); if (genericPropertyType == typeof(Dictionary <int, int>).GetGenericTypeDefinition()) { DialogTrace.WriteLine("Filling Dictionary {0}", buildablePropertyInfo.Name); FillDictionary(buildablePropertyInfo, buildablePropertyValue, userInterfacePropertyInfo, userInterfaceInstance); } else if (genericPropertyType == typeof(List <int>).GetGenericTypeDefinition()) { DialogTrace.WriteLine("Filling List {0}", buildablePropertyInfo.Name); FillList(buildablePropertyInfo, buildablePropertyValue, userInterfacePropertyInfo, userInterfaceInstance); } else { throw new Exception("Unexpected Generic Property Type " + buildablePropertyInfo.PropertyType); } } else { DialogTrace.WriteLine("Filling Element {0}", buildablePropertyInfo.Name); FillUserInterfaceElement(buildablePropertyInfo, buildablePropertyValue, userInterfacePropertyInfo, userInterfaceInstance); } }
public void RegisterConventionalKeys(Assembly assembly, string keyNamesEndWith = null) { keyNamesEndWith = keyNamesEndWith ?? ConventionalEnding; var elementTypes = assembly.GetTypes() .Where(t => t.Name.EndsWith(keyNamesEndWith)) .Where(t => !t.IsAbstract) .Where(t => Type.IsAssignableFrom(t)); foreach (var elementType in elementTypes) { var name = elementType.Name; if (name.EndsWith(keyNamesEndWith)) { name = name.Substring(0, name.Length - keyNamesEndWith.Length); } DialogTrace.WriteLine("Registering conventional type {0} {1}", name, elementType.Name); KnownKeys[name] = elementType; } }
private void UpdateVisibility() { var cell = CurrentAttachedCell; if (cell == null) { // no cell attached - but ask for update anyway // - this may update cached UIViews UpdateCellDisplay(cell); return; } var tableView = GetParentTableView(cell); if (tableView == null) { DialogTrace.WriteLine("How did this happen - CurrentAttachedCell is a child of a non-UITableView"); // no parented cell attached - but ask for update anyway // - this may update cached UIViews UpdateCellDisplay(cell); return; } var indexPath = tableView.IndexPathForCell(cell); if (indexPath == null) { // Indexpath can sometimes be null when replacing content of a list by setting a new RootElement. // It's a really rare situation, only seen when you perform several actions on a listview and it's // busy animating stuff. // In this case just do the simple update UpdateCellDisplay(cell); return; } // we have a table and an indexPath - so let's do an animated update tableView.ReloadRows( new[] { indexPath }, UITableViewRowAnimation.Fade); }
public virtual void FillProperty(object target, string targetPropertyName, object value) { var stringValue = value as string; if (stringValue != null) { if (stringValue.StartsWith(EscapedCustomPropertyIndicator)) { value = stringValue.Substring(EscapedCustomPropertyIndicator.Length); } else if (stringValue.StartsWith(CustomPropertyIndicator)) { FillCustomProperty(target, targetPropertyName, stringValue); return; } } var property = target.GetType().GetProperty(targetPropertyName); if (property == null) { DialogTrace.WriteLine("property {0} is not available on the receiver, skipping it", targetPropertyName); return; } if (property.PropertyType == typeof(Int32)) { var t = value.GetType(); if (t == typeof(Int64)) { value = (Int32)(Int64)value; } } else if (property.PropertyType == typeof(Dictionary <string, string>)) { value = FlattenToStringDictionary(value); } property.GetSetMethod().Invoke(target, new[] { value }); }