Ejemplo n.º 1
0
        /// <summary>
        /// Have the utility do what it does.
        /// </summary>
        public void Process()
        {
            try
            {
                FdoCache cache = (FdoCache)m_dlg.Mediator.PropertyTable.GetValue("cache");
                m_dlg.ProgressBar.Maximum = cache.LangProject.LexDbOA.EntriesOC.Count;
                m_dlg.ProgressBar.Step    = 1;
                string locale = InvokePython("-icu");                         //ask the python script for the icu local
                locale = locale.Trim();
                int ws = cache.LanguageEncodings.GetWsFromIcuLocale(locale);

                if (ws == 0)
                {
                    System.Windows.Forms.MessageBox.Show(
                        String.Format(LexTextStrings.ksCannotLocateWsForX, locale));
                    return;
                }

                foreach (ILexEntry e in  cache.LangProject.LexDbOA.EntriesOC)
                {
                    MultiUnicodeAccessor a = e.CitationForm;
                    string src             = a.VernacularDefaultWritingSystem;

                    string output = InvokePython("-i " + src).Trim();

                    a.SetAlternative(output, ws);
                    m_dlg.ProgressBar.PerformStep();
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format(LexTextStrings.ksErrorMsgWithStackTrace, e.Message, e.StackTrace));
            }
        }
Ejemplo n.º 2
0
 private void MergeVernacularString(MultiUnicodeAccessor fwString, string wsString)
 {
     if (wsString.Length > 0)
     {
         fwString.VernacularDefaultWritingSystem = wsString;
     }
 }
Ejemplo n.º 3
0
 /// ----------------------------------------------------------------------------------------
 /// <summary>
 /// Create a MultiUnicodeAccessor
 /// </summary>
 /// ----------------------------------------------------------------------------------------
 protected override void CreateTestData()
 {
     m_inMemoryCache.CacheAccessor.CacheVecProp(Cache.LangProject.Hvo,
                                                (int)LangProject.LangProjectTags.kflidCurAnalysisWss,
                                                new int[] { InMemoryFdoCache.s_wsHvos.De, InMemoryFdoCache.s_wsHvos.Es }, 2);
     Cache.LangProject.CacheDefaultWritingSystems();
     m_multi = m_inMemoryCache.CreateArbitraryMultiUnicodeAccessor();
 }
Ejemplo n.º 4
0
        private void MergeAnalysisString(MultiUnicodeAccessor fwString, string wsString)
        {
            if (wsString.Length > 0)
            {
                fwString.AnalysisDefaultWritingSystem = wsString;
            }

            //MultiStringAccessor a = new MultiStringAccessor(_cache, 0, 0, null);
            //existing.LexemeFormOA.Form.MergeAlternatives();
        }
Ejemplo n.º 5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set string values for the given property for each writing system represented in the
 /// nodelist
 /// </summary>
 /// <param name="multiUnicodeproperty">A MultiUnicodeAccessor representing the property
 /// whose value is to be set</param>
 /// <param name="nodes">An XmlNodeList with the strings in one or more writing systems
 /// </param>
 /// ------------------------------------------------------------------------------------
 private void SetMultiUnicodeAlternatives(MultiUnicodeAccessor multiUnicodeproperty,
                                          XmlNodeList nodes)
 {
     foreach (XmlNode node in nodes)
     {
         int    ws          = GetWs(node.Attributes);
         string alternative = node.InnerText;
         if (ws > 0 && alternative != null && alternative != string.Empty)
         {
             multiUnicodeproperty.SetAlternative(alternative, ws);
         }
         // REVIEW: What should we do when the writing system is not defined in the database?
     }
 }
Ejemplo n.º 6
0
 private void MergeIn(MultiUnicodeAccessor multiText, SimpleMultiText forms)
 {
     if (forms != null && forms.Keys != null)
     {
         foreach (string key in forms.Keys)
         {
             int wsHvo = GetWsFromLiftLang(key);
             if (wsHvo > 0)
             {
                 multiText.SetAlternative(forms[key], wsHvo);
             }
         }
     }
     // multiText.MergeIn(MultiText.Create(forms));
 }
Ejemplo n.º 7
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.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_multi = null;

			base.Dispose(disposing);
		}
Ejemplo n.º 8
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.
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_multi = null;

            base.Dispose(disposing);
        }
Ejemplo n.º 9
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case AtomicReferenceView.kFragAtomicRef:
                // Display a paragraph with a single item.
                int hvoProp = HvoOfObjectToDisplay(vwenv, hvo);
                if (hvoProp == 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.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.OpenMappedPara();
                    DisplayObjectProperty(vwenv, hvoProp);
                    vwenv.CloseParagraph();
                }
                break;

            case AtomicReferenceView.kFragObjName:
                // Display one reference.
            {
                ILgWritingSystemFactory wsf =
                    m_cache.LanguageWritingSystemFactoryAccessor;

                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvDefault,
                                      (int)TptEditable.ktptNotEditable);
                ITsString     tss;
                ITsStrFactory tsf = TsStrFactoryClass.Create();
                Debug.Assert(hvo != 0);
                // 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 info = pi.GetValue(obj, null);
                        // handle the object type
                        if (info is String)
                        {
                            tss = tsf.MakeString((string)info, ws);
                        }
                        else if (info is MultiUnicodeAccessor)
                        {
                            MultiUnicodeAccessor accessor = info as MultiUnicodeAccessor;
                            tss = accessor.GetAlternativeTss(ws);                                     // try the requested one (or default analysis)
                            if (tss == null || tss.Length == 0)
                            {
                                tss = accessor.BestAnalysisVernacularAlternative;                                         // get something
                            }
                        }
                        else if (info is ITsString)
                        {
                            tss = (ITsString)info;
                        }
                        else
                        {
                            tss = null;
                        }
                    }
                    else
                    {
                        tss = obj.ShortNameTSS;                                 // prefer this, which is hopefully smart about wss.
                        if (tss == null || tss.Length == 0)
                        {
                            tss = tsf.MakeString(obj.ShortName, ws);
                        }
                    }
                }
                vwenv.AddString(tss);
            }
            break;

            default:
                throw new ArgumentException(
                          "Don't know what to do with the given frag.", "frag");
            }
        }
Ejemplo n.º 10
0
		/// ----------------------------------------------------------------------------------------
		/// <summary>
		/// Create a MultiUnicodeAccessor
		/// </summary>
		/// ----------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_inMemoryCache.CacheAccessor.CacheVecProp(Cache.LangProject.Hvo,
				(int)LangProject.LangProjectTags.kflidCurAnalysisWss,
				new int[]{InMemoryFdoCache.s_wsHvos.De, InMemoryFdoCache.s_wsHvos.Es}, 2);
			Cache.LangProject.CacheDefaultWritingSystems();
			m_multi = m_inMemoryCache.CreateArbitraryMultiUnicodeAccessor();
		}