Exemplo n.º 1
0
        private bool OpenVirtualFileModel(string virtualPath)
        {
            int p = virtualPath.IndexOf("::");

            if (p < 0)
            {
                return(false);
            }

            string container = virtualPath.Substring(0, p);
            string ext       = Path.GetExtension(container).ToLower();

            if (ext != ".swf" && ext != ".swc" && ext != ".ane")
            {
                return(false);
            }
            if (!File.Exists(container))
            {
                return(false);
            }

            string    fileName = Path.Combine(container, virtualPath.Substring(p + 2).Replace('.', Path.DirectorySeparatorChar));
            PathModel path     = new PathModel(container, contextInstance);

            SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
            parser.Run();
            AbcConverter.Convert(parser, path, contextInstance);

            if (path.HasFile(fileName))
            {
                FileModel model = path.GetFile(fileName);
                ASComplete.OpenVirtualFile(model);
                return(true);
            }
            int split = fileName.LastIndexOf(Path.DirectorySeparatorChar) + 1;

            fileName = fileName.Substring(0, split) + "package.as";
            if (path.HasFile(fileName))
            {
                FileModel model = path.GetFile(fileName);
                ASComplete.OpenVirtualFile(model);
                return(true);
            }
            fileName = fileName.Substring(0, split) + "toplevel.as";
            if (path.HasFile(fileName))
            {
                FileModel model = path.GetFile(fileName);
                ASComplete.OpenVirtualFile(model);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private static PathModel ParseSWC(string swcFile)
        {
            PathModel path = new PathModel(System.IO.Path.GetFullPath(swcFile), context);

            if (!File.Exists(swcFile))
            {
                Console.WriteLine("Error: missing {0}, copy Flex SDK's lib directory", swcFile);
                return(path);
            }
            SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
            parser.Run();
            AbcConverter.Convert(parser.Abcs, path, context);
            return(path);
        }
Exemplo n.º 3
0
        private void Explore()
        {
            explored = true;

            if (parser != null)
            {
                return;
            }
            parser = new SwfOp.ContentParser(BackingPath);

            runner = new BackgroundWorker();
            runner.RunWorkerCompleted += new RunWorkerCompletedEventHandler(runner_ProcessEnded);
            runner.DoWork             += new DoWorkEventHandler(runner_DoWork);
            runner.RunWorkerAsync(parser);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Parse a packaged library file
 /// </summary>
 /// <param name="path">Models owner</param>
 public override void ExploreVirtualPath(PathModel path)
 {
     try
     {
         if (File.Exists(path.Path))
         {
             SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
             parser.Run();
             AbcConverter.Convert(parser, path, this);
         }
     }
     catch (Exception ex)
     {
         string message = TextHelper.GetString("Info.ExceptionWhileParsing");
         TraceManager.AddAsync(message + " " + path.Path);
         TraceManager.AddAsync(ex.Message);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Parse a packaged library file
        /// </summary>
        /// <param name="path">Models owner</param>
        public override void ExploreVirtualPath(PathModel path)
        {
            if (path.WasExplored)
            {
                if (MxmlFilter.HasCatalog(path.Path))
                {
                    MxmlFilter.AddCatalog(path.Path);
                }

                if (path.FilesCount != 0) // already parsed
                {
                    return;
                }
            }

            try
            {
                if (File.Exists(path.Path) && !path.WasExplored)
                {
                    bool isRefresh = path.FilesCount > 0;
                    //TraceManager.AddAsync("parse " + path.Path);
                    lock (path)
                    {
                        path.WasExplored = true;
                        SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
                        parser.Run();
                        AbcConverter.Convert(parser, path, this);
                    }
                    // reset FCSH
                    if (isRefresh)
                    {
                        EventManager.DispatchEvent(this,
                                                   new DataEvent(EventType.Command, "ProjectManager.RestartFlexShell", path.Path));
                    }
                }
            }
            catch (Exception ex)
            {
                string message = TextHelper.GetString("Info.ExceptionWhileParsing");
                TraceManager.AddAsync(message + " " + path.Path);
                TraceManager.AddAsync(ex.Message);
                TraceManager.AddAsync(ex.StackTrace);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Parse a packaged library file
        /// </summary>
        /// <param name="path">Models owner</param>
        public override void ExploreVirtualPath(PathModel path)
        {
            if (path.WasExplored)
            {
                if (MxmlFilter.HasCatalog(path.Path))
                {
                    MxmlFilter.AddCatalog(path.Path);
                }

                if (path.Files.Count != 0) // already parsed
                {
                    return;
                }
            }

            try
            {
                if (File.Exists(path.Path) && !path.WasExplored)
                {
                    //TraceManager.AddAsync("parse " + path.Path);
                    lock (path)
                    {
                        path.WasExplored = true;
                        SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
                        parser.Run();
                        AbcConverter.Convert(parser, path, this);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = TextHelper.GetString("Info.ExceptionWhileParsing");
                TraceManager.AddAsync(message + " " + path.Path);
                TraceManager.AddAsync(ex.Message);
            }
        }
Exemplo n.º 7
0
 private static PathModel ParseSWC(string swcFile)
 {
     PathModel path = new PathModel(System.IO.Path.GetFullPath(swcFile), context);
     if (!File.Exists(swcFile))
     {
         Console.WriteLine("Error: missing {0}, copy Flex SDK's lib directory", swcFile);
         return path;
     }
     SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
     parser.Run();
     AbcConverter.Convert(parser.Abcs, path, context);
     return path;
 }
Exemplo n.º 8
0
        private bool OpenVirtualFileModel(string virtualPath)
        {
            int p = virtualPath.IndexOf("::");
            if (p < 0) return false;

            string container = virtualPath.Substring(0, p);
            string ext = Path.GetExtension(container).ToLower();
            if (ext != ".swc" && ext != ".swf")
                return false;
            if (!File.Exists(container))
                return false;

            string fileName = Path.Combine(container, 
                virtualPath.Substring(p + 2).Replace('.', Path.DirectorySeparatorChar));
            PathModel path = new PathModel(container, contextInstance);
            SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
            parser.Run();
            AbcConverter.Convert(parser, path, contextInstance);
            
            if (path.HasFile(fileName))
            {
                FileModel model = path.GetFile(fileName);
                ASComplete.OpenVirtualFile(model);
            }
            return false;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Parse a packaged library file
 /// </summary>
 /// <param name="path">Models owner</param>
 public override void ExploreVirtualPath(PathModel path)
 {
     try
     {
         if (File.Exists(path.Path))
         {
             SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
             parser.Run();
             AbcConverter.Convert(parser, path, this);
         }
     }
     catch (Exception ex)
     {
         string message = TextHelper.GetString("Info.ExceptionWhileParsing");
         TraceManager.AddAsync(message + " " + path.Path);
         TraceManager.AddAsync(ex.Message);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Parse a packaged library file
        /// </summary>
        /// <param name="path">Models owner</param>
        public override void ExploreVirtualPath(PathModel path)
        {
            if (path.WasExplored)
            {
                if (MxmlFilter.HasCatalog(path.Path)) MxmlFilter.AddCatalog(path.Path);

                if (path.FilesCount != 0) // already parsed
                    return;
            }

            try
            {
                if (File.Exists(path.Path) && !path.WasExplored)
                {
                    bool isRefresh = path.FilesCount > 0;
                    //TraceManager.AddAsync("parse " + path.Path);
                    lock (path)
                    {
                        path.WasExplored = true;
                        SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
                        parser.Run();
                        AbcConverter.Convert(parser, path, this);
                    }
                    // reset FCSH
                    if (isRefresh)
                    {
                        EventManager.DispatchEvent(this,
                            new DataEvent(EventType.Command, "ProjectManager.RestartFlexShell", path.Path));
                    }
                }
            }
            catch (Exception ex)
            {
                string message = TextHelper.GetString("Info.ExceptionWhileParsing");
                TraceManager.AddAsync(message + " " + path.Path);
                TraceManager.AddAsync(ex.Message);
                TraceManager.AddAsync(ex.StackTrace);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Parse a packaged library file
        /// </summary>
        /// <param name="path">Models owner</param>
        public override void ExploreVirtualPath(PathModel path)
        {
            if (path.WasExplored)
            {
                if (MxmlFilter.HasCatalog(path.Path)) MxmlFilter.AddCatalog(path.Path);

                if (path.Files.Count != 0) // already parsed
                    return;
            }

            try
            {
                if (File.Exists(path.Path) && !path.WasExplored)
                {
                    //TraceManager.AddAsync("parse " + path.Path);
                    lock (path)
                    {
                        path.WasExplored = true;
                        SwfOp.ContentParser parser = new SwfOp.ContentParser(path.Path);
                        parser.Run();
                        AbcConverter.Convert(parser, path, this);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = TextHelper.GetString("Info.ExceptionWhileParsing");
                TraceManager.AddAsync(message + " " + path.Path);
                TraceManager.AddAsync(ex.Message);
            }
        }
Exemplo n.º 12
0
        private void AddExports()
        {
            // remove WorkingNode
            TreeView.BeginUpdate();
            try
            {
                if (parser == null)
                {
                    return;
                }
                if (parser.Errors.Count > 0)
                {
                    WorkingNode wnode = Nodes[0] as WorkingNode;
                    if (wnode == null)
                    {
                        Nodes.Clear();
                        wnode = new WorkingNode(BackingPath);
                        Nodes.Add(wnode);
                    }
                    wnode.SetErrorText(parser.Errors[0]);
                    return;
                }

                Nodes.Clear();
                ExportComparer classesComp = new ExportComparer();
                if (parser.Classes.Count == 1)
                {
                    classesComp.Compare(parser.Classes[0], parser.Classes[0]);
                }
                parser.Classes.Sort(classesComp);
                ExportComparer symbolsComp = new ExportComparer();
                if (parser.Symbols.Count == 1)
                {
                    symbolsComp.Compare(parser.Symbols[0], parser.Symbols[0]);
                }
                parser.Symbols.Sort(symbolsComp);
                ExportComparer fontsComp = new ExportComparer();
                if (parser.Fonts.Count == 1)
                {
                    fontsComp.Compare(parser.Fonts[0], parser.Fonts[0]);
                }
                parser.Fonts.Sort(fontsComp);

                if (parser.Classes.Count > 0)
                {
                    ClassesNode node   = new ClassesNode(BackingPath);
                    string[]    groups = new string[classesComp.groups.Keys.Count];
                    classesComp.groups.Keys.CopyTo(groups, 0);
                    Array.Sort(groups);
                    foreach (string groupName in groups)
                    {
                        if (node.Nodes.Count > 0)
                        {
                            SwfFrameNode frame = new SwfFrameNode(BackingPath, groupName);
                            frame.Text = groupName;
                            node.Nodes.Add(frame);
                        }
                        List <String> names = classesComp.groups[groupName];
                        names.Sort(); // TODO Add setting?
                        foreach (string cls in names)
                        {
                            node.Nodes.Add(new ClassExportNode(BackingPath, cls.Replace(':', '.')));
                        }
                    }
                    Nodes.Add(node);
                }

                if (parser.Symbols.Count > 0)
                {
                    SymbolsNode node2  = new SymbolsNode(BackingPath);
                    string[]    groups = new string[symbolsComp.groups.Keys.Count];
                    symbolsComp.groups.Keys.CopyTo(groups, 0);
                    Array.Sort(groups);
                    foreach (string groupName in groups)
                    {
                        if (node2.Nodes.Count > 0)
                        {
                            SwfFrameNode frame = new SwfFrameNode(BackingPath, groupName);
                            frame.Text = groupName;
                            node2.Nodes.Add(frame);
                        }
                        List <String> names = symbolsComp.groups[groupName];
                        names.Sort(); // TODO Add setting?
                        foreach (string symbol in names)
                        {
                            node2.Nodes.Add(new ExportNode(BackingPath, symbol));
                        }
                    }
                    Nodes.Add(node2);
                }

                if (parser.Fonts.Count > 0)
                {
                    FontsNode node2  = new FontsNode(BackingPath);
                    string[]  groups = new string[fontsComp.groups.Keys.Count];
                    fontsComp.groups.Keys.CopyTo(groups, 0);
                    Array.Sort(groups);
                    foreach (string groupName in groups)
                    {
                        if (node2.Nodes.Count > 0)
                        {
                            SwfFrameNode frame = new SwfFrameNode(BackingPath, groupName);
                            frame.Text = groupName;
                            node2.Nodes.Add(frame);
                        }
                        List <String> names = fontsComp.groups[groupName];
                        names.Sort(); // TODO Add setting?
                        foreach (string font in names)
                        {
                            node2.Nodes.Add(new FontExportNode(BackingPath, font));
                        }
                    }
                    Nodes.Add(node2);
                }
            }
            finally
            {
                // free parsed model
                parser = null;
                TreeView.EndUpdate();
            }
        }