本文整理汇总了C#中SIL.FieldWorks.Common.Controls.ProgressState.Breath方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressState.Breath方法的具体用法?C# ProgressState.Breath怎么用?C# ProgressState.Breath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.Common.Controls.ProgressState
的用法示例。
在下文中一共展示了ProgressState.Breath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FakeDoit
public virtual void FakeDoit(Set<int> itemsToChange, int tagFakeFlid, int tagEnabled,
ProgressState state)
{
ISilDataAccess sda = m_cache.MainCacheAccessor;
int[] chosenHvos = m_chosenHvos;
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));
ITsString tssChosenVal = BuildValueString(chosenHvos);
IVwCacheDa cda = m_cache.VwCacheDaAccessor;
foreach (int hvoItem in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count;
state.Breath();
}
ITsString tssVal = tssChosenVal;
int[] oldVals;
int[] newVal;
bool fEnable = false;
if (!DisableItem(hvoItem))
{
ComputeValue(chosenHvos, hvoItem, out oldVals, out newVal);
fEnable = !EqualIntArrays(oldVals, newVal);
if (fEnable)
{
if (newVal != chosenHvos)
tssVal = BuildValueString(newVal);
cda.CacheStringProp(hvoItem, tagFakeFlid, tssVal);
}
}
cda.CacheIntProp(hvoItem, tagEnabled, (fEnable ? 1 : 0));
}
}
示例2: FakeDoit
public override void FakeDoit(IEnumerable<int> itemsToChange, int tagFakeFlid, int tagEnabled,
ProgressState state)
{
ISilDataAccess sda = m_cache.DomainDataByFlid;
HvoTssComboItem item = m_combo.SelectedItem as HvoTssComboItem;
if (item == null)
return;
int hvoSelMorphType = item.Hvo;
// 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));
int i = 0;
foreach (int hvoLexEntry in itemsToChange)
{
if ((i + 1) % interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count();
state.Breath();
}
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);
// Per LT-5305, OK to switch types.
//bool fEnable = fAffix == fSelAffix && hvoMorphType != hvoSelMorphType;
bool fEnable = hvoMorphType != hvoSelMorphType;
if (fEnable)
m_sda.SetString(hvoLexEntry, tagFakeFlid, item.AsTss);
m_sda.SetInt(hvoLexEntry, tagEnabled, (fEnable ? 1 : 0));
i++;
}
}
示例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: DoIt
public virtual void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
UndoableUnitOfWorkHelper.Do(XMLViewsStrings.ksUndoBulkEdit, XMLViewsStrings.ksRedoBulkEdit,
m_cache.ServiceLocator.GetInstance<IActionHandler>(), () =>
{
//ISilDataAccess sda = m_cache.DomainDataByFlid; // used DataAccess, is that okay?
var chosenObjs = m_chosenObjs;
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 hvoItem in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count();
state.Breath();
}
if (DisableItem(hvoItem))
continue;
List<ICmObject> oldVals, newVal;
ComputeValue(chosenObjs, hvoItem, out oldVals, out newVal);
if (oldVals.SequenceEqual(newVal))
continue;
var newHvos = (from obj in newVal
select obj.Hvo).ToArray();
var realTarget = hvoItem;
if (m_ghostParentHelper != null)
{
realTarget = m_ghostParentHelper.FindOrCreateOwnerOfTargetProp(hvoItem, m_flid);
}
if (Atomic)
{
var newHvo = newHvos.Length > 0 ? newHvos[0] : 0;
DataAccess.SetObjProp(realTarget, m_flid, newHvo);
}
else
{
DataAccess.Replace(realTarget, m_flid, 0, oldVals.Count, newHvos, newHvos.Length);
}
}
});
}
示例5: 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();
}
示例6: DoIt
/// <summary>
/// Execute the change requested by the current selection in the combo.
/// Basically we want the MoInflClass indicated by m_selectedHvo, (even if 0?? not yet possible),
/// to become the InflectionClass of each record that is appropriate to change.
/// We do nothing to records where the check box is turned off,
/// and nothing to ones that currently have an MSA other than an MoStemMsa,
/// and nothing to ones that currently have an MSA with the wrong POS.
/// (a) If the owning entry has an MoStemMsa with the right inflection class (and presumably POS),
/// set the sense to use it.
/// (b) If all senses using the current MoStemMsa are to be changed, just update
/// the inflection class of that MoStemMsa.
/// We could add this...but very probably unused MSAs would have been taken over
/// when setting the POS.
/// --(c) If the entry has an MoStemMsa which is not being used at all, change it to
/// --the required POS and inflection class and use it.
/// (d) Make a new MoStemMsa in the LexEntry with the required POS and inflection class
/// and point the sense at it.
/// </summary>
public void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
CheckDisposed();
var pos = GetPOS();
// A Set of eligible parts of speech to use in filtering.
Set<int> possiblePOS = GetPossiblePartsOfSpeech();
// Make a Dictionary from HVO of entry to list of modified senses.
var sensesByEntryAndPos = new Dictionary<Tuple<ILexEntry, IPartOfSpeech>, List<ILexSense>>();
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 hvoSense in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 20 / itemsToChange.Count();
state.Breath();
}
if (!IsItemEligible(m_cache.DomainDataByFlid, hvoSense, possiblePOS))
continue;
var ls = m_cache.ServiceLocator.GetInstance<ILexSenseRepository>().GetObject(hvoSense);
var msa = (IMoStemMsa)ls.MorphoSyntaxAnalysisRA;
var entry1 = ls.Entry;
var key = new Tuple<ILexEntry, IPartOfSpeech>(entry1, msa.PartOfSpeechRA);
if (!sensesByEntryAndPos.ContainsKey(key))
sensesByEntryAndPos[key] = new List<ILexSense>();
sensesByEntryAndPos[key].Add(ls);
}
m_cache.DomainDataByFlid.BeginUndoTask(FdoUiStrings.ksUndoBEInflClass, FdoUiStrings.ksRedoBEInflClass);
i = 0;
interval = Math.Min(100, Math.Max(sensesByEntryAndPos.Count / 50, 1));
foreach (var kvp in sensesByEntryAndPos)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 80 / sensesByEntryAndPos.Count + 20;
state.Breath();
}
var entry = kvp.Key.Item1;
var sensesToChange = kvp.Value;
IMoStemMsa msmTarget = null;
foreach (var msa in entry.MorphoSyntaxAnalysesOC)
{
var msm = msa as IMoStemMsa;
if (msm != null && msm.InflectionClassRA != null && msm.InflectionClassRA.Hvo == m_selectedHvo)
{
// Can reuse this one!
msmTarget = msm;
break;
}
}
if (msmTarget == null)
{
// See if we can reuse an existing MoStemMsa by changing it.
// This is possible if it is used only by senses in the list, or not used at all.
var otherSenses = new List<ILexSense>();
if (entry.SensesOS.Count != sensesToChange.Count)
{
foreach (var ls in entry.SensesOS)
if (!sensesToChange.Contains(ls))
otherSenses.Add(ls);
}
foreach (var msa in entry.MorphoSyntaxAnalysesOC)
{
var msm = msa as IMoStemMsa;
if (msm == null)
continue;
bool fOk = true;
foreach (var ls in otherSenses)
{
if (ls.MorphoSyntaxAnalysisRA == msm)
{
fOk = false;
break;
}
}
if (fOk)
{
// Can reuse this one! Nothing we don't want to change uses it.
//.........这里部分代码省略.........
示例7: FakeDoit
/// <summary>
/// Fake doing the change by setting the specified property to the appropriate value
/// for each item in the list. Disable items that can't be set.
/// </summary>
/// <param name="itemsToChange"></param>
/// <param name="ktagFakeFlid"></param>
public void FakeDoit(IEnumerable<int> itemsToChange, int tagFakeFlid, int tagEnable, ProgressState state)
{
CheckDisposed();
ITsString tss = TsStringUtils.MakeTss(m_selectedLabel, m_cache.DefaultAnalWs);
// Build a Set of parts of speech that can take this class.
Set<int> possiblePOS = GetPossiblePartsOfSpeech();
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 = IsItemEligible(m_sda, hvo, possiblePOS);
if (fEnable)
m_sda.SetString(hvo, tagFakeFlid, tss);
m_sda.SetInt(hvo, tagEnable, (fEnable ? 1 : 0));
}
}
示例8: DoIt
public override void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
CheckDisposed();
var senseRepo = m_cache.ServiceLocator.GetInstance<ILexSenseRepository>();
// FWR-2781 should be able to bulk edit entries to POS <Not sure>.
IPartOfSpeech posWanted = null;
if (m_selectedHvo > 0)
posWanted = (IPartOfSpeech) m_cache.ServiceLocator.GetObject(m_selectedHvo);
// Make a hashtable from entry to list of modified senses.
var sensesByEntry = new Dictionary<ILexEntry, List<ILexSense>>();
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 hvoSense in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 20 / itemsToChange.Count();
state.Breath();
}
var sense = senseRepo.GetObject(hvoSense);
var msa = sense.MorphoSyntaxAnalysisRA;
if (msa != null && msa.ClassID != MoStemMsaTags.kClassId)
continue; // can't fix this one, not a stem.
var entry = sense.OwnerOfClass(LexEntryTags.kClassId) as ILexEntry;
List<ILexSense> senses;
if (!sensesByEntry.TryGetValue(entry, out senses))
{
senses = new List<ILexSense>();
sensesByEntry[entry] = senses;
}
senses.Add(sense);
}
UndoableUnitOfWorkHelper.Do(FdoUiStrings.ksUndoBulkEditPOS, FdoUiStrings.ksRedoBulkEditPOS, m_cache.ActionHandlerAccessor,
()=>DoUpdatePos(state, sensesByEntry, posWanted));
}
示例9: DoUpdatePos
private void DoUpdatePos(ProgressState state, Dictionary<ILexEntry, List<ILexSense>> sensesByEntry, IPartOfSpeech posWanted)
{
int i;
int interval;
i = 0;
interval = Math.Min(100, Math.Max(sensesByEntry.Count / 50, 1));
foreach (var kvp in sensesByEntry)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 80 / sensesByEntry.Count + 20;
state.Breath();
}
var entry = kvp.Key;
var sensesToChange = kvp.Value;
// Try to find an existing MSA with the right POS.
var msmTarget = (from msa in entry.MorphoSyntaxAnalysesOC
where msa.ClassID == (uint) MoStemMsaTags.kClassId
&& ((IMoStemMsa)msa).PartOfSpeechRA == posWanted
select (IMoStemMsa) msa).FirstOrDefault();
if (msmTarget == null)
{
// No existing MSA has the desired POS.
// See if we can reuse an existing MoStemMsa by changing it.
// This is possible if it is used only by senses in the list, or not used at all.
var otherSenses = new List<ILexSense>();
AddExcludedSenses(entry, otherSenses, sensesToChange); // Get all the unchanged senses of the entry.
foreach (var msa in entry.MorphoSyntaxAnalysesOC)
{
if (msa.ClassID != MoStemMsaTags.kClassId)
continue;
bool fOk = true;
foreach (var otherSense in otherSenses)
{
if (otherSense.MorphoSyntaxAnalysisRA == msa)
{
fOk = false; // we can't change it, one of the unchanged senses uses it
break;
}
}
if (fOk)
{
// Can reuse this one! Nothing we don't want to change uses it. Go ahead and set it to the
// required POS.
msmTarget = (IMoStemMsa)msa;
var oldPOS = msmTarget.PartOfSpeechRA;
msmTarget.PartOfSpeechRA = posWanted;
// compare MoStemMsa.ResetInflectionClass: changing POS requires us to clear inflection class,
// if it is set.
if (oldPOS != null && msmTarget.InflectionClassRA != null)
msmTarget.InflectionClassRA = null;
break;
}
}
}
if (msmTarget == null)
{
// Nothing we can reuse...make a new one.
msmTarget = m_cache.ServiceLocator.GetInstance<IMoStemMsaFactory>().Create();
entry.MorphoSyntaxAnalysesOC.Add(msmTarget);
msmTarget.PartOfSpeechRA = posWanted;
}
// Finally! Make the senses we want to change use it.
foreach (var sense in sensesToChange)
{
if (sense.MorphoSyntaxAnalysisRA == msmTarget)
continue; // reusing a modified msa.
sense.MorphoSyntaxAnalysisRA = msmTarget;
}
}
}
示例10: FakeDoit
public void FakeDoit(IEnumerable<int> itemsToChange, int tagFakeFlid, int tagEnable, ProgressState state)
{
CheckDisposed();
ITsString tss = TsStringUtils.MakeTss(m_selectedLabel, m_cache.DefaultAnalWs);
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)
m_sda.SetString(hvo, tagFakeFlid, tss);
m_sda.SetInt(hvo, tagEnable, (fEnable ? 1 : 0));
}
}
示例11: DoIt
/// <summary>
/// Execute the change requested by the current selection in the combo.
/// Basically we want a copy of the FsFeatStruc indicated by m_selectedHvo, (even if 0?? not yet possible),
/// to become the MsFeatures of each record that is appropriate to change.
/// We do nothing to records where the check box is turned off,
/// and nothing to ones that currently have an MSA other than an MoStemMsa,
/// and nothing to ones that currently have an MSA with the wrong POS.
/// (a) If the owning entry has an MoStemMsa with a matching MsFeatures (and presumably POS),
/// set the sense to use it.
/// (b) If all senses using the current MoStemMsa are to be changed, just update
/// the MsFeatures of that MoStemMsa.
/// We could add this...but very probably unused MSAs would have been taken over
/// when setting the POS.
/// --(c) If the entry has an MoStemMsa which is not being used at all, change it to
/// --the required POS and inflection class and use it.
/// (d) Make a new MoStemMsa in the LexEntry with the required POS and features
/// and point the sense at it.
/// </summary>
public void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
CheckDisposed();
var pos = GetPOS();
// Make a Set of eligible parts of speech to use in filtering.
Set<int> possiblePOS = GetPossiblePartsOfSpeech();
// Make a Dictionary from HVO of entry to list of modified senses.
var sensesByEntry = new Dictionary<int, Set<ILexSense>>();
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 hvoSense in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 20 / itemsToChange.Count();
state.Breath();
}
if (!IsItemEligible(m_cache.DomainDataByFlid, hvoSense, possiblePOS))
continue;
var ls = m_cache.ServiceLocator.GetInstance<ILexSenseRepository>().GetObject(hvoSense);
var msa = ls.MorphoSyntaxAnalysisRA;
int hvoEntry = ls.EntryID;
if (!sensesByEntry.ContainsKey(hvoEntry))
sensesByEntry[hvoEntry] = new Set<ILexSense>();
sensesByEntry[hvoEntry].Add(ls);
}
//REVIEW: Should these really be the same Undo/Redo strings as for InflectionClassEditor.cs?
m_cache.DomainDataByFlid.BeginUndoTask(FdoUiStrings.ksUndoBEInflClass, FdoUiStrings.ksRedoBEInflClass);
i = 0;
interval = Math.Min(100, Math.Max(sensesByEntry.Count / 50, 1));
IFsFeatStruc fsTarget = null;
if (m_selectedHvo != 0)
fsTarget = Cache.ServiceLocator.GetInstance<IFsFeatStrucRepository>().GetObject(m_selectedHvo);
foreach (var kvp in sensesByEntry)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 80 / sensesByEntry.Count + 20;
state.Breath();
}
var entry = m_cache.ServiceLocator.GetInstance<ILexEntryRepository>().GetObject(kvp.Key);
var sensesToChange = kvp.Value;
IMoStemMsa msmTarget = null;
foreach (var msa in entry.MorphoSyntaxAnalysesOC)
{
var msm = msa as IMoStemMsa;
if (msm != null && MsaMatchesTarget(msm, fsTarget))
{
// Can reuse this one!
msmTarget = msm;
break;
}
}
if (msmTarget == null)
{
// See if we can reuse an existing MoStemMsa by changing it.
// This is possible if it is used only by senses in the list, or not used at all.
var otherSenses = new Set<ILexSense>();
var senses = new Set<ILexSense>(entry.AllSenses.ToArray());
if (senses.Count != sensesToChange.Count)
{
foreach (var ls in senses)
{
if (!sensesToChange.Contains(ls))
otherSenses.Add(ls);
}
}
foreach (var msa in entry.MorphoSyntaxAnalysesOC)
{
var msm = msa as IMoStemMsa;
if (msm == null)
continue;
bool fOk = true;
foreach (var ls in otherSenses)
{
if (ls.MorphoSyntaxAnalysisRA == msm)
{
fOk = false;
//.........这里部分代码省略.........
示例12: DoIt
public override void DoIt(Set<int> itemsToChange, ProgressState state)
{
m_cache.BeginUndoTask(XMLViewsStrings.ksUndoBulkEdit, XMLViewsStrings.ksRedoBulkEdit);
ISilDataAccess sda = m_cache.MainCacheAccessor;
BulkEditBar.ForceRefreshOnUndoRedo(sda);
HvoTssComboItem item = m_combo.SelectedItem as HvoTssComboItem;
if (item == null)
return;
int hvoSelMorphType = item.Hvo;
bool fSelAffix = MoMorphType.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 = MoMorphType.IsAffixType(m_cache, hvoMorphType);
if (fAffix != fSelAffix)
{
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>();
Dictionary<IMoForm, ILexEntry> 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 = MoMorphType.IsAffixType(m_cache, hvoMorphType);
if (fAffix == fSelAffix)
{
if (hvoMorphType != hvoSelMorphType)
{
sda.SetObjProp(hvoLexemeForm, m_flidAtomicProp, hvoSelMorphType);
sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll,
hvoLexemeForm, m_flidAtomicProp,
0, (hvoSelMorphType == 0 ? 0 : 1), (hvoMorphType == 0 ? 0 : 1));
}
else if (fAffix)
{
ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, hvoLexEntry);
IMoAffixAllomorph affix = MoAffixAllomorph.CreateFromDBObject(m_cache, hvoLexemeForm);
MoStemAllomorph stem = new MoStemAllomorph();
int[] envs = affix.PhoneEnvRC.HvoArray;
SwapFormValues(entry, affix, stem, hvoSelMorphType, idsToDel);
foreach (int hvo in envs)
stem.PhoneEnvRC.Add(hvo);
newForms[stem] = entry;
//entry.ChangeAffixToStem(hvoSelMorphType, affix);
}
else
{
ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, hvoLexEntry);
IMoStemAllomorph stem = MoStemAllomorph.CreateFromDBObject(m_cache, hvoLexemeForm);
MoAffixAllomorph affix = new MoAffixAllomorph();
int[] envs = stem.PhoneEnvRC.HvoArray;
SwapFormValues(entry, stem, affix, hvoSelMorphType, idsToDel);
foreach (int hvo in envs)
affix.PhoneEnvRC.Add(hvo);
newForms[affix] = entry;
//entry.ChangeStemToAffix(hvoSelMorphType, stem);
}
}
//.........这里部分代码省略.........
示例13: DoIt
/// <summary>
/// Execute the change requested by the current selection in the combo.
/// Basically we want a copy of the FsFeatStruc indicated by m_selectedHvo, (even if 0?? not yet possible),
/// to become the MsFeatures of each record that is appropriate to change.
/// We do nothing to records where the check box is turned off,
/// and nothing to ones that currently have an MSA other than an MoStemMsa,
/// and nothing to ones that currently have an MSA with the wrong POS.
/// (a) If the owning entry has an MoStemMsa with a matching MsFeatures (and presumably POS),
/// set the sense to use it.
/// (b) If all senses using the current MoStemMsa are to be changed, just update
/// the MsFeatures of that MoStemMsa.
/// We could add this...but very probably unused MSAs would have been taken over
/// when setting the POS.
/// --(c) If the entry has an MoStemMsa which is not being used at all, change it to
/// --the required POS and inflection class and use it.
/// (d) Make a new MoStemMsa in the LexEntry with the required POS and features
/// and point the sense at it.
/// </summary>
public void DoIt(Set<int> itemsToChange, ProgressState state)
{
CheckDisposed();
int hvoPos = GetPOS();
// Make a Set of eligible parts of speech to use in filtering.
Set<int> possiblePOS = GetPossiblePartsOfSpeech();
// Make a Dictionary from HVO of entry to list of modified senses.
Dictionary<int, Set<ILexSense>> sensesByEntry = new Dictionary<int, Set<ILexSense>>();
int tagOwningEntry = m_cache.VwCacheDaAccessor.GetVirtualHandlerName("LexSense", "OwningEntry").Tag;
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 hvoSense in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 20 / itemsToChange.Count;
state.Breath();
}
if (!IsItemEligible(m_cache.MainCacheAccessor, hvoSense, possiblePOS))
continue;
ILexSense ls = (ILexSense)CmObject.CreateFromDBObject(m_cache, hvoSense, false);
IMoMorphSynAnalysis msa = ls.MorphoSyntaxAnalysisRA;
int hvoEntry = m_cache.MainCacheAccessor.get_ObjectProp(ls.Hvo, tagOwningEntry);
if (!sensesByEntry.ContainsKey(hvoEntry))
sensesByEntry[hvoEntry] = new Set<ILexSense>();
sensesByEntry[hvoEntry].Add(ls);
}
//REVIEW: Should these really be the same Undo/Redo strings as for InflectionClassEditor.cs?
m_cache.BeginUndoTask(FdoUiStrings.ksUndoBEInflClass, FdoUiStrings.ksRedoBEInflClass);
BulkEditBar.ForceRefreshOnUndoRedo(Cache.MainCacheAccessor);
i = 0;
interval = Math.Min(100, Math.Max(sensesByEntry.Count / 50, 1));
IFsFeatStruc fsTarget = null;
if (m_selectedHvo != 0)
fsTarget = FsFeatStruc.CreateFromDBObject(Cache, m_selectedHvo);
foreach (KeyValuePair<int, Set<ILexSense>> kvp in sensesByEntry)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 80 / sensesByEntry.Count + 20;
state.Breath();
}
ILexEntry entry = (ILexEntry)CmObject.CreateFromDBObject(m_cache, kvp.Key, false);
Set<ILexSense> sensesToChange = kvp.Value;
IMoStemMsa msmTarget = null;
foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC)
{
IMoStemMsa msm = msa as IMoStemMsa;
if (msm != null && MsaMatchesTarget(msm, fsTarget))
{
// Can reuse this one!
msmTarget = msm;
break;
}
}
if (msmTarget == null)
{
// See if we can reuse an existing MoStemMsa by changing it.
// This is possible if it is used only by senses in the list, or not used at all.
Set<ILexSense> otherSenses = new Set<ILexSense>();
Set<ILexSense> senses = new Set<ILexSense>(entry.AllSenses.ToArray());
if (senses.Count != sensesToChange.Count)
{
foreach (ILexSense ls in senses)
{
if (!sensesToChange.Contains(ls))
otherSenses.Add(ls);
}
}
foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC)
{
IMoStemMsa msm = msa as IMoStemMsa;
if (msm == null)
continue;
bool fOk = true;
foreach (ILexSense ls in otherSenses)
{
if (ls.MorphoSyntaxAnalysisRA == msm)
//.........这里部分代码省略.........
示例14: DoIt
/// <summary>
/// Execute the change requested by the current selection in the combo.
/// Basically we want the PartOfSpeech indicated by m_selectedHvo, even if 0,
/// to become the POS of each record that is appropriate to change.
/// We do nothing to records where the check box is turned off,
/// and nothing to ones that currently have an MSA other than an IMoStemMsa.
/// (a) If the owning entry has an IMoStemMsa with the
/// right POS, set the sense to use it.
/// (b) If the sense already refers to an IMoStemMsa, and any other senses
/// of that entry which point at it are also to be changed, change the POS
/// of the MSA.
/// (c) If the entry has an IMoStemMsa which is not used at all, change it to the
/// required POS and use it.
/// (d) Make a new IMoStemMsa in the ILexEntry with the required POS and point the sense at it.
/// </summary>
public override void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
CheckDisposed();
m_cache.DomainDataByFlid.BeginUndoTask(LexEdStrings.ksUndoBulkEditRevPOS,
LexEdStrings.ksRedoBulkEditRevPOS);
int i = 0;
int interval = Math.Min(100, Math.Max(itemsToChange.Count() / 50, 1));
foreach (int entryId in itemsToChange)
{
i++;
if (i % interval == 0)
{
state.PercentDone = i * 80 / itemsToChange.Count() + 20;
state.Breath();
}
IReversalIndexEntry entry = m_cache.ServiceLocator.GetInstance<IReversalIndexEntryRepository>().GetObject(entryId);
if (m_selectedHvo == 0)
entry.PartOfSpeechRA = null;
else
entry.PartOfSpeechRA = m_cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().GetObject(m_selectedHvo);
}
m_cache.DomainDataByFlid.EndUndoTask();
}
示例15: DoIt
/// <summary>
/// Execute the change requested by the current selection in the combo.
/// There are two main cases:
/// 1. The user is removing a feature.
/// 2. The user is using priority union to include the values of a feature structure.
/// The latter has two subcases:
/// a. The user has selected a value for the targeted feature and we have put that value in a FsFeatStruc.
/// b. The user has employed the chooser to build a FsFeatStruc with the value(s) to change. These values
/// may or may not be for the targeted feature.
/// We do nothing to (phoneme) records where the check box is turned off.
/// For phonemes with the check box on, we either
/// 1. remove the specified feature from the phoneme or
/// 2. use priority union to set the value(s) in the FsFeatStruc.
/// </summary>
public void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
{
CheckDisposed();
string labelToShow = SelectedLabel;
var selectedObject = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(SelectedHvo);
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));
m_cache.DomainDataByFlid.BeginUndoTask(FdoUiStrings.ksUndoBEPhonemeFeatures, FdoUiStrings.ksRedoBEPhonemeFeatures);
if (SelectedHvo != 0)
{
IFsFeatStruc fsTarget = GetTargetFsFeatStruc();
foreach (var hvoPhoneme in itemsToChange)
{
i++;
if (i%interval == 0)
{
state.PercentDone = i * 100 / itemsToChange.Count() + 20;
state.Breath();
}
var phoneme = m_cache.ServiceLocator.GetInstance<IPhPhonemeRepository>().GetObject(hvoPhoneme);
if (phoneme.FeaturesOA == null)
phoneme.FeaturesOA = Cache.ServiceLocator.GetInstance<IFsFeatStrucFactory>().Create();
if (fsTarget == null && selectedObject is IFsClosedFeature)
{ // it's the remove option
var closedValues = from s in phoneme.FeaturesOA.FeatureSpecsOC
where s.FeatureRA == selectedObject
select s;
if (closedValues.Any())
phoneme.FeaturesOA.FeatureSpecsOC.Remove(closedValues.First());
}
else
{
phoneme.FeaturesOA.PriorityUnion(fsTarget);
}
}
}
m_cache.DomainDataByFlid.EndUndoTask();
}