Ejemplo n.º 1
0
 internal static void ApplyPropertyValues(MobileControl mobileControl, Hashtable overrides)
 {
     if ((mobileControl != null) && (overrides != null))
     {
         IDictionaryEnumerator enumerator = overrides.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int num;
             string str2;
             object obj2 = mobileControl;
             string key = (string) enumerator.Key;
             object obj3 = enumerator.Value;
             if (!(key.ToLower() == "id"))
             {
                 goto Label_006A;
             }
             continue;
         Label_0039:
             str2 = key.Substring(0, num);
             obj2 = obj2.GetType().GetProperty(str2, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase).GetValue(obj2, null);
             key = key.Substring(num + 1);
         Label_006A:
             if ((num = key.IndexOf("-")) != -1)
             {
                 goto Label_0039;
             }
             FindAndApplyPropertyValue(obj2, key, obj3);
         }
     }
 }
Ejemplo n.º 2
0
 internal static unsafe void WriteDesignerStyleAttributes(HtmlMobileTextWriter writer, MobileControl control, Style style)
 {
     Alignment alignment = *((Alignment*) style.get_Item(Style.AlignmentKey, true));
     Wrapping wrapping = *((Wrapping*) style.get_Item(Style.WrappingKey, true));
     Color c = (Color) style.get_Item(Style.BackColorKey, true);
     bool flag = alignment != 0;
     bool flag2 = (wrapping == 1) || (wrapping == 0);
     string str = "100%";
     if (!flag2)
     {
         writer.Write(" style=\"overflow-x:hidden;width:" + str);
     }
     else
     {
         writer.Write(" style=\"word-wrap:break-word;overflow-x:hidden;width:" + str);
     }
     if (c != Color.Empty)
     {
         writer.Write(";background-color:" + ColorTranslator.ToHtml(c));
     }
     if (flag)
     {
         writer.Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment));
     }
 }
        /* Removed for DCR 4240
        internal static bool IsValidName(String name)
        {
            if (name == null || name.Length == 0)
            {
                return false;
            }

            for (int pos = 0; pos < name.Length; pos++)
            {
                Char ch = name[pos];
                if (Char.IsWhiteSpace(ch) || ch.Equals('"') || ch.Equals('<') || 
                    ch.Equals('>') || ch.Equals('\'') || ch.Equals('&'))
                {
                    return false;
                }
            }
            return true;
        }
        */

        internal static bool TopLevelControl(MobileControl control)
        {
            if (control is Form || control is StyleSheet)
            {
                return true;
            }
            return false;
        }
Ejemplo n.º 4
0
 protected MobileControl GetBaseControl()
 {
     if (this._control == null)
     {
         IComponent selectedComponent = base.GetSelectedComponent();
         this._control = (MobileControl) selectedComponent;
     }
     return this._control;
 }
Ejemplo n.º 5
0
 private Control FindContainer(MobileControl mc, Type containerType)
 {
     for (Control control = mc; control != null; control = control.Parent)
     {
         if (containerType.IsAssignableFrom(control.GetType()))
         {
             return control;
         }
     }
     return null;
 }
        internal void WriteDesignerStyleAttributes(MobileControl control, 
            Style style)
        {
            Alignment alignment = (Alignment) style[Style.AlignmentKey, true];
            Wrapping wrapping = (Wrapping) style[Style.WrappingKey, true];
            Color backColor = (Color) style[Style.BackColorKey, true];

            bool align  = (alignment != Alignment.NotSet);
            bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

            String width = DesignerAdapterUtil.GetWidth(control);

            byte templateStatus;
            int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(control, out templateStatus);
            if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
            {
                width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
            }

            if (!wrap)
            {
                Write(" style=\"overflow-x:hidden;width:" + width);
            }
            else
            {
                Write(" style=\"word-wrap:break-word;overflow-x:hidden;width:" + width);
            }

            if (backColor != Color.Empty)
            {
                Write(";background-color:" + ColorTranslator.ToHtml(backColor));
            }

            if (align)
            {
                Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment));
            }
        }
        internal void SetSecondaryUIMode(MobileControl control, int mode) {
            if (mode != NotSecondaryUI) {

                if (_secondaryUIControl != null && _secondaryUIControl != control) {
                    throw new Exception(
                        SR.GetString(SR.FormAdapterMultiControlsAttemptSecondaryUI));
                }
                _secondaryUIControl = control;
                _secondaryUIMode = mode;
                return;
            }

            if (control == _secondaryUIControl) {

                _secondaryUIControl = null;
            }
        }
 internal int GetSecondaryUIMode(MobileControl control) {
     return (control != null && _secondaryUIControl == control) ? _secondaryUIMode : NotSecondaryUI;
 }
        /// <summary>
        ///    <para>
        ///       Initializes the designer.
        ///    </para>
        /// </summary>
        /// <param name='component'>
        ///    The control element being designed.
        /// </param>
        /// <remarks>
        ///    <para>
        ///       This is called by the designer host to establish the component being
        ///       designed.
        ///    </para>
        /// </remarks>
        /// <seealso cref='System.ComponentModel.Design.IDesigner'/>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component is System.Web.UI.MobileControls.MobileControl ||
                         component is System.Web.UI.MobileControls.DeviceSpecific,
                         "MobileTemplatedControlDesigner.Initialize - Invalid (Mobile) Control");

            base.Initialize(component);

            if (component is System.Web.UI.MobileControls.MobileControl)
            {
                _mobileControl = (System.Web.UI.MobileControls.MobileControl) component;
            }
            // else the component is a DeviceSpecific control
            _control = (System.Web.UI.Control) component;

            if (IMobileWebFormServices != null)
            {
                this.TemplateDeviceFilter = (String) IMobileWebFormServices.GetCache(_control.ID, (Object)DefaultTemplateDeviceFilter);
            }
        }
Ejemplo n.º 10
0
 /// <include file='doc\MobilePage.uex' path='docs/doc[@for="MobilePage.GetControlAdapter"]/*' />
 public virtual IControlAdapter GetControlAdapter(MobileControl control)
 {
     IControlAdapter adapter = RequestingDeviceConfig.NewControlAdapter(control.GetType ());
     adapter.Control = control;
     return adapter;
 }
Ejemplo n.º 11
0
 internal void AddClientViewState(MobileControl control, Object viewState)
 {
     AddClientViewState(control.UniqueID, viewState);
 }
Ejemplo n.º 12
0
 internal static void SetDeviceSpecificChoice(MobileControl mobileControl, DeviceSpecificChoice choice)
 {
     typeof(DeviceSpecific).InvokeMember("SetDesignerChoice", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, mobileControl.get_DeviceSpecific(), new object[] { choice });
 }
        /// <summary>
        ///    <para>
        ///       Initializes the designer with the component for design.
        ///    </para>
        /// </summary>
        /// <param name='component'>
        ///    The control element for design.
        /// </param>
        /// <remarks>
        ///    <para>
        ///       This is called by the designer host to establish the component for
        ///       design.
        ///    </para>
        /// </remarks>
        /// <seealso cref='System.ComponentModel.Design.IDesigner'/>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component is System.Web.UI.MobileControls.MobileControl,
                "MobileControlDesigner.Initialize - Invalid MobileControl Control");

            base.Initialize(component);

            _mobileControl = (System.Web.UI.MobileControls.MobileControl) component;
        }
Ejemplo n.º 14
0
 public override void Initialize(IComponent component)
 {
     this._textControl = (MobileControl) component;
     base.Initialize(component);
 }
        internal static  int GetMaxWidthToFit(MobileControl control, out byte templateStatus)
        {
            IDesigner parentDesigner = ControlDesigner(control.Parent);
            IDesigner controlDesigner = ControlDesigner(control);
            int defaultControlWidthInTemplate;

            NativeMethods.IHTMLElement2 htmlElement2Parent = null;
            
            if (controlDesigner == null)
            {
                templateStatus = CONTROL_IN_TEMPLATE_NONEDIT;
                return 0;
            }
            Debug.Assert(controlDesigner is MobileControlDesigner ||
                         controlDesigner is MobileTemplatedControlDesigner, 
                         "controlDesigner is not MobileControlDesigner or MobileTemplatedControlDesigner");

            templateStatus = 0x00;
            if (parentDesigner is MobileTemplatedControlDesigner)
            {
                htmlElement2Parent =
                    (NativeMethods.IHTMLElement2) 
                    ((MobileTemplatedControlDesigner) parentDesigner).DesignTimeElementInternal;
            }
            else if (parentDesigner is MobileContainerDesigner)
            {
                htmlElement2Parent =
                    (NativeMethods.IHTMLElement2) 
                    ((MobileContainerDesigner) parentDesigner).DesignTimeElementInternal;
            }

            bool inTemplate;
            int nestingLevel = DesignerAdapterUtil.NestingLevel(control, out inTemplate, out defaultControlWidthInTemplate);
            if (inTemplate)
            {
                templateStatus = CONTROL_IN_TEMPLATE_EDIT;
            }

            if (htmlElement2Parent != null)
            {
                int maxWidth;
                if (!inTemplate)
                {
                    Debug.Assert(control.Parent is MobileControl);
                    Style parentStyle = ((MobileControl) control.Parent).Style;
                    Alignment alignment = (Alignment) parentStyle[Style.AlignmentKey, true];
                    int parentChildOffset=0;

                    // AUI 2786
                    if (alignment != Alignment.NotSet && alignment != Alignment.Left)
                    {
                        parentChildOffset = _regularParentChildOffset;
                    }
                    else
                    {
                        NativeMethods.IHTMLRectCollection rectColl = null;
                        NativeMethods.IHTMLRect rect = null;
                        int index = 0;
                        Object obj = index;

                        NativeMethods.IHTMLElement2 htmlElement2;
                        
                        if (controlDesigner is MobileControlDesigner)
                        { 
                            htmlElement2 = (NativeMethods.IHTMLElement2) ((MobileControlDesigner) controlDesigner).DesignTimeElementInternal;
                        }
                        else
                        {
                            htmlElement2 = (NativeMethods.IHTMLElement2) ((MobileTemplatedControlDesigner) controlDesigner).DesignTimeElementInternal;
                        }

                        if (null == htmlElement2)
                        {
                            return 0;
                        }

                        try
                        {
                            rectColl = htmlElement2.GetClientRects();
                        }
                        catch (Exception)
                        {
                            // this happens when switching from Design view to HTML view
                            return 0;
                        }

                        if( rectColl.GetLength() >= 1)
                        {
                            rect = (NativeMethods.IHTMLRect)rectColl.Item(ref obj);
                            parentChildOffset = rect.GetLeft();

                            rectColl = htmlElement2Parent.GetClientRects();
                            //Debug.Assert(rectColl.GetLength() == 1);
                            rect = (NativeMethods.IHTMLRect) rectColl.Item(ref obj);
                            parentChildOffset -= rect.GetLeft();
                        }
                    }

                    maxWidth = GetLength(htmlElement2Parent) - _marginWidth - parentChildOffset;
                    if (maxWidth > 0 && maxWidth > _defaultContainerWidth - nestingLevel * _marginPerLevel)
                    {
                        maxWidth = _defaultContainerWidth - nestingLevel * _marginPerLevel;
                    }
                }
                else
                {
                    int parentWidth = GetLength(htmlElement2Parent);
                    if (parentWidth == 0)
                    {
                        // AUI 4525
                        maxWidth = defaultControlWidthInTemplate;
                    }
                    else
                    {
                        maxWidth = parentWidth - _templateParentChildOffset;
                    }

                    if (maxWidth > 0 && maxWidth > defaultControlWidthInTemplate - nestingLevel * _marginPerLevel)
                    {
                        maxWidth = defaultControlWidthInTemplate - nestingLevel * _marginPerLevel;
                    }
                }
                return maxWidth;
            }
            return 0;
        }
 private bool IsAncestor(MobileControl ancestor, MobileControl descendant) {
     for (Control i = descendant; i != null; i = i.Parent) {
         if (i == ancestor) {
             return true;
         }
     }
     return false;
 }
        protected MobileControl GetBaseControl()
        {
            if (_control != null)
            {
                return _control;
            }

            IComponent selectedComponent = GetSelectedComponent();
            Debug.Assert(selectedComponent is MobileControl);
            _control = (MobileControl)selectedComponent;

            return _control;
        }
Ejemplo n.º 18
0
 internal static Style MapToWebControlStyle(MobileControl control)
 {
     object target = typeof(MobileControl).InvokeMember("Style", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, control, null);
     Style style = new Style();
     typeof(Style).InvokeMember("ApplyTo", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, target, new object[] { style });
     return style;
 }
Ejemplo n.º 19
0
 internal static void SetDeviceSpecificOwner(DeviceSpecific deviceSpecific, MobileControl control)
 {
     typeof(DeviceSpecific).InvokeMember("SetOwner", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, deviceSpecific, new object[] { control });
 }
 // Used for Secondary UI.
 private bool IsControlInFormHeader(MobileControl control) {
     return IsAncestor(Control.Header, control);
 }
Ejemplo n.º 21
0
 private StyleSheet GetContainingStyleSheet(MobileControl mc)
 {
     return FindContainer(mc, typeof(StyleSheet)) as StyleSheet;
 }
 // Used for Secondary UI.
 private bool IsControlInFormFooter(MobileControl control) {
     return IsAncestor(Control.Footer, control);
 }
Ejemplo n.º 23
0
 internal static void RefreshMobileControlStyle(MobileControl control)
 {
     typeof(MobileControl).InvokeMember("RefreshStyle", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, control, null);
 }
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.GetCustomAttributeValue1"]/*' />
 protected virtual String GetCustomAttributeValue(MobileControl control, String attributeName) {
     return((IAttributeAccessor)control).GetAttribute(attributeName);
 }
 internal String GetControlPostBackValue(MobileControl ctl)
 {
     WmlControlAdapter adapter = ctl.Adapter as WmlControlAdapter;
     return adapter != null ? adapter.GetPostBackValue() : null;
 }
Ejemplo n.º 26
0
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     this._mobileControl = (MobileControl) component;
     this._defaultValues = new Hashtable();
     this._overridenValues = new Hashtable();
     this._deviceSpecificSelectionProvider = (IDeviceSpecificSelectionProvider) this.GetService(typeof(IDeviceSpecificSelectionProvider));
     this.InitializeDefaultProperties();
     this.InitializeOverridenProperties();
     if (this._deviceSpecificSelectionProvider != null)
     {
         this._deviceSpecificSelectionProvider.SelectionChanged += new EventHandler(this.OnHostDeviceSpecificChanged);
         this.ActiveDeviceFilter = this._deviceSpecificSelectionProvider.CurrentFilter;
         if (this._mobileControl.get_DeviceSpecific() != null)
         {
             foreach (DeviceSpecificChoice choice in this._mobileControl.get_DeviceSpecific().get_Choices())
             {
                 string filterName = Utils.CreateUniqueChoiceName(choice);
                 if (!this._deviceSpecificSelectionProvider.FilterExists(filterName))
                 {
                     this._deviceSpecificSelectionProvider.AddFilter(filterName);
                 }
             }
         }
     }
     this.PrepareProperties();
     IDesignerHost service = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (service != null)
     {
         service.LoadComplete += new EventHandler(this.OnLoadComplete);
     }
 }
Ejemplo n.º 27
0
        /// <include file='doc\ItemPager.uex' path='docs/doc[@for="ItemPager.ItemPager1"]/*' />
        public ItemPager(ControlPager pager, MobileControl control, int itemCount, int itemsPerPage, int itemWeight)
        {
            _control = control;

            if (itemsPerPage > 0)
            {
                // User-specified pagination behavior, always given
                // number of items per page.

                if (itemCount < itemsPerPage)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage = _lastPage = pager.GetPage(itemCount * itemWeight);
                }
                else
                {
                    int numberOfPages = (itemCount - 1) / itemsPerPage + 1;
                    _firstPageItemCount = itemsPerPage;
                    _fullPageItemCount = itemsPerPage;
                    _lastPageItemCount = itemCount - (numberOfPages - 1) * itemsPerPage;
                    _firstPage = pager.GetPage(itemsPerPage * itemWeight);
                    pager.PageCount += numberOfPages - 1;
                    if (numberOfPages > 1)
                    {
                        pager.RemainingWeight = Math.Max(0, pager.PageWeight - _lastPageItemCount * itemWeight);
                    }
                    _lastPage = _firstPage + numberOfPages - 1;
                }
            }
            else
            {
                int totalItemWeight = itemCount * itemWeight;
                if (totalItemWeight <= pager.RemainingWeight)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage = _lastPage = pager.GetPage(totalItemWeight);
                }
                else
                {
                    _firstPageItemCount = pager.RemainingWeight / itemWeight;
                    int remainingItemCount = itemCount - _firstPageItemCount;
                    _fullPageItemCount  = Math.Max(1, pager.PageWeight / itemWeight);
                    int fullPageCount = remainingItemCount / _fullPageItemCount;
                    _lastPageItemCount  = remainingItemCount % _fullPageItemCount;
    
                    _firstPage = pager.PageCount;
    
                    //  increment for first page
                    pager.PageCount++;
                    pager.RemainingWeight = pager.PageWeight;
    
                    //  increment for full pages
                    pager.PageCount += fullPageCount;
    
                    //  remove remaining weight for last page
                    pager.RemainingWeight -= _lastPageItemCount * itemWeight;
    
                    //  correct if first page is empty
                    if (_firstPageItemCount == 0)
                    {
                        _firstPage++;
                        _firstPageItemCount = Math.Min(_fullPageItemCount, itemCount);
                    }
                    //  correct if last page is empty
                    if (_lastPageItemCount == 0)
                    {
                        pager.PageCount--;
                        _lastPageItemCount = Math.Min(_fullPageItemCount, itemCount);
                        pager.RemainingWeight = 0;
                    }
                    _lastPage = pager.PageCount;
                }
            }
            _control.FirstPage = _firstPage;
            _control.LastPage = _lastPage;
        }
Ejemplo n.º 28
0
 private Form GetContainingForm(MobileControl mc)
 {
     return FindContainer(mc, typeof(Form)) as Form;
 }
Ejemplo n.º 29
0
 internal void SetControl(MobileControl control)
 {
     _control = control;
     _cachedParentStyle = null;
 }
Ejemplo n.º 30
0
 /// <include file='doc\MobilePage.uex' path='docs/doc[@for="MobilePage.GetPrivateViewState"]/*' />
 public Object GetPrivateViewState(MobileControl ctl)
 {
     return _privateViewState == null ?
         null :
         _privateViewState[ctl.UniqueID];
 }
Ejemplo n.º 31
0
 protected virtual void OnPageChange(int oldPageIndex, int newPageIndex)
 {
     MobileControl.OnPageChangeRecursive(this, oldPageIndex, newPageIndex);
 }