Пример #1
0
        private void btAddTranslation_Click(object sender, EventArgs e)
        {
            if (selectedLangue == null)
            {
                MessageBox.Show("Please select a Language");
                return;
            }

            if (KeyTb.Text.Equals(""))
            {
                MessageBox.Show("Please Enter a Key");
                return;
            }
            if (TranslationTb.Text.Equals(""))
            {
                MessageBox.Show("Please Enter a Translation for the Key : " + KeyTb.Text);
                return;
            }
            if (selectedLangue.CheckForDuplicateElement(KeyTb.Text))
            {
                MessageBox.Show("The Key " + KeyTb.Text + " is already stored.");
                return;
            }

            LangueElement newLangueElement = new LangueElement(KeyTb.Text, TranslationTb.Text);
            selectedLangue.TranslationElement.Add(newLangueElement);
            this.reloadListTranslation();
        }
Пример #2
0
        private void GTranslate(LangueObject From, String To)
        {
            if (From.Langue == To.ToString()) return;
            LangueObject newLangue = new LangueObject(To.ToString());
            String CFrom = this.GetGoogleTranslateLanguageName(From.Langue);
            String CTo = GetGoogleTranslateLanguageName(To.ToString());
            try
            {
                for (int i = 0; i < From.TranslationElement.Count; i++)
                {
                    string key = From.TranslationElement[i].Translation;
                    MicrosoftTranslator.LanguageServiceClient TranslateC = new MicrosoftTranslator.LanguageServiceClient();
                    string[] l = TranslateC.GetLanguagesForTranslate("A1720512EE086AC9060D14F925EE3D0543CEDF90");
                    var availableLanguages = String.Join(",", l.Select(x => x.ToString()).ToArray());
                    MicrosoftTranslator.TranslateOptions options = new MicrosoftTranslator.TranslateOptions(); // Use the default options
                    string translation = TranslateC.GetTranslations("A1720512EE086AC9060D14F925EE3D0543CEDF90", key.ToString(), CFrom, CTo, 1, options).Translations[0].TranslatedText;
                    LangueElement newLangueElement = new LangueElement(key, translation);
                    newLangue.TranslationElement.Add(newLangueElement);

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("It's seems like google translate can't perform the request.");

            }

            //Add new Language
            if (newLangue.TranslationElement.Count > 0)
            {
                // Check if the new language exist
                for (int i = 0; i < this.project.Langues.Count; i++)
                {
                    if (this.project.Langues[i].Langue.Equals(To.ToString()))
                    {
                        // Removes the previous Langues files
                        this.project.Langues.Remove(this.project.Langues[i]);
                    }
                }
                this.project.Langues.Add(newLangue);

            }
        }
Пример #3
0
        private void LoadtBt_Click(object sender, EventArgs e)
        {
            if (languagesListBx.SelectedItems.Count > 0)
            {
                String langue = languagesListBx.SelectedItems[0].Text;
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter = "CSV file format (UTF-8) |*.csv";
                openFileDialog1.Title = "Open as CSV File (semicolon separator)";
                openFileDialog1.ShowDialog();

                try
                {
                    if (openFileDialog1.FileName != "" && File.Exists(openFileDialog1.FileName))
                    {
                         StringBuilder buffer = new StringBuilder();
                        Stream stream = openFileDialog1.OpenFile();
                        TextReader tr = new StreamReader(stream, Encoding.UTF8);
                        buffer.Append(tr.ReadToEnd());
                        tr.Close();
                        stream.Close();

                        String[] splittedbuff = buffer.ToString().Split('\n');

                        List<String> dicoLangue = new List<string>();
                        for (int i = 0; i < splittedbuff.Length; i++)
                        {
                            if (splittedbuff[i].StartsWith("#"))
                            {
                                //Is a comment, Do Nothing
                                continue;
                            }
                            String[] elements = splittedbuff[i].Split(';');
                            for (int j = 0; j < elements.Length; j++)
                            {
                                dicoLangue.Add(elements[j].ToString().Replace("\n", "!NL!"));
                            }

                        }
                        //Reload DicoLangue
                        this.selectedLangue = (LangueObject)this.languagesListBx.SelectedItems[0].Tag;
                        this.selectedLangue.TranslationElement.Clear();
                        for (int i = 0; i < dicoLangue.Count - 1; i++)
                        {
                            LangueElement newLangueElement = new LangueElement(dicoLangue[i], dicoLangue[i + 1]);
                            this.selectedLangue.TranslationElement.Add(newLangueElement);
                            i++;
                        }
                        this.reloadListTranslation();

                        MessageBox.Show("Import sucess!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("You need to select a CSV file to import it.", "Warning !", MessageBoxButtons.OK);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
Пример #4
0
        private void addFieldBt_Click(object sender, EventArgs e)
        {
            if (selectedLangue == null)
            {
                MessageBox.Show("Please select a Language");
                return;
            }

            if (this.newKeyTxtBx.Text.Equals(""))
            {
                MessageBox.Show("Please enter a translation key");
                return;
            }
            if (this.newValueTxtBx.Text.Equals(""))
            {
                MessageBox.Show("Please enter a translation for the Key : " + newKeyTxtBx.Text);
                return;
            }
            if (selectedLangue.CheckForDuplicateElement(newKeyTxtBx.Text))
            {
                MessageBox.Show("The Key " + newKeyTxtBx.Text + " is already stored.");
                return;
            }

            LangueElement newLangueElement = new LangueElement(newKeyTxtBx.Text, newValueTxtBx.Text);
            selectedLangue.TranslationElement.Add(newLangueElement);
            this.reloadListTranslation();
        }
Пример #5
0
        public void addFigureBt_Click(object sender, EventArgs e)
        {
            if (this.sceneEditorView1.FigActive != null &&
                (this.gameElementTreeView1.LayerSelected != null ||
                (this.gameElementTreeView1.CoronaObjectSelected !=null && this.gameElementTreeView1.CoronaObjectSelected.isEntity == true)))
            {

                this.sceneEditorView1.FigActive.FillColor = Color.Gray;
                this.sceneEditorView1.FigActive.Fill = true;
                if (this.sceneEditorView1.FigActive.ShapeType.Equals("CURVE"))
                {
                    CGE_Figures.CourbeBezier courbe = this.sceneEditorView1.FigActive as CGE_Figures.CourbeBezier;
                    if (courbe.UserPoints.Count < 2)
                        return;
                }

                if (this.sceneEditorView1.FigActive.ShapeType.Equals("LINE"))
                {
                    CGE_Figures.Line line = this.sceneEditorView1.FigActive as CGE_Figures.Line;

                    if (line.Points.Count < 2)
                        return;
                }

                //Creer un displayObject
                DisplayObject dispObject = new DisplayObject(this.sceneEditorView1.FigActive,null);
                if (dispObject.Type.Equals("FIGURE"))
                {
                    if (dispObject.Figure.ShapeType.Equals("TEXT"))
                    {
                        CGE_Figures.Texte text = dispObject.Figure as CGE_Figures.Texte;

                        //int width = Convert.ToInt32(text.font2.Size * (text.txt.Length / 1.5));
                        //int height = Convert.ToInt32(text.font2.Size * 1.5);
                        Point pDest = this.sceneEditorView1.surfaceTextTemp.Location;
                        Size size = this.sceneEditorView1.surfaceTextTemp.Size;
                        dispObject.SurfaceRect = new Rectangle(pDest, size);
                        this.sceneEditorView1.surfaceTextTemp = Rectangle.Empty ;
                        //Recuperer la clé du translate
                        bool isFound = false;
                        for (int i = 0; i < this.CurrentProject.Langues.Count; i++)
                        {
                            LangueObject langue = this.CurrentProject.Langues[i];
                            if (langue.Langue.Equals(this.CurrentProject.DefaultLanguage))
                            {
                                for (int j = 0; j < langue.TranslationElement.Count; j++)
                                {
                                    LangueElement elem = langue.TranslationElement[j];
                                    if (elem.Key.Equals(text.txt))
                                    {
                                        elem.Key = text.txt;
                                        elem.Translation = text.txt;
                                        isFound = true;
                                        break;
                                    }

                                }

                                if (isFound == false)
                                {
                                    LangueElement elem = new LangueElement(text.txt, text.txt);
                                    langue.TranslationElement.Add(elem);
                                }

                                break;
                            }
                        }

                    }
                }

                if (this.gameElementTreeView1.CoronaObjectSelected != null &&
                    (this.gameElementTreeView1.CoronaObjectSelected.isEntity == true ||this.gameElementTreeView1.CoronaObjectSelected.EntityParent != null))
                {
                    dispObject.Name = this.gameElementTreeView1.ProjectSelected.IncrementObjectName("shape" + this.gameElementTreeView1.CoronaObjectSelected.LayerParent.CoronaObjects.Count);
                    //Creer un corona object
                    CoronaObject obj = new CoronaObject(dispObject);

                    this.sceneEditorView1.GraphicsContentManager.UpdateSpriteContent(obj, this.sceneEditorView1.CurrentScale, this.sceneEditorView1.getOffsetPoint());

                    if (this.gameElementTreeView1.CoronaObjectSelected.isEntity == true)
                    {
                        //Ajouter l'objet au projet
                        this.gameElementTreeView1.CoronaObjectSelected.Entity.addObject(obj);
                    }
                    else
                    {
                        //Ajouter l'objet au projet
                        this.gameElementTreeView1.CoronaObjectSelected.EntityParent.addObject(obj);
                    }

                    this.gameElementTreeView1.newCoronaObject(obj);
                }
                else
                {
                    dispObject.Name = this.gameElementTreeView1.ProjectSelected.IncrementObjectName("shape" + this.gameElementTreeView1.LayerSelected.CoronaObjects.Count);

                    //Creer un corona object
                    CoronaObject obj = new CoronaObject(dispObject);

                    //Ajouter l'objet au projet
                    this.gameElementTreeView1.LayerSelected.addCoronaObject(obj, true);
                    this.sceneEditorView1.GraphicsContentManager.UpdateSpriteContent(obj,this.sceneEditorView1.CurrentScale,this.sceneEditorView1.getOffsetPoint());
                    this.gameElementTreeView1.newCoronaObject(obj);
                }

                this.sceneEditorView1.FigActive = null;
                this.sceneEditorView1.isBezierCreated = false;
                this.sceneEditorView1.isLineCreated = false;
                this.SetModeObject();
            }
        }