public override void OnComponentChanged(Object sender, ComponentChangedEventArgs ce)
        {
            base.OnComponentChanged(sender, ce);

            MemberDescriptor member = ce.Member;

            if (member != null &&
                member.GetType().FullName.Equals(Constants.ReflectPropertyDescriptorTypeFullName))
            {
                PropertyDescriptor propDesc = (PropertyDescriptor)member;

                switch (propDesc.Name)
                {
                case "ID":
                {
                    // Update the dictionary of device filters stored in the page designer
                    // setting to null will remove the entry.
                    IMobileWebFormServices.SetCache(ce.OldValue.ToString(), (Object)DefaultTemplateDeviceFilter, null);
                    break;
                }

                case "BackColor":
                case "ForeColor":
                case "Font":
                case "StyleReference":
                {
                    SetTemplateVerbsDirty();
                    break;
                }
                }
            }
        }
Beispiel #2
0
 private void RefreshPageView()
 {
     if (IMobileWebFormServices != null)
     {
         IMobileWebFormServices.RefreshPageView();
     }
 }
Beispiel #3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                UpdateActiveStyleSheet();

                if (_loadComplete != null)
                {
                    IWebFormsDocumentService.LoadComplete -= _loadComplete;
                    _loadComplete = null;
                }

                if (IMobileWebFormServices != null)
                {
                    // If the page is in loading mode, it means the remove is trigged by webformdesigner.
                    if (!LoadComplete)
                    {
                        IMobileWebFormServices.SetCache(_styleSheet.ID, (Object)_templateStyle, (Object)this.TemplateStyle);
                    }
                    else
                    {
                        // setting to null will remove the entry.
                        IMobileWebFormServices.SetCache(_styleSheet.ID, (Object)_templateStyle, null);
                    }
                }
            }

            base.Dispose(disposing);
        }
Beispiel #4
0
        /// <summary>
        ///   Update the designtime rendering for the container control and all controls
        ///   inside this container control.
        /// </summary>
        private void UpdateRenderingRecursive()
        {
            UpdateRendering();

            if (IMobileWebFormServices != null)
            {
                IMobileWebFormServices.UpdateRenderingRecursive(_mobileControl);
            }
        }
Beispiel #5
0
        /////////////////////////////////////////////////////////////////////////
        //  BEGIN STYLE DESIGNER EVENTHANDLERS
        /////////////////////////////////////////////////////////////////////////

        protected void OnShowStylesEditor(Object sender, EventArgs e)
        {
            IComponentChangeService changeService = null;

            changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            if (changeService != null)
            {
                try
                {
                    changeService.OnComponentChanging(_styleSheet, null);
                }
                catch (CheckoutException ex)
                {
                    if (ex == CheckoutException.Canceled)
                    {
                        return;
                    }
                    throw;
                }
            }

            DialogResult result = DialogResult.Cancel;

            try
            {
                StylesEditorDialog dialog = new StylesEditorDialog(_styleSheet, this, null);
                result = dialog.ShowDialog();
            }
            catch (ArgumentException ex)
            {
                Debug.Fail(ex.ToString());
                // Block user from entering StylesEditorDialog until they fix
                // duplicate style declarations.
            }
            finally
            {
                if (changeService != null)
                {
                    changeService.OnComponentChanged(_styleSheet, null, null, null);

                    if (IMobileWebFormServices != null)
                    {
                        IMobileWebFormServices.ClearUndoStack();
                    }
                }
            }
        }
        protected virtual void ShowTemplatingOptionsDialog()
        {
            IComponentChangeService changeService =
                (IComponentChangeService)GetService(typeof(IComponentChangeService));

            if (changeService != null)
            {
                try
                {
                    changeService.OnComponentChanging(_control, null);
                }
                catch (CheckoutException ex)
                {
                    if (ex == CheckoutException.Canceled)
                    {
                        return;
                    }
                    throw;
                }
            }

            try
            {
                TemplatingOptionsDialog dialog = new TemplatingOptionsDialog(
                    this,
                    _control.Site,
                    MobileControlDesigner.MergingContextTemplates);
                dialog.ShowDialog();
            }
            finally
            {
                if (changeService != null)
                {
                    changeService.OnComponentChanged(_control, null, null, null);

                    if (IMobileWebFormServices != null)
                    {
                        IMobileWebFormServices.ClearUndoStack();
                    }
                }
            }
        }
        /// <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);
            }
        }
Beispiel #8
0
        /// <summary>
        ///    <para>
        ///       Delegate to handle component changed event.
        ///    </para>
        /// </summary>
        /// <param name='sender'>
        ///    The object sending the event.
        /// </param>
        /// <param name='ce'>
        ///    The event object used when firing a component changed notification.
        /// </param>
        /// <remarks>
        ///    <para>
        ///       This is called after a property has been changed. It allows the implementor
        ///       to do any post-processing that may be needed after a property change.
        ///    </para>
        /// </remarks>
        public override void OnComponentChanged(Object sender, ComponentChangedEventArgs ce)
        {
            // Delegate to the base class implementation first!
            base.OnComponentChanged(sender, ce);

            MemberDescriptor member = ce.Member;

            if (member != null &&
                member.GetType().FullName.Equals(Constants.ReflectPropertyDescriptorTypeFullName))
            {
                PropertyDescriptor propDesc = (PropertyDescriptor)member;

                if (propDesc.Name.Equals("ID"))
                {
                    // Update the dictionary of device filters stored in the page designer
                    // setting to null will remove the entry.
                    IMobileWebFormServices.SetCache(ce.OldValue.ToString(), (Object)_templateStyle, null);
                }
            }
        }
        /// <summary>
        ///    <para>
        ///       Invokes the property builder beginning with the specified page.
        ///    </para>
        /// </summary>
        /// <param name='initialPage'>
        ///    The page to begin with.
        /// </param>
        protected internal void InvokePropertyBuilder(int initialPage)
        {
            IComponentChangeService changeService = null;
            bool result = false;

            changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            if (changeService != null)
            {
                try
                {
                    changeService.OnComponentChanging(_objectList, null);
                }
                catch (CheckoutException ex)
                {
                    if (ex == CheckoutException.Canceled)
                    {
                        return;
                    }
                    throw;
                }
            }

            try
            {
                ObjectListComponentEditor compEditor = new ObjectListComponentEditor(initialPage);
                result = compEditor.EditComponent(_objectList);
            }
            finally
            {
                if (changeService != null)
                {
                    changeService.OnComponentChanged(_objectList, null, null, null);

                    if (IMobileWebFormServices != null)
                    {
                        IMobileWebFormServices.ClearUndoStack();
                    }
                }
            }
        }
Beispiel #10
0
        ////////////////////////////////////////////////////////////////////////
        //  Begin Event Handling
        ////////////////////////////////////////////////////////////////////////

        private void OnEditFilters(Object sender, EventArgs e)
        {
            ISite componentSite = ((IComponent)(_designer.UnderlyingControl)).Site;

            Debug.Assert(componentSite != null, "Expected the runtime control to be sited.");

            IComponentChangeService changeService =
                (IComponentChangeService)componentSite.GetService(typeof(IComponentChangeService));

            IMobileWebFormServices wfServices =
                (IMobileWebFormServices)componentSite.GetService(typeof(IMobileWebFormServices));

            DialogResult result = DialogResult.Cancel;

            try
            {
                AppliedDeviceFiltersDialog dialog = new
                                                    AppliedDeviceFiltersDialog(
                    this,
                    _mergingContext
                    );

                result = dialog.ShowDialog();
            }
            finally
            {
                if (result != DialogResult.Cancel)
                {
                    SaveChoices();
                    SetDirty(false);

                    if (changeService != null)
                    {
                        changeService.OnComponentChanged(_designer.UnderlyingControl, null, null, null);
                    }
                }
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                DisposeTemplateVerbs();

                if (IMobileWebFormServices != null)
                {
                    // If the page is in loading mode, it means the remove is trigged by webformdesigner.
                    if (IWebFormsDocumentService.IsLoading)
                    {
                        IMobileWebFormServices.SetCache(_control.ID, (Object)DefaultTemplateDeviceFilter, (Object)this.TemplateDeviceFilter);
                    }
                    else
                    {
                        // setting to null will remove the entry.
                        IMobileWebFormServices.SetCache(_control.ID, (Object)DefaultTemplateDeviceFilter, null);
                    }
                }
            }

            base.Dispose(disposing);
        }
Beispiel #12
0
        /// <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.StyleSheet,
                         "StyleSheetDesigner.Initialize - Invalid StyleSheet Control");
            base.Initialize(component);

            _isDuplicate = false;
            _styleSheet  = (System.Web.UI.MobileControls.StyleSheet)component;
            if (_requiresDesignTimeChanges)
            {
                _shouldRepersistStyles = true;
            }
            _loadComplete = new EventHandler(this.OnLoadComplete);
            IWebFormsDocumentService.LoadComplete += _loadComplete;

            if (IMobileWebFormServices != null)
            {
                TemplateStyle        = (String)IMobileWebFormServices.GetCache(_styleSheet.ID, _templateStyle);
                TemplateDeviceFilter =
                    (String)IMobileWebFormServices.GetCache(
                        _styleSheet.ID,
                        MobileTemplatedControlDesigner.DefaultTemplateDeviceFilter);
            }
        }
Beispiel #13
0
        public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)
        {
            Debug.Assert(context.Instance is Control, "Expected control");
            Control ctrl = (Control)context.Instance;

            IServiceProvider serviceProvider;
            ISite            site = ctrl.Site;

            if (site == null && ctrl.Page != null)
            {
                site = ctrl.Page.Site;
            }
            if (site != null)
            {
                serviceProvider = site;
            }
            else
            {
                serviceProvider = provider;
            }
            Debug.Assert(serviceProvider != null,
                         "Failed to get the serviceProvider");

            IComponentChangeService changeService =
                (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService));

            IDesignerHost designerHost =
                (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));

            Debug.Assert(designerHost != null,
                         "Must always have access to IDesignerHost service");

            IDeviceSpecificDesigner dsDesigner =
                designerHost.GetDesigner(ctrl) as IDeviceSpecificDesigner;

            Debug.Assert(dsDesigner != null,
                         "Expected component designer to implement IDeviceSpecificDesigner");

            IMobileWebFormServices wfServices =
                (IMobileWebFormServices)serviceProvider.GetService(typeof(IMobileWebFormServices));

            DialogResult result = DialogResult.Cancel;

            DesignerTransaction transaction = designerHost.CreateTransaction(_propertyOverridesDescription);

            try
            {
                if (changeService != null)
                {
                    try
                    {
                        changeService.OnComponentChanging(ctrl, null);
                    }
                    catch (CheckoutException ce)
                    {
                        if (ce == CheckoutException.Canceled)
                        {
                            return(value);
                        }
                        throw;
                    }
                }

                try
                {
                    PropertyOverridesDialog dialog = new PropertyOverridesDialog(
                        dsDesigner,
                        MobileControlDesigner.MergingContextProperties
                        );
                    IWindowsFormsEditorService edSvc =
                        (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    result = edSvc.ShowDialog(dialog);
                }
                catch (InvalidChoiceException e)
                {
                    Debug.Fail(e.ToString());
                }
                finally
                {
                    if (changeService != null && result != DialogResult.Cancel)
                    {
                        changeService.OnComponentChanged(ctrl, null, null, null);
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    if (result == DialogResult.OK)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Cancel();
                    }
                }
            }

            return(value);
        }