public void Emit(StyleManager arg1, StyleChangeType arg2) { Interop.StyleChangedSignal.StyleChangedSignal_Emit(swigCPtr, StyleManager.getCPtr(arg1), (int)arg2); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
public override void OnStyleChange(NUI.StyleManager styleManager, StyleChangeType change) { if (change == StyleChangeType.DefaultFontSizeChange) { NUI.StyleManager.StyleChangedEventArgs args = new NUI.StyleManager.StyleChangedEventArgs(); args.StyleManager = styleManager; args.StyleChange = change; styleChangedEventHandlers?.Invoke(this, args); RelayoutRequest(); } }
// Callback for StyleManager StyleChangedsignal private void OnStyleChanged(IntPtr styleManager, StyleChangeType styleChange) { if (styleManagerStyleChangedEventHandler != null) { StyleChangedEventArgs e = new StyleChangedEventArgs(); // Populate all members of "e" (StyleChangedEventArgs) with real data. e.StyleManager = Registry.GetManagedBaseHandleFromNativePtr(styleManager) as StyleManager; e.StyleChange = styleChange; //Here we send all data to user event handlers. styleManagerStyleChangedEventHandler(this, e); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Click event of the m_btnOk control. /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnOk_Click(object sender, EventArgs e) { if (IsRootSiteDisposed()) { MessageBox.Show(FwCoreDlgs.kstidChangesAreLost, FwCoreDlgs.kstidWarning); DialogResult = DialogResult.Cancel; return; } using (new WaitCursor(this)) { using (UndoTaskHelper undoHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor, m_rootSite, "kstidUndoStyleChanges")) { // This makes sure the style sheet gets reinitialized after an Undo command. if (m_cache.DomainDataByFlid.GetActionHandler() != null) { m_cache.DomainDataByFlid.GetActionHandler().AddAction( new UndoStyleChangesAction(m_app, true)); } // Save any edits from the dialog to the selected style if (m_styleListHelper.SelectedStyle != null) { StyleInfo styleInfo = (StyleInfo)m_styleListHelper.SelectedStyle.StyleInfo; UpdateChanges(styleInfo); } try { // Check to make sure new styles are not going to result in duplicates // in the database m_styleSheet.CheckForDuplicates(m_styleTable); } catch (IncompatibleStyleExistsException isee) { MessageBoxUtils.Show(isee.Message, m_app.ApplicationName); } foreach (StyleInfo style in m_styleTable.Values) { if (style.IsParagraphStyle && !style.IsInternalStyle && (style.Context != style.NextStyle.Context || style.Structure == StructureValues.Body && style.NextStyle.Structure != style.Structure)) { MessageBox.Show(this, string.Format(FwCoreDlgs.kstidStyleContextMismatchMsg, style.NextStyle.Name, style.Name), FwCoreDlgs.kstidStyleContextMismatchCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); undoHelper.RollBack = true; DialogResult = DialogResult.None; CurrentStyle = style.Name; return; } } // Save any changed styles to the database foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) { // If there is already a real style, then the style has changed if (style.RealStyle != null) { style.SaveToDB(style.RealStyle, true, style.IsModified); m_changeType |= StyleChangeType.DefChanged; } else { // otherwise, the style does not exist - it has been added // REVIEW: Don't we need to make sure some other user hasn't already // added this style before saving it in the DB? var newStyle = m_cache.ServiceLocator.GetInstance<IStStyleRepository>().GetObject(m_styleSheet.MakeNewStyle()); style.SaveToDB(newStyle, false, true); m_changeType |= StyleChangeType.Added; } } } // Save the real styles for based-on and following style. Do this last so // all of the real styles for added styles will have been created. foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) style.SaveBasedOnAndFollowingToDB(); style.Dirty = false; } DeleteAndRenameStylesInDB(); // Has the user modified any of the styles? if (m_changeType > 0) { if ((m_changeType & StyleChangeType.RenOrDel) > 0) { // Styles were renamed or deleted. if (StylesRenamedOrDeleted != null) StylesRenamedOrDeleted(); } else { // This makes sure the style sheet gets reinitialized after a Redo command. if (m_cache.DomainDataByFlid.GetActionHandler() != null) { m_cache.DomainDataByFlid.GetActionHandler().AddAction( new UndoStyleChangesAction(m_app, false)); } } } else { // If nothing changed then we just pretend the user pressed Cancel. DialogResult = DialogResult.Cancel; } undoHelper.RollBack = false; } } SelectedStyle = m_styleListHelper.SelectedStyle == null ? "" : m_styleListHelper.SelectedStyle.Name; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Deletes the styles in the delete list. Also, rename instances of styles in the /// rename list. /// </summary> /// ------------------------------------------------------------------------------------ private void DeleteAndRenameStylesInDB() { if (m_deletedStyleNames.Count == 0 && m_renamedStyles.Keys.Count == 0) return; var replaceSpec = new Dictionary<string, string>(); foreach (string styleName in m_deletedStyleNames) { IStStyle deleteStyle = m_styleSheet.FindStyle(styleName); int context = (int)deleteStyle.Context; bool fIsCharStyle = deleteStyle.Type == StyleType.kstCharacter; m_styleSheet.Delete(deleteStyle.Hvo); // Note: instead of delete we replace the old style with the default style // for the correct context. Deleting a style always sets the style to "Normal" // which is wrong in TE where the a) the default style is "Paragraph" and b) // the default style for a specific paragraph depends on the current context // (e.g. in an intro paragraph the default paragraph style is "Intro Paragraph" // instead of "Paragraph"). This fixes TE-5873. string defaultStyleName = m_styleSheet.GetDefaultStyleForContext( context, fIsCharStyle); replaceSpec[styleName] = defaultStyleName; } foreach (var kvp in m_renamedStyles) replaceSpec[kvp.Value] = kvp.Key; StringServices.ReplaceStyles(m_cache, replaceSpec); m_changeType |= StyleChangeType.RenOrDel; }
/// <summary> /// This method should be overridden by deriving classes requiring notifications when the style changes. /// </summary> /// <param name="styleManager">The StyleManager object.</param> /// <param name="change">Information denoting what has changed.</param> /// <since_tizen> 3 </since_tizen> public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Deletes the styles in the delete list. Also, rename instances of styles in the /// rename list. /// </summary> /// ------------------------------------------------------------------------------------ private void DeleteAndRenameStylesInDB() { if (m_deletedStyleNames.Count == 0 && m_renamedStyles.Keys.Count == 0) return; IFwDbMergeStyles styleMerger = FwDbMergeStylesClass.Create(); Guid syncGuid = m_app.SyncGuid; styleMerger.InitializeEx(m_cache.DatabaseAccessor, Logger.Stream, m_hvoRootObject, ref syncGuid); foreach (string styleName in m_deletedStyleNames) { IStStyle deleteStyle = m_styleSheet.FindStyle(styleName); int context = (int)deleteStyle.Context; bool fIsCharStyle = deleteStyle.Type == StyleType.kstCharacter; m_styleSheet.Delete(deleteStyle.Hvo); // Note: instead of delete we replace the old style with the default style // for the correct context. Deleting a style always sets the style to "Normal" // which is wrong in TE where the a) the default style is "Paragraph" and b) // the default style for a specific paragraph depends on the current context // (e.g. in an intro paragraph the default paragraph style is "Intro Paragraph" // instead of "Paragraph"). This fixes TE-5873. string defaultStyleName = m_styleSheet.GetDefaultStyleForContext( context, fIsCharStyle); // If the style is "Default Paragraph Characters" (string.Empty), we just // want to remove the named style from the properties rather than replace it. if (string.IsNullOrEmpty(defaultStyleName)) styleMerger.AddStyleDeletion(styleName); else styleMerger.AddStyleReplacement(styleName, defaultStyleName); } foreach (string newName in m_renamedStyles.Keys) styleMerger.AddStyleReplacement(m_renamedStyles[newName], newName); styleMerger.Process((uint)Handle.ToInt32()); m_changeType |= StyleChangeType.RenOrDel; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Click event of the m_btnOk control. /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnOk_Click(object sender, EventArgs e) { if (IsRootSiteDisposed()) { MessageBox.Show(FwCoreDlgs.kstidChangesAreLost, FwCoreDlgs.kstidWarning); DialogResult = DialogResult.Cancel; return; } using (new WaitCursor(this)) { // We can't use using() here because we might have to create a new undo task below. CreateUndoTaskHelper(); try { // This makes sure the style sheet gets reinitialized after an Undo command. if (m_cache.ActionHandlerAccessor != null) { m_cache.ActionHandlerAccessor.AddAction( new UndoStyleChangesAction(m_app, m_cache, true)); } // Save any edits from the dialog to the selected style if (m_styleListHelper.SelectedStyle != null) { StyleInfo styleInfo = (StyleInfo)m_styleListHelper.SelectedStyle.StyleInfo; UpdateChanges(styleInfo); } // Check to make sure new styles are not going to result in duplicates // in the database m_styleSheet.CheckForDuplicates(m_styleTable); // Save any changed styles to the database foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) { // If there is already a real style, then the style has changed if (style.RealStyle != null) { style.SaveToDB(style.RealStyle, true); m_changeType |= StyleChangeType.DefChanged; } else { // otherwise, the style does not exist - it has been added // REVIEW: Don't we need to make sure some other user hasn't already // added this style before saving it in the DB? StStyle newStyle = new StStyle(m_cache, m_styleSheet.MakeNewStyle()); style.SaveToDB(newStyle, false); m_changeType |= StyleChangeType.Added; } } } // Save the real styles for based-on and following style. Do this last so // all of the real styles for added styles will have been created. foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) style.SaveBasedOnAndFollowingToDB(); style.Dirty = false; } DeleteAndRenameStylesInDB(); // Has the user modified any of the styles? if (m_changeType > 0) { if ((m_changeType & StyleChangeType.RenOrDel) > 0) { // Styles were renamed or deleted. // Because this might involve quite a bit of database interaction, the // styles dialog calls Save() before performing the rename/delete. This // ends the undo task (it's not undoable), so we can't end it again or // add new actions to it m_UndoTaskHelper.Dispose(); m_cache.Save(); CreateUndoTaskHelper(); if (StylesRenamedOrDeleted != null) StylesRenamedOrDeleted(); } else { // This makes sure the style sheet gets reinitialized after a Redo command. if (m_cache.ActionHandlerAccessor != null) { m_cache.ActionHandlerAccessor.AddAction( new UndoStyleChangesAction(m_app, m_cache, false)); } } m_app.Synchronize(new SyncInfo(SyncMsg.ksyncStyle, 0, 0), m_cache); } else { // If nothing changed then we just pretend the user pressed Cancel. DialogResult = DialogResult.Cancel; } } finally { m_UndoTaskHelper.Dispose(); m_UndoTaskHelper = null; } } }