public ConfigureInterlinDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider,
                                       InterlinLineChoices choices)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            AccessibleName = GetType().Name;

            m_helpTopicProvider        = helpTopicProvider;
            helpProvider               = new HelpProvider();
            helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
            helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

            m_cachedComboBoxes = new Dictionary <ColumnConfigureDialog.WsComboContent, ComboBox.ObjectCollection>();

            m_cache   = cache;
            m_choices = choices;

            InitPossibilitiesList();

            // Owner draw requires drawing the column header as well as the list items.  See LT-7007.
            currentList.DrawColumnHeader += currentList_DrawColumnHeader;
            InitCurrentList(0);             // also inits WsCombo.

            currentList.SelectedIndexChanged += currentList_SelectedIndexChanged;
            optionsList.SelectedIndexChanged += optionsList_SelectedIndexChanged;
            EnableControls();
        }
        protected InterlinearExporter(FdoCache cache, XmlWriter writer, ICmObject objRoot,
                                      InterlinLineChoices lineChoices, InterlinVc vc)
            : base(null, cache.MainCacheAccessor, objRoot.Hvo)
        {
            m_cache            = cache;
            m_writer           = writer;
            m_flidStTextTitle  = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);
            m_flidStTextSource = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Source", false);
            m_vc = vc;
            SetTextTitleAndMetadata(objRoot as IStText);

            // Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
            IMoMorphType mmtStem;
            IMoMorphType mmtPrefix;
            IMoMorphType mmtSuffix;
            IMoMorphType mmtInfix;
            IMoMorphType mmtBoundStem;
            IMoMorphType mmtSimulfix;
            IMoMorphType mmtSuprafix;

            m_cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetMajorMorphTypes(
                out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
                out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic,
                out mmtSimulfix, out mmtSuprafix);

            m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
            m_repoObj   = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>();
        }
Exemplo n.º 3
0
		protected InterlinearExporter(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
			: base(null, cache.MainCacheAccessor, hvoRoot)
		{
			m_cache = cache;
			m_writer = writer;
			ktagParaSegments = InterlinVc.ParaSegmentTag(cache);
			ktagSegmentForms = InterlinVc.SegmentFormsTag(cache);
			m_flidStringValue = CmBaseAnnotation.StringValuePropId(cache);
			m_lineChoices = lineChoices;
			m_defaultGlossVirtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
			m_vc = vc;
			m_tssPendingTitle = tssTextName;
			m_tssTitleAbbreviation = tssTextAbbreviation;

			// Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
			IMoMorphType mmtStem;
			IMoMorphType mmtPrefix;
			IMoMorphType mmtSuffix;
			IMoMorphType mmtInfix;
			IMoMorphType mmtBoundStem;
			IMoMorphType mmtSimulfix;
			IMoMorphType mmtSuprafix;
			MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
				out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
		}
Exemplo n.º 4
0
        public static InterlinLineChoices Restore(string data, ILgWritingSystemFactory wsf, int defVern, int defAnalysis, ILangProject proj)
        {
            InterlinLineChoices result;

            string[] parts = data.Split(',');

            switch (parts[0])
            {
            case "InterlinLineChoices":
                result = new InterlinLineChoices(defVern, defAnalysis, proj);
                break;

            case "EditableInterlinLineChoices":
                result = new EditableInterlinLineChoices(defVern, defAnalysis, proj);
                break;

            default:
                throw new Exception("Unrecognised type of InterlinLineChoices: " + parts[0]);
            }
            for (int i = 1; i < parts.Length; i++)
            {
                string[] flidAndWs = parts[i].Split('%');
                if (flidAndWs.Length != 2)
                {
                    throw new Exception("Unrecognized InterlinLineSpec: " + parts[i]);
                }
                int flid = Int32.Parse(flidAndWs[0]);
                int ws   = wsf.GetWsFromStr(flidAndWs[1]);
                result.Add(flid, ws);
            }
            return(result);
        }
Exemplo n.º 5
0
		public ConfigureInterlinDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider,
			InterlinLineChoices choices)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			AccessibleName = GetType().Name;

			m_helpTopicProvider = helpTopicProvider;
			helpProvider = new HelpProvider();
			helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
			helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
			helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

			m_cachedComboBoxes = new Dictionary<ColumnConfigureDialog.WsComboContent, ComboBox.ObjectCollection>();

			m_cache = cache;
			m_choices = choices;

			InitPossibilitiesList();

			// Owner draw requires drawing the column header as well as the list items.  See LT-7007.
			currentList.DrawColumnHeader += currentList_DrawColumnHeader;
			InitCurrentList(0); // also inits WsCombo.

			currentList.SelectedIndexChanged += currentList_SelectedIndexChanged;
			optionsList.SelectedIndexChanged += optionsList_SelectedIndexChanged;
			EnableControls();
		}
Exemplo n.º 6
0
        protected void ValidateExportedParagraph(XmlDocument exportedXml, InterlinLineChoices choices, IStTxtPara para)
        {
            ExportedInterlinearReader  exportReader = new ExportedInterlinearReader(exportedXml, choices);
            ExportedParagraphValidator validator    = new ExportedParagraphValidator(exportReader, para);

            validator.ValidateParagraphs(para, exportReader.GetParaNode(para.IndexInOwner));
        }
Exemplo n.º 7
0
 internal ExportedParagraphValidator(ExportedInterlinearReader reader, IStTxtPara para)
 {
     m_reader  = reader;
     m_choices = reader.Choices;
     m_para    = para;
     m_cache   = m_para.Cache;
 }
Exemplo n.º 8
0
        public ConfigureInterlinDialog(FdoCache cache, InterlinLineChoices choices)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.helpProvider = new System.Windows.Forms.HelpProvider();
            this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
            this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
            this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);

            m_cachedComboBoxes = new Dictionary <ColumnConfigureDialog.WsComboContent, ComboBox.ObjectCollection>();

            m_cache   = cache;
            m_choices = choices;

            InitPossibilitiesList();

            // Owner draw requires drawing the column header as well as the list items.  See LT-7007.
            currentList.DrawColumnHeader += new DrawListViewColumnHeaderEventHandler(currentList_DrawColumnHeader);
            InitCurrentList(0);             // also inits WsCombo.

            currentList.SelectedIndexChanged += new EventHandler(currentList_SelectedIndexChanged);
            optionsList.SelectedIndexChanged += new EventHandler(optionsList_SelectedIndexChanged);
            EnableControls();
        }
Exemplo n.º 9
0
			public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox)
			{
				m_caches = caches;
				m_cache = caches.MainCache; //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this.
				m_choices = choices;
				m_sandbox = sandbox;
				m_fIconsForAnalysisChoices = fIconsForAnalysisChoices;
				m_wsAnalysis = caches.MainCache.DefaultAnalWs;
				m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs;
				m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs);
				m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
				m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs);
				m_tssMissingEntry = m_tssMissingMorphs;
				// It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default
				// fonts may have different sizes, requiring differnt line heights to align things well.
				m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
				m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
				m_tssMissingWordPos = m_tssMissingMorphPos;
				m_PulldownArrowPic = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow);
				m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture);
				IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs);
				if (wsObj != null)
					m_fRtl = wsObj.RightToLeftScript;

			}
Exemplo n.º 10
0
		/// <summary>
		/// Create a new one.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="ss"></param>
		/// <param name="choices"></param>
		/// <param name="analysis"></param>
		/// <param name="mediator"></param>
		public TryAWordSandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss, InterlinLineChoices choices,
			IAnalysis analysis)
			: base(cache, mediator, ss, choices)
		{
			SizeToContent = true;
			LoadForWordBundleAnalysis(analysis.Hvo);
		}
Exemplo n.º 11
0
        private void AddAdditionalWsMenuItem(ToolStripMenuItem addSubMenu,
                                             InterlinLineChoices curLineChoices, int ilineChoice)
        {
            var curSpec             = curLineChoices[ilineChoice];
            var choices             = GetWsComboItems(curSpec);
            var curFlidDisplayedWss = curLineChoices.OtherWritingSystemsForFlid(curSpec.Flid, 0);
            var curRealWs           = GetRealWsFromSpec(curSpec);

            if (!curFlidDisplayedWss.Contains(curRealWs))
            {
                curFlidDisplayedWss.Add(curRealWs);
            }
            var lgWsAcc = Cache.LanguageWritingSystemFactoryAccessor;

            foreach (var item in choices)
            {
                var itemRealWs = lgWsAcc.GetWsFromStr(item.Id);
                // Skip 'Magic' wss and ones that are already displayed
                if (itemRealWs == 0 || curFlidDisplayedWss.Contains(itemRealWs))
                {
                    continue;
                }
                var menuItem = new AddWritingSystemMenuItem(curSpec.Flid, itemRealWs);
                menuItem.Text   = item.ToString();
                menuItem.Click += new EventHandler(addWsToFlidItem_Click);
                addSubMenu.DropDownItems.Add(menuItem);
            }
        }
Exemplo n.º 12
0
		public ConfigureInterlinDialog(FdoCache cache, InterlinLineChoices choices)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.helpProvider = new System.Windows.Forms.HelpProvider();
			this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
			this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
			this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);

			m_cachedComboBoxes = new Dictionary<ColumnConfigureDialog.WsComboContent, ComboBox.ObjectCollection>();

			m_cache = cache;
			m_choices = choices;

			InitPossibilitiesList();

			// Owner draw requires drawing the column header as well as the list items.  See LT-7007.
			currentList.DrawColumnHeader += new DrawListViewColumnHeaderEventHandler(currentList_DrawColumnHeader);
			InitCurrentList(0); // also inits WsCombo.

			currentList.SelectedIndexChanged += new EventHandler(currentList_SelectedIndexChanged);
			optionsList.SelectedIndexChanged += new EventHandler(optionsList_SelectedIndexChanged);
			EnableControls();
		}
Exemplo n.º 13
0
        /// <summary>
        /// Persist the new line choices and
        /// Reconstruct the document based on the given newChoices for interlinear lines.
        /// </summary>
        /// <param name="newChoices"></param>
        internal virtual void UpdateForNewLineChoices(InterlinLineChoices newChoices)
        {
            m_vc.LineChoices = newChoices;
            LineChoices      = newChoices;

            PersistAndDisplayChangedLineChoices();
        }
Exemplo n.º 14
0
		protected InterlinearExporter(FdoCache cache, XmlWriter writer, ICmObject objRoot,
			InterlinLineChoices lineChoices, InterlinVc vc)
			: base(null, cache.MainCacheAccessor, objRoot.Hvo)
		{
			m_cache = cache;
			m_writer = writer;
			m_flidStTextTitle = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);
			m_flidStTextSource = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Source", false);
			m_vc = vc;
			SetTextTitleAndMetadata(objRoot as IStText);

			// Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
			IMoMorphType mmtStem;
			IMoMorphType mmtPrefix;
			IMoMorphType mmtSuffix;
			IMoMorphType mmtInfix;
			IMoMorphType mmtBoundStem;
			IMoMorphType mmtSimulfix;
			IMoMorphType mmtSuprafix;
			m_cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetMajorMorphTypes(
				out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
				out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic,
				out mmtSimulfix, out mmtSuprafix);

			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_repoObj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
		}
            public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox)
            {
                m_caches  = caches;
                m_cache   = caches.MainCache;               //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this.
                m_choices = choices;
                m_sandbox = sandbox;
                m_fIconsForAnalysisChoices = fIconsForAnalysisChoices;
                m_wsAnalysis       = caches.MainCache.DefaultAnalWs;
                m_wsUi             = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs;
                m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs);
                m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
                m_tssEmptyVern     = m_tsf.MakeString("", m_sandbox.RawWordformWs);
                m_tssMissingEntry  = m_tssMissingMorphs;
                // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default
                // fonts may have different sizes, requiring differnt line heights to align things well.
                m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
                m_tssMissingMorphPos   = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
                m_tssMissingWordPos    = m_tssMissingMorphPos;
                m_PulldownArrowPic     = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow);
                m_dxmpArrowPicWidth    = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture);
                IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs);

                if (wsObj != null)
                {
                    m_fRtl = wsObj.RightToLeftScript;
                }
            }
Exemplo n.º 16
0
        protected InterlinearExporter(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache                = cache;
            m_writer               = writer;
            ktagParaSegments       = InterlinVc.ParaSegmentTag(cache);
            ktagSegmentForms       = InterlinVc.SegmentFormsTag(cache);
            m_flidStringValue      = CmBaseAnnotation.StringValuePropId(cache);
            m_lineChoices          = lineChoices;
            m_defaultGlossVirtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
            m_vc = vc;
            m_tssPendingTitle      = tssTextName;
            m_tssTitleAbbreviation = tssTextAbbreviation;

            // Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
            IMoMorphType mmtStem;
            IMoMorphType mmtPrefix;
            IMoMorphType mmtSuffix;
            IMoMorphType mmtInfix;
            IMoMorphType mmtBoundStem;
            IMoMorphType mmtSimulfix;
            IMoMorphType mmtSuprafix;

            MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
                                           out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
        }
Exemplo n.º 17
0
 internal FreeformAdder(int hvoType, RootSite site, bool fNeedReconstruct, InterlinVc vc) : base(site.Cache)
 {
     m_hvoType          = hvoType;
     m_site             = site;
     m_fNeedReconstruct = fNeedReconstruct;
     m_choices          = vc.LineChoices;
     m_vc = vc;
 }
Exemplo n.º 18
0
 public void UpdateLineChoices(InterlinLineChoices choices)
 {
     // Under certain circumstances this can get called when sandbox is null (LT-11468)
     if (m_sandbox != null)
     {
         m_sandbox.UpdateLineChoices(choices);
     }
 }
Exemplo n.º 19
0
		/// <summary>
		/// Create a new one.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="ss"></param>
		/// <param name="choices"></param>
		/// <param name="hvoWordform"></param>
		/// <param name="mediator"></param>
		public TryAWordSandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss, InterlinLineChoices choices,
			int hvoWordform)
			: base(cache, mediator, ss, choices)
		{
			SizeToContent = true;
			//RawWordform = word;
			base.LoadForWordBundleAnalysis(hvoWordform);
		}
Exemplo n.º 20
0
        public override void Initialize()
        {
            CheckDisposed();
            base.Initialize();

            m_text1   = SetupDataForText1();
            m_choices = new InterlinLineChoices(0, Cache.DefaultAnalWs, Cache.LangProject);
        }
Exemplo n.º 21
0
        public void AddFields()
        {
            InterlinLineChoices choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);

            choices.Add(InterlinLineChoices.kflidWord);
            choices.Add(InterlinLineChoices.kflidLexEntries);
            choices.Add(InterlinLineChoices.kflidWordGloss);
            choices.Add(InterlinLineChoices.kflidLexPos);
            choices.Add(InterlinLineChoices.kflidFreeTrans);
            choices.Add(InterlinLineChoices.kflidWordPos);
            choices.Add(InterlinLineChoices.kflidLexGloss);
            choices.Add(InterlinLineChoices.kflidLexGloss, 3003);

            // Check order inserted.
            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[1].Flid);
            // This gets reordered to keep the interlinears together.
            Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[2].Flid);
            // reordered past ff and word level
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
            // inserted third, but other things push past it.
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
            // reordered past a freeform.
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);

            // Check writing systems assigned by default.
            Assert.AreEqual(kwsVernInPara, choices[0].WritingSystem);
            Assert.AreEqual(WritingSystemServices.kwsFirstAnal, choices[3].WritingSystem);
            Assert.AreEqual(3003, choices[4].WritingSystem);

            // Check field levels
            Assert.IsTrue(choices[0].WordLevel);
            Assert.IsTrue(choices[1].WordLevel);
            Assert.IsFalse(choices[7].WordLevel);

            Assert.IsFalse(choices[0].MorphemeLevel);
            Assert.IsTrue(choices[1].MorphemeLevel);
            Assert.IsFalse(choices[6].MorphemeLevel);
            Assert.AreEqual(1, choices.FirstMorphemeIndex);
            Assert.AreEqual(1, choices.FirstLexEntryIndex);

            Assert.IsTrue(choices[1].LexEntryLevel);                    // lex entries
            Assert.IsTrue(choices[2].LexEntryLevel);                    // lex pos
            Assert.IsTrue(choices[3].LexEntryLevel);                    // lex gloss
            Assert.IsTrue(choices[4].LexEntryLevel);                    // lex gloss
            Assert.IsFalse(choices[0].LexEntryLevel);                   // word
            Assert.IsFalse(choices[5].LexEntryLevel);                   // word gloss
            Assert.IsFalse(choices[6].LexEntryLevel);                   // word pos
            Assert.IsFalse(choices[7].LexEntryLevel);                   // free trans

            choices.Add(InterlinLineChoices.kflidMorphemes);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
            Assert.AreEqual(1, choices.FirstMorphemeIndex);             // morpheme line
            Assert.AreEqual(2, choices.FirstLexEntryIndex);             // lex entry
            Assert.IsFalse(choices[1].LexEntryLevel);                   // morphemes
        }
Exemplo n.º 22
0
		public FocusBoxController(Mediator mediator, IVwStylesheet stylesheet, InterlinLineChoices lineChoices)
			: this()
		{
			m_mediator = mediator;
			m_stylesheet = stylesheet;
			m_lineChoices = lineChoices;
			if (m_mediator != null)
				SetToolTips();
		}
Exemplo n.º 23
0
        public override void Exit()
        {
            CheckDisposed();

            m_text1   = null;
            m_choices = null;

            base.Exit();
        }
Exemplo n.º 24
0
		public void AddFields()
		{
			InterlinLineChoices choices = new InterlinLineChoices(0, kwsAnalysis);
			choices.Add(InterlinLineChoices.kflidWord);
			choices.Add(InterlinLineChoices.kflidLexEntries);
			choices.Add(InterlinLineChoices.kflidWordGloss);
			choices.Add(InterlinLineChoices.kflidLexPos);
			choices.Add(InterlinLineChoices.kflidFreeTrans);
			choices.Add(InterlinLineChoices.kflidWordPos);
			choices.Add(InterlinLineChoices.kflidLexGloss);
			choices.Add(InterlinLineChoices.kflidLexGloss, 3003);

			// Check order inserted.
			Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[1].Flid);
			// This gets reordered to keep the interlinears together.
			Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[2].Flid);
			// reordered past ff and word level
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
			// inserted third, but other things push past it.
			Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
			// reordered past a freeform.
			Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);

			// Check writing systems assigned by default.
			Assert.AreEqual(kwsVern, choices[0].WritingSystem);
			Assert.AreEqual((int)LangProject.kwsFirstAnal, choices[3].WritingSystem);
			Assert.AreEqual(3003, choices[4].WritingSystem);

			// Check field levels
			Assert.IsTrue(choices[0].WordLevel);
			Assert.IsTrue(choices[1].WordLevel);
			Assert.IsFalse(choices[7].WordLevel);

			Assert.IsFalse(choices[0].MorphemeLevel);
			Assert.IsTrue(choices[1].MorphemeLevel);
			Assert.IsFalse(choices[6].MorphemeLevel);
			Assert.AreEqual(1, choices.FirstMorphemeIndex);
			Assert.AreEqual(1, choices.FirstLexEntryIndex);

			Assert.IsTrue(choices[1].LexEntryLevel);	// lex entries
			Assert.IsTrue(choices[2].LexEntryLevel);	// lex pos
			Assert.IsTrue(choices[3].LexEntryLevel);	// lex gloss
			Assert.IsTrue(choices[4].LexEntryLevel);	// lex gloss
			Assert.IsFalse(choices[0].LexEntryLevel);	// word
			Assert.IsFalse(choices[5].LexEntryLevel);	// word gloss
			Assert.IsFalse(choices[6].LexEntryLevel);	// word pos
			Assert.IsFalse(choices[7].LexEntryLevel);	// free trans

			choices.Add(InterlinLineChoices.kflidMorphemes);
			Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
			Assert.AreEqual(1, choices.FirstMorphemeIndex);	// morpheme line
			Assert.AreEqual(2, choices.FirstLexEntryIndex);	// lex entry
			Assert.IsFalse(choices[1].LexEntryLevel);	// morphemes
		}
Exemplo n.º 25
0
        private static IEnumerable <LineOption> GetUnusedSpecs(InterlinLineChoices curLineChoices)
        {
            var allOptions  = curLineChoices.LineOptions();
            var optionsUsed = curLineChoices.ItemsWithFlids(
                allOptions.Select(lineOption => lineOption.Flid).ToArray());

            return(allOptions.Where(option => !optionsUsed.Any(
                                        spec => spec.Flid == option.Flid)).ToList());
        }
Exemplo n.º 26
0
        private SandboxBase SetupSandbox(Func <AnalysisOccurrence> createDataForSandbox)
        {
            var occurrence  = createDataForSandbox();
            var lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs);
            var sandbox     = new SandboxBase(Cache, null, null, lineChoices, occurrence.Analysis.Hvo);

            sandbox.MakeRoot();
            return(sandbox);
        }
Exemplo n.º 27
0
        public void MoveDown()
        {
            InterlinLineChoices choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);

            // To make it less confusing, here we add them in an order that does not produce
            // reordering.
            MakeStandardState(choices);

            // lit trans can move up
            Assert.IsTrue(choices.OkToMoveDown(0));             // most moves are OK in non-edit mode
            Assert.IsTrue(choices.OkToMoveDown(1));
            Assert.IsTrue(choices.OkToMoveDown(2));
            Assert.IsTrue(choices.OkToMoveDown(3));
            Assert.IsTrue(choices.OkToMoveDown(4));             // whole morph bundle will move down
            Assert.IsTrue(choices.OkToMoveDown(5));
            Assert.IsFalse(choices.OkToMoveDown(6));            // Would put FF out of order
            Assert.IsTrue(choices.OkToMoveDown(7));
            Assert.IsFalse(choices.OkToMoveDown(8));

            choices.MoveDown(0);
            // morphemes is now top
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[0].Flid);
            // Word moved down to position 4
            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[4].Flid);
            // Lex Gloss (to pick just one) also moved up
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[2].Flid);

            choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);
            MakeStandardState(choices);
            choices.MoveDown(1);
            // nothing complicated, two items changed place.
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[2].Flid);

            choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);
            MakeStandardState(choices);
            choices.MoveDown(4);
            // Moves past whole morpheme bundle
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[2].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[3].Flid);

            choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);
            MakeStandardState(choices);
            choices.MoveDown(5);
            // nothing complicated, two items changed place.
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[5].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);

            choices = new InterlinLineChoices(m_lp, kwsVernInPara, kwsAnalysis);
            MakeStandardState(choices);
            choices.MoveDown(7);
            // nothing complicated, two items changed place.
            Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[7].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
        }
Exemplo n.º 28
0
        public void Persistence()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs;

            wsManager.GetOrSet("en", out enWs);
            int wsEng = enWs.Handle;

            CoreWritingSystemDefinition frWs;

            wsManager.GetOrSet("fr", out frWs);
            int wsFrn = frWs.Handle;

            CoreWritingSystemDefinition deWs;

            wsManager.GetOrSet("de", out deWs);
            int wsGer = deWs.Handle;

            InterlinLineChoices choices = new InterlinLineChoices(m_lp, wsFrn, wsEng);

            MakeStandardState(choices);
            string persist = choices.Persist(wsManager);

            choices = InterlinLineChoices.Restore(persist, wsManager, m_lp, wsFrn, wsEng);

            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

            // Check writing systems assigned by default.
            Assert.AreEqual(wsFrn, choices[0].WritingSystem);
            Assert.AreEqual(wsEng, choices[5].WritingSystem);
            Assert.AreEqual(wsFrn, choices[2].WritingSystem);

            choices = new EditableInterlinLineChoices(m_lp, 0, wsEng);
            MakeStandardState(choices);
            choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

            Assert.AreEqual(wsGer, choices[4].WritingSystem);
        }
Exemplo n.º 29
0
        public void ComboHandler_CreateCoreMorphItemBasedOnSandboxCurrentState_DeletedSense_DoesNotThrow()
        {
            // Make an entry with a morph and a sense with no MSA.
            var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create();
            var morph = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create();

            entry.LexemeFormOA = morph;
            morph.Form.SetVernacularDefaultWritingSystem("kick");
            morph.MorphTypeRA =
                Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot);
            // Set up first sense
            var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create();

            entry.SensesOS.Add(sense);
            sense.Gloss.SetAnalysisDefaultWritingSystem("silly");

            // Make an analysis from that MSA.
            var wf = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create();

            wf.Form.SetVernacularDefaultWritingSystem("kick");
            var wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create();

            wf.AnalysesOC.Add(wa);
            var mb = Cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create();

            wa.MorphBundlesOS.Add(mb);
            mb.SenseRA = sense;
            mb.MorphRA = morph;
            // Set up second sense
            var sense2 = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create();

            entry.SensesOS.Add(sense2);
            sense2.Gloss.SetAnalysisDefaultWritingSystem("problem");

            // Make a sandbox and sut
            InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject,
                                                                                 Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze);

            using (var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo))
            {
                var mockList = new MockComboHandler();
                sandbox.m_ComboHandler = mockList;
                // Merge the first sense into the second (invalidating analysis and sandbox cache)
                using (var handler = GetComboHandler(sandbox, InterlinLineChoices.kflidLexEntries, 0))
                {
                    // wipe out the sense that the morph bundle was based on.
                    sense2.MergeObject(sense, true);
                    Assert.AreEqual(entry.SensesOS[0], sense2);
                    Assert.DoesNotThrow(() =>
                    {
                        // ReSharper disable once UnusedVariable - Assignment is SUT
                        var i = handler.IndexOfCurrentItem;
                    });
                }
            }
        }
Exemplo n.º 30
0
        public void EntryHandler_NeedSelectSame_SelectSenseWhenAnalysisHasNoPos_ReturnsTrue()
        {
            // Make an entry with a morph and a sense with no MSA.
            var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create();
            var morph = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create();

            entry.LexemeFormOA = morph;
            morph.Form.SetVernacularDefaultWritingSystem("kick");
            morph.MorphTypeRA =
                Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot);
            var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create();

            entry.SensesOS.Add(sense);
            sense.Gloss.SetAnalysisDefaultWritingSystem("strike with foot");

            // Make an analysis from that MSA.
            var wf = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create();

            wf.Form.SetVernacularDefaultWritingSystem("kick");
            var wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create();

            wf.AnalysesOC.Add(wa);
            var mb = Cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create();

            wa.MorphBundlesOS.Add(mb);
            mb.SenseRA = sense;
            mb.MorphRA = morph;

            // Make a sandbox and sut
            InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject,
                                                                                 Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze);

            using (var sut = new SandboxBase.IhMissingEntry(null))
            {
                using (var sandbox = new SandboxBase(Cache, m_mediator, m_propertyTable, null, lineChoices, wa.Hvo))
                {
                    sut.SetSandboxForTesting(sandbox);
                    var mockList = MockRepository.GenerateMock <IComboList>();
                    sut.SetComboListForTesting(mockList);
                    sut.SetMorphForTesting(0);
                    sut.LoadMorphItems();
                    Assert.That(sut.NeedSelectSame(), Is.True);
                }

                // But if it already has an MSA it is not true.
                var msa = Cache.ServiceLocator.GetInstance <IMoStemMsaFactory>().Create();
                entry.MorphoSyntaxAnalysesOC.Add(msa);
                sense.MorphoSyntaxAnalysisRA = msa;
                mb.MsaRA = msa;
                using (var sandbox = new SandboxBase(Cache, m_mediator, m_propertyTable, null, lineChoices, wa.Hvo))
                {
                    sut.SetSandboxForTesting(sandbox);
                    Assert.That(sut.NeedSelectSame(), Is.False);
                }
            }
        }
        public override void TestSetup()
        {
            base.TestSetup();
            InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject,
                                                                                 Cache.DefaultVernWs,
                                                                                 Cache.DefaultAnalWs,
                                                                                 InterlinLineChoices.InterlinMode.Gloss);

            m_sandbox = new AddWordsToLexiconTests.SandboxForTests(Cache, lineChoices);
        }
Exemplo n.º 32
0
 /// <summary>
 /// Create a new one.
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="ss"></param>
 /// <param name="choices"></param>
 /// <param name="mediator"></param>
 public Sandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss,
                InterlinLineChoices choices, AnalysisOccurrence selected, FocusBoxController focusBox)
     : base(cache, mediator, ss, choices)
 {
     FocusBox             = focusBox;
     m_interlinDoc        = focusBox.InterlinDoc;
     m_occurrenceSelected = selected;
     // Finish initialization with occurrence context.
     LoadForWordBundleAnalysis(m_occurrenceSelected.Analysis.Hvo);
 }
Exemplo n.º 33
0
        private void AddHideLineMenuItem(ContextMenuStrip menu,
                                         InterlinLineChoices curLineChoices, int ilineChoice)
        {
            var lineLabel = GetAppropriateLineLabel(curLineChoices, ilineChoice);
            var hideItem  = new ToolStripMenuItem(String.Format(ITextStrings.ksHideLine, lineLabel));

            hideItem.Click += new EventHandler(hideItem_Click);
            hideItem.Tag    = ilineChoice;
            menu.Items.Add(hideItem);
        }
Exemplo n.º 34
0
		/// <summary>
		/// Create a new one.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="ss"></param>
		/// <param name="choices"></param>
		/// <param name="mediator"></param>
		public Sandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss,
			InterlinLineChoices choices, AnalysisOccurrence selected, FocusBoxController focusBox)
			: this(cache, mediator, ss, choices)
		{
			FocusBox = focusBox;
			m_interlinDoc = focusBox.InterlinDoc;
			m_occurrenceSelected = selected;
			// Finish initialization with occurrence context.
			LoadForWordBundleAnalysis(m_occurrenceSelected.Analysis.Hvo);
		}
Exemplo n.º 35
0
        public void Persistence()
        {
            ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();

            try
            {
                int wsEng = 1;
                int wsFrn = 2;
                int wsGer = 3;
                wsf.AddWritingSystem(wsEng, "en");
                wsf.AddWritingSystem(wsFrn, "fr");
                wsf.AddWritingSystem(wsGer, "de");
                InterlinLineChoices choices = new InterlinLineChoices(wsFrn, wsEng);
                MakeStandardState(choices);
                string persist = choices.Persist(wsf);
                choices = InterlinLineChoices.Restore(persist, wsf, wsFrn, wsEng);

                Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

                // Check writing systems assigned by default.
                Assert.AreEqual(wsFrn, choices[0].WritingSystem);
                Assert.AreEqual(wsEng, choices[5].WritingSystem);
                Assert.AreEqual(wsFrn, choices[2].WritingSystem);

                choices = new EditableInterlinLineChoices(0, wsEng);
                MakeStandardState(choices);
                choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
                Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

                Assert.AreEqual(wsGer, choices[4].WritingSystem);
            }
            finally
            {
                // we must shutdown and marshal this or else it could mess up other tests.
                wsf.Shutdown();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(wsf);
            }
        }
Exemplo n.º 36
0
 public FocusBoxController(Mediator mediator, IVwStylesheet stylesheet, InterlinLineChoices lineChoices)
     : this()
 {
     m_mediator    = mediator;
     m_stylesheet  = stylesheet;
     m_lineChoices = lineChoices;
     if (m_mediator != null)
     {
         SetToolTips();
     }
 }
Exemplo n.º 37
0
        private string GetAppropriateLineLabel(InterlinLineChoices curLineChoices, int ilineChoice)
        {
            var curSpec = curLineChoices[ilineChoice];
            var result  = curLineChoices.LabelFor(curSpec.Flid);

            if (curLineChoices.RepetitionsOfFlid(curSpec.Flid) > 1)
            {
                result += "(" + curSpec.WsLabel(Cache).Text + ")";
            }
            return(result);
        }
Exemplo n.º 38
0
		/// <summary>
		/// Create a new one.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="hvoAnalysis"></param>
		/// <param name="ss"></param>
		/// <param name="choices"></param>
		/// <param name="rawWordform"></param>
		/// <param name="fTreatAsSentenceInitial"></param>
		/// <param name="mediator"></param>
		/// <param name="parent"></param>
		public Sandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss,
			InterlinLineChoices choices, int hvoAnnotation, InterlinDocChild interlinDoc)
			: base(cache, mediator, ss, choices)
		{
			m_interlinDoc = interlinDoc;
			m_hvoAnnotation = hvoAnnotation;
			// Finish initialization with twfic context.
			int hvoInstanceOf = Cache.GetObjProperty(m_hvoAnnotation,
				(int)CmBaseAnnotation.CmAnnotationTags.kflidInstanceOf);
			LoadForWordBundleAnalysis(hvoInstanceOf);
		}
Exemplo n.º 39
0
 private void MakeStandardState(InterlinLineChoices choices)
 {
     choices.Add(InterlinLineChoices.kflidWord);             // 0
     choices.Add(InterlinLineChoices.kflidMorphemes);        // 1
     choices.Add(InterlinLineChoices.kflidLexEntries);       //2
     choices.Add(InterlinLineChoices.kflidLexGloss);         //3
     choices.Add(InterlinLineChoices.kflidLexPos);           //4
     choices.Add(InterlinLineChoices.kflidWordGloss);        //5
     choices.Add(InterlinLineChoices.kflidWordPos);          //6
     choices.Add(InterlinLineChoices.kflidFreeTrans);        //7
     choices.Add(InterlinLineChoices.kflidLitTrans);         //8
 }
Exemplo n.º 40
0
		public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, ICmObject objRoot,
			InterlinLineChoices lineChoices, InterlinVc vc)
		{
			if (mode != null && mode.ToLowerInvariant() == "elan")
			{
				return new InterlinearExporterForElan(cache, writer, objRoot, lineChoices, vc);
			}
			else
			{
				return new InterlinearExporter(cache, writer, objRoot, lineChoices, vc);
			}
		}
Exemplo n.º 41
0
        /// <summary>
        /// Tries to restore the LineChoices saved in the ConfigPropName property in the property table.
        /// </summary>
        /// <param name="lineChoices"></param>
        /// <returns></returns>
        internal bool TryRestoreLineChoices(out InterlinLineChoices lineChoices)
        {
            lineChoices = null;
            var persist = m_propertyTable.GetStringProperty(ConfigPropName, null, PropertyTable.SettingsGroup.LocalSettings);

            if (persist != null)
            {
                lineChoices = InterlinLineChoices.Restore(persist, m_cache.LanguageWritingSystemFactoryAccessor,
                                                          m_cache.LangProject, WritingSystemServices.kwsVernInParagraph, m_cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze, m_propertyTable, ConfigPropName);
            }
            return(persist != null && lineChoices != null);
        }
 public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, ICmObject objRoot,
                                          InterlinLineChoices lineChoices, InterlinVc vc)
 {
     if (mode != null && mode.ToLowerInvariant() == "elan")
     {
         return(new InterlinearExporterForElan(cache, writer, objRoot, lineChoices, vc));
     }
     else
     {
         return(new InterlinearExporter(cache, writer, objRoot, lineChoices, vc));
     }
 }
Exemplo n.º 43
0
		public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, int hvoRoot,
			InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
		{
			if (mode != null && mode.ToLowerInvariant() == "elan")
			{
				return new InterlinearExporterForElan(cache, writer, hvoRoot, lineChoices, vc, tssTextName,
													  tssTextAbbreviation);
			}
			else
			{
				return new InterlinearExporter(cache, writer, hvoRoot, lineChoices, vc, tssTextName, tssTextAbbreviation);
			}
		}
Exemplo n.º 44
0
			/// <summary>
			/// This contructor is only to be used by the
			/// </summary>
			/// <param name="owner"></param>
			/// <param name="caches"></param>
			/// <param name="choices"></param>
			/// <param name="anal"></param>
			public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices,
				WfiAnalysis anal)
			{
				m_sandbox = owner;
				m_caches = caches;
				m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo.
				//m_hvoWordform = hvoWordform;
				//m_hvoWfiAnalysis = hvoWfiAnalysis;
				m_anal = anal;
				//m_hvoWordGloss = hvoWordGloss;
				m_sda = m_caches.DataAccess;
				m_sdaMain = m_caches.MainCache.MainCacheAccessor;
				m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs);
				m_choices = choices;
				//m_tssForm = tssForm;
			}
			public GetRealAnalysisMethod(IHelpTopicProvider helpTopicProvider, SandboxBase owner,
				CachePair caches, int hvoSbWord, AnalysisTree oldAnalysis, IWfiAnalysis wa,
				IWfiGloss gloss, InterlinLineChoices choices, ITsString tssForm,
				bool fWantOnlyWfiAnalysis) : this()
			{
				m_helpTopicProvider = helpTopicProvider;
				m_sandbox = owner;
				m_caches = caches;
				m_hvoSbWord = hvoSbWord;
				m_oldAnalysis = oldAnalysis;
				m_wf = oldAnalysis.Wordform;
				m_wa = wa;
				m_wg = gloss;
				m_sda = m_caches.DataAccess;
				m_sdaMain = m_caches.MainCache.MainCacheAccessor;
				m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs);
				m_choices = choices;
				m_tssForm = tssForm;
				m_fWantOnlyWfiAnalysis = fWantOnlyWfiAnalysis;
			}
Exemplo n.º 46
0
			/// <summary>
			/// This contructor is only to be used by the
			/// </summary>
			/// <param name="owner"></param>
			/// <param name="caches"></param>
			/// <param name="choices"></param>
			/// <param name="anal"></param>
			public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices,
				IWfiAnalysis anal)
			{
				m_sandbox = owner;
				m_caches = caches;
				m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo.
				//m_hvoWordform = hvoWordform;
				//m_hvoWfiAnalysis = hvoWfiAnalysis;
				m_anal = anal;
				//m_hvoWordGloss = hvoWordGloss;
				m_sda = m_caches.DataAccess;
				m_sdaMain = m_caches.MainCache.MainCacheAccessor;
				m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs);
				m_choices = choices;
				//m_tssForm = tssForm;
				var servLoc = m_caches.MainCache.ServiceLocator;
				m_moFormRepos = servLoc.GetInstance<IMoFormRepository>();
				m_senseRepos = servLoc.GetInstance<ILexSenseRepository>();
				m_msaRepos = servLoc.GetInstance<IMoMorphSynAnalysisRepository>();
			}
Exemplo n.º 47
0
		private void AddAdditionalWsMenuItem(ToolStripMenuItem addSubMenu,
			InterlinLineChoices curLineChoices, int ilineChoice)
		{
			var curSpec = curLineChoices[ilineChoice];
			var choices = GetWsComboItems(curSpec);
			var curFlidDisplayedWss = curLineChoices.OtherWritingSystemsForFlid(curSpec.Flid, 0);
			var curRealWs = GetRealWsFromSpec(curSpec);
			if (!curFlidDisplayedWss.Contains(curRealWs))
				curFlidDisplayedWss.Add(curRealWs);
			var lgWsAcc = Cache.LanguageWritingSystemFactoryAccessor;
			foreach (var item in choices)
			{
				var itemRealWs = lgWsAcc.GetWsFromStr(item.Id);
				// Skip 'Magic' wss and ones that are already displayed
				if (itemRealWs == 0 || curFlidDisplayedWss.Contains(itemRealWs))
					continue;
				var menuItem = new AddWritingSystemMenuItem(curSpec.Flid, itemRealWs);
				menuItem.Text = item.ToString();
				menuItem.Click += new EventHandler(addWsToFlidItem_Click);
				addSubMenu.DropDownItems.Add(menuItem);
			}
		}
Exemplo n.º 48
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_vc != null)
					m_vc.Dispose();
				if (m_writer != null)
					m_writer.Close();
				if (m_stream != null)
					m_stream.Close();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_vc = null;
			m_textsDefn = null;
			m_text1 = null;
			m_exportedXml = null;
			m_writer = null;
			m_exporter = null;
			m_choices = null;
			m_stream = null;

			base.Dispose(disposing);
		}
Exemplo n.º 49
0
		private void AddHideLineMenuItem(ContextMenuStrip menu,
			InterlinLineChoices curLineChoices, int ilineChoice)
		{
			var lineLabel = GetAppropriateLineLabel(curLineChoices, ilineChoice);
			var hideItem = new ToolStripMenuItem(String.Format(ITextStrings.ksHideLine, lineLabel));
			hideItem.Click += new EventHandler(hideItem_Click);
			hideItem.Tag = ilineChoice;
			menu.Items.Add(hideItem);
		}
Exemplo n.º 50
0
		private string GetAppropriateLineLabel(InterlinLineChoices curLineChoices, int ilineChoice)
		{
			var curSpec = curLineChoices[ilineChoice];
			var result = curLineChoices.LabelFor(curSpec.Flid);
			if (curLineChoices.RepetitionsOfFlid(curSpec.Flid) > 1)
				result += "(" + curSpec.WsLabel(Cache).Text + ")";
			return result;
		}
		public void UpdateLineChoices(InterlinLineChoices choices)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 52
0
		private static IEnumerable<LineOption> GetUnusedSpecs(InterlinLineChoices curLineChoices)
		{
			var allOptions = curLineChoices.LineOptions();
			var optionsUsed = curLineChoices.ItemsWithFlids(
				allOptions.Select(lineOption => lineOption.Flid).ToArray());
			return allOptions.Where(option => !optionsUsed.Any(
				spec => spec.Flid == option.Flid)).ToList();
		}
Exemplo n.º 53
0
		/// <summary>
		/// </summary>
		/// <param name="lineConfigPropName">the key used to store/restore line configuration settings.</param>
		/// <param name="mode"></param>
		/// <returns></returns>
		public InterlinLineChoices SetupLineChoices(string lineConfigPropName, InterlinLineChoices.InterlinMode mode)
		{
			ConfigPropName = lineConfigPropName;
			InterlinLineChoices lineChoices;
			if (!TryRestoreLineChoices(out lineChoices))
			{
				if (ForEditing)
				{
					lineChoices = EditableInterlinLineChoices.DefaultChoices(m_fdoCache.LangProject,
						WritingSystemServices.kwsVernInParagraph, WritingSystemServices.kwsAnal);
					lineChoices.Mode = mode;
					if (mode == InterlinLineChoices.InterlinMode.Gloss ||
						mode == InterlinLineChoices.InterlinMode.GlossAddWordsToLexicon)
						lineChoices.SetStandardGlossState();
					else
						lineChoices.SetStandardState();
				}
				else
				{
					lineChoices = InterlinLineChoices.DefaultChoices(m_fdoCache.LangProject,
						WritingSystemServices.kwsVernInParagraph, WritingSystemServices.kwsAnal, mode);
				}
			}
			else if (ForEditing)
			{
				// just in case this hasn't been set for restored lines
				lineChoices.Mode = mode;
			}
			LineChoices = lineChoices;
			return LineChoices;
		}
Exemplo n.º 54
0
		/// <summary>
		/// Create a new one.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="mediator">The mediator.</param>
		/// <param name="ss">The stylesheet.</param>
		/// <param name="choices">The choices.</param>
		/// <param name="hvoAnalysis">The hvo analysis.</param>
		public OneAnalysisSandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss, InterlinLineChoices choices, int hvoAnalysis)
			: base(cache, mediator, ss, choices, hvoAnalysis)
		{
			SizeToContent = true;
			InitializeComponent();
		}
Exemplo n.º 55
0
		/// <summary>
		/// Tries to restore the LineChoices saved in the ConfigPropName property in the property table.
		/// </summary>
		/// <param name="lineChoices"></param>
		/// <returns></returns>
		internal bool TryRestoreLineChoices(out InterlinLineChoices lineChoices)
		{
			lineChoices = null;
			var persist = m_mediator.PropertyTable.GetStringProperty(ConfigPropName, null, PropertyTable.SettingsGroup.LocalSettings);
			if (persist != null)
			{
				lineChoices = InterlinLineChoices.Restore(persist, m_fdoCache.LanguageWritingSystemFactoryAccessor,
					m_fdoCache.LangProject, WritingSystemServices.kwsVernInParagraph, m_fdoCache.DefaultAnalWs);
			}
			return persist != null && lineChoices != null;
		}
Exemplo n.º 56
0
		internal FreeformAdder(int hvoType, RootSite site, bool fNeedReconstruct, InterlinVc vc) : base(site.Cache)
		{
			m_hvoType = hvoType;
			m_site = site;
			m_fNeedReconstruct = fNeedReconstruct;
			m_choices = vc.LineChoices;
			m_vc = vc;
		}
Exemplo n.º 57
0
		/// <summary>
		/// Persist the new line choices and
		/// Reconstruct the document based on the given newChoices for interlinear lines.
		/// </summary>
		/// <param name="newChoices"></param>
		internal virtual void UpdateForNewLineChoices(InterlinLineChoices newChoices)
		{
			m_vc.LineChoices = newChoices;
			LineChoices = newChoices;

			PersistAndDisplayChangedLineChoices();
		}
Exemplo n.º 58
0
		protected void ValidateExportedParagraph(XmlDocument exportedXml, InterlinLineChoices choices, IStTxtPara para)
		{
			ExportedInterlinearReader exportReader = new ExportedInterlinearReader(exportedXml, choices);
			ExportedParagraphValidator validator = new ExportedParagraphValidator(exportReader, para);
			validator.ValidateParagraphs(para, exportReader.GetParaNode(para.IndexInOwner));
		}
Exemplo n.º 59
0
		internal override void UpdateForNewLineChoices(InterlinLineChoices newChoices)
		{
			base.UpdateForNewLineChoices(newChoices);
			if (ExistingFocusBox != null)
			{
				ExistingFocusBox.UpdateLineChoices(newChoices);
				if (IsFocusBoxInstalled)
					MoveFocusBoxIntoPlace();
			}
		}
Exemplo n.º 60
0
		private void AddNewLineMenuItem(ToolStripMenuItem addLineSubMenu, InterlinLineChoices curLineChoices)
		{
			// Add menu options to add lines of flids that are in default list, but don't currently appear.
			var unusedSpecs = GetUnusedSpecs(curLineChoices);
			foreach (var specToAdd in unusedSpecs)
			{
				var menuItem = new AddLineMenuItem(specToAdd.Flid) { Text = specToAdd.ToString() };
				menuItem.Click += addLineItem_Click;
				addLineSubMenu.DropDownItems.Add(menuItem);
			}
		}