/// <summary> /// return an array of all of the objects which should /// 1) be queried when looking for someone to deliver a message to /// 2) be potential recipients of a broadcast /// </summary> /// <returns></returns> public IxCoreColleague[] GetMessageTargets() { List<IxCoreColleague> colleagues = new List<IxCoreColleague>(); colleagues.Add(this); // Add current FindComboFiller & UsedByFiller. // Those return colleagues.ToArray(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the earliest date and time the specified check was run. /// </summary> /// ------------------------------------------------------------------------------------ private DateTime GetLastRunInfoForCheck(Guid checkId, out string[] bookChkInfo) { List<string> bookChkInfoList = new List<string>(); bookChkInfo = new string[] { }; if (m_bookFilter.BookIds == null) return DateTime.MinValue; FdoOwningSequence<IScrBookAnnotations> booksAnnotations = m_cache.LangProject.TranslatedScriptureOA.BookAnnotationsOS; string fmtTip = TeResourceHelper.GetResourceString("kstidScrChecksTreeNodeTipFormat"); string fmtLastRunDate = TeResourceHelper.GetResourceString("kstidScrCheckRunDateTimeFormat"); string fmtLastRunNever = TeResourceHelper.GetResourceString("kstidScrCheckNeverRunMsg"); DateTime overallLastRun = DateTime.MaxValue; // Go through the books in the filter. foreach (int bookId in m_bookFilter.BookIds) { DateTime lastRun = DateTime.MinValue; string lastRunText = fmtLastRunNever; IScrBookAnnotations annotations = booksAnnotations[bookId - 1]; // Is there any history of this check having been run on this book? if (annotations.ChkHistRecsOC.Count == 0) overallLastRun = DateTime.MinValue; else { // Go through the records of each time this test was run for // this book and get the date and time of the last run. While // finding that time, also keep track of the earliest time the // check was run for all books. foreach (ScrCheckRun scr in annotations.ChkHistRecsOC) { if (scr.CheckId == checkId) { if (overallLastRun > scr.RunDate && overallLastRun != DateTime.MinValue) overallLastRun = scr.RunDate; if (lastRun < scr.RunDate) lastRun = scr.RunDate; } } if (lastRun > DateTime.MinValue) lastRunText = string.Format(fmtLastRunDate, lastRun); } bookChkInfoList.Add(string.Format(fmtTip, m_bookFilter.GetBookByOrd(bookId).BestUIName, lastRunText)); } bookChkInfo = bookChkInfoList.ToArray(); return (overallLastRun == DateTime.MaxValue ? DateTime.MinValue : overallLastRun); }
/// <summary> /// Get the items to be compared against the filter. /// </summary> /// <param name="item"></param> /// <returns></returns> protected override int[] GetItems(ManyOnePathSortItem item) { ISilDataAccess sda = m_cache.MainCacheAccessor; List<int> results = new List<int>(); if (item.PathLength > 0 && item.PathFlid(0) == kflidMsas) { // sorted by MSA, match just the one MSA. // I don't think this path can occur with the current XML spec where this is used. int hvoMsa; if (item.PathLength > 1) hvoMsa = item.PathObject(1); else hvoMsa = item.KeyObject; GetItemsForMsaType(sda, ref results, hvoMsa); } else if (item.PathLength >= 1 && item.PathFlid(0) == kflidEntrySenses) { // sorted in a way that shows one sense per row, test that sense's MSA. int hvoSense; if (item.PathLength > 1) hvoSense = item.PathObject(1); else hvoSense = item.KeyObject; int hvoMsa = sda.get_ObjectProp(hvoSense, (int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis); GetItemsForMsaType(sda, ref results, hvoMsa); } else { int hvoEntry = item.RootObject.Hvo; int cmsa = sda.get_VecSize(hvoEntry, kflidMsas); for (int imsa = 0; imsa < cmsa; imsa++) { int hvoMsa = sda.get_VecItem(hvoEntry, kflidMsas, imsa); GetItemsForMsaType(sda, ref results, hvoMsa); } } return results.ToArray(); }
/// <summary> /// Get the occurrences of a particular analysis in the currently interesting texts. /// </summary> private int[] GetAnalysisOccurrences(int hvo, bool includeChildren) { int[] values; if (m_values.TryGetValue(hvo, out values)) return values; var analysis = (IAnalysis)m_services.GetObject(hvo); var wf = analysis.Wordform; var bag = wf.OccurrencesBag; var valuesList = new List<int>(bag.Count); foreach (var seg in from item in bag.Items where BelongsToInterestingText(item) select item) { foreach (var occurrence in seg.GetOccurrencesOfAnalysis(analysis, bag.Occurrences(seg), includeChildren)) { var hvoOcc = m_nextId--; valuesList.Add(hvoOcc); m_occurrences[hvoOcc] = occurrence; } } AddAdditionalOccurrences(hvo, m_occurrences, ref m_nextId, valuesList); values = valuesList.ToArray(); m_values[hvo] = values; return values; }
private void SetNewOccurrencesOfWordforms(ProgressDialogWorkingOn progress) { Set<int> changes = new Set<int>(); foreach (ParaChangeInfo info in m_changedParas.Values) { changes.AddRange(info.Changes); } if (AllChanged) { m_newOccurrencesOldWf = new int[0]; // no remaining occurrences } else { // Only some changed, need to figure m_newOccurrences List<int> newOccurrencesOldWf = new List<int>(); foreach (int hvo in OldOccurrencesOfOldWordform) { //The offsets of our occurrences have almost certainly changed. //Update them so that the respelling dialog view will appear correct. var occur = RespellSda.OccurrenceFromHvo(hvo) as LocatedAnalysisOccurrence; if (occur != null) { occur.ResetSegmentOffsets(); } if (!changes.Contains(hvo)) { newOccurrencesOldWf.Add(hvo); } } m_newOccurrencesOldWf = newOccurrencesOldWf.ToArray(); } UpdateProgress(progress); List<int> newOccurrences = new List<int>(m_oldOccurrencesNewWf.Length + changes.Count); newOccurrences.AddRange(m_oldOccurrencesNewWf); newOccurrences.AddRange(changes); m_newOccurrencesNewWf = newOccurrences.ToArray(); RespellSda.ReplaceOccurrences(OldWordform, m_newOccurrencesOldWf); RespellSda.ReplaceOccurrences(NewWordform, m_newOccurrencesNewWf); SendCountVirtualPropChanged(NewWordform); SendCountVirtualPropChanged(OldWordform); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the message targets. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); // return list of view windows with focused window being the first one List<IxCoreColleague> targets = new List<IxCoreColleague>(); foreach (RootSiteGroup group in m_groups) { foreach (IRootSiteSlave slave in group.Slaves) { if (slave is IxCoreColleague && (((Control)slave).Contains((Control)FocusedRootSite) || slave == FocusedRootSite)) { targets.AddRange(((IxCoreColleague)slave).GetMessageTargets()); break; } } } targets.Add(this); return targets.ToArray(); }
/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOS != null) { // Cache items to add, which prevents prop changed being called for each add. (Fixes FWR-3083) List<HvoTssComboItem> itemsToAdd = new List<HvoTssComboItem>(); foreach (var slot in GetSlots()) { string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slot.Hvo, m_tsf.MakeString(name, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle)); itemsToAdd.Add(newItem); if (m_selectedSlot != null && m_selectedSlot.Hvo == newItem.Hvo) matchIdx = itemsToAdd.Count - 1; } } m_fwcbSlots.Items.AddRange(itemsToAdd.ToArray()); } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlot = null; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }
private Property[] MakePropertyArrayForSerializing(string settingsId, string[] omitSettingIds) { if (!Monitor.TryEnter(m_properties)) { TraceVerboseLine(">>>>>>>***** colision: <i> ********<<<<<<<<<<<"); Monitor.Enter(m_properties); } List<Property> list = new List<Property>(m_properties.Count); foreach (KeyValuePair<string, Property> kvp in m_properties) { Property property = kvp.Value; if (!property.doPersist) continue; if (!property.name.StartsWith(GetPathPrefixForSettingsId(settingsId))) continue; bool fIncludeThis = true; foreach (string omitSettingsId in omitSettingIds) { if (property.name.StartsWith(GetPathPrefixForSettingsId(omitSettingsId))) { fIncludeThis = false; break; } } if (fIncludeThis) list.Add(property); } Monitor.Exit(m_properties); return list.ToArray(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the possible message targets, i.e. the view(s) we are showing /// </summary> /// <returns>Message targets</returns> /// ------------------------------------------------------------------------------------ public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); // return list of view windows with focused window being the first one List<IxCoreColleague> targets = new List<IxCoreColleague>(); foreach (Control control in m_rgClientViews.Values) { IxCoreColleague view = control as IxCoreColleague; if (view != null && control != null) { if (control.Focused || control == ActiveView) targets.InsertRange(0, view.GetMessageTargets()); else if (control.Visible || control.ContainsFocus) targets.AddRange(view.GetMessageTargets()); } } targets.Add(this); return targets.ToArray(); }
/// <summary> /// return an array of all of the objects which should /// 1) be queried when looking for someone to deliver a message to /// 2) be potential recipients of a broadcast /// </summary> /// <returns></returns> public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); Control first = FirstControl; if (first != null && first.FindForm() == null) first = null; Control second = SecondControl; if (second != null && second.FindForm() == null) second = null; var targets = new List<IxCoreColleague> {this}; if (m_prioritySecond) { if (first != null) targets.Insert(0, first as IxCoreColleague); if (second != null) targets.Insert(0, second as IxCoreColleague); } else { if (second != null) targets.Insert(0, second as IxCoreColleague); if (first != null) targets.Insert(0, first as IxCoreColleague); } return targets.ToArray(); }
protected ContextMenu MakeSliceContextMenu(Slice slice, bool fHotLinkOnly)//, bool retrieveDoNotShow) { XmlNode configuration =slice.ConfigurationNode; XmlNode caller = slice.CallerNode; string menuId = null; if (caller != null) menuId = ShowContextMenu2Id(caller, fHotLinkOnly); if (menuId == null || menuId.Length == 0) menuId = ShowContextMenu2Id(configuration, fHotLinkOnly); XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window"); //an empty menu attribute means no menu if (menuId != null && menuId.Length== 0) return null; /* //a missing menu attribute means "figure out a default" if (menuId == null) { //todo: this is probably too simplistic //we are trying to select out just atomic objects //of this will currently also select "place keeping" nodes if(slice.IsObjectNode) // configuration.HasChildNodes /*<-- that's dumb // && configuration.SelectSingleNode("seq")== null // && !(e.Slice.Object.Hvo == slice.Container.RootObjectHvo)) { menuId="mnuDataTree-Object"; } else //we could not figure out a default menu for this item, so fall back on the auto menu { //todo: this must not be used in the final product! // return m_dataEntryForm.GetAutoMenu(sender, e); return null; } } if (menuId == "") return null; //explicitly stated that there should not be a menu */ //ChoiceGroup group; if(fHotLinkOnly) { return window.GetWindowsFormsContextMenu(menuId); } else { //string[] menus = new string[2]; List<string> menus = new List<string>(); menus.Add(menuId); if (slice is MultiStringSlice) menus.Add("mnuDataTree-MultiStringSlice"); else menus.Add("mnuDataTree-Object"); window.ShowContextMenu(menus.ToArray(), new Point(Cursor.Position.X, Cursor.Position.Y), null, // Don't care about a temporary colleague null); // or MessageSequencer return null; } // group.ConfigurationNode.AppendChild(group.ConfigurationNode.OwnerDocument.ImportNode(addon,true)); // This causes the menu to be actually populated with the items. It's a rather // ugly way to do it...happens all over again when the menu pops up...but we // need to know the actual items for various purposes, such as populating a // summary slice's command list. Refactoring is complicated because part of // the code is in a DotNetBar UiAdapter class that I can't easily modify. // group.OnDisplay(null, new EventArgs()); // return menu; }
/// <summary> /// return an array of all of the objects which should /// 1) be queried when looking for someone to deliver a message to /// 2) be potential recipients of a broadcast /// </summary> /// <returns></returns> public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); //note: we just let navigation commands go straight to the clerk, which will then send us a message. /* * important note about messages and record clerk: see the top of the recordClerk.cs file. */ List<IxCoreColleague> targets = new List<IxCoreColleague>(); // HACK: This needs to be controlled better, since this method is being called, // while the object is being disposed, which causes the call to the Clerk property to crash // with a null reference exception on the mediator. if (m_mediator != null) { // Additional targets are typically child windows that should have a chance to intercept // messages before the Clerk sees them. targets.AddRange(GetMessageAdditionalTargets()); targets.Add(Clerk); targets.Add(this); } return targets.ToArray(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a view with multiple LexEntry objects. /// </summary> /// <param name="rghvoEntries"></param> /// <param name="cache"></param> /// <param name="styleSheet"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private XmlView CreateSummaryView(List<int> rghvoEntries, FdoCache cache, IVwStylesheet styleSheet) { // Make a decorator to publish the list of entries as a fake property of the LexDb. int kflidEntriesFound = 8999950; // some arbitrary number not conflicting with real flids. var sda = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, kflidEntriesFound); int hvoRoot = RootHvo; sda.CacheVecProp(hvoRoot, rghvoEntries.ToArray()); //TODO: Make this method return a GeckoBrowser control, and generate the content here. // The name of this property must match the property used by the publishFound layout. sda.SetOwningPropInfo(LexDbTags.kflidClass, "LexDb", "EntriesFound"); // Make an XmlView which displays that object using the specified layout. XmlView xv = new XmlView(hvoRoot, "publishFound", null, false, sda); xv.Cache = cache; xv.Mediator = m_mediator; xv.StyleSheet = styleSheet; return xv; }
private bool TryParseGenDate(string sData, List<string> rgsFmt, out GenDate gdt) { GenDate.PrecisionType prec = GenDate.PrecisionType.Exact; if (sData[0] == '~') { prec = GenDate.PrecisionType.Approximate; sData = sData.Substring(1).Trim(); } else if (sData[0] == '<') { prec = GenDate.PrecisionType.Before; sData = sData.Substring(1).Trim(); } else if (sData[0] == '>') { prec = GenDate.PrecisionType.After; sData = sData.Substring(1).Trim(); } if (sData.Length == 0) { gdt = new GenDate(); return false; } int year = 0; bool fAD = true; DateTime dt; if (DateTime.TryParseExact(sData, rgsFmt.ToArray(), null, DateTimeStyles.None, out dt)) { if (dt.Year > 0) { year = dt.Year; } else { year = -dt.Year; fAD = false; } gdt = new GenDate(prec, dt.Month, dt.Day, year, fAD); return true; } foreach (string sFmt in rgsFmt) { GenDateInfo gdi; string sResidue = ParseFormattedDate(sData, sFmt, out gdi); if (!gdi.error) { year = gdi.year; if (prec == GenDate.PrecisionType.Exact) { if (sResidue.Trim().StartsWith("?")) prec = GenDate.PrecisionType.Approximate; else prec = gdi.prec; } if (year < 0) { year = -year; fAD = false; } gdt = new GenDate(prec, gdi.ymon, gdi.mday, year, fAD); return true; } } gdt = new GenDate(); return false; }
/// <summary> /// Reset the list of matching items. /// </summary> /// <param name="searchKey"></param> protected override void ResetMatches(string searchKey) { Cursor = Cursors.WaitCursor; try { if (m_oldSearchKey == searchKey) return; // Nothing new to do, so skip it. else btnOK.Enabled = false; // disable Go button until we rebuild our match list. m_oldSearchKey = searchKey; List<ExtantWfiWordformInfo> matches = ExtantWfiWordformInfo.ExtantWordformInfo(m_cache, searchKey, StringUtils.GetWsAtOffset(m_tbForm.Tss, 0)); this.matchingEntries.SuspendLayout(); List<int> rghvo = new List<int>(matches.Count); foreach (ExtantWfiWordformInfo match in matches) { bool isFiltered = false; foreach (ExtantWfiWordformInfo ewi in m_filteredEntries) { if (match.ID == ewi.ID) { isFiltered = true; break; } } if (!isFiltered) rghvo.Add(match.ID); } (Clerk as MatchingItemsRecordClerk).UpdateList(rghvo.ToArray()); this.matchingEntries.ResumeLayout(true); if (rghvo.Count == 0) { (this.matchingEntries as BrowseViewer).SelectedIndex = -1; m_selEntryID = 0; } else { (this.matchingEntries as BrowseViewer).SelectedIndex = Clerk.CurrentIndex; m_selEntryID = Clerk.CurrentObject.Hvo; //RaiseSelectionChanged(); //RaiseRestoreFocus(); } this.matchingEntries.TabStop = rghvo.Count > 0; btnOK.Enabled = (m_selEntryID > 0); } finally { matchingEntries_RestoreFocus(null, null); Cursor = Cursors.Default; } }
private void LaunchFilterTextsDialog(object sender, EventArgs args) { IFilterTextsDialog<IStText> dlg = null; try { var interestingTextsList = InterestingTextsDecorator.GetInterestingTextList(m_mediator, m_cache.ServiceLocator); var textsToChooseFrom = new List<IStText>(interestingTextsList.InterestingTexts); if (!FwUtils.IsOkToDisplayScriptureIfPresent) { // Mustn't show any Scripture, so remove scripture from the list textsToChooseFrom = textsToChooseFrom.Where(text => !ScriptureServices.ScriptureIsResponsibleFor(text)).ToList(); } var interestingTexts = textsToChooseFrom.ToArray(); if (FwUtils.IsOkToDisplayScriptureIfPresent) dlg = new FilterTextsDialogTE(m_cache, interestingTexts, m_mediator.HelpTopicProvider, m_bookImporter); else dlg = new FilterTextsDialog(m_cache, interestingTexts, m_mediator.HelpTopicProvider); // LT-12181: Was 'PruneToSelectedTexts(text) and most others were deleted. // We want 'PruneToInterestingTextsAndSelect(interestingTexts, selectedText)' dlg.PruneToInterestingTextsAndSelect(interestingTexts, (IStText)m_objRoot); dlg.TreeViewLabel = ITextStrings.ksSelectSectionsExported; if (dlg.ShowDialog(this) == DialogResult.OK) m_objs.AddRange(dlg.GetListOfIncludedTexts()); } finally { if (dlg != null) ((IDisposable)dlg).Dispose(); } }
public SelLevInfo[] GetLevelInfo(object ctxt, int cellIndex) { List<SelLevInfo> levels = new List<SelLevInfo>(); if (!m_patternModel.Root.IsLeaf) { ComplexConcPatternNode node = (ComplexConcPatternNode) ctxt; int i = cellIndex; while (node != null) { levels.Add(new SelLevInfo {tag = ComplexConcPatternSda.ktagChildren, ihvo = i}); i = GetNodeIndex(node); node = node.Parent; } } return levels.ToArray(); }
/// <summary> /// return an array of all of the objects which should /// 1) be queried when looking for someone to deliver a message to /// 2) be potential recipients of a broadcast /// </summary> /// <returns></returns> public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); if (m_list != null && m_list is IxCoreColleague) // JohnT: currently I don't think any subclass is? { // optimize JohnT: probably faster to use Array.Copy, but I don't think this branch is ever used anyway. var listColleagues = new List<IxCoreColleague>(((IxCoreColleague) m_list).GetMessageTargets()); listColleagues.Add(this); return listColleagues.ToArray(); } return new IxCoreColleague[] {this}; }
private Property[] MakePropertyArrayForSerializingForNewProjectName(string oldSettingsId, string newSettingsId) { if (!Monitor.TryEnter(m_properties)) { TraceVerboseLine(">>>>>>>***** colision: <i> ********<<<<<<<<<<<"); Monitor.Enter(m_properties); } List<Property> list = new List<Property>(m_properties.Count); foreach (KeyValuePair<string, Property> kvp in m_properties) { Property property = kvp.Value; if (!property.doPersist) continue; if (!property.name.StartsWith(GetPathPrefixForSettingsId(oldSettingsId))) continue; //Change the property.name's to match the new project name. StringBuilder strBuild = new StringBuilder(""); strBuild.Append(property.name.ToString()); String oldPathPrefix = GetPathPrefixForSettingsId(oldSettingsId); String newPathPrefix = GetPathPrefixForSettingsId(newSettingsId); strBuild.Replace(oldPathPrefix, newPathPrefix); property.name = strBuild.ToString(); list.Add(property); } Monitor.Exit(m_properties); return list.ToArray(); }
private void UpdateVisibleColumns() { var results = new List<string>(); foreach (var columnSpec in m_bvMatches.ColumnSpecs) { var colLabel = columnSpec.GetOptionalStringAttribute("layout", null); if (colLabel == null) { // In this case we are likely dealing with a dialog that does NOT use IsVisibleColumn() // and there will be one pre-determined SearchField continue; } results.Add(colLabel); } m_visibleColumns = results.ToArray(); }
/// ------------------------------------------------------------------------------------ /// <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); }
private string GetFiles(string currentFiles) { using (var openFileDialog = new OpenFileDialogAdapter()) { openFileDialog.Filter = ResourceHelper.BuildFileFilter(FileFilterType.InterlinearSfm, FileFilterType.AllFiles); openFileDialog.CheckFileExists = true; openFileDialog.Multiselect = true; // can import multiple files var files = SplitPaths(currentFiles); string dir = string.Empty; string initialFileName = string.Empty; openFileDialog.FileName = ""; if (files.Length > 0) { var firstFilePath = files[0].Trim(); // LT-6620 : putting in an invalid path was causing an exception in the openFileDialog.ShowDialog() // Now we make sure parts are valid before setting the values in the openfile dialog. try { dir = Path.GetDirectoryName(firstFilePath); if (File.Exists(firstFilePath)) initialFileName = Path.GetFileName(firstFilePath); } catch { } } if (Directory.Exists(dir)) openFileDialog.InitialDirectory = dir; // It doesn't seem to be possible to open the dialog with more than one file selected. // However there will often be only one so that's at least somewhat helpful. openFileDialog.FileName = initialFileName; openFileDialog.Title = ITextStrings.ksSelectInterlinFile; while (true) // loop until approved set of files or cancel { if (openFileDialog.ShowDialog() != DialogResult.OK) return currentFiles; var badFiles = new List<string>(); foreach (var fileName in openFileDialog.FileNames) { if (!new Sfm2Xml.IsSfmFile(fileName).IsValid) badFiles.Add(fileName); } if (badFiles.Count > 0) { string msg = String.Format(ITextStrings.ksInvalidInterlinearFiles, string.Join(", ", badFiles.ToArray())); DialogResult dr = MessageBox.Show(this, msg, ITextStrings.ksPossibleInvalidFile, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) return JoinPaths(openFileDialog.FileNames); if (dr == DialogResult.No) continue; // loop and show dialog again...hopefully same files selected. break; // user must have chosen cancel, break out of loop } return JoinPaths(openFileDialog.FileNames); } return currentFiles; // leave things unchanged. } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets PronunciationWritingSystems. /// </summary> /// <param name="cache">The cache.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ILgWritingSystem[] PronunciationWritingSystems(FdoCache cache) { // Ensure list is not empty. Set<NamedWritingSystem> wssPronunciation = cache.LangProject.GetPronunciationWritingSystems(); List<int> hvosWsPronunciation = new List<int>(); // add the "default" pronunciation at the top of our ws choice list. if (cache.LangProject.CurPronunWssRS.Count > 0) hvosWsPronunciation.Add(cache.LangProject.CurPronunWssRS[0].Hvo); foreach (NamedWritingSystem nws in wssPronunciation) { // add all other pronunciation wss that are not the "default" if (hvosWsPronunciation.Count > 0 && hvosWsPronunciation[0] != nws.Hvo) hvosWsPronunciation.Add(nws.Hvo); } return WssFromHvos(hvosWsPronunciation.ToArray(), cache); }
// Split up a list in the format produced by JoinPaths. We need to handle pathological strings that could NOT be // so produced, too, because the user can type straight into the box. internal static string[] SplitPaths(string input) { if (string.IsNullOrEmpty(input)) return new string[0]; var results = new List<string>(); var remaining = input; for (;;) { int index = remaining.IndexOf('"'); if (index < 0) { AddSimpleItems(results, remaining); return results.ToArray(); } var piece = remaining.Substring(0, index); AddSimpleItems(results, piece); int nextQuote = remaining.IndexOf('"', index + 1); if (nextQuote <= 0) { // unmatched...ugh! results.Add(remaining.Substring(index + 1)); return results.ToArray(); } results.Add(remaining.Substring(index + 1, nextQuote - index - 1)); remaining = remaining.Substring(nextQuote+1); } }
public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); List<IxCoreColleague> targets = new List<IxCoreColleague>(); targets.Add(this); return targets.ToArray(); }
/// <summary> /// Load the information about the lexical relations that link to hvoEntry. Specifically, we want LexReferences /// that refer to the target Entry (hvoEntry) and also some other lexical entry. /// For each such thing, we store in cdaTemp the name (or, if appropriate, the reverse name) of the /// relationship that hvoEntry has to the other entry(s) in the lex reference, as property RelatedWordsVc.ktagName of /// the LexReference Hvo. Return through relsOut the list of LexReferences that are thus related to hvoEntry. /// Return true if there are any. /// </summary> /// <param name="cache"></param> /// <param name="hvoEntry">ID of the lexical entry we're working with</param> /// <param name="relsOut">an array of IDs (HVOs) for related objects</param> /// <param name="cdaTemp"></param> /// <returns>false if the entry has no associated lexical relations, or none of them are linked to any other entries.</returns> // static private bool LoadLexicalRelationInfo(FdoCache cache, int hvoEntry, out int[] relsOut, IVwCacheDa cdaTemp) { var relatedObjectIds = new List<int>(); var entryRepository = cache.ServiceLocator.GetInstance<ILexEntryRepository>(); var lexEntry = entryRepository.GetObject(hvoEntry); var targets = new HashSet<ICmObject>(lexEntry.AllSenses.Cast<ICmObject>()) {lexEntry}; foreach (ILexRefType lexRefType in cache.LanguageProject.LexDbOA.ReferencesOA.ReallyReallyAllPossibilities) { foreach (var lexReference in lexRefType.MembersOC) { // If at least one target is the lex entry or one of its senses. if ((from target in lexReference.TargetsRS where targets.Contains(target) select target).FirstOrDefault() != null && (from target in lexReference.TargetsRS where !targets.Contains(target) select target).FirstOrDefault() != null) { // The name we want to use for our lex reference is either the name or the reverse name // (depending on the direction of the relationship, if relevant) of the owning lex ref type. var lexReferenceName = lexRefType.Name.BestVernacularAnalysisAlternative; if (lexRefType.MappingType == (int)MappingTypes.kmtEntryAsymmetricPair || lexRefType.MappingType == (int)MappingTypes.kmtEntryOrSenseAsymmetricPair || lexRefType.MappingType == (int)MappingTypes.kmtSenseAsymmetricPair || lexRefType.MappingType == (int)MappingTypes.kmtEntryTree || lexRefType.MappingType == (int)MappingTypes.kmtEntryOrSenseTree || lexRefType.MappingType == (int)MappingTypes.kmtSenseTree) { if (lexEntry.OwnOrd == 0 && lexRefType.Name != null) // the original code had a check for name length as well. lexReferenceName = lexRefType.ReverseName.BestVernacularAnalysisAlternative; } cdaTemp.CacheStringProp(lexReference.Hvo, RelatedWordsVc.ktagName, lexReferenceName); relatedObjectIds.Add(lexReference.Hvo); } } } relsOut = relatedObjectIds.ToArray(); return relsOut.Length > 0; }
/// <summary> /// Get the values we want for the occurrences of the specified LexSE HVO. /// </summary> /// <param name="hvo"></param> /// <returns></returns> int[] GetSenseOccurrences(int hvo) { int[] values; if (m_values.TryGetValue(hvo, out values)) return values; var sense = m_services.GetInstance<ILexSenseRepository>().GetObject(hvo); var bundles = m_services.GetInstance<IWfiMorphBundleRepository>().InstancesWithSense(sense); var valuesList = new List<int>(); foreach (IWfiAnalysis wa in (from bundle in bundles select bundle.Owner).Distinct()) { var bag = ((IWfiWordform)wa.Owner).OccurrencesBag; foreach (var seg in from item in bag.Items where BelongsToInterestingText(item) select item) { foreach (var occurrence in seg.GetOccurrencesOfAnalysis(wa, bag.Occurrences(seg), true)) { int hvoOcc = m_nextId--; valuesList.Add(hvoOcc); m_occurrences[hvoOcc] = occurrence; } } } values = valuesList.ToArray(); m_values[hvo] = values; return values; }
/// <summary> /// Set up the referring semantic domains for the domains found of an entry /// </summary> /// <param name="semanticDomainHvos">an array of semantic domain HVOs</param> void SetupDomainsForEntry(int[] semanticDomainHvos) { m_cdaTemp.CacheVecProp(m_hvoEntry, RelatedWordsVc.ktagDomains, semanticDomainHvos, semanticDomainHvos.Length); var entries = new List<int>(); var semanticDomainRepository = m_cache.ServiceLocator.GetInstance<ICmSemanticDomainRepository>(); foreach (var semanticDomainhvo in semanticDomainHvos) { var semanticDomain = semanticDomainRepository.GetObject(semanticDomainhvo); foreach (ICmObject obj in semanticDomain.ReferringObjects) { if (obj is ILexSense && (obj as ILexSense).SemanticDomainsRC.Contains(semanticDomain)) { var entry = obj.OwnerOfClass(LexEntryTags.kClassId) as ILexEntry; if (entry != null && entry.LexemeFormOA != null && entry.LexemeFormOA.Form != null) { entries.Add(entry.Hvo); m_cdaTemp.CacheStringProp(entry.Hvo, RelatedWordsVc.ktagName, entry.LexemeFormOA.Form.VernacularDefaultWritingSystem); } } } if (entries.Count > 0) { m_cdaTemp.CacheVecProp(semanticDomainhvo, RelatedWordsVc.ktagWords, entries.ToArray(), entries.Count); entries.Clear(); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the possible message targets, i.e. the view(s) we are showing /// </summary> /// <returns>Message targets</returns> /// ------------------------------------------------------------------------------------ public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); // return list of view windows with focused window being the first one List<IxCoreColleague> targets = new List<IxCoreColleague>(); targets.Add(m_diffViewWrapper); targets.Add(this); return targets.ToArray(); }
/// <summary> /// Set up the referring lexical entries of an entry /// </summary> /// <param name="lexicalRelationHvos">an array of lexical relation HVOs</param> private void SetupLexRelsForEntry(int[] lexicalRelationHvos) { m_cdaTemp.CacheVecProp(m_hvoEntry, RelatedWordsVc.ktagLexRels, lexicalRelationHvos, lexicalRelationHvos.Length); var references = new List<int>(); var lexRefRepository = m_cache.ServiceLocator.GetInstance<ILexReferenceRepository>(); var lexEntry = m_cache.ServiceLocator.GetInstance<ILexEntryRepository>().GetObject(m_hvoEntry); var targets = new HashSet<ICmObject>(lexEntry.AllSenses.Cast<ICmObject>()) { lexEntry }; foreach (var hvoLexRel in lexicalRelationHvos) { var lexReference = lexRefRepository.GetObject(hvoLexRel); foreach (ICmObject target in lexReference.TargetsRS) { // If at least one target is the lex entry or one of its senses. if ((from t in lexReference.TargetsRS where targets.Contains(t) select t).FirstOrDefault() != null && (from t in lexReference.TargetsRS where !targets.Contains(t) select t).FirstOrDefault() != null) { ILexEntry targetEntry = target is ILexSense ? target.OwnerOfClass(LexEntryTags.kClassId) as ILexEntry : target as ILexEntry; if (targetEntry != null && targetEntry.Hvo != m_hvoEntry && targetEntry.LexemeFormOA != null && targetEntry.LexemeFormOA.Form != null) { references.Add(targetEntry.Hvo); m_cdaTemp.CacheStringProp(targetEntry.Hvo, RelatedWordsVc.ktagName, targetEntry.HeadWord); } } } if (references.Count > 0) { m_cdaTemp.CacheVecProp(hvoLexRel, RelatedWordsVc.ktagWords, references.ToArray(), references.Count); references.Clear(); } } }