Click here to Skip to main content
15,884,836 members
Articles / Programming Languages / C#

XDD-Tools for developer

Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
24 Jun 2012CPOL2 min read 22.5K   449   14  
XDD-Tools for developer , count source code line,copy project file, remove comment in source code.
// Ԭ����( http://www.xdesigner.cn ) 2007-5-13

using System;

namespace XDesigner.Development.Dom
{
	/// <summary>
	/// VB�����ļ�����
	/// </summary>
	public class VBProjectDocument : ProjectElement
	{
		/// <summary>
		/// ��ʼ������
		/// </summary>
		public VBProjectDocument()
		{
		}
		/// <summary>
		/// �����Ŀ�ļ�����չ��
		/// </summary>
		/// <param name="strFileName">��Ŀ�ļ���</param>
		/// <returns>�Ƿ�ͨ�����</returns>
		public override bool CheckFileName(string strFileName)
		{
			string ext = FileHelper.GetExtension( strFileName );
			return ext == "VBP" || ext == "VBPROJ";
		}
		/// <summary>
		/// ������Ŀ�ļ�
		/// </summary>
		/// <param name="strFileName">�ļ���</param>
		public override void LoadProjectFile(string strFileName)
		{
			string ext = FileHelper.GetExtension( strFileName );
			if( ext == "VBPROJ")
			{
				int style = VSNETHelper.LoadProject( this , strFileName , "VisualBasic" );
				if( style == 2003 )
				{
					this.Style = ProjectStyle.VBNET2003 ;
				}
				else if( style == 2005 )
				{
					this.Style = ProjectStyle.VBNET2005 ;
				}
                else if (style == 2008)
                {
                    this.Style = ProjectStyle.VBNET2008;
                }
                else if (style == 2010)
                {
                    this.Style = ProjectStyle.VBNET2010;
                }
			}
			else if( ext == "PRJX" )
			{
				this.LoadFromPrjx( strFileName );
			}
			else if( ext == "VBP" )
			{
				this.strProjectFileName = strFileName;
				this.strRootPath = System.IO.Path.GetDirectoryName( strFileName );
				
				FileElement ProjFile = new FileElement();
				ProjFile.FileName = System.IO.Path.GetFileName( strFileName );
				ProjFile.FullFileName = strFileName ;
				ProjFile.Style = FileStyle.None ;
				myFiles.Add( ProjFile );
				
				this.Style = ProjectStyle.VB60 ;
				using( System.IO.StreamReader reader = new System.IO.StreamReader( 
						   strFileName ,
						   System.Text.Encoding.GetEncoding( 936 )))
				{
					string strLine = reader.ReadLine();
					while( strLine != null)
					{
						int index = strLine.IndexOf("=");
						if( index == -1 )
						{
							strLine = reader.ReadLine();
							continue ;
						}
						string strName = strLine.Substring( 0 , index );
						string strValue = strLine.Substring( index + 1 );

						if( strName == "Name" )
						{
							strValue = strValue.Trim();
							if( strValue[0] == '\"' )
							{
								strValue = strValue.Substring( 1 );
							}
							if( strValue.EndsWith("\""))
								strValue = strValue.Substring( 0 , strValue.Length - 1 );
							this.strName = strValue ;
						}
						else if( strName == "Form" 
							|| strName == "Module" 
							|| strName == "Class" 
							|| strName == "UserControl" )
						{
							index = strValue.IndexOf(";");
							if( index > 0 )
								strValue = strValue.Substring( index + 1 );
							strValue = strValue.Trim();
							if( strValue.Length > 0 )
							{
								FileElement NewFile = new FileElement();
								NewFile.FileName = strValue ;
								NewFile.Style = FileStyle.SourceCode ;
								if( System.IO.Path.IsPathRooted( NewFile.FileName ))
									NewFile.FullFileName = NewFile.FileName ;
								else
									NewFile.FullFileName = System.IO.Path.Combine( strRootPath , NewFile.FileName );
								this.myFiles.Add( NewFile );
								string newExt = null;
								if( strName == "Form")
								{
									newExt = ".frx" ;
								}
								else if( strName == "UserControl" )
								{
									newExt = ".ctx" ;
								}
								if( newExt != null )
								{
									string name2 = System.IO.Path.ChangeExtension( NewFile.FullFileName , newExt );
									if( System.IO.File.Exists( name2 ))
									{
										FileElement file2 = new FileElement();
										file2.FileName = System.IO.Path.ChangeExtension( NewFile.FileName , newExt );
										file2.FullFileName = name2 ;
										file2.Style = FileStyle.None ;
										myFiles.Add( file2 );
									}
								}
							}
						}//if
						strLine = reader.ReadLine();
					}//while( strLine != null)
				}
			}
		}//public override void LoadProjectFile(string strFileName)

        public override bool RemoveSourceControlInfo()
        {
            return VSNETHelper.RemoveSourceControlInfo(this , this.ProjectFileName , true );
        }
	}//public class VBProjectDocument : ProjectDocument
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer duchang soft
China China
yuan yong fu of duchang soft , come from CHINA , 2008 Microsoft MVP,Use GDI+,XML/XSLT, site:http://www.cnblogs.com/xdesigner/

Comments and Discussions