本文整理汇总了C#中XCore.List.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# List.Sort方法的具体用法?C# List.Sort怎么用?C# List.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.List
的用法示例。
在下文中一共展示了List.Sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeMenuItems
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget)
{
int tagNamePOS = UseAbbr ?
CmPossibilityTags.kflidAbbreviation :
CmPossibilityTags.kflidName;
List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>();
GatherPartsOfSpeech(Cache, List.Hvo, CmPossibilityListTags.kflidPossibilities,
CmPossibilityTags.kflidSubPossibilities,
PartOfSpeechTags.kflidInflectionClasses,
tagNamePOS, WritingSystem,
relevantPartsOfSpeech);
relevantPartsOfSpeech.Sort();
int tagNameClass = UseAbbr ?
MoInflClassTags.kflidAbbreviation :
MoInflClassTags.kflidName;
TreeNode match = null;
foreach(HvoTreeNode item in relevantPartsOfSpeech)
{
popupTree.Nodes.Add(item);
TreeNode match1 = AddNodes(item.Nodes, item.Hvo,
PartOfSpeechTags.kflidInflectionClasses,
MoInflClassTags.kflidSubclasses,
hvoTarget, tagNameClass);
if (match1 != null)
match = match1;
}
return match;
}
示例2: MakeMenuItems
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget)
{
int tagNamePOS = UseAbbr ?
(int)CmPossibility.CmPossibilityTags.kflidAbbreviation :
(int)CmPossibility.CmPossibilityTags.kflidName;
List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>();
InflectionClassPopupTreeManager.GatherPartsOfSpeech(Cache, List.Hvo,
(int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities,
(int)CmPossibility.CmPossibilityTags.kflidSubPossibilities,
(int)PartOfSpeech.PartOfSpeechTags.kflidInflectableFeats,
tagNamePOS, WritingSystem,
relevantPartsOfSpeech);
relevantPartsOfSpeech.Sort();
TreeNode match = null;
foreach(HvoTreeNode item in relevantPartsOfSpeech)
{
popupTree.Nodes.Add(item);
IPartOfSpeech pos = (IPartOfSpeech)PartOfSpeech.CreateFromDBObject(Cache, item.Hvo, false);
foreach(IFsFeatStruc fs in pos.ReferenceFormsOC)
{
// Note: beware of using fs.ShortName. That can be
// absolutely EMPTY (if the user has turned off the 'Show Abbreviation as its label'
// field for both the feature category and value).
// ChooserName shows the short name if it is non-empty, otherwise the long name.
HvoTreeNode node = new HvoTreeNode(fs.ChooserNameTS, fs.Hvo);
item.Nodes.Add(node);
if (fs.Hvo == hvoTarget)
match = node;
}
item.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ksChooseInflFeats), kMore));
}
return match;
}
示例3: LoadBarSettings
/// ------------------------------------------------------------------------------------
/// <summary>
/// Load tool bar settings from the registry, if available.
/// </summary>
/// ------------------------------------------------------------------------------------
private bool LoadBarSettings()
{
if (m_appsRegKeyPath == null)
return false;
List<InitialBarProps> ibpList = new List<InitialBarProps>();
foreach (ToolStrip bar in m_bars.Values)
{
int dx = (int)m_appsRegKeyPath.GetValue(bar.Name + "X", -1);
if (dx == -1)
return false;
InitialBarProps ibp = new InitialBarProps();
ibp.Name = bar.Name;
ibp.Side = m_appsRegKeyPath.GetValue(bar.Name + "Side", "Top") as string;
ibp.Location = new Point(dx,
(int)m_appsRegKeyPath.GetValue(bar.Name + "Y", bar.Top));
string strVal = m_appsRegKeyPath.GetValue(bar.Name + "Visible") as string;
bool visible;
ibp.Visible = (bool.TryParse(strVal, out visible) ? visible : false);
m_displayedBars[bar.Name] = ibp.Visible;
ibpList.Add(ibp);
}
// Sort the bar information read from the registry by visibility and location.
ibpList.Sort(InitialBarPropsComparer);
foreach (InitialBarProps sbp in ibpList)
{
ToolStrip bar = m_bars[sbp.Name];
bar.Visible = sbp.Visible;
bar.Location = sbp.Location;
if (m_tsContainer == null)
m_tsPanel.Controls.Add(bar);
else
{
switch (sbp.Side)
{
case "Bottom": m_tsContainer.BottomToolStripPanel.Controls.Add(bar); break;
case "Right": m_tsContainer.RightToolStripPanel.Controls.Add(bar); break;
case "Left": m_tsContainer.LeftToolStripPanel.Controls.Add(bar); break;
default: m_tsContainer.TopToolStripPanel.Controls.Add(bar); break;
}
}
}
return true;
}
示例4: LoadDefaultToolbarLayout
/// ------------------------------------------------------------------------------------
/// <summary>
/// Positions the toolbars to the positions specified in the xml deffinition file.
/// This method only gets called when tool bar locations and visibilities cannot be
/// found in the registry.
/// </summary>
/// ------------------------------------------------------------------------------------
private void LoadDefaultToolbarLayout()
{
List<InitialBarProps> ibpList = new List<InitialBarProps>();
foreach (ToolStrip bar in m_bars.Values)
{
InitialBarProps ibp = new InitialBarProps();
ibp.Name = bar.Name;
ibp.Location = bar.Location = m_barLocations[bar];
ibp.Side = "Top";
bool isBarDisplayed;
ibp.Visible = (m_displayedBars.TryGetValue(bar.Name, out isBarDisplayed) ?
isBarDisplayed : false);
ibpList.Add(ibp);
}
// Sort bars by visibility and location.
ibpList.Sort(InitialBarPropsComparer);
// Now add the bars to the top panel, arranging them accordingly.
int prevRow = 0;
int dx = 0;
foreach (InitialBarProps ibp in ibpList)
{
ToolStrip bar = m_bars[ibp.Name];
bar.Visible = ibp.Visible;
int barRow = bar.Top;
if (barRow != prevRow)
{
prevRow = barRow;
dx = 0;
}
bar.Top = (barRow * bar.Height);
bar.Left = dx;
if (m_tsContainer != null)
m_tsContainer.TopToolStripPanel.Controls.Add(bar);
else
m_tsPanel.Controls.Add(bar);
dx += (bar.Left + bar.Width);
}
}
示例5: PopulateStyleMenu
/// ------------------------------------------------------------------------------------
/// <summary>
/// Fill the Style menu the "No style" item, plus a an alphabetized list of all
/// character styles in stylesheet of the last Fw Edit Box to have focus. The style of
/// the current selection (if there is exactly one) will be checked. If the selection
/// contains no style, then "No style" will be checked. If the selection covers multiple
/// styles, nothing will be checked.
/// </summary>
/// ------------------------------------------------------------------------------------
protected void PopulateStyleMenu()
{
// TODO: Convert this method to use StyleListHelper.
// First clear any items added previously
mnuStyle.MenuItems.Clear();
EventHandler clickEvent = new EventHandler(StyleMenu_Click);
string sSelectedStyle = LastTextBoxInFocus.SelectedStyle;
MenuItem mnuItem = new MenuItem(FwCoreDlgs.kstidNoStyle, clickEvent);
mnuItem.Checked = (sSelectedStyle == string.Empty);
mnuStyle.MenuItems.Add(mnuItem);
mnuItem = new MenuItem(FdoResources.DefaultParaCharsStyleName, clickEvent);
mnuItem.Checked = (sSelectedStyle == FwStyleSheet.kstrDefaultCharStyle);
mnuStyle.MenuItems.Add(mnuItem);
int count = 0;
if (LastTextBoxInFocus.StyleSheet != null)
count = LastTextBoxInFocus.StyleSheet.CStyles;
string styleName;
List<string> styleNames = new List<string>(count / 2);
for (int i = 0; i < count; i++)
{
styleName = LastTextBoxInFocus.StyleSheet.get_NthStyleName(i);
if (LastTextBoxInFocus.StyleSheet.GetType(styleName) == 1) // character style
{
ContextValues context =
(ContextValues)LastTextBoxInFocus.StyleSheet.GetContext(styleName);
// Exclude Internal and InternalMappable style contexts
if (context != ContextValues.Internal &&
context != ContextValues.InternalMappable)
{
styleNames.Add(styleName);
}
}
}
styleNames.Sort();
foreach (string s in styleNames)
{
mnuItem = new MenuItem(s, clickEvent);
mnuItem.Checked = (sSelectedStyle == s);
mnuStyle.MenuItems.Add(mnuItem);
}
}
示例6: OnNextButton
protected override void OnNextButton()
{
if (CurrentStepNumber == 0)
{
// Populate m_mappingsList based on the selected files.
var sfmcounts = new Dictionary<string, int>();
var sfmOrder = new Dictionary<int, string>(); // key is 100000*fileNum + orderInFile, value is a marker
int fileNum = 0;
foreach (var pathName in InputFiles)
{
var reader = new SfmFileReaderEx(pathName);
followedBy = reader.GetFollowedByInfo();
foreach (string marker in reader.SfmInfo)
{
int oldVal;
if (!sfmcounts.TryGetValue(marker, out oldVal))
{
// first time we've seen it: this file determines order;
sfmOrder[fileNum * 100000 + reader.GetSFMOrder(marker)] = marker;
}
sfmcounts[marker] = oldVal + reader.GetSFMCount(marker);
}
fileNum++;
}
// Read the map file (unless we've been to this pane before...then use the saved settings), integrate with the sfmcount info.
var savedMappings = new Dictionary<string, InterlinearMapping>();
m_oldMappings = m_firstTimeInMappingsPane ? LoadSettings() : new List<InterlinearMapping>((m_mappings));
m_firstTimeInMappingsPane = false;
foreach (var mapping in m_oldMappings)
savedMappings[mapping.Marker] = mapping;
m_mappings.Clear();
var keys = new List<int>(sfmOrder.Keys);
keys.Sort();
foreach (var key in keys)
{
var marker = sfmOrder[key];
InterlinearMapping mapping;
if (savedMappings.TryGetValue(marker, out mapping))
{
mapping = new InterlinearMapping(mapping);
if (string.IsNullOrEmpty(mapping.WritingSystem))
{
var ws = GetDefaultWs(mapping);
if (ws != 0)
mapping.WritingSystem = m_cache.WritingSystemFactory.GetStrFromWs(ws);
}
else if (mapping.WritingSystem == "{vern}")
mapping.WritingSystem = m_cache.WritingSystemFactory.GetStrFromWs(m_cache.DefaultVernWs);
}
else
mapping = new InterlinearMapping() {Marker = marker};
mapping.Count = sfmcounts[marker].ToString();
m_mappings.Add(mapping);
}
m_mappingsList.SuspendLayout();
m_mappingsList.Items.Clear();
foreach (var mapping in m_mappings)
{
var item = new ListViewItem("\\" + mapping.Marker);
item.SubItems.Add(mapping.Count);
item.SubItems.Add(GetDestinationName(mapping.Destination));
item.SubItems.Add(mapping.WritingSystem != null ? GetWritingSystemName(mapping.WritingSystem) : "");
item.SubItems.Add(mapping.Converter ?? "");
m_mappingsList.Items.Add(item);
}
if (m_mappingsList.Items.Count > 0)
m_mappingsList.SelectedIndices.Add(0);
m_mappingsList.ResumeLayout();
}
else if(CurrentStepNumber == 1)
{
ICollection<IWritingSystem> currentVernacWSs = m_cache.LanguageProject.VernacularWritingSystems;
ICollection<IWritingSystem> currentAnalysWSs = m_cache.LanguageProject.AnalysisWritingSystems;
var vernToAdd = new ArrayList();
var analysToAdd = new ArrayList();
int textCount = CalculateTextCount(m_mappings, followedBy);
foreach(var mapping in m_mappings)
{
if (mapping.Destination == InterlinDestination.Ignored)
continue; // may well have no WS, in any case, we don't care whether it's in our list.
bool creationCancelled = false;
var ws = (IWritingSystem)m_cache.WritingSystemFactory.get_Engine(mapping.WritingSystem);
if (mapping.Destination == InterlinDestination.Baseline || mapping.Destination == InterlinDestination.Wordform)
{
if(!currentVernacWSs.Contains(ws) && !vernToAdd.Contains(ws))
{
//Show creation dialog for Vernacular
var result = MessageBox.Show(this,
String.Format(ITextStrings.ksImportSFMInterlinNewVernac, ws),
String.Format(ITextStrings.ksImportSFMInterlinNewWSTitle, ws), MessageBoxButtons.YesNo);
if(result == DialogResult.Yes)
{
vernToAdd.Add(ws);
}
else //if they bail out we won't add any writing systems, they might change them all
{
return;
}
}
}
//.........这里部分代码省略.........
示例7: MergeUnderlyingObject
/// <summary>
/// Merge the underling objects. This method handles the confirm dialog, then delegates
/// the actual merge to ReallyMergeUnderlyingObject. If the flag is true, we merge
/// strings and owned atomic objects; otherwise, we don't change any that aren't null
/// to begin with.
/// </summary>
/// <param name="fLoseNoTextData"></param>
public void MergeUnderlyingObject(bool fLoseNoTextData)
{
CheckDisposed();
var mainWindow = (Form) m_mediator.PropertyTable.GetValue("window");
using (new WaitCursor(mainWindow))
{
using (var dlg = new MergeObjectDlg(m_mediator.HelpTopicProvider))
{
var wp = new WindowParams();
var mergeCandidates = new List<DummyCmObject>();
string guiControl, helpTopic;
DummyCmObject dObj = GetMergeinfo(wp, mergeCandidates, out guiControl, out helpTopic);
mergeCandidates.Sort();
dlg.SetDlgInfo(m_cache, m_mediator, wp, dObj, mergeCandidates, guiControl, helpTopic);
if (DialogResult.OK == dlg.ShowDialog(mainWindow))
ReallyMergeUnderlyingObject(dlg.Hvo, fLoseNoTextData);
}
}
}
示例8: PopulateWritingSystemMenu
/// ------------------------------------------------------------------------------------
/// <summary>
/// Fill the Writing Systems menu with an alphebetized list of all writing systems
/// defined in this language project. The writing system of the current selection
/// (if there is exactly one) will be checked; otherwise, nothing will be checked.
/// </summary>
/// ------------------------------------------------------------------------------------
protected void PopulateWritingSystemMenu()
{
// First clear any items added previously
mnuWritingSystem.MenuItems.Clear();
EventHandler clickEvent = new EventHandler(WritingSystemMenu_Click);
m_htNamedWS.Clear();
// Convert from Set to List, since the Set can't sort.
List<NamedWritingSystem> writingSystems = new List<NamedWritingSystem>(m_cache.LangProject.GetActiveNamedWritingSystems().ToArray());
writingSystems.Sort();
string sCurrentWs = GetCurrentWS(LastTextBoxInFocus);
foreach (NamedWritingSystem nws in writingSystems)
{
// Writing systems come from vernacular and analysis lists and can exist in both.
// Do not try to add the same WS twice.
if (!m_htNamedWS.ContainsKey(nws.Name))
{
m_htNamedWS.Add(nws.Name, nws);
MenuItem mi = new MenuItem(nws.Name, clickEvent);
mi.Checked = (sCurrentWs == nws.Name);
mnuWritingSystem.MenuItems.Add(mi);
}
}
}
示例9: RemoveUnwantedSortItems
/// <summary>
/// This will remove the given hvosToRemove (if they exist in our sort items) and any items that refer to invalid objects.
/// Reload the view if there were any changes, and adjust the CurrentIndex
/// </summary>
protected internal void RemoveUnwantedSortItems(List<int> hvosToRemove)
{
if (m_sortedObjects == null)
return; // nothing to remove.
bool fUpdatingListOrig = m_fUpdatingList;
m_fUpdatingList = true;
try
{
int currentIndex = CurrentIndex;
int cOrigSortObjects = m_sortedObjects.Count;
// Note: We start with a Set, since it can't have duplicates.
// First remove the given hvos from our sort items.
Set<int> unwantedIndices = new Set<int>(IndicesOfSortItems(hvosToRemove));
// then remove any remaining items that point to invalid objects.
unwantedIndices.AddRange(IndicesOfInvalidSortItems());
// Put the now unique indices into a list,
// so we can make sure they are processed in reverse order.
List<int> sortedIndices = new List<int>(unwantedIndices.ToArray());
sortedIndices.Sort();
sortedIndices.Reverse();
foreach (int indexOfSortItem in sortedIndices)
{
if (indexOfSortItem >= 0)
{
m_sortedObjects.RemoveAt(indexOfSortItem);
if (indexOfSortItem < currentIndex || SortedObjects.Count <= currentIndex)
currentIndex--;
}
}
if (m_sortedObjects.Count == 0)
currentIndex = -1;
else if (currentIndex >= m_sortedObjects.Count)
currentIndex = m_sortedObjects.Count - 1;
CurrentIndex = currentIndex;
if (m_sortedObjects.Count != cOrigSortObjects)
{
SendPropChangedOnListChange(CurrentIndex,
SortedObjects, ListChangedEventArgs.ListChangedActions.Normal);
}
}
finally
{
m_fUpdatingList = fUpdatingListOrig;
}
}
示例10: ModifyOverlay
public void ModifyOverlay(bool fApplyTag, IVwOverlay pvo, int itag)
{
CheckDisposed();
if (m_rootb == null)
return;
Debug.WriteLine("WARNING: RootSite.ModifyOverlay() isn't tested yet");
int hvo;
uint clrFore;
uint clrBack;
uint clrUnder;
int unt;
bool fHidden;
string uid;
using (ArrayPtr arrayPtr = MarshalEx.StringToNative((int)VwConst1.kcchGuidRepLength + 1, true))
{
pvo.GetDbTagInfo(itag, out hvo, out clrFore, out clrBack, out clrUnder, out unt,
out fHidden, arrayPtr);
uid = MarshalEx.NativeToString(arrayPtr,
(int)VwConst1.kcchGuidRepLength, false);
}
IVwSelection vwsel;
ITsTextProps[] vttp;
IVwPropertyStore[] vvps;
if (EditingHelper.GetCharacterProps(out vwsel, out vttp, out vvps))
{
int cttp = vttp.Length;
for (int ittp = 0; ittp < cttp; ittp++)
{
string strGuid = vttp[ittp].GetStrPropValue(
(int)FwTextPropType.ktptTags);
// REVIEW (EberhardB): I'm not sure if this works
int cGuids = strGuid.Length / Marshal.SizeOf(typeof(Guid));
List<string> guids = new List<string>();
for (int i = 0; i < cGuids; i++)
guids.Add(strGuid.Substring(i, Marshal.SizeOf(typeof(Guid))));
if (fApplyTag)
{
// Add the tag if it does not exist
if (guids.BinarySearch(uid) >= 0)
{
// The tag has already been applied to the textprop, so it doesn't
// need to be modified.
vttp[ittp] = null;
continue;
}
else
{
// We need to add the tag to the textprop.
guids.Add(uid);
guids.Sort();
}
}
else
{
// Remove the tag from the textprop.
guids.Remove(uid);
}
ITsPropsBldr tpb = vttp[ittp].GetBldr();
tpb.SetStrPropValue((int)FwTextPropType.ktptTags,
guids.ToString());
vttp[ittp] = tpb.GetTextProps();
}
vwsel.SetSelectionProps(cttp, vttp);
/*
* ENHANCE (EberhardB): Implement this if we need it. It probably should be
* implemented in a derived class (view class for DataNotebook?)
// Update the RnGenericRec_PhraseTags table as necessary.
// (Yes, this is special case code!)
AfDbInfo * pdbi = NULL;
AfMainWnd * pamw = m_pwndSubclass->MainWindow();
if (pamw)
{
AfMdiMainWnd * pammw = dynamic_cast<AfMdiMainWnd *>(pamw);
AfLpInfo * plpi = NULL;
if (pammw)
{
plpi = pammw->GetLpInfo();
if (plpi)
pdbi = plpi->GetDbInfo();
}
}
if (pdbi)
{
int clevEnd;
int clevAnchor;
HVO hvoEnd;
HVO hvoAnchor;
PropTag tagEnd;
PropTag tagAnchor;
int ihvo;
int cpropPrev;
IVwPropertyStorePtr qvps;
//.........这里部分代码省略.........
示例11: FixLexRelationTypeList
private void FixLexRelationTypeList(LayoutTreeNode ltn)
{
// Get the canonical list from the project.
if (m_rgRelationTypes == null)
{
m_rgRelationTypes = m_cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.ToList();
m_rgRelationTypes.Sort(ComparePossibilitiesByName);
}
// Add any new types to our ordered list (or fill in an empty list).
var setSortedGuids = new Set<GuidAndSubClass>();
foreach (var lri in ltn.RelTypeList)
setSortedGuids.Add(new GuidAndSubClass(lri.ItemGuid, lri.SubClass));
foreach (var poss in m_rgRelationTypes)
{
var lrt = (ILexRefType)poss;
if (ltn.LexRelType == "sense")
{
if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryCollection ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntrySequence ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree)
{
continue;
}
}
else
{
if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseCollection ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSensePair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseSequence ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
{
continue;
}
}
var gsc = new GuidAndSubClass(poss.Guid, LexReferenceInfo.TypeSubClass.Normal);
if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
{
gsc.SubClass = LexReferenceInfo.TypeSubClass.Forward;
}
if (!setSortedGuids.Contains(gsc))
{
var lri = new LexReferenceInfo(true, poss.Guid)
{
SubClass = gsc.SubClass
};
ltn.RelTypeList.Add(lri);
}
if (gsc.SubClass == LexReferenceInfo.TypeSubClass.Forward)
{
gsc.SubClass = LexReferenceInfo.TypeSubClass.Reverse;
if (!setSortedGuids.Contains(gsc))
{
var lri = new LexReferenceInfo(true, poss.Guid)
{
SubClass = gsc.SubClass
};
ltn.RelTypeList.Add(lri);
}
}
}
// Remove any obsolete types from our ordered list.
var mapGuidType = new Dictionary<GuidAndSubClass, ILexRefType>();
foreach (var poss in m_rgRelationTypes)
{
var lrt = (ILexRefType)poss;
var gsc = new GuidAndSubClass(lrt.Guid, LexReferenceInfo.TypeSubClass.Normal);
if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree ||
lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
{
gsc.SubClass = LexReferenceInfo.TypeSubClass.Forward;
}
mapGuidType.Add(gsc, lrt);
if (gsc.SubClass == LexReferenceInfo.TypeSubClass.Forward)
{
var gsc2 = new GuidAndSubClass(lrt.Guid, LexReferenceInfo.TypeSubClass.Reverse);
mapGuidType.Add(gsc2, lrt);
}
}
var obsoleteItems = ltn.RelTypeList.Where(
lri => !mapGuidType.ContainsKey(new GuidAndSubClass(lri.ItemGuid, lri.SubClass))).ToList();
foreach (var lri in obsoleteItems)
ltn.RelTypeList.Remove(lri);
// Add the names to the items in the ordered list.
foreach (var lri in ltn.RelTypeList)
{
var lrt = mapGuidType[new GuidAndSubClass(lri.ItemGuid, lri.SubClass)];
if (lri.SubClass == LexReferenceInfo.TypeSubClass.Reverse)
lri.Name = lrt.ReverseName.BestAnalysisVernacularAlternative.Text;
//.........这里部分代码省略.........
示例12: LoadListView
/// ------------------------------------------------------------------------------------
/// <summary>
/// Loads the list view, sorted by the current sort column.
/// </summary>
/// ------------------------------------------------------------------------------------
private void LoadListView(List<ListViewItem> list)
{
m_lvModel.SuspendLayout();
m_lvModel.Items.Clear();
bool sortAscending = (bool)m_lvModel.Columns[m_sortCol].Tag;
list.Sort((x, y) => sortAscending ?
x.SubItems[m_sortCol].Text.CompareTo(y.SubItems[m_sortCol].Text) :
y.SubItems[m_sortCol].Text.CompareTo(x.SubItems[m_sortCol].Text));
m_lvModel.Items.AddRange(list.ToArray());
m_lvModel.ResumeLayout(true);
}
示例13: SetDlgInfo
//.........这里部分代码省略.........
AdjustTextBoxAndDialogHeight(m_tbLexicalForm);
}
// JohnT addition: if multiple analysis writing systems, replace tbGloss with msGloss
if (WritingSystemServices.GetWritingSystemList(m_cache, WritingSystemServices.kwsAnals, false).Count > 1)
{
msGloss = ReplaceTextBoxWithMultiStringBox(m_tbGloss, WritingSystemServices.kwsAnals, stylesheet);
m_lnkAssistant.Top = msGloss.Bottom - m_lnkAssistant.Height;
msGloss.TextChanged += tbGloss_TextChanged;
}
else
{
// See if we need to adjust the height of the gloss
AdjustTextBoxAndDialogHeight(m_tbGloss);
}
m_msaGroupBox.Initialize(cache, m_mediator, m_lnkAssistant, this);
// See if we need to adjust the height of the MSA group box.
int oldHeight = m_msaGroupBox.Height;
int newHeight = Math.Max(m_msaGroupBox.PreferredHeight, oldHeight);
GrowDialogAndAdjustControls(newHeight - oldHeight, m_msaGroupBox);
m_msaGroupBox.AdjustInternalControlsAndGrow();
Text = GetTitle();
m_lnkAssistant.Enabled = false;
// Set font for the combobox.
m_cbMorphType.Font = new Font(defAnalWs.DefaultFontName, 10);
// Populate morph type combo.
// first Fill ComplexFormType combo, since cbMorphType controls
// whether it gets enabled and which index is selected.
m_cbComplexFormType.Font = new Font(defAnalWs.DefaultFontName, 10);
var rgComplexTypes = new List<ICmPossibility>(m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.ReallyReallyAllPossibilities.ToArray());
rgComplexTypes.Sort();
m_idxNotComplex = m_cbComplexFormType.Items.Count;
m_cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksNotApplicable, false));
m_idxUnknownComplex = m_cbComplexFormType.Items.Count;
m_cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksUnknownComplexForm, true));
for (int i = 0; i < rgComplexTypes.Count; ++i)
{
var type = (ILexEntryType)rgComplexTypes[i];
m_cbComplexFormType.Items.Add(type);
}
m_cbComplexFormType.SelectedIndex = 0;
m_cbComplexFormType.Visible = true;
m_cbComplexFormType.Enabled = true;
// Convert from Set to List, since the Set can't sort.
var al = new List<IMoMorphType>();
foreach (IMoMorphType mType in m_cache.LanguageProject.LexDbOA.MorphTypesOA.ReallyReallyAllPossibilities.Cast<IMoMorphType>())
{
switch (filter)
{
case MorphTypeFilterType.Prefix:
if (mType.IsPrefixishType)
al.Add(mType);
break;
case MorphTypeFilterType.Suffix:
if (mType.IsSuffixishType)
al.Add(mType);
break;
case MorphTypeFilterType.Any:
al.Add(mType);
break;
}
}
al.Sort();
for (int i = 0; i < al.Count; ++i)
{
m_cbMorphType.Items.Add(al[i]);
if (al[i] == morphType)
m_cbMorphType.SelectedIndex = i;
}
m_morphType = morphType; // Is this still needed?
m_msaGroupBox.MorphTypePreference = m_morphType;
// Now position the searching animation
/*
* This position put the animation over the Glossing Assistant button. LT-9146
m_searchAnimation.Top = groupBox2.Top - m_searchAnimation.Height - 5;
m_searchAnimation.Left = groupBox2.Right - m_searchAnimation.Width - 10;
*/
/* This position puts the animation over the top left corner, but will that
* look okay with right-to-left?
m_searchAnimation.Top = groupBox2.Top + 40;
m_searchAnimation.Left = groupBox2.Left + 10;
*/
// This position puts the animation close to the middle of the list.
m_searchAnimation.Top = m_matchingEntriesGroupBox.Top + (m_matchingEntriesGroupBox.Height / 2) - (m_searchAnimation.Height / 2);
m_searchAnimation.Left = m_matchingEntriesGroupBox.Left + (m_matchingEntriesGroupBox.Width / 2) - (m_searchAnimation.Width / 2);
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
MessageBox.Show(e.StackTrace);
}
}
示例14: SetDlgInfo
protected void SetDlgInfo(FdoCache cache, IMoMorphType morphType, int wsVern, MorphTypeFilterType filter)
{
ReplaceMatchingEntriesControl();
IVwStylesheet stylesheet = null;
if (m_mediator != null)
{
stylesheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
if (matchingEntries != null)
matchingEntries.Initialize(cache, stylesheet, m_mediator);
}
m_cache = cache;
m_fNewlyCreated = false;
m_oldForm = "";
if (m_types == null)
m_types = new MoMorphTypeCollection(cache);
// Set fonts for the two edit boxes.
if (stylesheet != null)
{
tbLexicalForm.StyleSheet = stylesheet;
tbGloss.StyleSheet = stylesheet;
}
// Set writing system factory and code for the two edit boxes.
tbLexicalForm.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
if (wsVern <= 0)
wsVern = cache.LangProject.DefaultVernacularWritingSystem;
tbLexicalForm.WritingSystemCode = wsVern;
tbLexicalForm.AdjustStringHeight = false;
tbGloss.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
tbGloss.WritingSystemCode = cache.LangProject.DefaultAnalysisWritingSystem;
tbGloss.AdjustStringHeight = false;
// initialize to empty TsStrings
ITsStrFactory tsf = TsStrFactoryClass.Create();
//we need to use the weVern so that tbLexicalForm is sized correctly for the font size.
//In Interlinear text the baseline can be in any of the vernacular writing systems, not just
//the defaultVernacularWritingSystem.
TssForm = tsf.MakeString("", wsVern);
TssGloss = tsf.MakeString("", cache.LangProject.DefaultAnalysisWritingSystem);
((System.ComponentModel.ISupportInitialize)(this.tbLexicalForm)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tbGloss)).EndInit();
int cVern = LabeledMultiStringView.GetWritingSystemList(m_cache, LangProject.kwsVerns, false).Length;
if (cVern > 1)
{
msLexicalForm = ReplaceTextBoxWithMultiStringBox(tbLexicalForm, LangProject.kwsVerns, stylesheet);
msLexicalForm.TextChanged += new EventHandler(tbLexicalForm_TextChanged);
}
else
{
// See if we need to adjust the height of the lexical form
AdjustTextBoxAndDialogHeight(tbLexicalForm);
}
// JohnT addition: if multiple analysis writing systems, replace tbGloss with msGloss
int cWritingSystem = LabeledMultiStringView.GetWritingSystemList(m_cache, LangProject.kwsAnals, false).Length;
if (cWritingSystem > 1)
{
msGloss = ReplaceTextBoxWithMultiStringBox(tbGloss, LangProject.kwsAnals, stylesheet);
m_lnkAssistant.Top = msGloss.Bottom - m_lnkAssistant.Height;
msGloss.TextChanged += new System.EventHandler(this.tbGloss_TextChanged);
}
else
{
// See if we need to adjust the height of the gloss
AdjustTextBoxAndDialogHeight(tbGloss);
}
m_msaGroupBox.Initialize(cache, m_mediator, m_lnkAssistant, this);
// See if we need to adjust the height of the MSA group box.
int oldHeight = m_msaGroupBox.Height;
int newHeight = Math.Max(m_msaGroupBox.PreferredHeight, oldHeight);
GrowDialogAndAdjustControls(newHeight - oldHeight, m_msaGroupBox);
m_msaGroupBox.AdjustInternalControlsAndGrow();
Text = GetTitle();
m_lnkAssistant.Enabled = false;
// Set font for the combobox.
cbMorphType.Font =
new Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10);
// Populate morph type combo.
// first Fill ComplexFormType combo, since cbMorphType controls
// whether it gets enabled and which index is selected.
cbComplexFormType.Font =
new Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10);
List<ICmPossibility> rgComplexTypes = new List<ICmPossibility>(m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.ReallyReallyAllPossibilities.ToArray());
rgComplexTypes.Sort();
m_idxNotComplex = cbComplexFormType.Items.Count;
cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksNotApplicable, false));
m_idxUnknownComplex = cbComplexFormType.Items.Count;
cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksUnknownComplexForm, true));
for (int i = 0; i < rgComplexTypes.Count; ++i)
{
//.........这里部分代码省略.........
示例15: Report
public static void Report()
{
// Can't use StringCollection, because it can't sort.
List<string> items = new List<string>();
foreach (KeyValuePair<string, TimeVal> kvp in s_dict)
{
items.Add(kvp.Key);
}
items.Sort();
foreach(string key in items)
{
Debug.WriteLine(key + ": " + s_dict[key].duration.ToString());
}
s_dict.Clear();
s_blockname = ""; // just to be sure
}