static public bool ImportDialoguesFromCsv(string importPath, List <Package> packages, List <Language> languages, bool importLocalization, bool importWorkstring, bool importInformation)
        {
            var project = ResourcesHandler.Project;

            //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments
            var headerRedirects = new Dictionary <string, string>();

            headerRedirects.Add("ID", "Node ID");
            headerRedirects.Add("Workstring", "Workstring Text");

            if (importPath == String.Empty)
            {
                EditorCore.LogError("Import Localization failed : no file specified");
                return(false);
            }

            if (!File.Exists(importPath))
            {
                EditorCore.LogError("Import Localization failed : file not found");
                return(false);
            }

            while (Utility.IsFileLocked(importPath))
            {
                EditorCore.LogError("Import Localization failed : file is locked");

                var          dialogLocked = new DialogLockedFile(importPath);
                DialogResult eResult      = dialogLocked.ShowDialog();
                if (eResult == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            DateTime currentTime = Utility.GetCurrentTime();

            using (System.IO.StreamReader file = new System.IO.StreamReader(importPath, Encoding.UTF8))
            {
                ExporterCsv.CsvFileReader reader = new ExporterCsv.CsvFileReader();
                if (reader.ParseHeaders(file, headerRedirects))
                {
                    while (reader.ParseNextLine())
                    {
                        Dialogue dialogue = ResourcesHandler.GetDialogue(reader.GetCell("Dialogue"));
                        if (dialogue != null)
                        {
                            if (!packages.Contains(dialogue.Package))
                            {
                                continue;
                            }

                            int          id   = TranslationTable.GetNodeIDFromPrefixedString(reader.GetCell("ID"));
                            DialogueNode node = dialogue.GetNodeByID(id);
                            if (node == null)
                            {
                                continue;
                            }

                            if (node is DialogueNodeRoot)
                            {
                                var dialogueNodeRoot = node as DialogueNodeRoot;

                                if (importInformation)
                                {
                                    //Import general Dialogue informations
                                    dialogue.Package   = project.GetPackage(reader.GetCell("Package"));
                                    dialogue.SceneType = reader.GetCell("Scene Type");
                                    dialogue.Context   = reader.GetCell("Context");
                                }
                            }
                            else
                            {
                                DateTime timestampLoca = reader.GetCellAsDate("Timestamp");
                                DateTime timestampWorkstring;

                                if (node is DialogueNodeSentence)
                                {
                                    var dialogueNodeSentence = node as DialogueNodeSentence;

                                    if (importWorkstring)
                                    {
                                        //The current workstring is more recent than the modified workstring
                                        if (dialogueNodeSentence.LastEditDate > timestampLoca)
                                        {
                                            //TODO: popup or option to choose what to do here
                                            EditorCore.LogWarning(String.Format("{0} {1} - New workstring older than currently registered workstring, but updated anyway", dialogue.GetName(), id), dialogue, node);
                                        }

                                        dialogueNodeSentence.Sentence     = reader.GetCell("Workstring");
                                        dialogueNodeSentence.LastEditDate = currentTime;
                                        timestampLoca = currentTime;
                                    }

                                    if (importInformation)
                                    {
                                        //Import Sentence informations (Voicing, Context, Speaker..)
                                        string context = reader.GetCell("Context");
                                        dialogueNodeSentence.Context = context;

                                        string voicing = reader.GetCell("Voicing");
                                        dialogueNodeSentence.Comment = voicing;

                                        string voiceIntensity = reader.GetCell("Voice Intensity");
                                        dialogueNodeSentence.VoiceIntensity = voiceIntensity;

                                        string speakerID = ResourcesHandler.Project.GetActorID(reader.GetCell("Speaker"));
                                        dialogueNodeSentence.SpeakerID = speakerID;
                                    }

                                    timestampWorkstring = dialogueNodeSentence.LastEditDate;
                                }
                                else
                                {
                                    var dialogueNodeReply = node as DialogueNodeReply;

                                    if (importWorkstring)
                                    {
                                        //The current workstring is more recent than the modified workstring
                                        if (dialogueNodeReply.LastEditDate > timestampLoca)
                                        {
                                            //TODO: popup or option to choose what to do here
                                            EditorCore.LogWarning(String.Format("{0} {1} - New workstring older than currently registered workstring, but updated anyway", dialogue.GetName(), id), dialogue, node);
                                        }

                                        dialogueNodeReply.Reply        = reader.GetCell("Workstring");
                                        dialogueNodeReply.LastEditDate = currentTime;
                                        timestampLoca = currentTime;
                                    }

                                    timestampWorkstring = dialogueNodeReply.LastEditDate;
                                }

                                if (importLocalization)
                                {
                                    foreach (var language in languages)
                                    {
                                        //TODO: extract this part in a function, to be used from other importers

                                        ETranslationResult translationResult = dialogue.Translations.AddOrUpdateNodeEntry(
                                            id,
                                            language,
                                            timestampLoca,
                                            reader.GetCell(language.Name + " Text")
                                            );

                                        if (translationResult == ETranslationResult.Accepted ||
                                            translationResult == ETranslationResult.Accepted_IdenticalTimestamp ||
                                            translationResult == ETranslationResult.Accepted_IdenticalText)
                                        {
                                            //The current workstring is more recent than the localized entry
                                            if (timestampWorkstring > timestampLoca)
                                            {
                                                EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but based on an outdated workstring, will be re-exported", dialogue.GetName(), id, language.Name), dialogue, node);
                                            }
                                            else
                                            {
                                                //EditorCore.LogInfo(String.Format("{0} {1} - Translation accepted", dialogue.GetName(), id), dialogue.GetName(), id);
                                            }
                                        }

                                        if (translationResult == ETranslationResult.Accepted_IdenticalTimestamp)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but with an identical timestamp as the previous entry", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Accepted_IdenticalText)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but with an identical text as the previous entry", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_EmptyText)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation refused : empty text", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_Outdated)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation refused : outdated timestamp", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_Identical)
                                        {
                                            //ignored
                                        }
                                    }
                                }
                            }
                        }

                        ResourcesHandler.SetDirty(dialogue);
                    }

                    ResourcesHandler.SaveAllDirty();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }

                    EditorCore.ProjectExplorer.ResyncAllFiles();
                }
            }
            return(true);
        }
        static public bool ImportConstantsFromCsv(string importPath, List <Language> languages, bool importLocalization, bool importWorkstring, bool importInformation)
        {
            var project = ResourcesHandler.Project;

            if (importPath == String.Empty)
            {
                EditorCore.LogError("Import Constants failed : no file specified");
                return(false);
            }

            if (!File.Exists(importPath))
            {
                EditorCore.LogError("Import Constants failed : file not found");
                return(false);
            }

            while (Utility.IsFileLocked(importPath))
            {
                EditorCore.LogError("Import Constants failed : file is locked");

                var          dialogLocked = new DialogLockedFile(importPath);
                DialogResult eResult      = dialogLocked.ShowDialog();
                if (eResult == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            DateTime currentTime = Utility.GetCurrentTime();

            using (System.IO.StreamReader file = new System.IO.StreamReader(importPath, Encoding.UTF8))
            {
                ExporterCsv.CsvFileReader reader = new ExporterCsv.CsvFileReader();
                if (reader.ParseHeaders(file))
                {
                    while (reader.ParseNextLine())
                    {
                        string   id       = reader.GetCell("ID");
                        Constant constant = project.ListConstants.Find(item => item.ID == id);
                        if (constant != null)
                        {
                            DateTime timestampLoca = reader.GetCellAsDate("Timestamp");
                            DateTime timestampWorkstring;

                            if (importWorkstring)
                            {
                                //The current workstring is more recent than the modified workstring
                                if (constant.LastEditDate > timestampLoca)
                                {
                                    //TODO: popup or option to choose what to do here
                                    EditorCore.LogWarning(String.Format("Constant {0} - New workstring older than currently registered workstring, but updated anyway", id));
                                }

                                constant.Workstring   = reader.GetCell("Workstring");
                                constant.LastEditDate = currentTime;
                                timestampLoca         = currentTime;
                            }

                            if (importInformation)
                            {
                                string voicing = reader.GetCell("Comment");
                                constant.Comment = voicing;
                            }

                            timestampWorkstring = constant.LastEditDate;

                            if (importLocalization)
                            {
                                foreach (var language in languages)
                                {
                                    //TODO: extract this part in a function, to be used from other importers

                                    ETranslationResult translationResult = project.Translations.AddOrUpdateEntry(
                                        id,
                                        language,
                                        timestampLoca,
                                        reader.GetCell(language.Name + " Text")
                                        );

                                    if (translationResult == ETranslationResult.Accepted ||
                                        translationResult == ETranslationResult.Accepted_IdenticalTimestamp ||
                                        translationResult == ETranslationResult.Accepted_IdenticalText)
                                    {
                                        //The current workstring is more recent than the localized entry
                                        if (timestampWorkstring > timestampLoca)
                                        {
                                            EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but based on an outdated workstring, will be re-exported", id, language.Name));
                                        }
                                        else
                                        {
                                            //EditorCore.LogInfo(String.Format("{0} {1} - Translation accepted", dialogue.GetName(), id), dialogue.GetName(), id);
                                        }
                                    }

                                    if (translationResult == ETranslationResult.Accepted_IdenticalTimestamp)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but with an identical timestamp as the previous entry", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Accepted_IdenticalText)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but with an identical text as the previous entry", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_EmptyText)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation refused : empty text", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_Outdated)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation refused : outdated timestamp", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_Identical)
                                    {
                                        //ignored
                                    }
                                }
                            }
                        }
                    }

                    ResourcesHandler.SaveProject();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }
                }
            }

            return(true);
        }