Exemplo n.º 1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textTranslation.Text == "" && textComments.Text == "")
     {
         //If only the translation is "", then the Lan.g routine will simply ignore it and use English.
         if (!IsNew)
         {
             if (MessageBox.Show("This translation is blank and will be deleted.  Continue?", ""
                                 , MessageBoxButtons.OKCancel) != DialogResult.OK)
             {
                 return;
             }
             LanguageForeigns.Delete(LanForeign);
         }
         DialogResult = DialogResult.OK;
         return;
     }
     LanForeign.Translation = textTranslation.Text;
     LanForeign.Comments    = textComments.Text;
     if (IsNew)
     {
         LanguageForeigns.Insert(LanForeign);
     }
     else
     {
         LanguageForeigns.Update(LanForeign);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 2
0
        ///<summary>Only exports for the current culture.</summary>
        private void butExport_Click(object sender, System.EventArgs e)
        {
            saveFileDialog1.InitialDirectory = Application.StartupPath;
            string fileName = CultureInfo.CurrentCulture.Name + ".sql";        //eg en-US.sql

            saveFileDialog1.FileName = fileName;
            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            StreamWriter sw = new StreamWriter(fileName, false, System.Text.Encoding.UTF8);

            sw.WriteLine("DELETE FROM languageforeign WHERE Culture='" + CultureInfo.CurrentCulture.Name + "';");
            LanguageForeign[] LFList = LanguageForeigns.GetListForCulture(CultureInfo.CurrentCulture);
            for (int i = 0; i < LFList.Length; i++)
            {
                sw.WriteLine(
                    "INSERT INTO languageforeign VALUES ('" + POut.PString(LFList[i].ClassType)
                    + "', '" + POut.PString(LFList[i].English)
                    + "', '" + POut.PString(LFList[i].Culture)
                    + "', '" + POut.PString(LFList[i].Translation)
                    + "', '" + POut.PString(LFList[i].Comments) + "');"
                    );
            }            //for
            sw.Close();
            MessageBox.Show("Done");
        }
Exemplo n.º 3
0
        private void butDownload_Click(object sender, System.EventArgs e)
        {
            string    remoteUri           = "http://www.open-dent.com/cultures/";
            string    fileName            = CultureInfo.CurrentCulture.Name + ".sql";//eg. en-US.sql
            string    myStringWebResource = null;
            WebClient myWebClient         = new WebClient();

            myStringWebResource = remoteUri + fileName;
            try{
                myWebClient.DownloadFile(myStringWebResource, fileName);
            }
            catch {
                MessageBox.Show("Either you do not have internet access, or no translations are available for " + CultureInfo.CurrentCulture.DisplayName);
                return;
            }
            ClassConvertDatabase ConvertDB = new ClassConvertDatabase();

            try{
                ConvertDB.ExecuteFile(fileName);
            }
            catch {
                MessageBox.Show("Translations not installed properly.");
                return;
            }
            LanguageForeigns.Refresh(CultureInfo.CurrentCulture);
            MessageBox.Show("Done");
        }
Exemplo n.º 4
0
        private void butDownload_Click(object sender, System.EventArgs e)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                MessageBox.Show("Not allowed when using client web.");
                return;
            }
            string    remoteUri           = "http://www.opendental.com/cultures/";
            string    fileName            = CultureInfo.CurrentCulture.Name + ".txt";//eg. en-US.txt
            string    myStringWebResource = null;
            WebClient myWebClient         = new WebClient();

            myStringWebResource = remoteUri + fileName;
            try{
                myWebClient.DownloadFile(myStringWebResource, fileName);
            }
            catch {
                MessageBox.Show("Either you do not have internet access, or no translations are available for " + CultureInfo.CurrentCulture.DisplayName);
                return;
            }
            //ClassConvertDatabase ConvertDB=new ClassConvertDatabase();
            try{
                //ConvertDB.ExecuteFile(fileName);
                string content = File.ReadAllText(fileName).Trim();
                Lans.LoadTranslationsFromTextFile(content);
            }
            catch {
                MessageBox.Show("Translations not installed properly.");
                return;
            }
            LanguageForeigns.Refresh(CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            MessageBox.Show("Done");
        }
Exemplo n.º 5
0
        private void FillGrid()
        {
            LanList     = Lan.GetListForCat(ClassType);
            ListForType = LanguageForeigns.GetListForType(ClassType);
            LanguageForeigns.Refresh(CultureInfo.CurrentCulture);
            gridLan.BeginUpdate();
            gridLan.Columns.Clear();
            ODGridColumn column = new ODGridColumn("English", 220);

            gridLan.Columns.Add(column);
            column = new ODGridColumn(CultureInfo.CurrentCulture.DisplayName, 220);
            gridLan.Columns.Add(column);
            column = new ODGridColumn("Other " + CultureInfo.CurrentCulture.Parent.DisplayName + " Translation", 220);
            gridLan.Columns.Add(column);
            column = new ODGridColumn(CultureInfo.CurrentCulture.DisplayName + " Comments", 220);
            gridLan.Columns.Add(column);
            //gridLan.Columns[1].Heading=;
            //gridLan.Columns[2].Heading="Other "+CultureInfo.CurrentCulture.Parent.DisplayName+" Translation";
            //gridLan.Columns[3].Heading=CultureInfo.CurrentCulture.DisplayName+" Comments";
            gridLan.Rows.Clear();
            UI.ODGridRow    row;
            LanguageForeign lanForeign;
            LanguageForeign lanForeignOther;

            for (int i = 0; i < LanList.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(LanList[i].English);
                lanForeign      = LanguageForeigns.GetForCulture(ListForType, LanList[i].English, CultureInfo.CurrentCulture.Name);
                lanForeignOther = LanguageForeigns.GetOther(ListForType, LanList[i].English, CultureInfo.CurrentCulture.Name);
                if (lanForeign == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(lanForeign.Translation);
                }
                if (lanForeignOther == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(lanForeignOther.Translation);
                }
                if (lanForeign == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(lanForeign.Comments);
                }
                gridLan.Rows.Add(row);
            }
            gridLan.EndUpdate();
        }
Exemplo n.º 6
0
        private void gridLan_CellDoubleClick(object sender, OpenDental.UI.ODGridClickEventArgs e)
        {
            Language        LanCur          = LanList[e.Row];
            LanguageForeign lanForeign      = LanguageForeigns.GetForCulture(ListForType, LanCur.English, CultureInfo.CurrentCulture.Name);
            LanguageForeign lanForeignOther = LanguageForeigns.GetOther(ListForType, LanCur.English, CultureInfo.CurrentCulture.Name);
            string          otherTrans      = "";

            if (lanForeignOther != null)
            {
                otherTrans = lanForeignOther.Translation;
            }
            FormTranslationEdit FormTE = new FormTranslationEdit(LanCur, lanForeign, otherTrans);

            FormTE.ShowDialog();
            FillGrid();
        }
Exemplo n.º 7
0
        ///<summary>Only exports for the current culture.</summary>
        private void butExport_Click(object sender, System.EventArgs e)
        {
            string fileName = CultureInfo.CurrentCulture.Name + ".sql";        //eg en-US.sql
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
            }
            else
            {
                saveFileDialog1.InitialDirectory = Application.StartupPath;
                saveFileDialog1.FileName         = fileName;
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog1.FileName;
            }
            StreamWriter sw = new StreamWriter(filePath, false, System.Text.Encoding.UTF8);

            sw.WriteLine("DELETE FROM languageforeign WHERE Culture='" + CultureInfo.CurrentCulture.Name + "';");
            LanguageForeign[] LFList = LanguageForeigns.GetListForCurrentCulture();
            for (int i = 0; i < LFList.Length; i++)
            {
                sw.WriteLine(
                    "INSERT INTO languageforeign (ClassType,English,Culture,Translation,Comments) VALUES ('" + POut.String(LFList[i].ClassType)
                    + "', '" + POut.String(LFList[i].English)
                    + "', '" + POut.String(LFList[i].Culture)
                    + "', '" + POut.String(LFList[i].Translation)
                    + "', '" + POut.String(LFList[i].Comments) + "');"
                    );
            }            //for
            sw.Close();
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show("Done");
            }
        }
Exemplo n.º 8
0
        private void butDeleteUnused_Click(object sender, EventArgs e)
        {
            List <string>   strList = new List <string>();
            LanguageForeign lanForeign;
            LanguageForeign lanForeignOther;

            for (int i = 0; i < LanList.Length; i++)
            {
                lanForeign      = LanguageForeigns.GetForCulture(ListForType, LanList[i].English, CultureInfo.CurrentCulture.Name);
                lanForeignOther = LanguageForeigns.GetOther(ListForType, LanList[i].English, CultureInfo.CurrentCulture.Name);
                if (lanForeign == null && lanForeignOther == null)
                {
                    strList.Add(LanList[i].English);
                }
            }
            if (strList.Count == 0)
            {
                MsgBox.Show(this, "All unused rows have already been deleted.");
                return;
            }
            Lans.DeleteItems(ClassType, strList);
            FillGrid();
        }