/// <summary> /// Get protected and user-stored dictionary configurations to load into the dialog. /// Tests will override this to load the manager in their own fashion. /// </summary> private void LoadDataFromInventory(XmlNode current) { // Tuples are <uniqueCode, dispName, IsProtected> var configList = new List<Tuple<string, string, bool>>(); // put them in configList and feed them into the Manager's dictionary. foreach (var xnView in m_originalViewConfigNodes) { var sLabel = XmlUtils.GetManditoryAttributeValue(xnView, "label"); var sLayout = XmlUtils.GetManditoryAttributeValue(xnView, "layout"); var fProtected = !sLayout.Contains(Inventory.kcMarkLayoutCopy); configList.Add(new Tuple<string, string, bool>(sLayout, sLabel, fProtected)); } LoadInternalDictionary(configList); var sLayoutCurrent = XmlUtils.GetManditoryAttributeValue(current, "layout"); m_originalView = sLayoutCurrent; m_currentView = m_originalView; if (m_configList.Count == 0) return; // Now set up the actual dialog's contents RefreshView(); }
public PossibilityAutoComplete(FdoCache cache, Mediator mediator, ICmPossibilityList list, Control control, string displayNameProperty, string displayWs) { m_cache = cache; m_mediator = mediator; m_control = control; m_displayNameProperty = displayNameProperty; m_displayWs = displayWs; m_listBox = new ComboListBox {DropDownStyle = ComboBoxStyle.DropDownList, ActivateOnShow = false}; m_listBox.SelectedIndexChanged += HandleSelectedIndexChanged; m_listBox.SameItemSelected += HandleSameItemSelected; m_listBox.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator); m_listBox.WritingSystemFactory = cache.WritingSystemFactory; m_searcher = new StringSearcher<ICmPossibility>(SearchType.Prefix, cache.ServiceLocator.WritingSystemManager); m_possibilities = new List<ICmPossibility>(); var stack = new Stack<ICmPossibility>(list.PossibilitiesOS); while (stack.Count > 0) { ICmPossibility poss = stack.Pop(); m_possibilities.Add(poss); foreach (ICmPossibility child in poss.SubPossibilitiesOS) stack.Push(child); } m_control.KeyDown += HandleKeyDown; m_control.KeyPress += HandleKeyPress; }
/// <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(); }
public Control PopulateCtrlTabTargetCandidateList(List<Control> targetCandidates) { CheckDisposed(); if (targetCandidates == null) throw new ArgumentNullException("targetCandidates"); targetCandidates.Add(this); return ContainsFocus ? this : null; }
public Control PopulateCtrlTabTargetCandidateList(List<Control> targetCandidates) { if (targetCandidates == null) throw new ArgumentNullException("'targetCandidates' is null."); targetCandidates.Add(this); return ContainsFocus ? this : null; }
public void InitMacro_SurvivesTooManyMacros() { var ml = new MacroListener(); var macroImplementors = new List<IFlexMacro>(); for (int i = 0; i < 20; i++) macroImplementors.Add(new MacroF4()); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.EqualTo(macroImplementors[1])); // first free slot gets the second one Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); // first one that wants to be a F4 Assert.That(macros[1], Is.EqualTo(macroImplementors[2])); // can't put where it wants to be, put it in next free slot. Assert.That(macros[3], Is.EqualTo(macroImplementors[3])); // from here on they line up. }
/// <summary> /// Traverse a tree of objects. /// Put the appropriate descendant identifiers into collector. /// </summary> /// <param name="cache">data access to retrieve info</param> /// <param name="rootHvo">starting object</param> /// <param name="rootFlid">the children of rootHvo are in this property.</param> /// <param name="subFlid">grandchildren and great...grandchildren are in this one</param> /// <param name="itemFlid">want children where this is non-empty in the collector</param> /// <param name="flidName">multistring prop to get name of item from</param> /// <param name="wsName">multistring writing system to get name of item from</param> /// <param name="collector">Add for each item an HvoTreeNode with the name and id of the item.</param> internal static void GatherPartsOfSpeech(FdoCache cache, int rootHvo, int rootFlid, int subFlid, int itemFlid, int flidName, int wsName, List<HvoTreeNode> collector) { ISilDataAccess sda = cache.MainCacheAccessor; int chvo = sda.get_VecSize(rootHvo, rootFlid); for (int ihvo = 0; ihvo < chvo; ihvo++) { int hvoItem = sda.get_VecItem(rootHvo, rootFlid, ihvo); if (sda.get_VecSize(hvoItem, itemFlid) > 0) { ITsString tssLabel = GetTssLabel(cache, hvoItem, flidName, wsName); collector.Add(new HvoTreeNode(tssLabel, hvoItem)); } GatherPartsOfSpeech(cache, hvoItem, subFlid, subFlid, itemFlid, flidName, wsName, collector); } }
public List<ListView> GetControlsFromChoice(ListPropertyChoice choice) { List<ListView> controls = new List<ListView>(); if (choice.ParameterNode == null) return null; foreach(XmlNode panel in choice.ParameterNode.SelectNodes("panels/listPanel")) { string listId = XmlUtils.GetManditoryAttributeValue(panel, "listId"); string label = XmlUtils.GetManditoryAttributeValue(panel, "label"); ListView list = MakeList(listId, label); controls.Add(list); } return controls; }
static FLExBridgeListener() { OldLiftBridgeProjects = new List<string>(); var repoMapFile = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LiftBridge"), "LanguageProject_Repository_Map.xml"); // look for old liftbridge repo info in path similar to C:\Users\<user>\AppData\Local\LiftBridge\LanguageProject_Repository_Map.xml if(File.Exists(repoMapFile)) { var repoMapDoc = new XmlDocument(); repoMapDoc.Load(repoMapFile); var mappingNodes = repoMapDoc.SelectNodes("//Mapping"); if(mappingNodes != null) { foreach(XmlElement mappingNode in mappingNodes) { OldLiftBridgeProjects.Add(mappingNode.Attributes["projectguid"].Value); } } } }
public bool OnMoveReversalPOS(object cmd) { FdoCache cache = Cache; var labels = new List<ObjectLabel>(); foreach (IPartOfSpeech pos in MergeOrMoveCandidates) { if (!pos.SubPossibilitiesOS.Contains(POS)) { labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis")); } } using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_mediator.HelpTopicProvider, labels, null, LexEdStrings.ksCategoryToMoveTo, null)) { dlg.SetHelpTopic("khtpChoose-CategoryToMoveTo"); if (dlg.ShowDialog() == DialogResult.OK) { IPartOfSpeech currentPOS = POS; IPartOfSpeech newOwner = (IPartOfSpeech)dlg.ChosenOne.Object; UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMoveRevCategory, LexEdStrings.ksRedoMoveRevCategory, cache.ActionHandlerAccessor, () => { newOwner.MoveIfNeeded(currentPOS); //important when an item is moved into it's own subcategory if (!newOwner.SubPossibilitiesOS.Contains(currentPOS)) //this is also prevented in the interface, but I'm paranoid { newOwner.SubPossibilitiesOS.Add(currentPOS); } }); // Note: PropChanged should happen on the old owner and the new in the 'Add" method call. // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories. m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo); } } return true; }
private static void AddHvoPOStoResults(ISilDataAccess sda, List<int> results, int hvoMsa, int flidPos) { int hvoPOS; hvoPOS = sda.get_ObjectProp(hvoMsa, flidPos); if (hvoPOS != 0) results.Add(hvoPOS); }
/// <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; }
/// <summary> /// This is the one (and should be only) handler for the user Refresh command. /// Refresh wants to first clean up the cache, then give things like Clerks a /// chance to reload stuff (calling the old OnRefresh methods), then give /// windows a chance to redisplay themselves. /// </summary> public void OnMasterRefresh(object sender) { // TODO: This is no longer called by the Mediator, since this class // is no longer an xcore colleague. But, it can't be removed either, // since it is used by another method on this clsss. :-( CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. FwXWindow activeWnd = ActiveForm as FwXWindow; List<FwXWindow> rgxw = new List<FwXWindow>(); foreach (IFwMainWnd wnd in MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } if (activeWnd != null) rgxw.Remove(activeWnd); foreach (FwXWindow xwnd in rgxw) { xwnd.FinishRefresh(); xwnd.Refresh(); } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); } }
public void HandleIncomingLink(FwLink link) { CheckDisposed(); FwXWindow fwxwnd = null; string server = link.Server.Replace(".", Environment.MachineName); // = FwLink.RestoreServerFromURL(link.Server).Replace(".", Environment.MachineName); Debug.Assert(server != null && server != String.Empty); string database = link.Database; Debug.Assert(database != null && database != String.Empty); string key = MakeKey(server, database); if (!m_caches.ContainsKey(key)) { // Add command line info. Dictionary<string, List<String>> oldTable = m_commandLineArgs; // Save original args. m_commandLineArgs = new Dictionary<string, List<String>>(); List<String> list = new List<String>(); list.Add(server); m_commandLineArgs.Add("c", list); list = new List<String>(); list.Add(database); m_commandLineArgs.Add("db", list); list = new List<String>(); list.Add(link.ToString()); m_commandLineArgs.Add("link", list); Form frm = ActiveForm; fwxwnd = (FwXWindow)NewMainWindow(null, false); AdjustNewWindowPosition(fwxwnd, frm); m_commandLineArgs = oldTable; // Restore oringinal args. } else { FdoCache cache = m_caches[key]; // Get window that uses the given DB. foreach (FwXWindow wnd in m_rgMainWindows) { if (wnd.Cache == cache) { fwxwnd = wnd; break; } } } fwxwnd.Mediator.SendMessage("FollowLink", link); bool topmost = fwxwnd.TopMost; fwxwnd.TopMost = true; fwxwnd.TopMost = topmost; fwxwnd.Activate(); }
private void m_btnDuplicate_Click(object sender, EventArgs e) { Debug.Assert(m_current.Level > 0); StoreNodeData(); // Ensure duplicate has current data. LayoutTreeNode ltnDup = (LayoutTreeNode)m_current.Clone(); ltnDup.IsDuplicate = true; // Generate a unique label to identify this as the n'th duplicate in the list. List<string> rgsLabels = new List<string>(); string sBaseLabel = null; for (int i = 0; i < m_current.Parent.Nodes.Count; ++i) { LayoutTreeNode ltn = (LayoutTreeNode)m_current.Parent.Nodes[i]; if (ltn.Configuration == m_current.Configuration && ltn.LayoutName == m_current.LayoutName && ltn.PartName == m_current.PartName) { rgsLabels.Add(ltn.Label); if (!ltn.IsDuplicate) sBaseLabel = ltn.Label; } } if (sBaseLabel == null) sBaseLabel = m_current.Label; int cDup = 1; string sLabel = String.Format("{0} ({1})", sBaseLabel, cDup); while (rgsLabels.Contains(sLabel)) { ++cDup; sLabel = String.Format("{0} ({1})", sBaseLabel, cDup); } ltnDup.Label = sLabel; // sets Text as well. string sDup = ltnDup.DupString; if (String.IsNullOrEmpty(sDup)) sDup = cDup.ToString(); else sDup = String.Format("{0}-{1}", sDup, cDup); ltnDup.DupString = sDup; int idx = m_current.Index; m_current.Parent.Nodes.Insert(idx + 1, ltnDup); m_tvParts.SelectedNode = ltnDup; }
internal bool GetModifiedLayouts(List<XmlNode> rgxn) { List<XmlNode> rgxnDirtyLayouts = new List<XmlNode>(); for (int i = 0; i < Nodes.Count; ++i) { LayoutTreeNode ltn = (LayoutTreeNode)Nodes[i]; if (ltn.GetModifiedLayouts(rgxn)) { XmlNode xn = ltn.ParentLayout; if (xn != null && !rgxnDirtyLayouts.Contains(xn)) rgxnDirtyLayouts.Add(xn); foreach (LayoutTreeNode ltnMerged in ltn.MergedNodes) { xn = ltnMerged.ParentLayout; if (xn != null && !rgxnDirtyLayouts.Contains(xn)) rgxnDirtyLayouts.Add(xn); } } } if (Level == 0 && OverallLayoutVisibilityChanged()) { if (!rgxnDirtyLayouts.Contains(m_xnParentLayout)) rgxnDirtyLayouts.Add(m_xnParentLayout); } foreach (XmlNode xnDirtyLayout in rgxnDirtyLayouts) { // Create a new layout node with all its parts in order. This is needed // to handle arbitrary reordering and possible addition or deletion of // duplicate nodes. This is complicated by the presence (or rather absence) // of "hidden" nodes, and by "merged" nodes. XmlNode xnLayout = xnDirtyLayout.Clone(); if (xnDirtyLayout == m_xnParentLayout && Level == 0 && OverallLayoutVisibilityChanged()) UpdateAttribute(xnLayout, "visibility", this.Checked ? "always" : "never"); XmlAttribute[] rgxa = new XmlAttribute[xnLayout.Attributes.Count]; xnLayout.Attributes.CopyTo(rgxa, 0); List<XmlNode> rgxnGen = new List<XmlNode>(); List<int> rgixn = new List<int>(); int cChildren = xnLayout.ChildNodes.Count; for (int i = 0; i < xnLayout.ChildNodes.Count; ++i) { XmlNode xn = xnLayout.ChildNodes[i]; if (xn.Name != "part") { rgxnGen.Add(xn); rgixn.Add(i); } } xnLayout.RemoveAll(); for (int i = 0; i < rgxa.Length; ++i) xnLayout.Attributes.SetNamedItem(rgxa[i]); for (int i = 0; i < Nodes.Count; ++i) { LayoutTreeNode ltn = (LayoutTreeNode)Nodes[i]; if (ltn.ParentLayout == xnDirtyLayout) { xnLayout.AppendChild(ltn.Configuration.CloneNode(true)); } else if (ltn.HiddenParent == xnDirtyLayout) { xnLayout.AppendChild(ltn.HiddenNode.CloneNode(true)); } else { for (int itn = 0; itn < ltn.MergedNodes.Count; itn++) { LayoutTreeNode ltnMerged = ltn.MergedNodes[itn]; if (ltnMerged.ParentLayout == xnDirtyLayout) { xnLayout.AppendChild(ltnMerged.Configuration.CloneNode(true)); break; } } } } XmlNode xnRef; for (int i = 0; i < rgxnGen.Count; ++i) { if (rgixn[i] <= xnLayout.ChildNodes.Count / 2) { xnRef = xnLayout.ChildNodes[rgixn[i]]; xnLayout.InsertBefore(rgxnGen[i], xnRef); } else { if (rgixn[i] < xnLayout.ChildNodes.Count) xnRef = xnLayout.ChildNodes[rgixn[i]]; else xnRef = xnLayout.LastChild; xnLayout.InsertAfter(rgxnGen[i], xnRef); } } if (!rgxn.Contains(xnLayout)) rgxn.Add(xnLayout); } if (Level == 0) return UpdateLayoutVisibilityIfChanged(); bool fDirty = Level > 0 && IsNodeDirty(); if (fDirty) StoreUpdatedValuesInConfiguration(); return fDirty; }
private List<LayoutTreeNode> BuildLayoutTree(XmlNode xnLayoutType) { List<LayoutTreeNode> rgltn = new List<LayoutTreeNode>(); foreach (XmlNode config in xnLayoutType.ChildNodes) { if (config is XmlComment || config.Name != "configure") continue; rgltn.Add(BuildMainLayout(config)); } return rgltn; }
/// <summary> /// Adjust our height (but, since we're changing the height to hide a panel at the bottom, /// do NOT move controls docked bottom). /// </summary> void AdjustHeightAndMinSize(int newHeight, Size newMinSize) { var bottomControls = new List<Control>(); SuspendLayout(); foreach (Control c in Controls) { if (((int) c.Anchor & (int) AnchorStyles.Bottom) == 0) continue; bottomControls.Add(c); c.Anchor = (AnchorStyles)((int)c.Anchor & ~((int)AnchorStyles.Bottom)); } if (newHeight < Height) { // Adjust minsize first, lest new height is less than old minimum. MinimumSize = newMinSize; Height = newHeight; } else // increasing height { // Adjust height first, lest old height is less than new minimum. Height = newHeight; MinimumSize = newMinSize; } PerformLayout(); foreach (var c in bottomControls) { c.Anchor = (AnchorStyles)((int)c.Anchor | ((int)AnchorStyles.Bottom)); } ResumeLayout(); }
/// <summary> /// This is the one (and should be only) handler for the user Refresh command. /// Refresh wants to first clean up the cache, then give things like Clerks a /// chance to reload stuff (calling the old OnRefresh methods), then give /// windows a chance to redisplay themselves. /// </summary> public void OnMasterRefresh(object sender) { CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. string sDatabase = null; string sServer = null; FwXWindow activeWnd = ActiveForm as FwXWindow; if (activeWnd != null) { sDatabase = activeWnd.Cache.DatabaseName.ToLowerInvariant(); sServer = activeWnd.Cache.ServerName.ToLowerInvariant(); } List<FwXWindow> rgxw = new List<FwXWindow>(); foreach (IFwMainWnd wnd in MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { if (sDatabase == null || (xwnd.Cache.DatabaseName.ToLowerInvariant() == sDatabase && xwnd.Cache.ServerName.ToLowerInvariant() == sServer)) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } } FwApp.App.ClearAllCaches(sDatabase, sServer); foreach (FwXWindow xwnd in rgxw) { if (activeWnd != xwnd) xwnd.FinishRefresh(); } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Activate(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Update all the changed wordforms to point at the new Wf. /// Must be called before we change the text of the paragraph, as it /// depends on offsets into the old string. /// This is usually redundant, since updating the text of the paragraph automatically updates the /// segment analysis. However, this can be used to force an upper case occurrence to be analyzed /// as the lower-case wordform (FWR-3134). The paragraph adjustment does not force this back /// (at least not immediately). /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateInstanceOf(ProgressDialogWorkingOn progress) { Debug.Fail( @"use of this method was causing very unpleasant data corruption in texts, the bug it fixed needs addressing though."); var analysesToChange = new List<Tuple<ISegment, int>>(); RespellingSda sda = m_action.RespellSda; foreach (var hvoFake in m_changes) { int hvoSeg = sda.get_ObjectProp(hvoFake, ConcDecorator.kflidSegment); int beginOffset = sda.get_IntProp(hvoFake, ConcDecorator.kflidBeginOffset); if (hvoSeg > 0) { ISegment seg = m_action.RepoSeg.GetObject(hvoSeg); int canal = seg.AnalysesRS.Count; for (int i = 0; i < canal; ++i) { IAnalysis anal = seg.AnalysesRS[i]; if (anal.HasWordform && anal.Wordform.Hvo == m_action.OldWordform) { if (seg.GetAnalysisBeginOffset(i) == beginOffset) { // Remember that we want to change it, but don't do it yet, // because there may be other occurrences in this paragraph, // and changing the analysis to something which may have a different // length could mess things up. analysesToChange.Add(new Tuple<ISegment, int>(seg, i)); } } } } } if (analysesToChange.Count > 0) { var newVal = new[] { m_action.RepoWf.GetObject(m_action.NewWordform) }; foreach (var change in analysesToChange) change.Item1.AnalysesRS.Replace(change.Item2, 1, newVal); } RespellUndoAction.UpdateProgress(progress); }
/// <summary> /// Initialize an Concorder dlg. /// </summary> /// <param name="xwindow">The main window for this modeless dlg.</param> /// <param name="configurationNode">The XML node to control the ConcorderControl.</param> internal void SetDlgInfo(XWindow xwindow, XmlNode configurationNode) { CheckDisposed(); if (xwindow == null) throw new ArgumentNullException("Main window is missing."); if (m_myOwnPrivateMediator != null) throw new InvalidOperationException("It is not legal to call this method more than once."); m_xwindow = xwindow; m_cache = m_xwindow.Mediator.PropertyTable.GetValue("cache") as FdoCache; m_myOwnPrivateMediator = new Mediator(); // The extension XML files should be stored in the data area, not in the code area. // This reduces the need for users to have administrative privileges. string dir = DirectoryFinder.GetFWDataSubDirectory(@"Language Explorer\Configuration\Extensions\Concorder"); m_myOwnPrivateMediator.StringTbl = new StringTable(dir); m_myOwnPrivateMediator.PropertyTable.SetProperty("cache", m_cache, false); m_myOwnPrivateMediator.PropertyTable.SetPropertyPersistence("cache", false); m_myOwnPrivateMediator.PropertyTable.SetPropertyDispose("cache", false); m_myOwnPrivateMediator.SpecificToOneMainWindow = true; //FwStyleSheet styleSheet = m_xwindow.Mediator.PropertyTable.GetValue("FwStyleSheet") as FwStyleSheet; //m_myOwnPrivateMediator.PropertyTable.SetProperty("FwStyleSheet", styleSheet); //m_myOwnPrivateMediator.PropertyTable.SetPropertyPersistence("FwStyleSheet", false); //m_myOwnPrivateMediator.PropertyTable.SetPropertyPersistence("FwStyleSheet", false); List<ConcorderControl.FindComboFillerBase> fcfList = new List<ConcorderControl.FindComboFillerBase>(); ConcorderControl.FindComboFillerBase fcf = null; // Find: main POS: // UsedBy: MSAs, senses, entries, analyses (x2), wordforms, compound rules fcf = new ConcorderControl.FindPossibilityComboFiller(m_cache.LangProject.PartsOfSpeechOA); fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcGrammaticalCategory']")); fcfList.Add(fcf); // Find: sense // UsedBy: Analyses, Sentences fcf = new ConcorderControl.FindComboFiller(); fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcSense']")); fcfList.Add(fcf); /* // Find: allomorph (main and alternates) // UsedBy: Analyses, Sentences, Ad hoc rules fcf = new ConcorderControl.FindComboFiller(); fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcAllomorph']")); fcfList.Add(fcf); // Find: entry // UsedBy: Analyses, Sentences fcf = new ConcorderControl.FindComboFiller(); fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcEntry']")); fcfList.Add(fcf); // Find: Wordform // UsedBy: Sentences fcf = new ConcorderControl.FindComboFiller(); fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcWordform']")); fcfList.Add(fcf); //// Find: MSA //// UsedBy: Senses, Analyses, Sentences //fcf = new ConcorderControl.FindComboFiller(); //fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcGrammaticalFunction']")); //fcfList.Add(fcf); //// Find: Analysis //// UsedBy: Sentences //fcf = new ConcorderControl.FindComboFiller(); //fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcAnalysis']")); //fcfList.Add(fcf); //// Find: Environment //// UsedBy: Allomorphs //fcf = new ConcorderControl.FindComboFiller(); //fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcEnvironment']")); //fcfList.Add(fcf); //// Find: Word-level gloss //// UsedBy: Sentences //fcf = new ConcorderControl.FindComboFiller(); //fcf.Init(m_myOwnPrivateMediator, configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcWordLevelGloss']")); //fcfList.Add(fcf); // Find: Phonemes // UsedBy: // Find: Natural Classes // UsedBy: // Find: Features // UsedBy: // Find: Exception Features // UsedBy: // // Find: eng rev POS // // UsedBy: rev entries // ubfList = new List<ConcorderControl.UsedByFiller>(); // fcfConfigNode = configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcXX']"); // fcf = new ConcorderControl.FindComboFiller("Grammatical Category: English Reversal", ubfList); // fcfList.Add(fcf); // ubfList.Add(new ConcorderControl.UsedByFiller("Reversal Entries" )); // // Find: spn rev POS // // UsedBy: rev entries // ubfList = new List<ConcorderControl.UsedByFiller>(); // fcfConfigNode = configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcXX']"); // fcf = new ConcorderControl.FindComboFiller("Grammatical Category: Spanish Reversal", ubfList); // fcfList.Add(fcf); // ubfList.Add(new ConcorderControl.UsedByFiller("Reversal Entries" )); //// Find: Academic Domain //// UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcAcademicDomain']"), // ubfList, // m_cache.LangProject.LexDbOA.DomainTypesOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Senses']"))); //// Find: Anthropology Category //// UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcAnthropologyCategory']"), // ubfList, // m_cache.LangProject.AnthroListOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Senses']"))); // Find: Confidence Level // UsedBy: // Find: Education Level // UsedBy: //// Find: Entry Type //// UsedBy: Entries //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcEntryType']"), // ubfList, // m_cache.LangProject.LexDbOA.EntryTypesOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Entries']"))); // Find: Feature Type // UsedBy: // Find: Lexical Reference Type // UsedBy: // Find: Location // UsedBy: // Find: Minor Entry Condition // UsedBy: Entries //ubfList = new List<ConcorderControl.UsedByFiller>(); //// TODO: Where is its pos list? //fcf = new ConcorderControl.FindComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcMinorEntryCondition']"), // ubfList); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller("Entries" )); //// Find: Morpheme Type //// UsedBy: Allomorphs //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcMorphemeType']"), // ubfList, // m_cache.LangProject.LexDbOA.MorphTypesOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Allomorphs']"))); // Find: People // UsedBy: // Find: Positions // UsedBy: // Find: Restrictions // UsedBy: //// Find: Semantic Domain //// UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcSemanticDomain']"), // ubfList, // m_cache.LangProject.SemanticDomainListOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Senses']"))); // Find: Sense Status // UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //// TODO: Where is the pos list? //fcf = new ConcorderControl.FindComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcSenseStatus']"), // ubfList); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller("Senses" )); //// Find: Sense Type //// UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcSenseType']"), // ubfList, // m_cache.LangProject.LexDbOA.SenseTypesOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Senses']"))); // Find: Status // UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //// TODO: Where is the pos list? //fcf = new ConcorderControl.FindComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcStatus']"), // ubfList); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller("Senses" )); // Find: Translation Type // UsedBy: //// Find: Usages //// UsedBy: Senses //ubfList = new List<ConcorderControl.UsedByFiller>(); //fcf = new ConcorderControl.FindPossibilityComboFiller( // configurationNode.SelectSingleNode("sourcecontrols/control[@id='srcUsages']"), // ubfList, // m_cache.LangProject.LexDbOA.UsageTypesOA); //fcfList.Add(fcf); //ubfList.Add(new ConcorderControl.UsedByFiller( // configurationNode.SelectSingleNode("targetcontrols/control[@id='Senses']"))); */ m_concorderControl.SetupDlg(m_myOwnPrivateMediator, fcfList, fcfList[0]); }
internal IFlexMacro[] AssignMacrosToSlots(List<IFlexMacro> macroImplementors) { IFlexMacro[] macros = new IFlexMacro[MacroCount]; var conflicts = new List<IFlexMacro>(); // Put each at its preferred key if possible foreach (var macro in macroImplementors) { int index = GetMacroIndex(macro.PreferredFunctionKey); if (macros[index] == null) macros[index] = macro; else conflicts.Add(macro); } // Put any conflicts in remaining slots; if too many, arbitrary ones will be left out. foreach (var macro in conflicts) { for (int index = 0; index < MacroCount; index++) { if (macros[index] == null) { macros[index] = macro; break; } } } return macros; }
private List<string> GetExcludedFlexStyleNames() { List<string> styles = new List<string>(); switch (m_cboTypes.SelectedIndex) { case 0: // basic -- use current table of styles to obtain names foreach (var style in m_styleTable.Keys) { if (style.StartsWith("Dictionary") || style.StartsWith("Classified")) styles.Add(style); } break; case 1: // all break; case 2: // custom -- styleSheet contains all built-in styles (can't change names) foreach (var style in m_styleSheet.Styles) { if (style.IsBuiltIn) styles.Add(style.Name); } styles.Add(StyleUtils.DefaultParaCharsStyleName); break; case 3: // dictionary -- use current table of styles to obtain names foreach (var style in m_styleTable.Keys) { if (!style.StartsWith("Dictionary") && !style.StartsWith("Classified")) styles.Add(style); } styles.Add(StyleUtils.DefaultParaCharsStyleName); break; } return styles; }
/// <summary> /// /// </summary> /// <param name="argument">The xCore Command object.</param> /// <returns>true</returns> public bool OnAddApprovedAnalysis(object argument) { var mainWnd = (FwXWindow)m_dataEntryForm.FindForm(); using (EditMorphBreaksDlg dlg = new EditMorphBreaksDlg(mainWnd.Mediator.HelpTopicProvider)) { IWfiWordform wf = Wordform; if (wf == null) return true; ITsString tssWord = Wordform.Form.BestVernacularAlternative; string morphs = tssWord.Text; var cache = Cache; dlg.Initialize(tssWord, morphs, cache.MainCacheAccessor.WritingSystemFactory, cache, m_dataEntryForm.Mediator.StringTbl, m_dataEntryForm.StyleSheet); // Making the form active fixes problems like LT-2619. // I'm (RandyR) not sure what adverse impact might show up by doing this. mainWnd.Activate(); if (dlg.ShowDialog(mainWnd) == DialogResult.OK) { morphs = dlg.GetMorphs().Trim(); if (morphs.Length == 0) return true; string[] prefixMarkers = MorphServices.PrefixMarkers(cache); string[] postfixMarkers = MorphServices.PostfixMarkers(cache); List<string> allMarkers = new List<string>(); foreach (string s in prefixMarkers) { allMarkers.Add(s); } foreach (string s in postfixMarkers) { if (!allMarkers.Contains(s)) allMarkers.Add(s); } allMarkers.Add(" "); string[] breakMarkers = new string[allMarkers.Count]; for (int i = 0; i < allMarkers.Count; ++i) breakMarkers[i] = allMarkers[i]; string fullForm = SandboxBase.MorphemeBreaker.DoBasicFinding(morphs, breakMarkers, prefixMarkers, postfixMarkers); var command = (Command) argument; UndoableUnitOfWorkHelper.Do(command.UndoText, command.RedoText, cache.ActionHandlerAccessor, () => { IWfiAnalysis newAnalysis = Cache.ServiceLocator.GetInstance<IWfiAnalysisFactory>().Create(); Wordform.AnalysesOC.Add(newAnalysis); newAnalysis.ApprovalStatusIcon = 1; // Make it human approved. int vernWS = TsStringUtils.GetWsAtOffset(tssWord, 0); foreach (string morph in fullForm.Split(Unicode.SpaceChars)) { if (morph != null && morph.Length != 0) { IWfiMorphBundle mb = cache.ServiceLocator.GetInstance<IWfiMorphBundleFactory>().Create(); newAnalysis.MorphBundlesOS.Add(mb); mb.Form.set_String(vernWS, Cache.TsStrFactory.MakeString(morph, vernWS)); } } }); } } return true; }
/// <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; }
public IxCoreColleague[] GetMessageTargets() { CheckDisposed(); List<IxCoreColleague> targets = new List<IxCoreColleague>(); targets.Add(this); return targets.ToArray(); }
/// <summary> /// Add to excludedSenses (an array of HVOs) any value in property flid of object /// hvoBase (which might be entry or sense) which is not a member of includedSenses. /// Also any nested senses. /// </summary> /// <param name="hvoBase"></param> /// <param name="flid"></param> /// <param name="excludedSenses"></param> /// <param name="includedSenses"></param> void AddExcludedSenses(ISilDataAccess sda, int hvoBase, int flid, List<int> excludedSenses, List<int> includedSenses) { int chvo = sda.get_VecSize(hvoBase, flid); for (int ihvo = 0; ihvo < chvo; ihvo++) { int hvoSense = sda.get_VecItem(hvoBase, flid, ihvo); if (!includedSenses.Contains(hvoSense)) excludedSenses.Add(hvoSense); AddExcludedSenses(sda, hvoSense, (int)LexSense.LexSenseTags.kflidSenses, excludedSenses, includedSenses); } }
private List<IStText> GetScriptureTexts() { var result = new List<IStText>(); if (m_propertyTable == null) return result; var idList = m_propertyTable.GetStringProperty(PersistPropertyName, ""); foreach (string id in idList.Split(',')) { if (id.Length == 0) continue; // we get one empty string even from splitting an empty one. Guid guid; try { guid = new Guid(Convert.FromBase64String(id)); } catch (FormatException) { // Just ignore this one. (I'd like to Assert, but a unit test verifies we can handle garbage). Debug.WriteLine(PersistPropertyName + "contains invalid guid " + id); continue; } IStText item; if (m_stTextRepository.TryGetObject(guid, out item)) result.Add(m_stTextRepository.GetObject(guid)); // An invalid item is not an error, it may just have been deleted while the interesting // text list was not monitoring things. } return result; }
/// ------------------------------------------------------------------------------------ /// <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> /// This routine is where InterlinMaster sends the results of running the IFilterTextsDialog. /// The list may include regular as well as scripture texts. /// We persist them separately because Scripture is excluded by default and regular texts are included by default. /// Thus, storing a list of the INCLUDED scripture means that originally, or if we clear all saved settings, /// NO scripture is included, and any newly created Scripture is also excluded until manually added. /// Storing a lis of EXCLUDED regular texts means that originally, or if we clear all saved settings, /// ALL regular texts are included, and if we add a new one, it is automatically included. /// </summary> /// <param name="stTexts"></param> public void SetInterestingTexts(IEnumerable<IStText> stTexts) { var oldTexts = InterestingTexts.ToArray(); m_scriptureTexts = new List<IStText>(); var excludedGuids = new HashSet<Guid>(from obj in AllCoreTexts select obj.Guid); foreach (var obj in stTexts) { if (obj.Owner is IText) excludedGuids.Remove(obj.Guid); else m_scriptureTexts.Add(obj); } UpdatePropertyTable(); UpdateExcludedCoreTexts(excludedGuids); m_coreTexts = null; m_interestingTests = null; // regenerate when next needed. (Before we raise changed, which may use it...) var newTexts = InterestingTexts.ToArray(); int firstChange = 0; int minLength = Math.Min(oldTexts.Length, newTexts.Length); while (firstChange < minLength && newTexts[firstChange] == oldTexts[firstChange]) firstChange++; int endMatchCount = 0; while (endMatchCount < minLength - firstChange && newTexts[newTexts.Length - endMatchCount - 1] == oldTexts[oldTexts.Length - endMatchCount - 1]) endMatchCount++; // Enhance JohnT: could look for unchanged items in the list. But this is fairly rare, // typically when someone runs the configure dialog and OKs it. RaiseInterestingTextsChanged(firstChange, newTexts.Length - firstChange - endMatchCount, oldTexts.Length - firstChange - endMatchCount); }