我的博客小站

Visual Studio .NET项目转换器(ProjectConverter)修改

Visual Studio .NET 项目转换器非常类似于ASP.NET版本转换器,区别在于它用于转换 Visual Studio 项目文件的版本。尽管在 .NET 框架的 1.0 版和 1.1 版之间只有很小的差异,但一旦将项目文件从 Visual Studio .NET 2002 转换到 Visual Studio .NET 2003,将无法再把它转换回去。虽然这在大多数时候可能不会成为问题(因为在 .NET 框架 1.0 版和 1.1 版之间几乎没有什么破坏性的更改),但在某些时刻你可能需要将项目转换回去。该转换器可以将任何解决方案或项目文件从 Visual Studio 7.1 (Visual Studio .NET 2003) 转换到 Visual Studio 7.0 (Visual Studio .NET 2002),并在必要时进行反向转换。

 原始程序:

这个程序的不方便之处:

1、不支持文件拖放,每次点击后面按钮流量项目解决文件还要找半天。

2、启动不在屏幕最中央。

3、不置顶。

针对以上情况修改完善,打开.NET Reflector导出工程源码,修复编译错误,

添加拖放支持:

        private void fmMain_DragDrop(object sender, DragEventArgs e)
        {
            this.tbSolutionFile.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
            try{
                if ( this.VerifyVersion(this.GetVersion(this.tbSolutionFile.Text))==false ) {
                    this.tbSolutionFile.Text = "";
                }
            }catch (Exception exception1) {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                Interaction.MsgBox("Error reading the solution file\r" + exception.Message, MsgBoxStyle.Critical, "Error");
                ProjectData.ClearProjectError();
                this.tbSolutionFile.Text = "";
            }
        }

        private void fmMain_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
                e.Effect = DragDropEffects.Link;
            }else {
                e.Effect = DragDropEffects.None;
            }
        }

置顶和屏幕居中:

        private void fmMain_Load(object sender, EventArgs e)
        {
            AllowDrop = true;
            CenterToScreen();
            if (MyProject.Application.CommandLineArgs.Count == 1)
            {
                this.tbSolutionFile.Text = MyProject.Application.CommandLineArgs[0];
                try
                {
                    this.VerifyVersion(this.GetVersion(this.tbSolutionFile.Text));
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    Interaction.MsgBox("Error reading the solution file\r" + exception.Message, MsgBoxStyle.Critical, "Error");
                    ProjectData.ClearProjectError();
                }
            }
            TopMost = true;
        }
        [DebuggerNonUserCode]
        public fmMain()
        {
            TopMost = true;
            base.Load += new EventHandler(this.fmMain_Load);
            base.DragEnter += new System.Windows.Forms.DragEventHandler(this.fmMain_DragEnter);
            base.DragDrop += new System.Windows.Forms.DragEventHandler(this.fmMain_DragDrop);
            __ENCList.Add(new WeakReference(this));
            this.InitializeComponent();
        }

修改完成后将原始程序的图标添加为资源,.NET Reflector导出的工程没有图标的,编译成功通过截图:

现在支持:

1、启动后屏幕居中显示。

2、置顶显示。

3、支持文件拖放,直接拖拽.sln文件到窗口即可。

编译后的exe文件放在csdn资源下载站:

http://download.csdn.net/detail/asmcvc/7136663

修改后的C#源代码工程文件(可编译)也放在csdn资源下载站:

http://download.csdn.net/detail/asmcvc/7136693

posted on 2014-04-02 17:17  BIGSING  阅读(881)  评论(1编辑  收藏  举报

导航

我的博客小站