Exemplo n.º 1
0
        void IDeviceSpecificDesigner.SetDeviceSpecific(String deviceSpecificParentID, DeviceSpecific ds)
        {
            Style style = (Style)_styleSheet[deviceSpecificParentID];

            Debug.Assert(null != style, "style is null in IDeviceSpecificDesigner.SetDeviceSpecific");
            if (null != ds)
            {
                ds.SetOwner((MobileControl)_styleSheet);
            }
            style.DeviceSpecific = ds;

            if (CurrentChoice != null && 0 == String.Compare(CurrentStyle.Name, deviceSpecificParentID, StringComparison.OrdinalIgnoreCase))
            {
                if (ds == null)
                {
                    CurrentChoice = null;
                }
                else
                {
                    // This makes sure that the CurrentChoice value is set to null is
                    // it was deleted during the deviceSpecific object editing
                    if (CurrentChoice.Filter.Length == 0)
                    {
                        TemplateDeviceFilter = SR.GetString(SR.DeviceFilter_DefaultChoice);
                    }
                    else
                    {
                        TemplateDeviceFilter = DesignerUtility.ChoiceToUniqueIdentifier(CurrentChoice);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void FillChoicesComboBox()
        {
            Debug.Assert(_dsd != null);

            _cmbChoices.Items.Clear();

            if (null != _ds || null != _dsd.UnderlyingObject)
            {
                _cmbChoices.Items.Add(SR.GetString(SR.DeviceFilter_NoChoice));
            }

            if (null == _ds)
            {
                if (_cmbChoices.Items.Count > 0)
                {
                    _cmbChoices.SelectedIndex = 0;
                }
            }
            else
            {
                bool addedDefault = false;
                foreach (DeviceSpecificChoice choice in _ds.Choices)
                {
                    if (String.Empty == choice.Filter)
                    {
                        if (!addedDefault)
                        {
                            _cmbChoices.Items.Add(SR.GetString(SR.DeviceFilter_DefaultChoice));
                            addedDefault = true;
                        }
                    }
                    else
                    {
                        if (!choice.Filter.Equals(SR.GetString(SR.DeviceFilter_NoChoice)))
                        {
                            _cmbChoices.Items.Add(DesignerUtility.ChoiceToUniqueIdentifier(choice));
                        }
                    }
                }
                if (null != _designer.CurrentChoice && _designer.CurrentDeviceSpecific == _ds)
                {
                    if (String.Empty == _designer.CurrentChoice.Filter)
                    {
                        _cmbChoices.SelectedItem = SR.GetString(SR.DeviceFilter_DefaultChoice);
                    }
                    else
                    {
                        _cmbChoices.SelectedItem = DesignerUtility.ChoiceToUniqueIdentifier(_designer.CurrentChoice);
                    }
                }
                else
                {
                    Debug.Assert(_cmbChoices.Items.Count > 0);
                    _cmbChoices.SelectedItem = SR.GetString(SR.DeviceFilter_NoChoice);
                }
            }
        }
Exemplo n.º 3
0
 private void debug_CheckChoicesForDuplicate(DeviceSpecificChoice runtimeChoice)
 {
     foreach (ChoiceTreeNode choiceNode in _cbChoices.Items)
     {
         if (choiceNode.Name == runtimeChoice.Filter &&
             choiceNode.RuntimeChoice.Argument == runtimeChoice.Argument)
         {
             Debug.Fail("Loaded duplicate choice: " +
                        DesignerUtility.ChoiceToUniqueIdentifier(runtimeChoice));
         }
     }
 }
Exemplo n.º 4
0
        protected override String GetDesignTimeNormalHtml()
        {
            String curChoice, message;
            bool   _isNonHtmlSchema = false;

            if (null == CurrentChoice)
            {
                curChoice = SR.GetString(SR.DeviceSpecific_PropNotSet);
                message   = SR.GetString(SR.DeviceSpecific_DefaultMessage);
            }
            else
            {
                if (CurrentChoice.Filter.Length == 0)
                {
                    curChoice = SR.GetString(SR.DeviceFilter_DefaultChoice);
                }
                else
                {
                    curChoice = HttpUtility.HtmlEncode(DesignerUtility.ChoiceToUniqueIdentifier(CurrentChoice));
                }

                if (IsHTMLSchema(CurrentChoice))
                {
                    message = SR.GetString(SR.DeviceSpecific_TemplateEditingMessage);
                }
                else
                {
                    _isNonHtmlSchema = true;
                    message          = SR.GetString(SR.DeviceSpecific_DefaultMessage);
                }
            }

            if (_isDuplicate || _isNonHtmlSchema)
            {
                return(String.Format(CultureInfo.CurrentCulture, _duplicateDesignTimeHTML,
                                     new Object[]
                {
                    _ds.Site.Name,
                    curChoice,
                    message,
                    _isDuplicate ? MobileControlDesigner.errorIcon :
                    MobileControlDesigner.infoIcon,
                    _isDuplicate ?
                    SR.GetString(SR.DeviceSpecific_DuplicateWarningMessage) :
                    SR.GetString(SR.MobileControl_NonHtmlSchemaErrorMessage)
                }));
            }
            else
            {
                return(String.Format(CultureInfo.CurrentCulture, _designTimeHTML, _ds.Site.Name, curChoice, message));
            }
        }
        void IDeviceSpecificDesigner.SetDeviceSpecific(String deviceSpecificParentID, DeviceSpecific ds)
        {
            Debug.Assert(_defaultDeviceSpecificIdentifier == deviceSpecificParentID);

            if (_mobileControl != null)
            {
                if (null != ds)
                {
                    ds.SetOwner(_mobileControl);
                }
                _mobileControl.DeviceSpecific = ds;
            }
            else if (_control != null && ds == null)
            {
                Debug.Assert(_control is DeviceSpecific);

                // Clear the choices if it is a DeviceSpecific control.
                ((DeviceSpecific)_control).Choices.Clear();
            }

            if (null != CurrentChoice)
            {
                if (null == ds)
                {
                    CurrentChoice = null;
                }
                else
                {
                    // This makes sure that the CurrentChoice value is set to null if
                    // it was deleted during the deviceSpecific object editing
                    if (CurrentChoice.Filter.Length == 0)
                    {
                        TemplateDeviceFilter = SR.GetString(SR.DeviceFilter_DefaultChoice);
                    }
                    else
                    {
                        TemplateDeviceFilter = DesignerUtility.ChoiceToUniqueIdentifier(CurrentChoice);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private DeviceSpecificChoice GetChoiceFromIdentifier(String choiceIdentifier, DeviceSpecific ds)
        {
            if (null == ds)
            {
                return(null);
            }

            Debug.Assert(ds.Choices != null);

            foreach (DeviceSpecificChoice choice in ds.Choices)
            {
                if (DesignerUtility.ChoiceToUniqueIdentifier(choice).Equals(choiceIdentifier) ||
                    (String.Empty == choice.Filter &&
                     choiceIdentifier.Equals(SR.GetString(SR.DeviceFilter_DefaultChoice))))
                {
                    return(choice);
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// </summary>
        protected virtual Object [] GetChoices(Object instance)
        {
            bool           defaultAdded = false;
            DeviceSpecific deviceSpecific;

            if (instance is System.Web.UI.MobileControls.StyleSheet)
            {
                StyleSheet ss            = (StyleSheet)instance;
                ISite      componentSite = ss.Site;
                Debug.Assert(componentSite != null, "Expected the component to be sited.");
                IDesignerHost designerHost = (IDesignerHost)componentSite.GetService(typeof(IDesignerHost));
                Debug.Assert(designerHost != null, "Expected a designer host.");
                Object designer = designerHost.GetDesigner(ss);
                Debug.Assert(designer != null, "Expected a designer for the stylesheet.");
                Debug.Assert(designer is StyleSheetDesigner, "Expected a StyleSheet designer.");
                StyleSheetDesigner ssd = (StyleSheetDesigner)designer;
                Style style            = (Style)ssd.CurrentStyle;
                if (null != style)
                {
                    deviceSpecific = style.DeviceSpecific;
                }
                else
                {
                    deviceSpecific = null;
                }
            }
            else if (instance is System.Web.UI.MobileControls.DeviceSpecific)
            {
                deviceSpecific = (DeviceSpecific)instance;
            }
            else if (instance is MobileControl)
            {
                MobileControl mc = (MobileControl)instance;
                deviceSpecific = mc.DeviceSpecific;
            }
            else
            {
                // Simply return null if the instance is not recognizable.
                return(null);
            }

            ArrayList returnArray = new ArrayList();

            // entry that corresponds to null CurrentChoice.
            returnArray.Add(SR.GetString(SR.DeviceFilter_NoChoice));

            if (null == deviceSpecific)
            {
                return(returnArray.ToArray());
            }

            Debug.Assert(deviceSpecific.Choices != null);
            foreach (DeviceSpecificChoice choice in deviceSpecific.Choices)
            {
                // Choice must have a Name
                if (choice.Filter != null && choice.Filter.Length == 0)
                {
                    if (!defaultAdded)
                    {
                        returnArray.Add(SR.GetString(SR.DeviceFilter_DefaultChoice));
                        defaultAdded = true;
                    }
                }
                else
                {
                    if (!choice.Filter.Equals(SR.GetString(SR.DeviceFilter_NoChoice)))
                    {
                        returnArray.Add(DesignerUtility.ChoiceToUniqueIdentifier(choice));
                    }
                }
            }
            returnArray.Sort();
            return(returnArray.ToArray());
        }
Exemplo n.º 8
0
        protected override String GetDesignTimeNormalHtml()
        {
            String    curStyle, message;
            ArrayList lstStylesInCycle = null;

            if (null == CurrentStyle)
            {
                curStyle = SR.GetString(SR.StyleSheet_PropNotSet);
            }
            else
            {
                curStyle = HttpUtility.HtmlEncode(CurrentStyle.Name);
            }

            String curChoice;

            if (null == CurrentChoice)
            {
                curChoice = SR.GetString(SR.StyleSheet_PropNotSet);
            }
            else
            {
                if (CurrentChoice.Filter.Length == 0)
                {
                    curChoice = SR.GetString(SR.DeviceFilter_DefaultChoice);
                }
                else
                {
                    curChoice = HttpUtility.HtmlEncode(DesignerUtility.ChoiceToUniqueIdentifier(CurrentChoice));
                }
            }

            message = SR.GetString(SR.StyleSheet_DefaultMessage);

            bool   renderErrorMsg = false;
            String errorMsg       = null;
            String errorIconUrl   = null;

            if (_isDuplicate)
            {
                renderErrorMsg = true;
                errorMsg       = SR.GetString(SR.StyleSheet_DuplicateWarningMessage);
                errorIconUrl   = MobileControlDesigner.errorIcon;
            }
            else if (_styleSheet.DuplicateStyles.Count > 0)
            {
                renderErrorMsg = true;
                errorMsg       = SR.GetString(
                    SR.StyleSheet_DuplicateStyleNamesMessage,
                    GenericUI.BuildCommaDelimitedList(
                        GetDuplicateStyleNames()
                        )
                    );
                errorIconUrl = MobileControlDesigner.errorIcon;
            }
            else if (null != CurrentStyle && null != CurrentChoice)
            {
                if (IsHTMLSchema(CurrentChoice))
                {
                    message = SR.GetString(SR.StyleSheet_TemplateEditingMessage);
                }
                else
                {
                    // User has selected non-html schema
                    renderErrorMsg = true;
                    errorMsg       = SR.GetString(SR.MobileControl_NonHtmlSchemaErrorMessage);
                    errorIconUrl   = MobileControlDesigner.infoIcon;
                }
            }

            if (renderErrorMsg)
            {
                Debug.Assert(errorMsg != null && errorIconUrl != null);
                return(String.Format(CultureInfo.CurrentCulture, _specialCaseDesignTimeHTML,
                                     new Object[]
                {
                    _styleSheet.Site.Name,
                    curStyle,
                    curChoice,
                    message,
                    errorIconUrl,
                    errorMsg
                }));
            }
            else
            {
                lstStylesInCycle = DetectCycles();

                //

                if (lstStylesInCycle != null && lstStylesInCycle.Count > 0)
                {
                    String cycledStyles = String.Empty;
                    //

                    foreach (Object obj in lstStylesInCycle)
                    {
                        Style cycledStyle = (Style)obj;
                        if (cycledStyles.Length > 0)
                        {
                            cycledStyles += ", ";
                        }
                        cycledStyles += cycledStyle.Name;
                    }
                    return(String.Format(CultureInfo.CurrentCulture, _specialCaseDesignTimeHTML,
                                         new Object[]
                    {
                        _styleSheet.Site.Name,
                        curStyle,
                        curChoice,
                        message,
                        MobileControlDesigner.errorIcon,
                        SR.GetString(SR.StyleSheet_RefCycleErrorMessage, cycledStyles)
                    }));
                }
                else
                {
                    return(String.Format(CultureInfo.CurrentCulture, _designTimeHTML,
                                         new Object[]
                    {
                        _styleSheet.Site.Name,
                        curStyle,
                        curChoice,
                        message
                    }));
                }
            }
        }