Пример #1
0
        private void OnClickEditStylesButton(Object source, EventArgs e)
        {
            StylesEditorDialog dialog;

            try
            {
                dialog = new StylesEditorDialog(
                    _styleSheet,
                    this,
                    (null != _tmpCurrentStyle) ? _tmpCurrentStyle.Name : null
                    );
            }
            catch (ArgumentException ex)
            {
                Debug.Fail(ex.ToString());
                // Block user from entering StylesEditorDialog until they fix
                // duplicate style declarations.
                return;
            }

            StylesEditorDialog.StyleRenamedEventHandler renameHandler =
                new StylesEditorDialog.StyleRenamedEventHandler(OnStyleRenamedInEditor);
            StylesEditorDialog.StyleDeletedEventHandler deleteHandler =
                new StylesEditorDialog.StyleDeletedEventHandler(OnStyleDeletedInEditor);
            dialog.StyleRenamed += renameHandler;
            dialog.StyleDeleted += deleteHandler;
            try
            {
                _deviceSpecificEditor.BeginExternalDeviceSpecificEdit();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _deviceSpecificEditor.EndExternalDeviceSpecificEdit(
                        true /* commit changes */);
                    OnInternalChange();

                    ((IDeviceSpecificDesigner)this).RefreshHeader(0);
                    // using mergingContext 0 because this implementation does not use the param.
                    if (_mergedUI.CbStyles.Items.Count == 0)
                    {
                        _deviceSpecificEditor.Refresh(null, null); // force the clean up and
                        // disabling of the filter controls.
                        _tmpCurrentStyle = null;
                    }

                    _deviceSpecificEditor.UnderlyingObjectsChanged();
                }
                else
                {
                    _deviceSpecificEditor.EndExternalDeviceSpecificEdit(
                        false /* do not commit changes */);
                }
            }
            finally
            {
                dialog.StyleRenamed -= renameHandler;
                dialog.StyleDeleted -= deleteHandler;
            }
        }
Пример #2
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();
                    }
                }
            }
        }
        public override bool EditComponent(ITypeDescriptorContext context, Object component)
        {
            Debug.Assert(component is StyleSheet);

            StyleSheet         styleSheet = (StyleSheet)component;
            StyleSheetDesigner designer   =
                (StyleSheetDesigner)DesignerAdapterUtil.ControlDesigner(styleSheet);

            //String currentStyle = designer.TemplateStyle;

            if (designer.InTemplateMode)
            {
                MessageBox.Show(SR.GetString(SR.BaseTemplatedMobileComponentEditor_TemplateModeErrorMessage),
                                SR.GetString(SR.BaseTemplatedMobileComponentEditor_TemplateModeErrorTitle),
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                return(false);
            }

            StylesEditorDialog dialog;

            try
            {
                dialog = new StylesEditorDialog(
                    styleSheet,
                    designer,
                    null /*currentStyle*/
                    );
            }
            catch//(ArgumentException e)
            {
                // Debug.Fail(e.ToString());
                // Block user from entering StylesEditorDialog until they fix
                // duplicate style declarations.
                return(false);
            }

            return(dialog.ShowDialog() == DialogResult.OK);
        }
        public override bool EditComponent(ITypeDescriptorContext context, Object component)  
        {
            Debug.Assert(component is StyleSheet);

            StyleSheet styleSheet = (StyleSheet)component;
            StyleSheetDesigner designer = 
                (StyleSheetDesigner)DesignerAdapterUtil.ControlDesigner(styleSheet);
            //String currentStyle = designer.TemplateStyle;

            if (designer.InTemplateMode)
            {
                MessageBox.Show(SR.GetString(SR.BaseTemplatedMobileComponentEditor_TemplateModeErrorMessage), 
                    SR.GetString(SR.BaseTemplatedMobileComponentEditor_TemplateModeErrorTitle),
                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                return false;
            }

            StylesEditorDialog dialog;
            
            try
            {
                dialog = new StylesEditorDialog(
                    styleSheet,
                    designer,
                    null /*currentStyle*/
                );
            }
            catch//(ArgumentException e)
            {
                // Debug.Fail(e.ToString());
                // Block user from entering StylesEditorDialog until they fix
                // duplicate style declarations.
                return false;
            }

            return (dialog.ShowDialog() == DialogResult.OK);
        }
        private void OnClickEditStylesButton(Object source, EventArgs e)
        {

            StylesEditorDialog dialog;
            
            try
            {
                dialog = new StylesEditorDialog(
                    _styleSheet,
                    this,
                    (null != _tmpCurrentStyle) ? _tmpCurrentStyle.Name : null
                );
            }
            catch(ArgumentException ex)
            {
                Debug.Fail(ex.ToString());
                // Block user from entering StylesEditorDialog until they fix
                // duplicate style declarations.
                return;
            }
            
            StylesEditorDialog.StyleRenamedEventHandler renameHandler =
                new StylesEditorDialog.StyleRenamedEventHandler(OnStyleRenamedInEditor);
            StylesEditorDialog.StyleDeletedEventHandler deleteHandler =
                new StylesEditorDialog.StyleDeletedEventHandler(OnStyleDeletedInEditor);
            dialog.StyleRenamed += renameHandler;
            dialog.StyleDeleted += deleteHandler;
            try
            {
                _deviceSpecificEditor.BeginExternalDeviceSpecificEdit();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _deviceSpecificEditor.EndExternalDeviceSpecificEdit(
                        true /* commit changes */ );
                    OnInternalChange();

                    ((IDeviceSpecificDesigner) this).RefreshHeader(0);
                    // using mergingContext 0 because this implementation does not use the param.
                    if (_mergedUI.CbStyles.Items.Count == 0)
                    {
                        _deviceSpecificEditor.Refresh(null, null); // force the clean up and 
                        // disabling of the filter controls.
                        _tmpCurrentStyle = null;
                    }

                    _deviceSpecificEditor.UnderlyingObjectsChanged();
                }
                else
                {
                    _deviceSpecificEditor.EndExternalDeviceSpecificEdit(
                        false /* do not commit changes */ );
                }
            }
            finally
            {
               dialog.StyleRenamed -= renameHandler;
               dialog.StyleDeleted -= deleteHandler;
            }
        }
        /////////////////////////////////////////////////////////////////////////
        //  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();
                    }
                }
            }
        }