コード例 #1
0
        /// <summary>
        /// Initialize the combo contents.
        /// </summary>
        public void SetupCombo()
        {
            CheckDisposed();

            ITsStrBldr builder = TsStrBldrClass.Create();

            m_fInitializing = true;
            int wordformHvo = m_owner.GetWordformHvoOfAnalysis();

            // Add the analyses, and recursively the other items.
            foreach (int hvoAnalysis in m_cache.GetVectorProperty(wordformHvo,
                                                                  (int)WfiWordform.WfiWordformTags.kflidAnalyses, false))
            {
                IWfiAnalysis wa = (IWfiAnalysis)CmObject.CreateFromDBObject(m_cache,
                                                                            hvoAnalysis,
                                                                            CmObject.GetTypeFromFullClassName(m_cache, "SIL.FieldWorks.FDO.Ling.WfiAnalysis"),
                                                                            false, false);
                Opinions o = wa.GetAgentOpinion(
                    m_cache.LangProject.DefaultUserAgent);
                // skip any analysis the user has disapproved.
                if (o != Opinions.disapproves)
                {
                    AddAnalysisItems(hvoAnalysis);
                    AddSeparatorLine();
                }
            }

            // Add option to clear the analysis altogeter.
            AddItem(wordformHvo, MakeSimpleString(ITextStrings.ksNewAnalysis), false, WfiWordform.kclsidWfiWordform);
            // Add option to reset to the default
            AddItem(0, MakeSimpleString(ITextStrings.ksUseDefaultAnalysis), false);

            m_fInitializing = false;
        }
コード例 #2
0
        public void SetAgentOpinion()
        {
            ICmAgent     agent = Cache.LangProject.DefaultComputerAgent;
            IWfiWordform wf    = WfiWordformServices.FindOrCreateWordform(Cache,
                                                                          TsStringUtils.MakeTss("xxxyyyzzz12234", Cache.DefaultVernWs));
            IWfiAnalysis wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create();

            wf.AnalysesOC.Add(wa);
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.approves);
            Assert.AreEqual(Opinions.approves, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.disapproves);
            Assert.AreEqual(Opinions.disapproves, wa.GetAgentOpinion(agent));

            wa.SetAgentOpinion(agent, Opinions.noopinion);
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));
        }
コード例 #3
0
		private void AssertHumanApprovedOpinion(IWfiWordform wfiWord, IWfiAnalysis wfiAnalysis)
		{
			Assert.That(wfiWord.HumanApprovedAnalyses.Count(), Is.EqualTo(1));
			ICmAgent humanAgent = Cache.LangProject.DefaultUserAgent;
			Assert.That(wfiAnalysis.GetAgentOpinion(humanAgent), Is.EqualTo(Opinions.approves));
		}
コード例 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the root box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void MakeRoot()
        {
            CheckDisposed();

            if (m_fdoCache == null || DesignMode || m_wfiAnalysis == null)
            {
                return;
            }

            m_rootb = VwRootBoxClass.Create();
            m_rootb.SetSite(this);

            m_vc = new InterlinVc(m_fdoCache);
            // Theory has it that the slices that have 'true' in this attribute will allow the sandbox to be used.
            // We'll see how the theory goes, when I get to the point of wanting to see the sandbox.
            var isEditable = IsEditable;

            m_vc.ShowMorphBundles = true;
            m_vc.ShowDefaultSense = true;
            if ((m_wfiAnalysis.GetAgentOpinion(m_fdoCache.LanguageProject.DefaultParserAgent) == Opinions.approves) &&
                (m_wfiAnalysis.GetAgentOpinion(m_fdoCache.LanguageProject.DefaultUserAgent) != Opinions.approves))
            {
                m_vc.UsingGuess = true;
            }

            // JohnT: kwsVernInParagraph is rather weird here, where we don't have a paragraph, but it allows the
            // VC to deduce the WS of the wordform, not from the paragraph, but from the best vern WS of the wordform itself.
            if (isEditable)
            {
                m_vc.LineChoices = new EditableInterlinLineChoices(m_fdoCache.LanguageProject, WritingSystemServices.kwsVernInParagraph,
                                                                   m_fdoCache.DefaultAnalWs);
            }
            else
            {
                m_vc.LineChoices = new InterlinLineChoices(m_fdoCache.LanguageProject, WritingSystemServices.kwsVernInParagraph,
                                                           m_fdoCache.DefaultAnalWs);
            }
            m_vc.LineChoices.Add(InterlinLineChoices.kflidMorphemes);          // 1
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexEntries);         //2
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexGloss);           //3
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexPos);             //4

            m_rootb.DataAccess = m_fdoCache.MainCacheAccessor;
            FixWs();             // AFTER setting DA!

            const int selectorId = InterlinVc.kfragSingleInterlinearAnalysisWithLabelsLeftAlign;

            m_rootb.SetRootObject(m_wfiAnalysis.Hvo, m_vc, selectorId, m_styleSheet);

            base.MakeRoot();

            if (!IsEditable)
            {
                return;
            }

            m_oneAnalSandbox = new OneAnalysisSandbox(m_fdoCache,
                                                      Mediator,
                                                      StyleSheet,
                                                      m_vc.LineChoices,
                                                      m_wfiAnalysis.Hvo)
            {
                Visible = false
            };
            Controls.Add(m_oneAnalSandbox);
            if (m_oneAnalSandbox.RootBox == null)
            {
                m_oneAnalSandbox.MakeRoot();                    // adding sandbox to Controls doesn't make rootbox.
            }
            InitSandbox();
            m_oneAnalSandbox.SizeChanged += (HandleSandboxSizeChanged);
            if (m_fSliceIsCurrent)
            {
                TurnOnSandbox();
            }
        }