예제 #1
0
        private void SetupWsParams(XmlNode output, int fieldId)
        {
            if (fieldId == 0)
            {
                return;
            }
            int ws = m_mdc.GetFieldWs(fieldId);

            if (ws != 0)
            {
                // We've got the ws of the field, but there's a good chance it's for a multistring and is "plural"  However, the column can
                // only show one ws at a time, so we use this method to convert the "plural" ws to a "singular" one.
                // Since this may be a bulk edit field, we also want to use a simple WSID for the active one, while keeping the
                // other, if present, to indicate the other options.
                var wsSingular = WritingSystemServices.PluralMagicWsToSingularMagicWs(ws);
                var wsSimple   = WritingSystemServices.SmartMagicWsToSimpleMagicWs(ws);
                var newWsName  = "$ws=" + WritingSystemServices.GetMagicWsNameFromId(wsSimple);
                if (wsSimple != wsSingular)
                {
                    // replace wsName, and also append an "originalWs", which is not exactly the 'original' ws, but
                    // one of the ones the column configure dialog recognizes that will allow all relevant options
                    // to be chosen. If we use this part generator for cases where we want to allow multiple WSs
                    // to show, we need to change this to just use ws instead of wsSingular, but then we will need
                    // to generalize ColumnConfigureDialog.UpdateWsComboValue.
                    var visitorWs = new ReplaceAttrAndAppend("$wsName", newWsName,
                                                             "originalWs", WritingSystemServices.GetMagicWsNameFromId(wsSingular));
                    XmlUtils.VisitAttributes(output, visitorWs);
                    visitorWs.DoTheAppends();                     // after loop terminates.
                }
                else
                {
                    // no substitution, just replace wsName
                    XmlUtils.VisitAttributes(output, new ReplaceSubstringInAttr("$wsName", newWsName));
                }
            }
        }
예제 #2
0
		private void SetupWsParams(XmlNode output, int fieldId)
		{
			if (fieldId == 0)
				return;
			int ws = m_mdc.GetFieldWs(fieldId);
			if (ws != 0)
			{
				// We've got the ws of the field, but there's a good chance it's for a multistring and is "plural"  However, the column can
				// only show one ws at a time, so we use this method to convert the "plural" ws to a "singular" one.
				// Since this may be a bulk edit field, we also want to use a simple WSID for the active one, while keeping the
				// other, if present, to indicate the other options.
				var wsSingular = WritingSystemServices.PluralMagicWsToSingularMagicWs(ws);
				var wsSimple = WritingSystemServices.SmartMagicWsToSimpleMagicWs(ws);
				var newWsName = "$ws=" + WritingSystemServices.GetMagicWsNameFromId(wsSimple);
				if (wsSimple != wsSingular)
				{
					// replace wsName, and also append an "originalWs", which is not exactly the 'original' ws, but
					// one of the ones the column configure dialog recognizes that will allow all relevant options
					// to be chosen. If we use this part generator for cases where we want to allow multiple WSs
					// to show, we need to change this to just use ws instead of wsSingular, but then we will need
					// to generalize ColumnConfigureDialog.UpdateWsComboValue.
					var visitorWs = new ReplaceAttrAndAppend("$wsName", newWsName,
							"originalWs", WritingSystemServices.GetMagicWsNameFromId(wsSingular));
					XmlUtils.VisitAttributes(output, visitorWs);
					visitorWs.DoTheAppends(); // after loop terminates.

				}
				else
				{
					// no substitution, just replace wsName
					XmlUtils.VisitAttributes(output, new ReplaceSubstringInAttr("$wsName", newWsName));
				}
			}
		}