本文整理汇总了C#中IApp.Synchronize方法的典型用法代码示例。如果您正苦于以下问题:C# IApp.Synchronize方法的具体用法?C# IApp.Synchronize怎么用?C# IApp.Synchronize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApp
的用法示例。
在下文中一共展示了IApp.Synchronize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunStylesDialogForCombo
/// <summary>
/// Run the styles dialog in order to configure styles for a combo box that selects a style.
/// </summary>
/// <param name="combo">The combo we are configuring. Items may be StyleComboItem or simple strings (style names)</param>
/// <param name="fixCombo">An action to run after the dialog closes</param>
/// <param name="defaultStyle">style to select in the combo if none chosen in the dialog</param>
/// <param name="stylesheet">that the dialog will configure</param>
/// <param name="nMaxStyleLevel">optional constraint on which styles show</param>
/// <param name="hvoAppRoot">root HVO for the application, e.g., Scripture for TE</param>
/// <param name="cache"></param>
/// <param name="owner">parent window</param>
/// <param name="app"></param>
/// <param name="helpTopicProvider"></param>
public static void RunStylesDialogForCombo(ComboBox combo, Action fixCombo, string defaultStyle,
FwStyleSheet stylesheet, int nMaxStyleLevel, int hvoAppRoot, FdoCache cache,
IWin32Window owner, IApp app, IHelpTopicProvider helpTopicProvider)
{
var sci = combo.SelectedItem as StyleComboItem;
string charStyleName = combo.SelectedItem as string;
if (sci != null)
charStyleName = (sci != null && sci.Style != null) ? sci.Style.Name : "";
var paraStyleName = stylesheet.GetDefaultBasedOnStyleName();
// Although we call this 'paraStyleName', it's actual function is to determine the style that
// will be selected in the dialog when it launches. We want that to be the one from the style
// combo we are editing, whether it's a paragraph or character one.
if (!string.IsNullOrEmpty(charStyleName))
paraStyleName = charStyleName;
// ReSharper disable ConvertToConstant.Local
bool fRightToLeft = false;
// ReSharper restore ConvertToConstant.Local
IVwRootSite site = null; // Do we need something better? We don't have anything!
// ReSharper disable RedundantAssignment
var selectedStyle = "";
// ReSharper restore RedundantAssignment
using (var stylesDlg = new FwStylesDlg(
site,
cache,
stylesheet,
// ReSharper disable ConditionIsAlwaysTrueOrFalse
fRightToLeft,
// ReSharper restore ConditionIsAlwaysTrueOrFalse
cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
stylesheet.GetDefaultBasedOnStyleName(),
nMaxStyleLevel,
app.MeasurementSystem,
paraStyleName,
charStyleName,
hvoAppRoot,
app,
helpTopicProvider))
{
stylesDlg.ShowTEStyleTypes = false;
stylesDlg.CanSelectParagraphBackgroundColor = false;
if (stylesDlg.ShowDialog(owner) == DialogResult.OK &&
((stylesDlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
(stylesDlg.ChangeType & StyleChangeType.Added) > 0))
{
app.Synchronize(SyncMsg.ksyncStyle);
selectedStyle = stylesDlg.SelectedStyle;
var oldStyle = GetStyleName(combo.SelectedItem);
if (fixCombo != null)
fixCombo();
if (string.IsNullOrEmpty(selectedStyle))
selectedStyle = defaultStyle;
// Make the requested change if possible...otherwise restore the previous selction.
if (!SelectStyle(combo, selectedStyle))
SelectStyle(combo, oldStyle);
}
}
}