public void ReadFromVectorsEfficiencyComparison(FdoCache fcTLP) { LangProject lp = fcTLP.LangProject; //bad for (int i = 1; i < lp.OverlaysOC.Count; i++) // must create an FdoOwnColVector each time! { CmOverlay o = new CmOverlay(fcTLP, lp.OverlaysOC.hvoArray[i]); // must create an FdoOwnColVector each time! Console.WriteLine(o.Name); } //better int[] hvos = lp.OverlaysOC.hvoArray; // get the vector just once for (int i = 1; i < hvos.Length; i++) { CmOverlay o = new CmOverlay(fcTLP, hvos[i]); Console.WriteLine(o.Name); } //best: get vector just once, and all of the overlays will be cached at once foreach (CmOverlay o in lp.OverlaysOC) { Console.WriteLine(o.Name); } }
public void PrintLexDBName(FdoCache fcTLP) { LangProject lp = fcTLP.LangProject; LexDb lxdb = lp.LexDbOA; Console.WriteLine(lxdb.Name.AnalysisDefaultWritingSystem); }
public void ModifyVectors(LangProject lp) { //add a new item to an owned sequence attribute CmAnthroItem a = (CmAnthroItem)lp.AnthroListOA.PossibilitiesOS.Append(new CmAnthroItem()); //add a new item to an owned collection attribute CmOverlay overlay = (CmOverlay)lp.OverlaysOC.Add(new CmOverlay()); //add a new item to a reference collection attribute CmPossibility position = (CmPossibility)lp.PositionsOA.PossibilitiesOS [0]; CmPerson person = (CmPerson)lp.PeopleOA.PossibilitiesOS[0]; person.PositionsRC.Add(position); //move the last item in a sequence to the beginning FdoOwnSeqVector positions = lp.PositionsOA.PossibilitiesOS; position = (CmPossibility)positions[positions.Count - 1]; positions.InsertAt(position, 0); //do the same, without instantiating the object we're moving int hvo = positions.hvoArray[positions.Count - 1]; positions.InsertAt(hvo, 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateLanguageCombos() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); string userLocale = wsf.GetStrFromWs(wsf.UserWs); // Get the set of writing systems. Set <NamedWritingSystem> writingSystems = LangProject.GetAllNamedWritingSystemsFromLDFs(wsf, userLocale); NamedWritingSystem wsSaveVern = (NamedWritingSystem)m_cbVernWrtSys.SelectedItem; NamedWritingSystem wsSaveAnal = (NamedWritingSystem)m_cbAnalWrtSys.SelectedItem; m_cbAnalWrtSys.Items.Clear(); m_cbVernWrtSys.Items.Clear(); m_cbAnalWrtSys.BeginUpdate(); m_cbVernWrtSys.BeginUpdate(); foreach (NamedWritingSystem nws in writingSystems) { m_cbAnalWrtSys.Items.Add(nws); m_cbVernWrtSys.Items.Add(nws); } int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.Name)); m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0); m_cbVernWrtSys.EndUpdate(); i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.Name)); m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0); m_cbAnalWrtSys.EndUpdate(); }
private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i) { string sField = ksEditColumnBaseName + i; XmlNode node = m_columns[i - 1] as XmlNode; // Make a cell and embed an editable virtual string for the column. vwenv.OpenTableCell(1, 1); // Initialize the virtual property. IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField); Debug.Assert(vh != null); int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false); int ws = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs); // Paragraph directionality must be set before the paragraph is opened. bool fRTL = IsWsRTL(ws); vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft); vh.Load(khvoNewItem, flid, ws, cda); // Fill in the cell with the virtual property. vwenv.OpenParagraph(); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptIsEditable); vwenv.AddStringAltMember(flid, ws, this); vwenv.CloseParagraph(); vwenv.CloseTableCell(); }
public void MakeNewObjects(LangProject lp) { // add a new morphological data to the language project // (and replace the existing one, if there is one) lp.MorphologicalDataOA = new MoMorphData(); // add a new set of test words to the morphological data object lp.MorphologicalDataOA.TestSetsOC.Add(new WfiWordSet()); }
public void AssignObjects(LangProject lp) { //assign an atomic reference attribute FdoObjectSet os = (FdoObjectSet)lp.ResearchNotebookOA.RecordsOC.GetEnumerator(); os.MoveNext(); RnGenericRec record = (RnGenericRec)os.Current; record.ConfidenceRA = (CmPossibility)lp.ConfidenceLevelsOA.PossibilitiesOS[0]; }
public void ReadFromVectors(LangProject lp) { //read a single item, the third element in the AnthroList CmAnthroItem p = (CmAnthroItem)lp.AnthroListOA.PossibilitiesOS[2]; //read all of the items in the AntrhoList foreach (CmAnthroItem item in lp.AnthroListOA.PossibilitiesOS) { Console.WriteLine(item.Name.AnalysisDefaultWritingSystem); } }
public void NamedWritingSystemsWithDefaultListOfWritingSystems_DbOnly() { CheckDisposed(); // Request the list of all writing systems in the database. Set <NamedWritingSystem> set = LangProject.GetAllNamedWritingSystems(m_lp, "en", new string[0]); Assert.AreEqual(7, set.Count, "Wrong number of writing systems."); Assert.IsTrue(set.Contains(new NamedWritingSystem("English", "en"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("Spanish", "es"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("French", "fr"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("English IPA", "en-IPA"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("German", "de"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("Kalaba", "xkal"))); Assert.IsTrue(set.Contains(new NamedWritingSystem("Urdu", "ur"))); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up a Chrp consistent with the current style sheet /// </summary> /// ------------------------------------------------------------------------------------ protected void MakeCharProps() { LangProject lp = m_Parent.LangProj; // Make a text property with the named style. ITsPropsBldr tsPropsBuilder = TsPropsBldrClass.Create(); tsPropsBuilder.SetStrPropValue((int)VwStyleProperty.kspNamedStyle, m_FieldSpec.Style); tsPropsBuilder.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_ws); ITsTextProps tsTextProps = tsPropsBuilder.GetTextProps(); // Fill out the LgCharRenderProps. ILgWritingSystemFactory lgEncFactory; IVwPropertyStore vwPropertyStore = VwPropertyStoreClass.Create(); IVwStylesheet vwStylesheet = DeStyleSheet; if (vwStylesheet != null) { vwPropertyStore.Stylesheet = vwStylesheet; } if (lp != null) { lgEncFactory = lp.Cache.LanguageWritingSystemFactoryAccessor; } else { // Get default registry-based factory. lgEncFactory = LgWritingSystemFactoryClass.Create(); } Debug.Assert(lgEncFactory != null); vwPropertyStore.WritingSystemFactory = lgEncFactory; m_CharacterRenderingProps = vwPropertyStore.get_ChrpFor(tsTextProps); IWritingSystem writingSystem = lgEncFactory.get_EngineOrNull(m_CharacterRenderingProps.ws); Debug.Assert(writingSystem != null); writingSystem.InterpretChrp(ref m_CharacterRenderingProps); // For our purposes here, we don't want transparent backgrounds. if ((int)m_CharacterRenderingProps.clrBack == (int)FwTextColor.kclrTransparent) { m_CharacterRenderingProps.clrBack = (uint)SystemColors.Window.ToArgb(); } // Make a brush for the background. m_BackgroundBrush = new SolidBrush(Color.FromArgb((int)m_CharacterRenderingProps.clrBack)); }
private int getWsFromIcuCode(string IcuCode) { // special case, the only few we support so far (and only for a few fields). if (IcuCode == "best analysis") { return(LangProject.kwsFirstAnal); } else if (IcuCode == "vern in para") { return(LangProject.kwsVernInParagraph); } Debug.Assert(!LangProject.GetWsRequiresObject(IcuCode), "Writing system is magic. These should never be used in the Interlinear area."); int ws = LangProject.InterpretWsLabel(m_cache, IcuCode, -50, 0, 0, null); Debug.Assert(ws != -50, "InterpretWsLabel was not able to interpret the Ws Label. The most likely cause for this is that a magic ws was passed in."); return(ws); }
/// <summary> /// The main entry point for the application. /// </summary> // [STAThread] // static void Main(string[] args) // { // Snippets t = new Snippets(); // t.DoAllSnippets(); // // Console.WriteLine("Press Enter To Exit"); // Console.ReadLine(); // }; public bool DoAllSnippets(FdoCache fcTLP) { // const string ksCmPossLangProj = "TestLangProj"; // using(FdoCache fcTLP = new FdoCache(ksCmPossLangProj)) { LangProject lp = fcTLP.LangProject; PrintLexDBName(fcTLP); PrintCmPossibility(fcTLP); AssignObjects(lp); MakeNewObjects(lp); DeleteObjects(fcTLP); ReadFromVectors(lp); ModifyVectors(lp); ReadFromVectorsEfficiencyComparison(fcTLP); ListLexEntries(fcTLP); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Use to try to reload the ws from the configuration node. Default writing systems such as "vernacular" or "analysis" /// may change after initialization. (cf. LT-4882). /// </summary> /// <param name="cache">The cache.</param> /// <param name="hvo">the object we want to find the ws for magic writing systems (e.g. for best analysis)</param> /// <param name="defaultWsId">ws we will use if we can't find one.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected virtual int WsId(FdoCache cache, int hvo, int defaultWsId) { int ws = 0; if (m_configuration != null && cache != null) { if (hvo != 0) { int flid = cache.GetFlid(hvo, ClassName, FieldName); ws = LangProject.GetWritingSystem(m_configuration, cache, null, hvo, flid, defaultWsId); } else { ws = LangProject.GetWritingSystem(m_configuration, cache, null, 0); } } if (ws == 0) { ws = defaultWsId; } return(ws); }
public void DeleteObjects(FdoCache fcTLP) { //fcTLP.BeginUndoTask("test", "test"); LangProject lp = fcTLP.LangProject; MoMorphData mmd = lp.MorphologicalDataOA; if (mmd != null) { mmd.DeleteUnderlyingObject(); //see that this call cleared out members of that object Debug.Assert(mmd.hvo < 0); mmd = null; // just in case I try to use it again. } // or, if we we don't want to bother loading the object, // fcTLP.DeleteObject(lp.MorphologicalDataOAHvo); //fcTLP.EndUndoTask(); //fcTLP.Undo ();//don't really want to delete that }
/// <summary> /// Calls the sort method. /// </summary> /// <param name="cmo">The object.</param> /// <param name="sortedFromEnd">if set to <c>true</c> [sorted from end].</param> /// <returns></returns> private string CallSortMethod(ICmObject cmo, bool sortedFromEnd) { Type typeCmo = cmo.GetType(); try { MethodInfo mi = typeCmo.GetMethod(m_sMethodName); if (mi == null) { return(null); } object obj; if (mi.GetParameters().Length == 2) { // Enhance JohnT: possibly we should seek to evaluate this every time, in case it is a magic WS like // "best vernacular". But interpreting those requires a flid, and we don't have one; indeed, the // method may retrieve information from several. So we may as well just accept that the fancy ones // won't work. if (m_ws == 0 && WritingSystemName != null) { m_ws = LangProject.InterpretWsLabel(cmo.Cache, WritingSystemName, 0, 0, 0, null); } obj = mi.Invoke(cmo, new object[] { sortedFromEnd, m_ws }); } else { obj = mi.Invoke(cmo, new object[] { sortedFromEnd }); } return((string)obj); } catch (Exception) { return(null); } }
/// <summary> /// Create the ordered vector of writing sytems to try for displaying names. /// </summary> protected void EstablishWritingSystemsToTry(string sDisplayWs) { if (m_cache == null || m_writingSystemIds != null) { return; } if (sDisplayWs == null || sDisplayWs == String.Empty) { sDisplayWs = "analysis vernacular"; // very general default. } int flid = 0; if (!string.IsNullOrEmpty(m_displayNameProperty)) { string className = m_cache.GetClassName((uint)m_cache.GetClassOfObject(Hvo)); IVwVirtualHandler vh = m_cache.VwCacheDaAccessor.GetVirtualHandlerName(className, m_displayNameProperty); if (vh != null) { flid = vh.Tag; } } m_writingSystemIds = LangProject.GetWritingSystemIdsFromLabel(m_cache, sDisplayWs, m_cache.DefaultUserWs, m_hvo, flid, null); }
private void EndUndoTaskCommon(bool updateDateModified) { if (m_uowService.CurrentProcessingState != UnitOfWorkService.FdoBusinessTransactionState.ProcessingDataChanges) { throw new InvalidOperationException("Cannot end task that has not been started."); } if (updateDateModified) { // A generic side effect of all changes is to update DateModified. // Collect the objects we want to record the modify time on. Don't do each as found: // Updating them will add new dirtballs, which will mess up the DirtyObjects iterator. // Also, we don't need the overhead of updating an object repeatedly if it has several changes. var collector = new HashSet <ICmObjectInternal>(); foreach (var item in m_currentBundle.DirtyObjects) { item.CollectDateModifiedObject(collector); } // Don't update the modify time on new objects, it should be near enough, and Undo will fail // trying to restore the modify time on the deleted object. var newObjects = m_currentBundle.NewObjects; foreach (var dmObj in collector) { if (!newObjects.Contains(dmObj.Id) && !m_currentBundle.IsDateModifiedExplicitly(dmObj)) { dmObj.UpdateDateModified(); } } // Update the project DateModified, but only once every 2 minutes at most. if (m_currentBundle.DirtyObjects.Count() > 0) { LangProject proj = m_currentBundle.DirtyObjects.ElementAt(0).Cache.LangProject as LangProject; TimeSpan span = new TimeSpan(DateTime.Now.Ticks - proj.DateModified.Ticks); if (span.Minutes >= 2 || m_currentBundle.DirtyObjects.Contains(proj)) { proj.UpdateDateModifiedInternal(); } } } m_uowService.m_lock.ExitWriteLock(); m_uowService.CurrentProcessingState = UnitOfWorkService.FdoBusinessTransactionState.BroadcastingPropChanges; if (m_currentBundle.HasDataChange) { // Can't redo these now. // If m_currentBundle can't be finished well, // then it can all be rolled back ClearRedoStack(); PushUowOnUndoStack(m_currentBundle); m_currentBundle.SetAfterXml(); m_uowService.SuppressSelections = true; try { // Handle Step 2.B (PropChanged calls) here. // Do them here because we may not commit yet. // 2.B can be moved after the optional save, but then rethink the states. m_uowService.SendPropChangedNotifications(m_currentBundle.GetPropChangeInformation(false)); } finally { m_uowService.SuppressSelections = false; } } m_currentBundle = null; m_uowService.CurrentProcessingState = UnitOfWorkService.FdoBusinessTransactionState.ReadyForBeginTask; // Do this after we are back in a safe state to do a new UOW, if necessary. RaisePropChangedCompleted(false); }
public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj, StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller) { Slice slice = null; switch (editor) { case "string": { if (flid == 0) { throw new ApplicationException("field attribute required for basic properties " + node.OuterXml); } int ws = GetWs(mediator, cache, node); if (ws != 0) { slice = new StringSlice(obj.Hvo, flid, ws); } else { slice = new StringSlice(obj.Hvo, flid); } break; } case "multistring": { if (flid == 0) { throw new ApplicationException("field attribute required for multistring " + node.OuterXml); } string wsSpec = XmlUtils.GetOptionalAttributeValue(node, "ws"); int wsMagic; wsMagic = LangProject.GetMagicWsIdFromName(wsSpec); if (wsMagic == 0) { throw new ApplicationException( "ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'" + " it said '" + wsSpec + "'."); } bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false); bool spellCheck = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true); bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true); slice = new MultiStringSlice(obj.Hvo, flid, wsMagic, forceIncludeEnglish, editable, spellCheck); break; } case "jtview": { string layout = XmlUtils.GetOptionalAttributeValue(caller, "param"); if (layout == null) { layout = XmlUtils.GetManditoryAttributeValue(node, "layout"); } // Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not. bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true) && XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true); slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable)); break; } case "summary": { slice = new SummarySlice(obj, caller, node, stringTbl); break; } case "enumcombobox": { slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]); break; } case "referencecombobox": { slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator); break; } case "typeaheadrefatomic": { slice = new AtomicRefTypeAheadSlice(obj.Hvo, flid); break; } case "msareferencecombobox": { slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator); break; } case "lit": // was "message" { string message = XmlUtils.GetManditoryAttributeValue(node, "message"); if (stringTbl != null) { string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", ""); if (sTranslate.Trim().ToLower() != "do not translate") { message = stringTbl.LocalizeLiteralValue(message); } } slice = new MessageSlice(message); break; } case "picture": { slice = new PictureSlice((FDO.Cellar.CmPicture)obj); break; } case "image": { try { slice = new ImageSlice(DirectoryFinder.FWCodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1")); } catch (Exception error) { slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed, error.Message)); } break; } case "checkbox": { slice = new CheckboxSlice(cache, obj, flid, node); break; } case "time": { slice = new DateSlice(cache, obj, flid); break; } case "integer": // produced in the auto-generated parts from the conceptual model case "int": // was "integer" { slice = new IntegerSlice(cache, obj, flid); break; } case "morphtypeatomicreference": { slice = new MorphTypeAtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "atomicreferencepos": { slice = new AtomicReferencePOSSlice(cache, obj, flid, persistenceProvider, mediator); break; } case "defaultatomicreference": { slice = new AtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "derivmsareference": { slice = new DerivMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "inflmsareference": { slice = new InflMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "defaultvectorreference": { slice = new ReferenceVectorSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "phoneenvreference": { slice = new PhoneEnvReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl); break; } case "sttext": { slice = new StTextSlice(obj.Hvo, flid, GetWs(mediator, cache, node)); break; } case "custom": { slice = (Slice)DynamicLoader.CreateObject(node); break; } case "customwithparams": { slice = (Slice)DynamicLoader.CreateObject(node, new object[] { cache, editor, flid, node, obj, stringTbl, persistenceProvider, GetWs(mediator, cache, node) }); break; } case "command": { slice = new CommandSlice(node["deParams"]); break; } case null: //grouping nodes do not necessarily have any editor { slice = new Slice(); break; } case "message": // case "integer": // added back in to behave as "int" above throw new Exception("use of obsolete editor type (message->lit, integer->int)"); case "autocustom": slice = MakeAutoCustomSlice(cache, node, obj, caller); if (slice == null) { return(null); } break; default: { //Since the editor has not been implemented yet, //is there a bitmap file that we can show for this editor? //Such bitmaps belong in the distFiles xde directory string fwCodeDir = DirectoryFinder.FWCodeDirectory; string editorBitmapRelativePath = @"xde\" + editor + ".bmp"; if (System.IO.File.Exists(Path.Combine(fwCodeDir, editorBitmapRelativePath))) { slice = new ImageSlice(fwCodeDir, editorBitmapRelativePath); } else { slice = new MessageSlice(String.Format(DetailControlsStrings.ksBadEditorType, editor)); } break; } } slice.AccessibleName = editor; return(slice); }
/// <summary> /// This is the basic method needed for the view constructor. /// </summary> public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case VectorReferenceView.kfragTargetVector: // Check for an empty vector. if (m_cache.GetVectorSize(hvo, m_flid) == 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, 18000); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); //vwenv.AddString(m_cache.MakeUserTss("Click to select -->")); vwenv.NoteDependency(new int[] { hvo }, new int[] { m_flid }, 1); } else { vwenv.OpenParagraph(); vwenv.AddObjVec(m_flid, this, frag); vwenv.CloseParagraph(); } break; case VectorReferenceView.kfragTargetObj: // Display one object from the vector. { ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptIsEditable); ITsString tss; ITsStrFactory tsf = TsStrFactoryClass.Create(); Debug.Assert(hvo != 0); #if USEBESTWS if (m_displayWs != null && m_displayWs.StartsWith("best")) { // The flid can be a variety of types, so deal with those. Debug.WriteLine("Using 'best ws': " + m_displayWs); int magicWsId = LangProject.GetMagicWsIdFromName(m_displayWs); int actualWS = m_cache.LangProject.ActualWs(magicWsId, hvo, m_flid); Debug.WriteLine("Actual ws: " + actualWS.ToString()); } else { #endif // Use reflection to get a prebuilt name if we can. Otherwise // settle for piecing together a string. Debug.Assert(m_cache != null); ICmObject obj = CmObject.CreateFromDBObject(m_cache, hvo); Debug.Assert(obj != null); System.Type type = obj.GetType(); System.Reflection.PropertyInfo pi = type.GetProperty("TsName", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy); if (pi != null) { tss = (ITsString)pi.GetValue(obj, null); } else { if (m_displayNameProperty != null && m_displayNameProperty != string.Empty) { pi = type.GetProperty(m_displayNameProperty, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy); } int ws = wsf.GetWsFromStr(obj.SortKeyWs); if (ws == 0) { ws = m_cache.DefaultAnalWs; } if (pi != null) { object s = pi.GetValue(obj, null); if (s is ITsString) { tss = (ITsString)s; } else { tss = tsf.MakeString((string)s, ws); } } else { tss = obj.ShortNameTSS; } #if USEBESTWS } #endif } vwenv.AddString(tss); } break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for the FwDataEntryForm class that takes a language project. /// </summary> /// ------------------------------------------------------------------------------------ public FwDataEntryForm(LangProject lp) : this() { m_LangProj = lp; }