private bool AddNewText(Command command)
        {
            // Get the default writing system for the new text.  See LT-6692.
            m_wsPrevText = Cache.DefaultVernWs;
            if (CurrentObject != null && Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Count > 1)
            {
                m_wsPrevText = WritingSystemServices.ActualWs(Cache, WritingSystemServices.kwsVernInParagraph,
                                                              CurrentObject.Hvo, StTextTags.kflidParagraphs);
            }
            if (m_list.Filter != null)
            {
                // Tell the user we're turning off the filter, and then do it.
                MessageBox.Show(ITextStrings.ksTurningOffFilter, ITextStrings.ksNote, MessageBoxButtons.OK);
                m_mediator.SendMessage("RemoveFilters", this);
                m_activeMenuBarFilter = null;
            }
            SaveOnChangeRecord();             // commit any changes before we create a new text.
            RecordList.ICreateAndInsert <IStText> createAndInsertMethodObj;
            if (command != null)
            {
                createAndInsertMethodObj = new UndoableCreateAndInsertStText(Cache, command, this);
            }
            else
            {
                createAndInsertMethodObj = new NonUndoableCreateAndInsertStText(Cache, this);
            }
            var newText = m_list.DoCreateAndInsert(createAndInsertMethodObj);

            // Check to if a genre was assigned to this text
            // (when selected from the text list: ie a genre w/o a text was sellected)
            string property  = GetCorrespondingPropertyName("DelayedGenreAssignment");
            var    genreList = m_mediator.PropertyTable.GetValue(property, null) as List <TreeNode>;
            var    ownerText = newText.Owner as FDO.IText;

            if (genreList != null && genreList.Count > 0 && ownerText != null)
            {
                foreach (var node in genreList)
                {
                    ownerText.GenresRC.Add((ICmPossibility)node.Tag);
                }
                m_mediator.PropertyTable.RemoveProperty(property);
            }

            if (CurrentObject == null || CurrentObject.Hvo == 0)
            {
                return(false);
            }
            if (!InDesiredTool("interlinearEdit"))
            {
                m_mediator.SendMessage("FollowLink", new FwLinkArgs("interlinearEdit", CurrentObject.Guid));
            }
            // This is a workable alternative (where link is the one created above), but means this code has to know about the FwXApp class.
            //(FwXApp.App as FwXApp).OnIncomingLink(link);
            // This alternative does NOT work; it produces a deadlock...I think the remote code is waiting for the target app
            // to return to its message loop, but it never does, because it is the same app that is trying to send the link, so it is busy
            // waiting for 'Activate' to return!
            //link.Activate();
            return(true);
        }
Beispiel #2
0
            public void CreateStText(LcmCache cache)
            {
                CreateAndInsertStText createAndInsertStText = new NonUndoableCreateAndInsertStText(cache, this);
                XmlDocument           xmlDoc = new XmlDocument();
                // xml taken from a dummy project
                string outerXmlFromProject = "<recordList owner=\"LangProject\" property=\"InterestingTexts\"><!-- We use a decorator here so it can override certain virtual properties and limit occurrences to interesting texts. --><decoratorClass assemblyPath=\"xWorks.dll\" class=\"SIL.FieldWorks.XWorks.InterestingTextsDecorator\" /></recordList>";

                xmlDoc.LoadXml(outerXmlFromProject);
                XmlNode root = xmlDoc.FirstChild;
                XmlNode attr = xmlDoc.CreateNode(XmlNodeType.Attribute, "property", "InterestingTexts");

                root.Attributes.SetNamedItem(attr);
                m_list = RecordList.Create(cache, m_mediator, m_propertyTable, root);
                createAndInsertStText.Create();
            }