コード例 #1
0
        ElementBase IVbElementSerializer.Deserialize(string content, IVbProject project)
        {
            string kind  = content.Substring(0, content.IndexOf('='));
            string value = content.Remove(0, kind.Length + 1);

            switch (kind)
            {
            case "Reference":
                return(_referenceParser.Parse(value));

            case "Object":
                return(ParseObject(value));

            case "Module":
                return(ParseModule(value));

            case "Class":
                return(ParseClass(value));

            case "Form":
                return(ParseForm(value));

            case "UserControl":
                return(ParseUserControl(value));
            }

            throw new NotSupportedException(string.Format("Kind '{0}' is not supported!", kind));
        }
コード例 #2
0
        internal static IEnumerable <ElementBase> GetAllElements(this IVbProject project)
        {
            List <ElementBase> elements = new List <ElementBase>();

            elements.AddRange(project.References);
            elements.AddRange(project.Modules);
            elements.AddRange(project.Objects);
            elements.AddRange(project.Classes);
            elements.AddRange(project.Forms);
            elements.AddRange(project.UserControls);
            return(elements);
        }
コード例 #3
0
ファイル: VB6Helper.cs プロジェクト: mks786/vb6leap
        internal static void RunProject(IVbProject project)
        {
            string arguments = string.Format("/run \"{0}\"", project.Source.FullName);

            using (Process process = new Process())
            {
                process.StartInfo.FileName = GetVB6Path();
                process.StartInfo.Arguments = arguments;

                process.Start();
                process.WaitForExit();
            }
        }
コード例 #4
0
ファイル: VB6Helper.cs プロジェクト: joangilabert/vb6leap
        internal static void RunProject(IVbProject project)
        {
            string arguments = string.Format("/run \"{0}\"", project.Source.FullName);

            using (Process process = new Process())
            {
                process.StartInfo.FileName  = GetVB6Path();
                process.StartInfo.Arguments = arguments;

                process.Start();
                process.WaitForExit();
            }
        }
コード例 #5
0
        private void btnOpenProject_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = Properties.Resources.Vb6ProjectFileFilter;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileInfo fileToParse = new FileInfo(ofd.FileName);

                IVbProjectReader parser = new Vb6ProjectReader();
                using (Stream stream = fileToParse.OpenRead())
                {
                    _project = parser.Read(fileToParse, stream);
                }

                Dictionary <string, IEnumerable <ElementBase> > map = new Dictionary <string, IEnumerable <ElementBase> >();
                map["REFERENCES"] = _project.References;
                map["MODULES"]    = _project.Modules;
                map["CLASSES"]    = _project.Classes;
                map["FORMS"]      = _project.Forms;
                map["OBJECTS"]    = _project.Objects;

                foreach (var mapItem in map)
                {
                    TreeNode node = trvProject.Nodes[0].Nodes[mapItem.Key];
                    node.Nodes.Clear();

                    foreach (var item in mapItem.Value.OrderBy(_ => _.Name))
                    {
                        TreeNode itemNode = new TreeNode();
                        if (!string.IsNullOrWhiteSpace(item.Name))
                        {
                            itemNode.Text = item.Name;
                        }
                        else
                        {
                            itemNode.Text = item.FileName;
                        }

                        itemNode.Tag = item;
                        ExtendNode(item, itemNode);
                        node.Nodes.Add(itemNode);
                    }
                }

                trvProject.Nodes[0].Nodes["MODULES"].Expand();
                trvProject.Nodes[0].Nodes["CLASSES"].Expand();
                trvProject.Nodes[0].Nodes["FORMS"].Expand();
            }
        }
コード例 #6
0
ファイル: ElementBase.cs プロジェクト: mks786/vb6leap
        /// <summary>
        /// Returns the absolute path to the underlying file.
        /// </summary>
        /// <param name="project">The <see cref="IVbProject"/> instance used for retrieving the full path (if the file path is relative).</param>
        /// <returns>The absolute path to the underlying file.</returns>
        public string GetAbsoluteFileName(IVbProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (Path.IsPathRooted(this.FileName))
            {
                return this.FileName;
            }

            return Path.Combine(project.Source.DirectoryName, this.FileName);
        }
コード例 #7
0
ファイル: ElementBase.cs プロジェクト: joangilabert/vb6leap
        /// <summary>
        /// Returns the absolute path to the underlying file.
        /// </summary>
        /// <param name="project">The <see cref="IVbProject"/> instance used for retrieving the full path (if the file path is relative).</param>
        /// <returns>The absolute path to the underlying file.</returns>
        public string GetAbsoluteFileName(IVbProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (Path.IsPathRooted(this.FileName))
            {
                return(this.FileName);
            }

            return(Path.Combine(project.Source.DirectoryName, this.FileName));
        }
コード例 #8
0
ファイル: VB6Helper.cs プロジェクト: joangilabert/vb6leap
        private static IEnumerable <string> MakeProjectCore(IVbProject project)
        {
            string outFilePath = Path.GetTempFileName();
            string arguments   = string.Format("/make \"{0}\" /out \"{1}\"", project.Source.FullName, outFilePath);

            using (Process process = new Process())
            {
                process.StartInfo.FileName  = GetVB6Path();
                process.StartInfo.Arguments = arguments;

                process.Start();
                process.WaitForExit();
            }

            return(File.ReadAllLines(outFilePath).Where(_ => !string.IsNullOrWhiteSpace(_)));
        }
コード例 #9
0
        void IVbProjectWriter.Write(IVbProject project, Stream stream)
        {
            StreamWriter writer = new StreamWriter(stream);

            foreach (ElementBase element in project.GetAllElements())
            {
                writer.WriteLine(_serializer.Serialize(element));
            }

            foreach (string key in project.Properties)
            {
                writer.WriteLine("{0}={1}", key, project.Properties.Get(key, ""));
            }

            writer.Flush();
        }
コード例 #10
0
ファイル: VB6Helper.cs プロジェクト: mks786/vb6leap
        private static IEnumerable<string> MakeProjectCore(IVbProject project)
        {
            string outFilePath = Path.GetTempFileName();
            string arguments = string.Format("/make \"{0}\" /out \"{1}\"", project.Source.FullName, outFilePath);

            using (Process process = new Process())
            {
                process.StartInfo.FileName = GetVB6Path();
                process.StartInfo.Arguments = arguments;

                process.Start();
                process.WaitForExit();
            }

            return File.ReadAllLines(outFilePath).Where(_ => !string.IsNullOrWhiteSpace(_));
        }
コード例 #11
0
ファイル: Vb6ProjectWriter.cs プロジェクト: mks786/vb6leap
        void IVbProjectWriter.Write(IVbProject project, Stream stream)
        {
            StreamWriter writer = new StreamWriter(stream);

            foreach (ElementBase element in project.GetAllElements())
            {
                writer.WriteLine(_serializer.Serialize(element));
            }

            foreach (string key in project.Properties)
            {
                writer.WriteLine("{0}={1}", key, project.Properties.Get(key, ""));
            }

            writer.Flush();
        }
コード例 #12
0
ファイル: VbpProject.cs プロジェクト: mks786/vb6leap
        public VbpProject(ProjectLoadInformation info)
            : base(info)
        {
            _projectReader = new Vb6ProjectReader();
            _projectWriter = new Vb6ProjectWriter();

            FileInfo file = new FileInfo(info.FileName);
            using (Stream stream = file.OpenRead())
            {
                _vbProject = _projectReader.Read(file, stream);
            }

            AddGenericItems();
            AddReferences();

            _symbolCache = VbpProjectSymbolCache.FromProject(this);
        }
コード例 #13
0
ファイル: VbpProject.cs プロジェクト: joangilabert/vb6leap
        public VbpProject(ProjectLoadInformation info)
            : base(info)
        {
            _projectReader = new Vb6ProjectReader();
            _projectWriter = new Vb6ProjectWriter();

            FileInfo file = new FileInfo(info.FileName);

            using (Stream stream = file.OpenRead())
            {
                _vbProject = _projectReader.Read(file, stream);
            }

            AddGenericItems();
            AddReferences();

            _symbolCache = VbpProjectSymbolCache.FromProject(this);
        }
コード例 #14
0
ファイル: VB6Helper.cs プロジェクト: mks786/vb6leap
        internal static MakeResult MakeProject(IVbProject project)
        {
            MakeResult result = new MakeResult();

            try
            {
                result.Results = MakeProjectCore(project).ToArray();

                // HACK: This is not too good. Should be refactored.
                if (result.Results.Length == 1 && result.Results[0].ToLowerInvariant().Contains("succeeded"))
                {
                    result.Results = new string[0];
                }
            }
            catch (Exception ex)
            {
                result.Results = new string[] { ex.Message };
            }

            return result;
        }
コード例 #15
0
ファイル: VB6Helper.cs プロジェクト: joangilabert/vb6leap
        internal static MakeResult MakeProject(IVbProject project)
        {
            MakeResult result = new MakeResult();

            try
            {
                result.Results = MakeProjectCore(project).ToArray();

                // HACK: This is not too good. Should be refactored.
                if (result.Results.Length == 1 && result.Results[0].ToLowerInvariant().Contains("succeeded"))
                {
                    result.Results = new string[0];
                }
            }
            catch (Exception ex)
            {
                result.Results = new string[] { ex.Message };
            }

            return(result);
        }
コード例 #16
0
ファイル: VbElementSerializer.cs プロジェクト: mks786/vb6leap
        ElementBase IVbElementSerializer.Deserialize(string content, IVbProject project)
        {
            string kind = content.Substring(0, content.IndexOf('='));
            string value = content.Remove(0, kind.Length + 1);

            switch (kind)
            {
                case "Reference":
                    return _referenceParser.Parse(value);
                case "Object":
                    return ParseObject(value);
                case "Module":
                    return ParseModule(value);
                case "Class":
                    return ParseClass(value);
                case "Form":
                    return ParseForm(value);
                case "UserControl":
                    return ParseUserControl(value);
            }

            throw new NotSupportedException(string.Format("Kind '{0}' is not supported!", kind));
        }
コード例 #17
0
ファイル: Vb6FileReader.cs プロジェクト: mks786/vb6leap
 Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject)
 {
     return File.OpenRead(element.GetAbsoluteFileName(parentProject));
 }
コード例 #18
0
ファイル: Vb6FileWriter.cs プロジェクト: mks786/vb6leap
 void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream)
 {
     throw new NotImplementedException("Not implemented... yet!");
 }
コード例 #19
0
 public VB6Namespace(IVbProject parent)
 {
     _name = parent.Properties.Name;
 }
コード例 #20
0
 public ViewModel(IVbProject project, VB6leapProjectOptionsPanel parent)
 {
     _project = project;
     _parent = parent;
 }
コード例 #21
0
 public ViewModel(IVbProject project, VB6leapProjectOptionsPanel parent)
 {
     _project = project;
     _parent  = parent;
 }
コード例 #22
0
 void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream)
 {
     throw new NotImplementedException("Not implemented... yet!");
 }
コード例 #23
0
ファイル: Vb6FileReader.cs プロジェクト: joangilabert/vb6leap
 Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject)
 {
     return(File.OpenRead(element.GetAbsoluteFileName(parentProject)));
 }
コード例 #24
0
ファイル: MainForm.cs プロジェクト: mks786/vb6leap
        private void btnOpenProject_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = Properties.Resources.Vb6ProjectFileFilter;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileInfo fileToParse = new FileInfo(ofd.FileName);

                IVbProjectReader parser = new Vb6ProjectReader();
                using (Stream stream = fileToParse.OpenRead())
                {
                    _project = parser.Read(fileToParse, stream);
                }

                Dictionary<string, IEnumerable<ElementBase>> map = new Dictionary<string, IEnumerable<ElementBase>>();
                map["REFERENCES"] = _project.References;
                map["MODULES"] = _project.Modules;
                map["CLASSES"] = _project.Classes;
                map["FORMS"] = _project.Forms;
                map["OBJECTS"] = _project.Objects;

                foreach (var mapItem in map)
                {
                    TreeNode node = trvProject.Nodes[0].Nodes[mapItem.Key];
                    node.Nodes.Clear();

                    foreach (var item in mapItem.Value.OrderBy(_ => _.Name))
                    {
                        TreeNode itemNode = new TreeNode();
                        if (!string.IsNullOrWhiteSpace(item.Name))
                        {
                            itemNode.Text = item.Name;
                        }
                        else
                        {
                            itemNode.Text = item.FileName;
                        }

                        itemNode.Tag = item;
                        ExtendNode(item, itemNode);
                        node.Nodes.Add(itemNode);
                    }
                }

                trvProject.Nodes[0].Nodes["MODULES"].Expand();
                trvProject.Nodes[0].Nodes["CLASSES"].Expand();
                trvProject.Nodes[0].Nodes["FORMS"].Expand();
            }
        }
コード例 #25
0
ファイル: VB6Namespace.cs プロジェクト: mks786/vb6leap
 public VB6Namespace(IVbProject parent)
 {
     _name = parent.Properties.Name;
 }