/// <summary> /// Create a new StylesEditorDialog instance /// </summary> /// <internalonly/> internal StylesEditorDialog(StyleSheet stylesheet, StyleSheetDesigner styleSheetDesigner, String initialStyleName) { if (stylesheet.DuplicateStyles.Count > 0) { GenericUI.ShowErrorMessage( SR.GetString(SR.StylesEditorDialog_Title), SR.GetString(SR.StylesEditorDialog_DuplicateStyleNames) ); throw new ArgumentException( SR.GetString(SR.StylesEditorDialog_DuplicateStyleException) ); } _tempStyleSheet = new StyleSheet(); _previewStyle = new Style(); _styleSheet = stylesheet; _styleSheetDesigner = styleSheetDesigner; _tempStyleSheet.Site = _styleSheet.Site; InitializeComponent(); InitAvailableStyles(); LoadStyleItems(); if (_tvDefinedStyles.Nodes.Count > 0) { int initialIndex = 0; if (initialStyleName != null) { initialIndex = StyleIndex(initialStyleName); } SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[initialIndex]; _tvDefinedStyles.Enabled = true; UpdateTypeText(); UpdatePropertyGrid(); } UpdateButtonsEnabling(); UpdateFieldsEnabling(); }
public override void OnSetParent() { base.OnSetParent(); // This is not a MobilePage or the styleSheet is already the active styleSheet. // The latter happens when the active StyleSheet is drag/drop to another location // which forces its parent to be changed. if (MobilePage == null) { return; } if (MobilePage.StyleSheet == _styleSheet) { if (!(_styleSheet.Parent is MobilePage || _styleSheet.Parent is MobileUserControl)) { UpdateActiveStyleSheet(); } return; } if (MobilePage.StyleSheet != StyleSheet.Default) { // can't accept more than 1 stylesheet TreatAsDuplicate(true); // the current valid StyleSheet is intentionaly refreshed because // if this stylesheet instance is recreated via a Undo operation // the current valid StyleSheet appears as a duplicate if not refreshed. IDesigner designer = Host.GetDesigner((IComponent)MobilePage.StyleSheet); Debug.Assert(designer != null, "designer is null in StyleSheetDesigner"); StyleSheetDesigner ssd = (StyleSheetDesigner)designer; ssd.UpdateRendering(); } else if (_styleSheet.Parent is MobilePage || _styleSheet.Parent is MobileUserControl) { // the active stylesheet is changed MobilePage.StyleSheet = _styleSheet; _isDuplicate = false; } RefreshPageView(); }
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 UpdateActiveStyleSheet() { if (MobilePage != null && MobilePage.StyleSheet == _styleSheet) { IDesigner designer = null; // currently active stylesheet is deleted MobilePage.StyleSheet = StyleSheet.Default; StyleSheet _newStyleSheet = null; Debug.Assert(RootControl != null); foreach (Control control in RootControl.Controls) { // Find new stylesheet if (control is StyleSheet && _newStyleSheet == null && control != _styleSheet) { designer = Host.GetDesigner((IComponent)control); // AUI 7285 if (designer != null) { _newStyleSheet = (StyleSheet)control; } } } MobilePage.StyleSheet = _newStyleSheet; if (null != _newStyleSheet) { Debug.Assert(designer != null); StyleSheetDesigner ssd = designer as StyleSheetDesigner; Debug.Assert(ssd != null, "ssd is null in StyleSheetDesigner"); ssd.TreatAsDuplicate(false); } RefreshPageView(); } }
/// <summary> /// Create a new StylesEditorDialog instance /// </summary> /// <internalonly/> internal StylesEditorDialog(StyleSheet stylesheet, StyleSheetDesigner styleSheetDesigner, String initialStyleName) : base (stylesheet.Site) { if(stylesheet.DuplicateStyles.Count > 0) { GenericUI.ShowErrorMessage( SR.GetString(SR.StylesEditorDialog_Title), SR.GetString(SR.StylesEditorDialog_DuplicateStyleNames) ); throw new ArgumentException( SR.GetString(SR.StylesEditorDialog_DuplicateStyleException) ); } _tempStyleSheet = new StyleSheet(); _previewStyle = new Style(); _styleSheet = stylesheet; _styleSheetDesigner = styleSheetDesigner; _tempStyleSheet.Site = _styleSheet.Site; InitializeComponent(); InitAvailableStyles(); LoadStyleItems(); if (_tvDefinedStyles.Nodes.Count > 0) { int initialIndex = 0; if (initialStyleName != null) { initialIndex = StyleIndex(initialStyleName); } SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[initialIndex]; _tvDefinedStyles.Enabled = true; UpdateTypeText(); UpdatePropertyGrid(); } UpdateButtonsEnabling(); UpdateFieldsEnabling(); }