Ejemplo n.º 1
0
        private void LoadDialog(bool merge = false)
        {
            string jsonPath    = string.Empty;
            string jsonContent = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "json files (*.json)|*.json";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    jsonPath = openFileDialog.FileName;

                    //Read the contents of the file into a stream
                    var fileStream = openFileDialog.OpenFile();

                    using (StreamReader reader = new StreamReader(fileStream))
                    {
                        BindingSource            bindingSource = (BindingSource)AnimationListBox.DataSource;
                        System.Collections.IList SourceList    = bindingSource.List;
                        SourceList.Clear();
                        jsonContent = reader.ReadToEnd();
                        animationGroups.LoadFromJson(jsonContent, merge);
                        animationListBinding.ResetBindings(false);
                        Loader.Global.SetSaveRequiredFlag(true, false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ImportBtn_Click(object sender, EventArgs e)
        {
            string jsonPath    = string.Empty;
            string jsonContent = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "json files (*.json)|*.json";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    jsonPath = openFileDialog.FileName;

                    //Read the contents of the file into a stream
                    var fileStream = openFileDialog.OpenFile();

                    using (StreamReader reader = new StreamReader(fileStream))
                    {
                        jsonContent = reader.ReadToEnd();
                        animationGroups.LoadFromJson(jsonContent);
                        animationListBinding.ResetBindings(false);
                        Loader.Global.SetSaveRequiredFlag(true, false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void ImportAnimationGroups(string jsonPath)
        {
            AnimationGroupList animationGroups = new AnimationGroupList();
            var fileStream = File.Open(jsonPath, FileMode.Open);

            using (StreamReader reader = new StreamReader(fileStream))
            {
                string jsonContent = reader.ReadToEnd();
                animationGroups.LoadFromJson(jsonContent);
            }
        }
Ejemplo n.º 4
0
        public static void MergeAnimationGroups(string jsonPath, string old_root, string new_root)
        {
            AnimationGroupList animationGroups = new AnimationGroupList();
            var fileStream = File.Open(jsonPath, FileMode.Open);

            using (StreamReader reader = new StreamReader(fileStream))
            {
                string jsonContent          = reader.ReadToEnd();
                string textToFind           = string.Format(@"\b{0}\b", old_root);
                string overridedJsonContent = Regex.Replace(jsonContent, textToFind, new_root);
                animationGroups.LoadFromJson(overridedJsonContent, true);
            }
        }