Esempio n. 1
0
 public virtual void RemoveNativeChildView(UIElement view)
 {
     if (this.NativeUIElement != null)
     {
         ((ViewGroup)this.NativeUIElement).RemoveView(view.NativeUIElement);
     }
 }
Esempio n. 2
0
 private static bool ChechFocus(UIElement element)
 {
     // An element might have NativeUIElement set to null,
     // because a control could not be presented by a descendant of UIView.
     var nativeElement = element.NativeUIElement;
     return nativeElement != null && nativeElement.IsFirstResponder;
 }
Esempio n. 3
0
 protected void RemoveNativeChildView(UIElement child)
 {
     this.NativeUIElement.InvokeOnMainThread(() =>
     {
         child.NativeUIElement.RemoveFromSuperview();
     });
 }
Esempio n. 4
0
 internal static IEnumerator GetLogicalChildren(DependencyObject current)
 {
     Appercode.UI.Controls.UIElement currentUIElement = current as Appercode.UI.Controls.UIElement;
     if (currentUIElement != null)
     {
         return(currentUIElement.LogicalChildren);
     }
     return(null);
 }
Esempio n. 5
0
        internal object GetRawValue(DependencyObject d, out object source, DependencyProperty dp)
        {
            Appercode.UI.Controls.UIElement frameworkElement = null;
            object unsetValue = null;

            source = null;
            if (!this.ReadInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid))
            {
                ////this.mentorCache = Helper.FindMentor(d);
                this.WriteInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid, true);
                if (this.mentorCache != null && this.mentorCache != this.targetObject)
                {
                    ////Helper.DowncastToFEorFCE(this.mentorCache, out frameworkElement, out frameworkContentElement, true);
                    if (frameworkElement != null)
                    {
                        frameworkElement.ResourcesChanged += new EventHandler(this.InvalidateExpressionValue);
                    }
                }
            }

            /*
             * if (this.mentorCache == null)
             * {
             *  //unsetValue = Helper.FindResourceFromAppOrSystem(this.resourceKey, out source, false, true, false) ?? DependencyProperty.UnsetValue;
             * }
             * else
             * {
             *  //Helper.DowncastToFEorFCE(this.mentorCache, out frameworkElement1, out frameworkContentElement1, true);
             *  //unsetValue = UIElement.FindResourceInternal(frameworkElement1, frameworkContentElement1, dp, this.resourceKey, null, true, false, null, false, out source);
             * }
             */

            if (unsetValue == null)
            {
                unsetValue = DependencyProperty.UnsetValue;
            }
            this.cachedResourceValue = unsetValue;
            this.WriteInternalState(ResourceReferenceExpression.InternalState.HasCachedResourceValue, true);
            object value = unsetValue;
            DeferredResourceReference deferredResourceReference = unsetValue as DeferredResourceReference;

            if (deferredResourceReference != null)
            {
                if (deferredResourceReference.IsInflated)
                {
                    value = deferredResourceReference.Value as Freezable;
                }
                else if (!this.ReadInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated))
                {
                    deferredResourceReference.AddInflatedListener(this);
                    this.WriteInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated, true);
                }
            }
            this.ListenForFreezableChanges(value);
            return(unsetValue);
        }
 internal void Disconnect()
 {
     if (this.mentor == null)
     {
         return;
     }
     this.mentor.DataContextChanged -= new DataContextChangedEventHandler(this.MentorDataContextChanged);
     this.mentor = null;
     this.weakListener = null;
 }
Esempio n. 7
0
 protected void AddNativeChildView(UIElement child)
 {
     if (this.NativeUIElement != null)
     {
         this.NativeUIElement.InvokeOnMainThread(() =>
         {
             child.NativeUIElement.RemoveFromSuperview();
             this.NativeUIElement.AddSubview(child.NativeUIElement);
         });
     }
 }
Esempio n. 8
0
 public static void AddLogicalChild(DependencyObject parent, object child)
 {
     if (child != null && parent != null)
     {
         Appercode.UI.Controls.UIElement parentUIElement = parent as Appercode.UI.Controls.UIElement;
         if (parentUIElement != null)
         {
             parentUIElement.AddLogicalChild(child);
             return;
         }
     }
 }
Esempio n. 9
0
        /*Group*/
        protected override View CreateLayoutControl(UIElement value)
        {
            LogicalTreeHelper.AddLogicalChild(this, value);
            var innerLayoutControl = new NativeScrollViewer(this.Context);
            innerLayoutControl.ScrollChanged += innerDefaultControl_ScrollChanged;
            innerLayoutControl.LayoutParameters = this.CreateLayoutParams();
            innerLayoutControl.ChildView = value.NativeUIElement;
            SetBackground();
            this.ContentNativeUIElement = innerLayoutControl;

            return this.ContentNativeUIElement;
        }
Esempio n. 10
0
 public virtual void AddNativeChildView(UIElement view)
 {
     if (this.NativeUIElement != null)
     {
         var wvg = this.NativeUIElement as WrapedViewGroup;
         if (wvg != null)
         {
             wvg.AddViewInLayoutOverride(view.NativeUIElement);
             return;
         }
         ((ViewGroup)this.NativeUIElement).AddView(view.NativeUIElement);
     }
 }
Esempio n. 11
0
        public static IEnumerable GetChildren(DependencyObject current)
        {
            if (current == null)
            {
                throw new ArgumentNullException("current");
            }

            Appercode.UI.Controls.UIElement currentUIElement = current as Appercode.UI.Controls.UIElement;
            if (currentUIElement != null)
            {
                return(new LogicalTreeHelper.EnumeratorWrapper(currentUIElement.LogicalChildren));
            }
            return(EnumeratorWrapper.Empty);
        }
Esempio n. 12
0
        public static DependencyObject GetParent(DependencyObject current)
        {
            if (current == null)
            {
                throw new ArgumentNullException("current");
            }

            Appercode.UI.Controls.UIElement currentUIElement = current as Appercode.UI.Controls.UIElement;
            if (currentUIElement != null)
            {
                return(currentUIElement.Parent);
            }
            return(null);
        }
Esempio n. 13
0
 private static object GetFocusedChild(UIElement element)
 {
     if (ChechFocus(element))
     {
         return element;
     }
     var children = LogicalTreeHelper.GetChildren(element);
     foreach (var child in children)
     {
         if (child is UIElement)
         {
             var focused = GetFocusedChild((UIElement)child);
             if (focused != null)
             {
                 return focused;
             }
         }
     }
     return null;
 }
Esempio n. 14
0
        public static DependencyObject FindLogicalNode(DependencyObject logicalTreeNode, string elementName)
        {
            if (logicalTreeNode == null)
            {
                throw new ArgumentNullException("logicalTreeNode");
            }
            if (elementName == null)
            {
                throw new ArgumentNullException("elementName");
            }
            if (elementName == string.Empty)
            {
                throw new ArgumentException("Parameter cannot be a zero-length string.", "elementName");
            }

            DependencyObject logicalNode = null;

            Appercode.UI.Controls.UIElement logicalTreeNodeUIElement = logicalTreeNode as Appercode.UI.Controls.UIElement;
            if (logicalTreeNodeUIElement != null && logicalTreeNodeUIElement.Name == elementName)
            {
                logicalNode = logicalTreeNode;
            }
            if (logicalNode == null)
            {
                IEnumerator logicalChildren = LogicalTreeHelper.GetLogicalChildren(logicalTreeNode);
                if (logicalChildren != null)
                {
                    logicalChildren.Reset();
                    while (logicalNode == null && logicalChildren.MoveNext())
                    {
                        DependencyObject current = logicalChildren.Current as DependencyObject;
                        if (current == null)
                        {
                            continue;
                        }
                        logicalNode = LogicalTreeHelper.FindLogicalNode(current, elementName);
                    }
                }
            }
            return(logicalNode);
        }
Esempio n. 15
0
 private void InvalidateMentorCache()
 {
     Appercode.UI.Controls.UIElement frameworkElement = null;
     if (this.ReadInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid))
     {
         if (this.mentorCache != null)
         {
             if (this.mentorCache != this.targetObject)
             {
                 ////Helper.DowncastToFEorFCE(this.mentorCache, out frameworkElement, out frameworkContentElement, true);
                 if (frameworkElement != null)
                 {
                     frameworkElement.ResourcesChanged -= new EventHandler(this.InvalidateExpressionValue);
                 }
             }
             this.mentorCache = null;
         }
         this.WriteInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid, false);
     }
     this.InvalidateCacheValue();
 }
        internal static void AddNodeToLogicalTree(DependencyObject parent, Type type, bool treeNodeIsFE, Appercode.UI.Controls.UIElement treeNodeFE, Appercode.UI.Controls.UIElement treeNodeFCE)
        {
            Appercode.UI.Controls.UIElement frameworkContentElement = parent as Appercode.UI.Controls.UIElement;
            if (frameworkContentElement != null)
            {
                IEnumerator logicalChildren = frameworkContentElement.LogicalChildren;
                if (logicalChildren != null && logicalChildren.MoveNext())
                {
                    throw new InvalidOperationException("AlreadyHasLogicalChildren");
                }
            }
            IAddChild addChild = parent as IAddChild;

            if (addChild == null)
            {
                throw new InvalidOperationException("CannotHookupFCERoot");
            }
            if (treeNodeFE != null)
            {
                addChild.AddChild(treeNodeFE);
                return;
            }
            addChild.AddChild(treeNodeFCE);
        }
 // float rowHeight = -1;
 //            public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
 //            {
 ////                if (indexPath.Row >= this.listItems.Count)
 ////                {
 ////                    var listItem = (UIElement)this.panel.Generator.Generate(indexPath.Row);
 ////                    LogicalTreeHelper.AddLogicalChild(this.panel, listItem);
 ////                
 ////                    var availableSize = this.panel.Orientation == Orientation.Horizontal
 ////                        ? new SizeF(float.PositiveInfinity, this.panel.measuredSize.Height)
 ////                        : new SizeF(this.panel.measuredSize.Width, float.PositiveInfinity);
 ////
 ////                    listItem.MeasureOverride(availableSize);
 ////                    this.listItems.Add(listItem);
 ////                }
 ////                else
 ////                {
 ////                    this.listItems[indexPath.Row] = this.panel.Generator.Reuse(indexPath.Row, this.listItems[indexPath.Row]);
 ////                }
 ////
 ////                return this.listItems[indexPath.Row].measuredSize.Height;
 //
 //                if(rowHeight == -1)
 //                {
 //                    var listItem = (UIElement)this.panel.Generator.Generate(indexPath.Row);
 //                    LogicalTreeHelper.AddLogicalChild(this.panel, listItem);
 //                
 //                    var availableSize = this.panel.Orientation == Orientation.Horizontal
 //                        ? new SizeF(float.PositiveInfinity, this.panel.measuredSize.Height)
 //                        : new SizeF(this.panel.measuredSize.Width, float.PositiveInfinity);
 //
 //                    rowHeight = listItem.MeasureOverride(availableSize).Height;
 //                    this.listItems.Add(listItem);
 //                }
 //
 //                return rowHeight;
 //            }
 public virtual CGSize MeasureItemAt(int index, CGSize availableSize)
 {
     if (measurementListItem == null)
     {
         measurementListItem = (UIElement)this.panel.Generator.Generate(index);
         LogicalTreeHelper.AddLogicalChild(this.panel, measurementListItem);
     }
     else
     {
         measurementListItem = this.panel.Generator.Reuse(index, measurementListItem);
     }
     return measurementListItem.MeasureOverride(availableSize);
 }
Esempio n. 18
0
 internal static void AddCustomTemplateRoot(Appercode.UI.Controls.UIElement container, Appercode.UI.Controls.UIElement uiElement)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
 internal void RemoveNativeChildView(UIElement item)
 {
 }
 private void NativeTemplateUpdate(UIElement oldValue, UIElement value)
 {
 }
 private WeakDataContextChangedListener(UIElement source, IDataContextChangedListener listener)
 {
     this.mentor = source;
     this.mentor.DataContextChanged += new DataContextChangedEventHandler(this.MentorDataContextChanged);
     this.weakListener = new WeakReference(listener);
 }
Esempio n. 22
0
 private void UpdateProperties(UIElement child)
 {
     child.NativeInit();
     var children = LogicalTreeHelper.GetChildren(child);
     foreach (var item in children)
     {
         if (item is UIElement)
         {
             this.UpdateProperties((UIElement)item);
         }
     }
     child.OnLoaded();
 }
 public UiElementTuple(UIElement element, int index)
 {
     this.Element = element;
     this.Index = index;
 }
Esempio n. 24
0
 private static bool ChechFocus(UIElement element)
 {
     return false;
 }
 public void ArrangeItemAtPosition(UIElement child, int index)
 {
     child.MeasureOverride(this.arrangedSize);
     var rect = new RectangleF(new PointF(index * this.arrangedSize.Width, 0), this.arrangedSize);
     child.Arrange(rect);
 }
Esempio n. 26
0
 private void OnNativeContentChanged(UIElement oldValue, UIElement newValue)
 {
 }
 private void ArrangeItemAtPosition(UIElement res, int position)
 {
 }
Esempio n. 28
0
 internal void AddNativeChildView(UIElement item)
 {
 }
 public void ArrangeItemAtPosition(UIElement child, int index)
 {
     child.MeasureOverride(this.arrangedSize);
     child.Arrange(this.GetChildRect(index));
 }