예제 #1
0
        public override void MakeRoot(IVwGraphics vg, ILgEncodingFactory encfParam, out IVwRootBox rootbParam)
        {
            rootbParam = null;

            // JohnT: this is a convenient though somewhat unconventional place to create and partly
            // initialize the combo box. We can't set its position yet, as that depends on what the user
            // clicks. Nor do we yet add it to our list of windows, nor make it visible.
            typeComboBox = new System.Windows.Forms.ComboBox();
            typeComboBox.Items.AddRange(new object[] { "sal", "noun", "verb", "det", "adj", "adv" });
            typeComboBox.DropDownWidth         = 280;     // Todo JohnT: make right for showing all options
            typeComboBox.SelectedValueChanged += new EventHandler(this.HandleComboSelChange);

            base.MakeRoot(vg, encfParam, out rootbParam);

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

            IVwRootBox rootb = (IVwRootBox) new FwViews.VwRootBoxClass();

            rootb.SetSite(this);

            int hvoRoot = khvoText;

            // Set up sample data (not in the database for now)
            ITsStrFactory tsf    = (ITsStrFactory) new FwKernelLib.TsStrFactoryClass();
            int           encEng = 0;   // TODO: Implement StrUtil::ParseEnc

            string[] words      = { "Hello", "world!", "This", "is", "an", "interlinear", "view" };
            string[] wordtypes  = { "sal", "noun", "det", "verb", "det", "adj", "noun" };
            int[]    rghvoWords = new int[(words.Length)];
            for (int i = 0; i < words.Length; ++i)
            {
                ITsString tss = tsf.MakeString(words[i], encEng);
                // Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
                m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Form, tss);
                tss = tsf.MakeString(wordtypes[i], encEng);
                // Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
                m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Type, tss);
                rghvoWords[i] = i + 1;
            }
            m_fdoCache.VwCacheDaAccessor.CacheVecProp(khvoText, ktagText_Words, rghvoWords, rghvoWords.Length);

            int frag = kfrText;

            m_iVc = new InterlinearVc();

            if (encfParam != null)
            {
                m_fdoCache.MainCacheAccessor.set_EncodingFactory(encfParam);
            }

            rootb.set_DataAccess(m_fdoCache.MainCacheAccessor);

            rootb.SetRootObject(hvoRoot, m_iVc, frag, null);
            rootbParam = rootb;
        }
예제 #2
0
		public override void MakeRoot(IVwGraphics vg, ILgEncodingFactory encfParam, out IVwRootBox rootbParam)
		{
			rootbParam = null;

			// JohnT: this is a convenient though somewhat unconventional place to create and partly
			// initialize the combo box. We can't set its position yet, as that depends on what the user
			// clicks. Nor do we yet add it to our list of windows, nor make it visible.
			typeComboBox = new System.Windows.Forms.ComboBox();
			typeComboBox.Items.AddRange(new object[] {"sal", "noun", "verb", "det", "adj", "adv"});
			typeComboBox.DropDownWidth = 280; // Todo JohnT: make right for showing all options
			typeComboBox.SelectedValueChanged += new EventHandler(this.HandleComboSelChange);

			base.MakeRoot(vg, encfParam, out rootbParam);

			if (m_fdoCache == null || DesignMode)
				return;

			IVwRootBox rootb = (IVwRootBox)new FwViews.VwRootBoxClass();
			rootb.SetSite(this);

			int hvoRoot = khvoText;

			// Set up sample data (not in the database for now)
			ITsStrFactory tsf = (ITsStrFactory)new FwKernelLib.TsStrFactoryClass();
			int encEng = 0; // TODO: Implement StrUtil::ParseEnc
			string[] words = {"Hello","world!","This","is","an","interlinear","view"};
			string[] wordtypes = {"sal","noun","det","verb","det","adj","noun"};
			int[] rghvoWords = new int[(words.Length)];
			for (int i = 0; i < words.Length; ++i)
			{
				ITsString tss = tsf.MakeString(words[i], encEng);
				// Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
				m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Form, tss);
				tss = tsf.MakeString(wordtypes[i], encEng);
				// Use i+1 as the HVO for the word objects. Avoid using 0 as an HVO
				m_fdoCache.VwCacheDaAccessor.CacheStringProp(i + 1, ktagWord_Type, tss);
				rghvoWords[i] = i + 1;
			}
			m_fdoCache.VwCacheDaAccessor.CacheVecProp(khvoText, ktagText_Words, rghvoWords, rghvoWords.Length);

			int frag = kfrText;
			m_iVc = new InterlinearVc();

			if (encfParam != null)
				m_fdoCache.MainCacheAccessor.set_EncodingFactory(encfParam);

			rootb.set_DataAccess(m_fdoCache.MainCacheAccessor);

			rootb.SetRootObject(hvoRoot, m_iVc, frag, null);
			rootbParam = rootb;
		}