コード例 #1
0
        private void defs_file_name_Click(object sender, EventArgs e)
        {
            if (OpenDataDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string data_path = OpenDataDialog.FileName;

            defs_file_name.Text = System.IO.Path.GetFileName(data_path);

            String file_dir = System.IO.Path.GetDirectoryName(data_path);

            Logger.Write(data_path);

            List <string> lines = File.ReadAllLines(data_path).ToList();

            nodes.Clear();

            for (int i = 1; i < lines.Count; i++)
            {
                char[] delimeters = { ' ', ';', '\t' };

                String[] triplet = lines[i].Split(delimeters);

                if (triplet.Length == 3)
                {
                    Node node = new Node(triplet[0]);

                    String keyframe_file_path = file_dir + "\\" + triplet[1];

                    if (System.IO.File.Exists(keyframe_file_path))
                    {
                        node.vertex.frames = ParseKeyFrames(keyframe_file_path);
                    }
                    else
                    {
                        Logger.Write("ERROR: can't find path = " + keyframe_file_path);
                    }

                    if (node.vertex.frames != null && node.vertex.frames.Count > 0)
                    {
                        node.vertex.current_keyframe = node.vertex.frames[0];
                        nodes.Add(node);
                    }
                }
                else
                {
                    Logger.Write("ERROR: can't parse at line " + i + ", expected three values");
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Tanelxen/NEKKI_TestTask
        private void data_file_name_Click(object sender, EventArgs e)
        {
            if (OpenDataDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string data_path = OpenDataDialog.FileName;

            data_file_name.Text = System.IO.Path.GetFileName(data_path);

            Logger.Write(data_path);

            List <string> lines = File.ReadAllLines(data_path).ToList();

            keyframes.Clear();

            for (int i = 1; i < lines.Count; i++)
            {
                char[] delimeters = { ' ', ';', '\t' };

                String[] triplet = lines[i].Split(delimeters);

                if (triplet.Length == 3)
                {
                    float t, x, y;

                    if (float.TryParse(triplet[0], out t) && float.TryParse(triplet[1], out x) && float.TryParse(triplet[2], out y))
                    {
                        keyframes.Add(new KeyFrame(t, x, y));
                    }
                    else
                    {
                        Logger.Write("ERROR: can't parse at line " + i + ", \"" + lines[i] + "\"");
                    }
                }
                else
                {
                    Logger.Write("ERROR: can't parse at line " + i + ", expected three values");
                }
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Tanelxen/NEKKI_TestTask
        private void args_file_name_Click(object sender, EventArgs e)
        {
            OpenDataDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

            if (OpenDataDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string args_path = OpenDataDialog.FileName;

            args_file_name.Text = System.IO.Path.GetFileName(args_path);

            Logger.Write(args_path);

            List <string> lines = File.ReadAllLines(args_path).ToList();

            timeline.Clear();

            for (int i = 1; i < lines.Count; i++)
            {
                float t;

                if (float.TryParse(lines[i], out t))
                {
                    timeline.Add(t);
                }
                else
                {
                    Logger.Write("ERROR: can't parse at line " + i + ", \"" + lines[i] + "\"");
                }
            }

            if (keyframes.Count > 0 || timeline.Count > 0)
            {
                Calculate();
            }
        }
コード例 #4
0
        private void hierarchy_file_name_Click(object sender, EventArgs e)
        {
            if (OpenDataDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string args_path = OpenDataDialog.FileName;

            hierarchy_file_name.Text = System.IO.Path.GetFileName(args_path);

            Logger.Write(args_path);

            List <string> lines = File.ReadAllLines(args_path).ToList();


            for (int i = 1; i < lines.Count; i++)
            {
                var rx = new Regex(" -> ");

                String[] pair = rx.Split(lines[i]);

                if (pair.Length == 2)
                {
                    Node parent_node = nodes.Find(p => p.name == pair[0]);
                    Node child_node  = nodes.Find(p => p.name == pair[1]);

                    if (parent_node != null && child_node != null)
                    {
                        child_node.parent = parent_node;
                    }
                }
                else
                {
                    Logger.Write("ERROR: can't parse at line " + i + ", expected two values");
                }
            }
        }