本文整理汇总了C#中SIL.FieldWorks.Common.Controls.ProgressState类的典型用法代码示例。如果您正苦于以下问题:C# ProgressState类的具体用法?C# ProgressState怎么用?C# ProgressState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProgressState类属于SIL.FieldWorks.Common.Controls命名空间,在下文中一共展示了ProgressState类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoSuggestTask
private void DoSuggestTask(ProgressState state)
{
var newCol = -1;
if (PreviewOn)
{
// Clear the previous preview
DoClearPreviewTask(state);
}
PreviewOn = true;
if (m_operationsTabControl.SelectedTab == m_listChoiceTab)
{
if (m_itemIndex >= 0)
{
MakeSuggestions(state);
newCol = m_itemIndex + 1;
}
}
else
{
MessageBox.Show(this, XMLViewsStrings.ksSorryNoPreview, XMLViewsStrings.ksUnimplFeature);
PreviewOn = false; // Didn't actually happen
}
if (newCol > 0)
{
// Use the BrowseViewer special 'decorator' SDA.
m_bv.SpecialCache.SetInt(m_bv.RootObjectHvo, XMLViewsDataCache.ktagActiveColumn, newCol);
}
}
示例2: SetDlgInfo
/// <summary>
/// Despite being public where the other SetDlgInfo is internal, this is a "special-case"
/// initialization method not used in Flex, but in TE, where there is not a pre-existing mediator
/// for each main window. This initializer obtains the configuration parameters and sets up a
/// suitable mediator. In doing so it duplicates knowledge from various places:
/// 1. Along with the code that initializes xWindow and various other places, it 'knows' where
/// to find the configuration node for the respeller dialog.
/// 2. It duplicates some of the logic in FwXWindow.InitMediatorValues and RestoreProperties,
/// knowing the LocalSettingsId and how to use it to restore mediator properties, and what items
/// must be in the mediator. Also logic in xWindow for restoring global settings.
/// 3. It knows how to initialize a number of virtual properties normally created as part of
/// FLEx's startup code.
/// 4. It knows how to set up the string table that Flex uses.
/// 5. It knows how to initialize the Flex part inventories.
/// </summary>
public bool SetDlgInfo(IWfiWordform wf, Form parent, IApp app)
{
if (wf == null)
throw new ArgumentNullException("wf");
if (parent == null)
throw new ArgumentNullException("parent");
if (app == null)
throw new ArgumentNullException("app");
using (var dlg = new ProgressDialogWorkingOn())
{
dlg.Owner = parent;
dlg.Text = MEStrings.ksFindingOccurrences;
dlg.WorkingOnText = MEStrings.ksSearchingOccurrences;
dlg.ProgressLabel = MEStrings.ksProgress;
dlg.Show(ActiveForm);
dlg.Update();
dlg.BringToFront();
//var progressState = new MilestoneProgressState(dlg.ProgressDisplayer);
try
{
m_cache = wf.Cache;
m_srcwfiWordform = wf;
// Get the parameter node.
var path = Path.Combine(FwDirectoryFinder.GetCodeSubDirectory(
Path.Combine(FwUtils.ksFlexAppName, Path.Combine("Configuration", "Words"))), "areaConfiguration.xml");
var doc = XWindow.LoadConfigurationWithIncludes(path, true);
var paramNode = doc.DocumentElement.SelectSingleNode("listeners/listener[@class=\"SIL.FieldWorks.XWorks.MorphologyEditor.RespellerDlgListener\"]/parameters");
Debug.Assert(paramNode != null);
// Initialize a mediator.
var mediator = new Mediator();
m_fDisposeMediator = true;
// Copied from FwXWindow.InitMediatorValues
mediator.PropertyTable.LocalSettingsId = "local";
mediator.PropertyTable.SetProperty("cache", m_cache);
mediator.PropertyTable.SetPropertyPersistence("cache", false);
string userPath = DirectoryFinder.UserAppDataFolder(app.ApplicationName);
Directory.CreateDirectory(userPath);
mediator.PropertyTable.UserSettingDirectory = userPath;
//// Enhance JohnT: possibly these three lines (also copied) are not needed.
//mediator.PropertyTable.SetProperty("DocumentName", GetMainWindowCaption(cache));
//mediator.PropertyTable.SetPropertyPersistence("DocumentName", false);
mediator.PathVariables["{DISTFILES}"] = FwDirectoryFinder.CodeDirectory;
mediator.PropertyTable.RestoreFromFile(mediator.PropertyTable.GlobalSettingsId);
mediator.PropertyTable.RestoreFromFile(mediator.PropertyTable.LocalSettingsId);
//progressState.SetMilestone();
// Set this AFTER the restore! Otherwise it goes away!
mediator.PropertyTable.SetProperty("window", dlg.Owner);
mediator.PropertyTable.SetPropertyPersistence("window", false);
string directoryContainingConfiguration = Path.Combine(FwDirectoryFinder.FlexFolder, "Configuration");
StringTable table = new StringTable(directoryContainingConfiguration);
mediator.StringTbl = table;
mediator.FeedbackInfoProvider = (IFeedbackInfoProvider)app;
//progressState.SetMilestone();
//progressState.SetMilestone();
LayoutCache.InitializePartInventories(m_cache.ProjectId.Name, app, m_cache.ProjectId.ProjectFolder);
//progressState.SetMilestone();
// Get all the scripture texts.
// Review: should we include IText ones too?
// NB: The ownership check is designed to exclude archived drafts.
// The second half collects footnotes and the title of the book.
var stTextRepos = m_cache.ServiceLocator.GetInstance<IStTextRepository>();
var unarchivedScriptureTexts = m_cache.LangProject.TranslatedScriptureOA.StTexts.ToList();
//progressState.SetMilestone();
// Build concordance info, including the occurrence list for our wordform.
ProgressState state = new ProgressState(dlg.ProgressDisplayer);
// This is an ugly way of getting the state to the RespellingSda method
mediator.PropertyTable.SetProperty("SpellingPrepState", state);
mediator.PropertyTable.SetPropertyPersistence("SpellingPrepState", false);
NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor,
() =>
{
int done = 0;
int total = unarchivedScriptureTexts.Count;
foreach (var txt in unarchivedScriptureTexts)
{
done++;
foreach (IStTxtPara para in txt.ParagraphsOS)
{
//.........这里部分代码省略.........
示例3: FakeDoit
public void FakeDoit(Set<int> itemsToChange, int tagFakeFlid, int tagEnable, ProgressState state)
{
CheckDisposed();
IVwCacheDa cda = m_cache.VwCacheDaAccessor;
ISilDataAccess sda = m_cache.MainCacheAccessor;
ITsString tss = m_cache.MakeAnalysisTss(m_selectedLabel);
int i = 0;
// Report progress 50 times or every 100 items, whichever is more (but no more than once per item!)
int interval = Math.Min(100, Math.Max(itemsToChange.Count / 50, 1));
foreach (int hvo in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count;
state.Breath();
}
bool fEnable = CanFakeIt(hvo);
if (fEnable)
cda.CacheStringProp(hvo, tagFakeFlid, tss);
cda.CacheIntProp(hvo, tagEnable, (fEnable ? 1 : 0));
}
}
示例4: FakeDoit
public override void FakeDoit(IEnumerable<int> itemsToChange, int tagFakeFlid, int tagEnabled, ProgressState state)
{
m_complexEntryRefs = null; // reset the filtered entry refs cache.
base.FakeDoit(itemsToChange, tagFakeFlid, tagEnabled, state);
}
示例5: DoIt
public override void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
UndoableUnitOfWorkHelper.Do(XMLViewsStrings.ksUndoBulkEdit, XMLViewsStrings.ksRedoBulkEdit, m_cache.ActionHandlerAccessor,
() =>
{
ISilDataAccess sda = m_cache.DomainDataByFlid;
HvoTssComboItem item = m_combo.SelectedItem as HvoTssComboItem;
if (item == null)
return;
int hvoSelMorphType = item.Hvo;
bool fSelAffix = false;
if (hvoSelMorphType != 0)
fSelAffix = MorphServices.IsAffixType(m_cache, hvoSelMorphType);
bool fAnyFundamentalChanges = false;
// Preliminary check and warning if changing fundamental type.
foreach (int hvoLexEntry in itemsToChange)
{
int hvoLexemeForm = sda.get_ObjectProp(hvoLexEntry, m_flidParent);
if (hvoLexemeForm == 0)
continue;
int hvoMorphType = sda.get_ObjectProp(hvoLexemeForm, m_flidAtomicProp);
if (hvoMorphType == 0)
continue;
bool fAffix = MorphServices.IsAffixType(m_cache, hvoMorphType);
if (fAffix != fSelAffix && hvoSelMorphType != 0)
{
string msg = String.Format(XMLViewsStrings.ksMorphTypeChangesSlow,
(fAffix ? XMLViewsStrings.ksAffixes : XMLViewsStrings.ksStems),
(fAffix ? XMLViewsStrings.ksStems : XMLViewsStrings.ksAffixes));
if (MessageBox.Show(this.m_combo, msg, XMLViewsStrings.ksChangingMorphType,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning) != DialogResult.OK)
{
return;
}
fAnyFundamentalChanges = true;
break; // user OKd it, no need to check further.
}
}
if (fAnyFundamentalChanges)
{
m_containingViewer.SetListModificationInProgress(true);
}
try
{
// Report progress 50 times or every 100 items, whichever is more
// (but no more than once per item!)
Set<int> idsToDel = new Set<int>();
var newForms = new Dictionary<IMoForm, ILexEntry>();
int interval = Math.Min(80, Math.Max(itemsToChange.Count()/50, 1));
int i = 0;
foreach (int hvoLexEntry in itemsToChange)
{
// Guess we're 80% done when through all but deleting leftover objects and moving
// new MoForms to LexemeForm slot.
if ((i + 1)%interval == 0)
{
state.PercentDone = i*80/itemsToChange.Count();
state.Breath();
}
i++;
int hvoLexemeForm = sda.get_ObjectProp(hvoLexEntry, m_flidParent);
if (hvoLexemeForm == 0)
continue;
int hvoMorphType = sda.get_ObjectProp(hvoLexemeForm, m_flidAtomicProp);
if (hvoMorphType == 0)
continue;
bool fAffix = MorphServices.IsAffixType(m_cache, hvoMorphType);
var stemAlloFactory = m_cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>();
var afxAlloFactory = m_cache.ServiceLocator.GetInstance<IMoAffixAllomorphFactory>();
if (fAffix == fSelAffix)
{
// Not changing C# type of allomorph object, just set the morph type.
if (hvoMorphType != hvoSelMorphType)
{
sda.SetObjProp(hvoLexemeForm, m_flidAtomicProp, hvoSelMorphType);
}
}
else if (fAffix)
{
// Changing from affix to stem, need a new allomorph object.
var entry = m_cache.ServiceLocator.GetInstance<ILexEntryRepository>().GetObject(hvoLexEntry);
var affix = m_cache.ServiceLocator.GetInstance<IMoAffixAllomorphRepository>().GetObject(hvoLexemeForm);
var stem = stemAlloFactory.Create();
SwapFormValues(entry, affix, stem, hvoSelMorphType, idsToDel);
foreach (var env in affix.PhoneEnvRC)
stem.PhoneEnvRC.Add(env);
newForms[stem] = entry;
}
else
{
// Changing from stem to affix, need a new allomorph object.
var entry = m_cache.ServiceLocator.GetInstance<ILexEntryRepository>().GetObject(hvoLexEntry);
var stem = m_cache.ServiceLocator.GetInstance<IMoStemAllomorphRepository>().GetObject(hvoLexemeForm);
var affix = afxAlloFactory.Create();
SwapFormValues(entry, stem, affix, hvoSelMorphType, idsToDel);
foreach (var env in stem.PhoneEnvRC)
affix.PhoneEnvRC.Add(env);
newForms[affix] = entry;
//.........这里部分代码省略.........
示例6: MakeSuggestions
/// <summary>
/// Tells SemanticDomainChooserBEditControl to make suggestions and then call FakeDoIt
/// </summary>
public override void MakeSuggestions(IEnumerable<int> itemsToChange, int tagFakeFlid, int tagEnabled, ProgressState state)
{
m_doingSuggest = true;
ChosenObjects = new List<ICmObject>(0);
// Unfortunately ProgressState is from FwControls which depends on FDO, so passing it as a parameter
// to the searchCache's InitializeCache method would result in a circular dependency.
state.PercentDone = 15;
state.Breath(); // give the user a LITTLE hope that things are happening!
// Should be the only time we need to loop through all the Semantic Domains
m_searchCache.InitializeCache();
m_suggestionCache = new Dictionary<int, List<ICmObject>>();
base.FakeDoit(itemsToChange, tagFakeFlid, tagEnabled, state);
if (SomeChangesAreWaiting(itemsToChange, tagEnabled))
EnableButtonsIfChangesWaiting();
}
示例7: Doit
public void Doit(IEnumerable<int> itemsToChange, ProgressState state)
{
m_sda.BeginUndoTask(XMLViewsStrings.ksUndoBulkEdit, XMLViewsStrings.ksRedoBulkEdit);
string commitChanges = XmlUtils.GetOptionalAttributeValue(m_nodeSpec, "commitChanges");
int i = 0;
// Report progress 50 times or every 100 items, whichever is more (but no more than once per item!)
int interval = Math.Min(100, Math.Max(itemsToChange.Count() / 50, 1));
foreach (int hvo in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count();
state.Breath();
}
Doit(hvo);
BulkEditBar.CommitChanges(hvo, commitChanges, m_cache, m_accessor.WritingSystem);
}
m_sda.EndUndoTask();
}
示例8: DoClearPreviewTask
private void DoClearPreviewTask(ProgressState state)
{
m_bv.SpecialCache.SetInt(m_bv.RootObjectHvo, XMLViewsDataCache.ktagActiveColumn, 0);
PreviewOn = false;
}
示例9: DeleteSelectedObjects
/// <summary>
/// Delete ALL the checked objects!!
/// </summary>
private void DeleteSelectedObjects(ProgressState state)
{
Set<int> idsToDelete = new Set<int>();
UpdateCurrentGhostParentHelper(); // needed for code below.
foreach (int hvo in ItemsToChange(true))
{
if (m_bv.SpecialCache.get_IntProp(hvo, XMLViewsDataCache.ktagItemEnabled) != 0)
{
if (VerifyRowDeleteAllowable(hvo))
{
//allow deletion for the class we expect to be bulk editing.
int hvoToDelete = 0;
if (DomainObjectServices.IsSameOrSubclassOf(m_cache.DomainDataByFlid.MetaDataCache,
m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo).ClassID,
m_expectedListItemsClassId))
hvoToDelete = hvo;
else if (m_ghostParentHelper != null)
hvoToDelete = m_ghostParentHelper.GetOwnerOfTargetProperty(hvo);
if (hvoToDelete != 0)
idsToDelete.Add(hvoToDelete);
}
}
}
bool fUndo;
if (!CheckMultiDeleteConditionsAndReport(idsToDelete, out fUndo))
return;
try
{
state.PercentDone = 10;
state.Breath();
m_bv.SetListModificationInProgress(true);
int total = idsToDelete.Count;
int interval = Math.Min(100, Math.Max(idsToDelete.Count / 90, 1));
int i = 0;
UndoableUnitOfWorkHelper.Do(XMLViewsStrings.ksUndoBulkDelete, XMLViewsStrings.ksRedoBulkDelete,
m_cache.ActionHandlerAccessor,
() =>
{
foreach (int hvo in idsToDelete)
{
if ((i + 1) % interval == 0)
{
state.PercentDone = i * 90 / idsToDelete.Count + 10;
state.Breath();
}
i++;
ICmObject obj;
if (m_cache.ServiceLocator.ObjectRepository.TryGetObject(hvo, out obj))
m_bv.SpecialCache.DeleteObj(hvo);
}
if (m_expectedListItemsClassId == LexEntryTags.kClassId ||
m_expectedListItemsClassId == LexSenseTags.kClassId)
{
#if WANTPPORT
CmObject.DeleteOrphanedObjects(m_cache, fUndo, state);
#endif
}
});
m_bv.SetListModificationInProgress(false);
ResumeRecordListRowChanges(); // need to show the updated list of rows!
state.PercentDone = 100;
state.Breath();
}
finally
{
// need to recompute what needs to be enabled after the deletion.
m_items.Clear();
}
}
示例10: ShowPreviewItems
/// <summary/>
protected virtual void ShowPreviewItems(ProgressState state)
{
BulkEditItem bei = m_beItems[m_itemIndex];
bei.BulkEditControl.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
}
示例11: DoPreviewTask
private void DoPreviewTask(ProgressState state)
{
var newCol = -1;
if (PreviewOn)
{
// Clear the previous preview
DoClearPreviewTask(state);
}
PreviewOn = true;
if (m_operationsTabControl.SelectedTab == m_listChoiceTab)
{
if (m_itemIndex >= 0)
{
ShowPreviewItems(state);
newCol = m_itemIndex + 1;
}
}
else if (m_operationsTabControl.SelectedTab == m_findReplaceTab)
{
ReplaceWithMethod method = MakeReplaceWithMethod(out newCol);
if (method == null)
return;
method.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
}
else if (m_operationsTabControl.SelectedTab == m_bulkCopyTab)
{
BulkCopyMethod method = MakeBulkCopyMethod(out newCol);
if (method == null)
return;
method.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
}
else if (m_operationsTabControl.SelectedTab == m_transduceTab)
{
TransduceMethod method = MakeTransduceMethod(out newCol);
if (method == null)
return;
method.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
}
else if (m_operationsTabControl.SelectedTab == m_deleteTab && !DeleteRowsItemSelected)
{
// clear a field
if (m_deleteWhatCombo.SelectedItem is TargetFieldItem)
{
TargetFieldItem item = m_deleteWhatCombo.SelectedItem as TargetFieldItem;
int index = item.ColumnIndex;
BulkEditItem bei = m_beItems[index];
bei.BulkEditControl.SetClearField();
bei.BulkEditControl.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
newCol = index + 1;
}
else if (m_deleteWhatCombo.SelectedItem is FieldComboItem)
{
ClearMethod method = MakeClearMethod(out newCol);
if (method == null)
return;
method.FakeDoit(ItemsToChange(false), XMLViewsDataCache.ktagAlternateValue,
XMLViewsDataCache.ktagItemEnabled, state);
}
}
else
{
MessageBox.Show(this, XMLViewsStrings.ksSorryNoPreview, XMLViewsStrings.ksUnimplFeature);
PreviewOn = false; // Didn't actually happen
}
if (newCol != -1)
{
// Use the BrowseViewer special 'decorator' SDA.
m_bv.SpecialCache.SetInt(m_bv.RootObjectHvo, XMLViewsDataCache.ktagActiveColumn, newCol);
}
}
示例12: DoIt
public abstract void DoIt(Set<int> itemsToChange, ProgressState state);
示例13: DeleteObjectSideEffects
/// <summary>
/// This method is the one to override if you need side effects when DeleteUnderlyingObject
/// is called. If other objects should be deleted also, do NOT delete them directly; this
/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
/// whole lot (including this) will be deleted in one relatively efficient operation.
/// You should not modify objectsToDeleteAlso except to add HVOs to it.
/// You must not use the FDO object after calling this, it has been put into the deleted state.
/// </summary>
/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
/// <param name="state"></param>
public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
{
if (Owner.ClassID == PhMetathesisRule.kclsidPhMetathesisRule)
{
// update the StrucChange field to reflect the removed simple context
IPhMetathesisRule rule = Owner as IPhMetathesisRule;
int removeCtxt = rule.UpdateStrucChange(rule.GetStrucChangeIndex(Hvo), IndexInOwner, false);
if (removeCtxt != 0)
objectsToDeleteAlso.Add(removeCtxt);
}
base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
}