Example #1
0
 private void TfoDownload_FormDestroy(object sender, EventArgs e)
 {
     DataStream.Dispose();
     LogFile.SaveToFile(baseFolder + "update.log");
     LogFile.Clear();
     LogFile = null;
     if (idleHandler != null)
     {
         Application.Idle -= idleHandler;
     }
 }
Example #2
0
    // IniFile Constructor.
    public TIniFile(string strIniPath)
    {
        m_Path = strIniPath;

        TmpList = new TStringList();
        TmpList.Clear();
        if (File.Exists(m_Path))
        {
            TmpList.LoadFromFile(m_Path);
        }
    }
Example #3
0
        public void GetListOfLanguages(TStringList list)
        {
            string filename, path;
            string langcode;
            int    j;

            list.Clear();

            // Iterate through filesystem
            foreach (string name in System.IO.Directory.EnumerateDirectories(Directory, "*"))
            {
                if (name != "." && name != "..")
                {
                    filename = Directory + name + Path.DirectorySeparatorChar + "LC_MESSAGES" + Path.DirectorySeparatorChar + Domain + ".mo";
                    if (File.Exists(filename))
                    {
                        langcode = name.ToLower();
                        if (list.IndexOf(langcode) == -1)
                        {
                            list.Add(langcode);
                        }
                    }
                }
            }

            // Iterate through embedded files
            for (int i = 0; i < TFileLocator.filelist.Count; i++)
            {
                filename = TFileLocator.basedirectory + TFileLocator.filelist.Strings[i];
                path     = Directory;
                path     = path.ToUpper();
                filename = filename.ToUpper();
                j        = path.Length;
                if (filename.Substring(0, j) == path)
                {
                    path = Path.DirectorySeparatorChar + "LC_MESSAGES" + Path.DirectorySeparatorChar + Domain + ".mo";
                    path = path.ToUpper();
                    if (filename.Substring(filename.Length - path.Length, path.Length) == path)
                    {
                        langcode = filename.Substring(j, filename.Length - path.Length - j).ToLower();
                        langcode = langcode.Substring(0, 3) + langcode.Substring(3).ToUpper();
                        if (list.IndexOf(langcode) == -1)
                        {
                            list.Add(langcode);
                        }
                    }
                }
            }
        }
Example #4
0
        public void Execute()
        {
            int     I;
            uint    dwTick2C;
            string  s18 = string.Empty;
            string  s1C = string.Empty;
            string  s24 = string.Empty;
            string  s28 = string.Empty;
            int     nC;
            int     n10;
            int     n14;
            TConfig Config;

            Config   = LSShare.g_Config;
            dwTick2C = 0;
            while (true)
            {
                if ((HUtil32.GetTickCount() - dwTick2C) > 5 * 60 * 1000)
                {
                    dwTick2C = HUtil32.GetTickCount();
                    try
                    {
                        if (File.Exists(Config.sFeedIDList))
                        {
                            AccountLoadList.Clear();
                            AccountLoadList.LoadFromFile(Config.sFeedIDList);
                            if (AccountLoadList.Count > 0)
                            {
                                AccountCostList.Clear();
                                for (I = 0; I < AccountLoadList.Count; I++)
                                {
                                    s18 = AccountLoadList[I].Trim();
                                    s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" });
                                    n10 = HUtil32.Str_ToInt(s24, 0);
                                    n14 = HUtil32.Str_ToInt(s28, 0);
                                    nC  = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0));
                                    AccountCostList.Add(s1C, nC);
                                    if (!bo40)
                                    {
                                        if ((I % 100) == 0)
                                        {
                                            Thread.Sleep(1);
                                        }
                                    }
                                }
                            }

                            //LoadAccountCostList(Config, AccountCostList);
                        }
                    }
                    catch
                    {
                        LSShare.MainOutMessage("Exception] loading on IDStrList.");
                    }
                    try
                    {
                        if (File.Exists(Config.sFeedIPList))
                        {
                            IPaddrLoadList.Clear();
                            IPaddrLoadList.LoadFromFile(Config.sFeedIPList);
                            if (IPaddrLoadList.Count > 0)
                            {
                                IPaddrCostList.Clear();
                                for (I = 0; I < IPaddrLoadList.Count; I++)
                                {
                                    s18 = IPaddrLoadList[I].Trim();
                                    s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" });
                                    n10 = HUtil32.Str_ToInt(s24, 0);
                                    n14 = HUtil32.Str_ToInt(s28, 0);

                                    //@ Unsupported function or procedure: 'MakeLong'
                                    nC = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0));
                                    IPaddrCostList.Add(s1C, nC);
                                    if (!bo40)
                                    {
                                        if ((I % 100) == 0)
                                        {
                                            Thread.Sleep(1);
                                        }
                                    }
                                }
                            }

                            //LoadIPaddrCostList(Config, IPaddrCostList);
                        }
                    }
                    catch
                    {
                        LSShare.MainOutMessage("Exception] loading on IPStrList.");
                    }
                }
                Thread.Sleep(10);

                //@ Unsupported property or method(C): 'Terminated'
                //if (this.Terminated)
                //{
                //    break;
                //}
            }
        }
        public override void Execute()
        {
            ICollection <List <TTP_RetranslatorItem> > items = (ICollection <List <TTP_RetranslatorItem> >)ValuesProp.GetValue(list, null);

            foreach (var item in items.Flatten())
            {
                object obj = item.obj.IsAlive ? item.obj.Target : null;
                if (obj == null)
                {
                    continue;
                }
                if (obj is Component)
                {
                    var comp = ((Component)obj).FindComponent("GNUgettextMarker") as TGnuGettextComponentMarker;
                    if (comp != null && this != comp.Retranslator)
                    {
                        comp.Retranslator.Execute();
                        continue;
                    }
                }
                if (obj is TStringList)
                {
                    // Since we don't know the order of items in sl, and don't have
                    // the original .Objects[] anywhere, we cannot anticipate anything
                    // about the current sl.Strings[] and sl.Objects[] values. We therefore
                    // have to discard both values. We can, however, set the original .Strings[]
                    // value into the list and retranslate that.
                    var sl = new TStringList();
                    try
                    {
                        sl.Text = item.OldValue;
                        TGnuGettextInstance.TranslateStrings(sl, TextDomain);
                        ((TStringList)obj).BeginUpdate();
                        try
                        {
                            ((TStringList)obj).Text = sl.Text;
                        }
                        finally
                        {
                            ((TStringList)obj).EndUpdate();
                        }
                    }
                    finally
                    {
                        sl.Clear();
                        sl = null;
                    }
                }
                else
                {
                    string newValue;
                    if (TextDomain == "" || TextDomain == TGnuGettextInstance.DefaultTextDomain)
                    {
                        newValue = Utils.ComponentGettext(item.OldValue);
                    }
                    else
                    {
                        newValue = TGnuGettextInstance.dgettext(TextDomain, item.OldValue);
                    }
                    var ppi = obj.GetType().GetProperty(item.Propname);
                    if (ppi != null)
                    {
                        ppi.SetValue(obj, newValue, null);
                    }
                    else
                    {
#if DXGETTEXTDEBUG
                        Debug.WriteLine("ERROR: On retranslation, property disappeared: " + item.Propname + " for object of type " + obj.GetType().Name);
#endif
                    }
                }
            }
        }