/// <summary>
        /// Init the dialog with a simple context.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="fs"></param>
        public void SetDlgInfo(FdoCache cache, XCore.Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            CheckDisposed();

            m_rule = rule;
            m_ctxt = ctxt;
            RestoreWindowPosition(mediator);
            m_cache = cache;

            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromMediator(mediator);
            m_valuesCombo.WritingSystemCode    = m_cache.DefaultUserWs;
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrAgree);
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrDisagree);
            m_valuesCombo.Items.Add(MEStrings.ks_DontCare_);

            List <int>    hvos     = new List <int>();
            IPhNCFeatures natClass = m_ctxt.FeatureStructureRA as IPhNCFeatures;

            foreach (int hvo in m_cache.LangProject.PhFeatureSystemOA.FeaturesOC.HvoArray)
            {
                if (natClass.FeaturesOAHvo == 0 || natClass.FeaturesOA.FindClosedValue(hvo) == null)
                {
                    hvos.Add(hvo);
                }
            }
            LoadPhonFeats(hvos);
            BuildInitialBrowseView(mediator, hvos);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        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)
            {
                if (m_helpProvider != null)
                {
                    m_helpProvider.Dispose();
                }
            }
            if (m_cache != null)
            {
                IVwCacheDa cda = m_cache.MainCacheAccessor as IVwCacheDa;
                cda.CacheVecProp(m_cache.LangProject.Hvo, m_fakeFlid, null, 0);
                cda     = null;
                m_cache = null;
            }
            m_ctxt        = null;
            m_mediator    = null;
            m_bvList      = null;
            m_valuesCombo = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_helpProvider != null)
                {
                    m_helpProvider.Dispose();
                }
            }
            m_cache       = null;
            m_ctxt        = null;
            m_mediator    = null;
            m_bvList      = null;
            m_valuesCombo = null;
            m_sda         = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Init the dialog with a simple context.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="fs"></param>
        public void SetDlgInfo(FdoCache cache, XCore.Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            CheckDisposed();

            m_rule   = rule;
            m_ctxt   = ctxt;
            Mediator = mediator;
            m_cache  = cache;

            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromMediator(mediator);
            m_valuesCombo.WritingSystemCode    = m_cache.DefaultUserWs;
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrAgree);
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrDisagree);
            m_valuesCombo.Items.Add(MEStrings.ks_DontCare_);

            var feats    = new HashSet <IFsFeatDefn>();
            var natClass = m_ctxt.FeatureStructureRA as IPhNCFeatures;

            foreach (var feat in m_cache.LangProject.PhFeatureSystemOA.FeaturesOC)
            {
                if (natClass.FeaturesOA == null || natClass.FeaturesOA.GetValue(feat as IFsClosedFeature) == null)
                {
                    feats.Add(feat);
                }
            }
            LoadPhonFeats(feats);
            BuildInitialBrowseView(mediator, feats);
        }
Example #5
0
        int GetNCFeatsWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv)
        {
            int           maxLen   = 0;
            IPhNCFeatures natClass = ctxt.FeatureStructureRA as IPhNCFeatures;

            foreach (IFsFeatureSpecification spec in natClass.FeaturesOA.FeatureSpecsOC)
            {
                IFsClosedValue curVal   = spec as IFsClosedValue;
                ITsString      featLine = CreateFeatureLine(curVal);
                int            len      = GetStrWidth(featLine, null, vwenv);
                if (len > maxLen)
                {
                    maxLen = len;
                }
            }

            int plusLen = GetVariablesWidth(ctxt, vwenv, true);

            if (plusLen > maxLen)
            {
                maxLen = plusLen;
            }

            int minusLen = GetVariablesWidth(ctxt, vwenv, false);

            if (minusLen > maxLen)
            {
                maxLen = minusLen;
            }
            return(maxLen);
        }
Example #6
0
        public bool OnContextJumpToNaturalClass(object args)
        {
            CheckDisposed();
            IPhSimpleContextNC ctxt = RuleFormulaControl.CurrentContext as IPhSimpleContextNC;

            Mediator.PostMessage("FollowLink", new FwLinkArgs("naturalClassedit",
                                                              ctxt.FeatureStructureRA.Guid));
            return(true);
        }
        private void SetDlgInfo(FdoCache cache, Mediator mediator, int hvoOwner, int owningFlid, IFsFeatStruc fs, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            m_fs         = fs;
            m_owningFlid = owningFlid;
            m_hvoOwner   = hvoOwner;
            m_rule       = rule;
            m_ctxt       = ctxt;
            Mediator     = mediator;
            m_cache      = cache;
            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            LoadPhonFeats(m_fs);
            BuildInitialBrowseView(mediator);
        }
Example #8
0
        int GetVariablesWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv, bool polarity)
        {
            ILcmReferenceSequence <IPhFeatureConstraint> vars = polarity ? ctxt.PlusConstrRS : ctxt.MinusConstrRS;
            int maxLen = 0;

            foreach (IPhFeatureConstraint var in vars)
            {
                ITsString varLine = CreateVariableLine(var, polarity);
                int       len     = GetStrWidth(varLine, null, vwenv);
                if (len > maxLen)
                {
                    maxLen = len;
                }
            }
            return(maxLen);
        }
Example #9
0
        int GetVariablesWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv, bool polarity)
        {
            FdoSequence <IPhFeatureConstraint> vars = polarity ? ctxt.PlusConstrRS : ctxt.MinusConstrRS;
            int maxLen = 0;

            for (int i = 0; i < vars.Count; i++)
            {
                ITsString varLine = CreateVariableLine(vars[i], polarity);
                int       len     = GetStrWidth(varLine, null, vwenv);
                if (len > maxLen)
                {
                    maxLen = len;
                }
            }
            return(maxLen);
        }
Example #10
0
 int GetNCCtxtWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv)
 {
     if (ctxt.FeatureStructureRAHvo != 0 && ctxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
     {
         int numLines = GetNumLines(ctxt);
         if (numLines == 1)
         {
             int len = 0;
             if (ctxt.FeatureStructureRA.Abbreviation.UserDefaultWritingSystem == "C" ||
                 ctxt.FeatureStructureRA.Abbreviation.UserDefaultWritingSystem == "V")
             {
                 len = GetStrWidth(ctxt.FeatureStructureRA.Abbreviation.BestAnalysisAlternative, null, vwenv);
             }
             else
             {
                 len = GetNCFeatsWidth(ctxt, vwenv);
             }
             len += GetStrWidth(m_leftBracket, null, vwenv);
             len += GetStrWidth(m_rightBracket, null, vwenv);
             return(len);
         }
         else
         {
             int len = GetNCFeatsWidth(ctxt, vwenv);
             len += GetStrWidth(m_leftBracketUpHook, m_bracketProps, vwenv);
             len += GetStrWidth(m_rightBracketUpHook, m_bracketProps, vwenv);
             return(len);
         }
     }
     else
     {
         int len = 0;
         if (ctxt.FeatureStructureRAHvo == 0)
         {
             len = GetStrWidth(m_questions, null, vwenv);
         }
         else
         {
             len = GetStrWidth(ctxt.FeatureStructureRA.Abbreviation.BestAnalysisAlternative, null, vwenv);
         }
         len += GetStrWidth(m_leftBracket, null, vwenv);
         len += GetStrWidth(m_rightBracket, null, vwenv);
         return(len);
     }
 }
Example #11
0
        /// <summary>
        /// Gets the number of lines needed to display the specified context or variable.
        /// </summary>
        /// <param name="ctxtOrVar">The context or variable.</param>
        /// <returns></returns>
        protected int GetNumLines(IPhContextOrVar ctxtOrVar)
        {
            if (ctxtOrVar == null)
            {
                return(1);
            }

            switch (ctxtOrVar.ClassID)
            {
            case PhSequenceContext.kclsidPhSequenceContext:
                IPhSequenceContext seqCtxt = ctxtOrVar as IPhSequenceContext;
                int maxNumLines            = 1;
                foreach (IPhPhonContext cur in seqCtxt.MembersRS)
                {
                    int numLines = GetNumLines(cur);
                    if (numLines > maxNumLines)
                    {
                        maxNumLines = numLines;
                    }
                }
                return(maxNumLines);

            case PhIterationContext.kclsidPhIterationContext:
                IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
                return(GetNumLines(iterCtxt.MemberRA));

            case PhSimpleContextNC.kclsidPhSimpleContextNC:
                int numFeats = 0;
                IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC;
                if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
                {
                    IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;
                    if (natClass.FeaturesOAHvo != 0)
                    {
                        numFeats = natClass.FeaturesOA.FeatureSpecsOC.Count;
                    }
                }
                return(ncCtxt.PlusConstrRS.Count + ncCtxt.MinusConstrRS.Count + numFeats);
            }
            return(1);
        }
Example #12
0
        private void SetDlgInfo(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, int hvoOwner, int owningFlid, IFsFeatStruc fs, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            m_fs            = fs;
            m_owningFlid    = owningFlid;
            m_hvoOwner      = hvoOwner;
            m_rule          = rule;
            m_ctxt          = ctxt;
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            if (m_propertyTable != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                if (m_propertyTable.PropertyExists("phonFeatListDlgLocation") &&
                    m_propertyTable.PropertyExists("phonFeatListDlgSize"))
                {
                    var locWnd = m_propertyTable.GetValue <Point>("phonFeatListDlgLocation");
                    var szWnd  = m_propertyTable.GetValue <Size>("phonFeatListDlgSize");
                    var rect   = new Rectangle(locWnd, szWnd);
                    ScreenHelper.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }

                var helpTopicProvider = (m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider"));
                if (helpTopicProvider != null)                 // Will be null when running tests
                {
                    m_helpProvider.HelpNamespace = helpTopicProvider.HelpFile;
                    m_helpProvider.SetHelpKeyword(this, helpTopicProvider.GetHelpString(m_helpTopic));
                    m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
                }
            }
            m_cache = cache;
            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);

            LoadPhonFeats(m_fs);
            BuildInitialBrowseView();
        }
Example #13
0
		/// <summary>
		/// Collects all of the alpha variables in the specified sequence of simple contexts.
		/// </summary>
		/// <param name="ctxt">The context.</param>
		/// <param name="featureConstrs">The feature indices.</param>
		/// <param name="excludeCtxt">The natural class context to exclude.</param>
		void CollectVars(IPhPhonContext ctxt, List<int> featureConstrs, IPhSimpleContextNC excludeCtxt)
		{
			if (ctxt == null || (excludeCtxt != null && ctxt.Hvo == excludeCtxt.Hvo))
				return;

			switch (ctxt.ClassID)
			{
				case PhSequenceContext.kclsidPhSequenceContext:
					IPhSequenceContext seqCtxt = ctxt as IPhSequenceContext;
					foreach (IPhPhonContext cur in seqCtxt.MembersRS)
						CollectVars(cur as IPhSimpleContextNC, featureConstrs, excludeCtxt);
					break;

				case PhIterationContext.kclsidPhIterationContext:
					IPhIterationContext iterCtxt = ctxt as IPhIterationContext;
					CollectVars(iterCtxt.MemberRA, featureConstrs, excludeCtxt);
					break;

				case PhSimpleContextNC.kclsidPhSimpleContextNC:
					IPhSimpleContextNC ncCtxt = ctxt as IPhSimpleContextNC;
					CollectVars(ncCtxt.PlusConstrRS, featureConstrs);
					CollectVars(ncCtxt.MinusConstrRS, featureConstrs);
					break;
			}
		}
Example #14
0
		int GetNCFeatsWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv)
		{
			int maxLen = 0;
			IPhNCFeatures natClass = ctxt.FeatureStructureRA as IPhNCFeatures;
			if (natClass != null && natClass.FeaturesOA != null)
			{
				foreach (IFsFeatureSpecification spec in natClass.FeaturesOA.FeatureSpecsOC)
				{
					IFsClosedValue curVal = spec as IFsClosedValue;
					ITsString featLine = CreateFeatureLine(curVal);
					int len = GetStrWidth(featLine, null, vwenv);
					if (len > maxLen)
						maxLen = len;
				}
			}

			int plusLen = GetVariablesWidth(ctxt, vwenv, true);
			if (plusLen > maxLen)
				maxLen = plusLen;

			int minusLen = GetVariablesWidth(ctxt, vwenv, false);
			if (minusLen > maxLen)
				maxLen = minusLen;
			return maxLen;
		}
Example #15
0
		int GetNCCtxtWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv)
		{
			if (ctxt.FeatureStructureRA != null && ctxt.FeatureStructureRA.ClassID == PhNCFeaturesTags.kClassId)
			{
				int numLines = GetNumLines(ctxt);
				if (numLines == 1)
				{
					int len = 0;
					if (ctxt.FeatureStructureRA.Abbreviation.UserDefaultWritingSystem.Text == "C"
						|| ctxt.FeatureStructureRA.Abbreviation.UserDefaultWritingSystem.Text == "V")
					{
						len = GetStrWidth(ctxt.FeatureStructureRA.Abbreviation.BestAnalysisAlternative, null, vwenv);
					}
					else
					{
						len = GetNCFeatsWidth(ctxt, vwenv);
					}
					len += GetStrWidth(m_leftBracket, null, vwenv);
					len += GetStrWidth(m_rightBracket, null, vwenv);
					return len;
				}
				else
				{
					int len = GetNCFeatsWidth(ctxt, vwenv);
					len += GetStrWidth(m_leftBracketUpHook, m_bracketProps, vwenv);
					len += GetStrWidth(m_rightBracketUpHook, m_bracketProps, vwenv);
					return len;
				}
			}
			else
			{
				int len = 0;
				if (ctxt.FeatureStructureRA == null)
					len = GetStrWidth(m_questions, null, vwenv);
				else
					len = GetStrWidth(ctxt.FeatureStructureRA.Abbreviation.BestAnalysisAlternative, null, vwenv);
				len += GetStrWidth(m_leftBracket, null, vwenv);
				len += GetStrWidth(m_rightBracket, null, vwenv);
				return len;
			}
		}
Example #16
0
		/// <summary>
		/// Gets all of the feature constraints in this rule except those
		/// contained within the specified natural class context.
		/// </summary>
		/// <param name="excludeCtxt">The natural class context.</param>
		/// <returns>The feature constraints.</returns>
		public List<int> GetFeatureConstraintsExcept(IPhSimpleContextNC excludeCtxt)
		{
			List<int> featureConstrs = new List<int>();
			CollectVars(StrucDescOS, featureConstrs, excludeCtxt);
			foreach (IPhSegRuleRHS rhs in RightHandSidesOS)
			{
				CollectVars(rhs.StrucChangeOS, featureConstrs, excludeCtxt);
				CollectVars(rhs.LeftContextOA, featureConstrs, excludeCtxt);
				CollectVars(rhs.RightContextOA, featureConstrs, excludeCtxt);
			}
			return featureConstrs;
		}
        /// <summary>
        /// Init the dialog with an existing context.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="rule"></param>
        /// <param name="ctxt"></param>
        public void SetDlgInfo(FdoCache cache, Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            CheckDisposed();

            IFsFeatStruc fs = ((IPhNCFeatures)ctxt.FeatureStructureRA).FeaturesOA;

            SetDlgInfo(cache, mediator, ctxt.FeatureStructureRA.Hvo, PhNCFeaturesTags.kflidFeatures, fs, rule, ctxt);
        }
Example #18
0
		/// <summary>
		/// Inserts an item from a natural class.
		/// </summary>
		/// <param name="nc">The natural class.</param>
		/// <param name="sel">The selection.</param>
		/// <param name="cellIndex">Index of the new item.</param>
		/// <param name="ctxt">The new context.</param>
		/// <returns>
		/// The ID of the cell that the item was inserted into
		/// </returns>
		protected virtual int InsertNC(IPhNaturalClass nc, SelectionHelper sel, out int cellIndex, out IPhSimpleContextNC ctxt)
		{
			throw new NotImplementedException();
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (m_helpProvider != null)
					m_helpProvider.Dispose();
			}
			m_cache = null;
			m_fs = null;
			m_ctxt = null;
			m_mediator = null;
			m_cache = null;
			m_bvList = null;
			m_valuesCombo = null;

			base.Dispose( disposing );
		}
		private void SetDlgInfo(FdoCache cache, Mediator mediator, int hvoOwner, int owningFlid, IFsFeatStruc fs, IPhRegularRule rule, IPhSimpleContextNC ctxt)
		{
			m_fs = fs;
			m_owningFlid = owningFlid;
			m_hvoOwner = hvoOwner;
			m_rule = rule;
			m_ctxt = ctxt;
			Mediator = mediator;
			m_cache = cache;
			m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
			m_valuesCombo.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

			LoadPhonFeats(m_fs);
			BuildInitialBrowseView(mediator);
		}
		/// <summary>
		/// Init the dialog with an existing context.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		/// <param name="rule"></param>
		/// <param name="ctxt"></param>
		public void SetDlgInfo(FdoCache cache, Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
		{
			CheckDisposed();

			IFsFeatStruc fs = ((IPhNCFeatures) ctxt.FeatureStructureRA).FeaturesOA;
			SetDlgInfo(cache, mediator, ctxt.FeatureStructureRA.Hvo, PhNCFeaturesTags.kflidFeatures, fs, rule, ctxt);
		}
Example #22
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case kfragContext:
                IPhContextOrVar ctxtOrVar       = PhContextOrVar.CreateFromDBObject(m_cache, hvo);
                bool            isOuterIterCtxt = false;
                // are we inside an iteration context? this is important since we only open a context pile if we are not
                // in an iteration context, since an iteration context does it for us
                if (vwenv.EmbeddingLevel > 0)
                {
                    int outerHvo, outerTag, outerIndex;
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex);
                    isOuterIterCtxt = m_cache.GetClassOfObject(outerHvo) == PhIterationContext.kclsidPhIterationContext;
                }

                switch (ctxtOrVar.ClassID)
                {
                case PhSequenceContext.kclsidPhSequenceContext:
                    if (m_cache.GetVectorSize(hvo, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) > 0)
                    {
                        vwenv.AddObjVecItems((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragContext);
                    }
                    else
                    {
                        OpenContextPile(vwenv, false);
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragEmpty);
                        CloseContextPile(vwenv, false);
                    }
                    break;

                case PhSimpleContextNC.kclsidPhSimpleContextNC:
                    IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC;
                    if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
                    {
                        // Natural class simple context with a feature-based natural class
                        IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;

                        int numLines = GetNumLines(ncCtxt);
                        if (numLines == 0)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else if (numLines == 1)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            // use normal brackets for a single line context
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

                            // special consonant and vowel natural classes only display the abbreviation
                            if (natClass.Abbreviation.AnalysisDefaultWritingSystem == "C" ||
                                natClass.Abbreviation.AnalysisDefaultWritingSystem == "V")
                            {
                                vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                            }
                            else
                            {
                                if (natClass.FeaturesOAHvo != 0 && natClass.FeaturesOA.FeatureSpecsOC.Count > 0)
                                {
                                    vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                                }
                                else if (ncCtxt.PlusConstrRS.Count > 0)
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                                }
                                else
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                                }
                            }
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else
                        {
                            // multiline context

                            // left bracket pile
                            int maxNumLines = MaxNumLines;
                            vwenv.Props = m_bracketProps;
                            vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                            }
                            vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                            vwenv.CloseInnerPile();

                            // feature and variable pile
                            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, vwenv);
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                            vwenv.CloseInnerPile();

                            // right bracket pile
                            vwenv.Props = m_bracketProps;
                            if (!isOuterIterCtxt)
                            {
                                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            }
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv);
                            vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
                            }
                            vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
                            vwenv.CloseInnerPile();
                        }
                    }
                    else
                    {
                        // natural class context with segment-based natural class
                        if (!isOuterIterCtxt)
                        {
                            OpenContextPile(vwenv);
                        }

                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                        if (ncCtxt.FeatureStructureRAHvo != 0)
                        {
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                        }
                        else
                        {
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                        }
                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                        if (!isOuterIterCtxt)
                        {
                            CloseContextPile(vwenv);
                        }
                    }
                    break;

                case PhIterationContext.kclsidPhIterationContext:
                    IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
                    if (iterCtxt.MemberRAHvo != 0)
                    {
                        int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext);
                        if (numLines > 1)
                        {
                            vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            DisplayIterCtxt(iterCtxt, numLines, vwenv);
                        }
                        else
                        {
                            OpenContextPile(vwenv);
                            if (iterCtxt.MemberRA.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC)
                            {
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            }
                            else
                            {
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen);
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen);
                            }
                            DisplayIterCtxt(iterCtxt, 1, vwenv);
                            // Views doesn't handle selection properly when we have an inner pile with strings on either side,
                            // so we don't add a zero-width space at the end
                            CloseContextPile(vwenv, false);
                        }
                    }
                    else
                    {
                        OpenContextPile(vwenv);
                        vwenv.AddProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragQuestions);
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextSeg.kclsidPhSimpleContextSeg:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextBdry.kclsidPhSimpleContextBdry:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhVariable.kclsidPhVariable:
                    OpenContextPile(vwenv);
                    vwenv.AddProp(ktagXVariable, this, kfragXVariable);
                    CloseContextPile(vwenv);
                    break;
                }
                break;

            case kfragNC:
                int ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation);
                if (ncWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, ncWs, this);
                }
                else
                {
                    ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidName);
                    if (ncWs != 0)
                    {
                        vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidName, ncWs, this);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions);
                    }
                }
                break;

            case kfragTerminalUnit:
                int tuWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstVern, hvo, (int)PhTerminalUnit.PhTerminalUnitTags.kflidName);
                if (tuWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, tuWs, this);
                }
                else
                {
                    vwenv.AddProp((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, this, kfragQuestions);
                }
                break;

            case kfragFeatNC:
                vwenv.AddObjProp((int)PhNCFeatures.PhNCFeaturesTags.kflidFeatures, this, kfragFeats);
                break;

            case kfragFeats:
                vwenv.AddObjVecItems((int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature);
                break;

            case kfragFeature:
                vwenv.AddProp(ktagFeature, this, kfragFeatureLine);
                break;

            case kfragPlusVariable:
                vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine);
                break;

            case kfragMinusVariable:
                vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
                break;
            }
        }
		/// <summary>
		/// Init the dialog with a simple context.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		/// <param name="fs"></param>
		public void SetDlgInfo(FdoCache cache, XCore.Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
		{
			CheckDisposed();

			m_rule = rule;
			m_ctxt = ctxt;
			RestoreWindowPosition(mediator);
			m_cache = cache;

			m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
			m_valuesCombo.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_valuesCombo.WritingSystemCode = m_cache.DefaultUserWs;
			m_valuesCombo.Items.Add(MEStrings.ksFeatConstrAgree);
			m_valuesCombo.Items.Add(MEStrings.ksFeatConstrDisagree);
			m_valuesCombo.Items.Add(MEStrings.ks_DontCare_);

			List<int> hvos = new List<int>();
			IPhNCFeatures natClass = m_ctxt.FeatureStructureRA as IPhNCFeatures;
			foreach (int hvo in m_cache.LangProject.PhFeatureSystemOA.FeaturesOC.HvoArray)
			{
				if (natClass.FeaturesOAHvo == 0 || natClass.FeaturesOA.FindClosedValue(hvo) == null)
					hvos.Add(hvo);
			}
			LoadPhonFeats(hvos);
			BuildInitialBrowseView(mediator, hvos);
		}
Example #24
0
        protected override int InsertNC(IPhNaturalClass nc, SelectionHelper sel, out int cellIndex, out IPhSimpleContextNC ctxt)
        {
            ctxt = m_cache.ServiceLocator.GetInstance <IPhSimpleContextNCFactory>().Create();
            var cellId = InsertContext(ctxt, sel, out cellIndex);

            ctxt.FeatureStructureRA = nc;
            return(cellId);
        }
Example #25
0
		int GetVariablesWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv, bool polarity)
		{
			var vars = polarity ? ctxt.PlusConstrRS : ctxt.MinusConstrRS;
			int maxLen = 0;
			for (int i = 0; i < vars.Count; i++)
			{
				ITsString varLine = CreateVariableLine(vars[i], polarity);
				int len = GetStrWidth(varLine, null, vwenv);
				if (len > maxLen)
					maxLen = len;
			}
			return maxLen;
		}
Example #26
0
		/// <summary>
		/// Collects all of the alpha variables in the specified sequence of simple contexts.
		/// </summary>
		/// <param name="seq">The sequence.</param>
		/// <param name="featureConstrs">The feature constraints.</param>
		/// <param name="excludeCtxt">The natural class context to exclude.</param>
		void CollectVars(FdoSequence<IPhSimpleContext> seq, List<int> featureConstrs, IPhSimpleContextNC excludeCtxt)
		{
			foreach (IPhSimpleContext ctxt in seq)
			{
				if ((excludeCtxt == null || ctxt.Hvo != excludeCtxt.Hvo)
					&& ctxt.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC)
				{
					IPhSimpleContextNC ncCtxt = ctxt as IPhSimpleContextNC;
					CollectVars(ncCtxt, featureConstrs, excludeCtxt);
				}
			}
		}
Example #27
0
		int GetVariablesWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv, bool polarity)
		{
			IFdoReferenceSequence<IPhFeatureConstraint> vars = polarity ? ctxt.PlusConstrRS : ctxt.MinusConstrRS;
			int maxLen = 0;
			foreach (IPhFeatureConstraint var in vars)
			{
				ITsString varLine = CreateVariableLine(var, polarity);
				int len = GetStrWidth(varLine, null, vwenv);
				if (len > maxLen)
					maxLen = len;
			}
			return maxLen;
		}
		protected override int InsertNC(IPhNaturalClass nc, SelectionHelper sel, out int cellIndex, out IPhSimpleContextNC ctxt)
		{
			ctxt = m_cache.ServiceLocator.GetInstance<IPhSimpleContextNCFactory>().Create();
			var cellId = InsertContext(ctxt, sel, out cellIndex);
			ctxt.FeatureStructureRA = nc;
			return cellId;
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		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)
			{
				if (m_helpProvider != null)
					m_helpProvider.Dispose();
			}
			if (m_cache != null)
			{
				IVwCacheDa cda = m_cache.MainCacheAccessor as IVwCacheDa;
				cda.CacheVecProp(m_cache.LangProject.Hvo, m_fakeFlid, null, 0);
				cda = null;
				m_cache = null;
			}
			m_ctxt = null;
			m_mediator = null;
			m_bvList = null;
			m_valuesCombo = null;

			base.Dispose(disposing);
		}