#副標=Visual Studio 2005新功能系列(10)
#大標=運用入門套件快速發展應用程式
#眉標=Visual Studio 2005
#作者=文/沈炳宏
==========程式=========
程式1
Private Sub bindingNavigatorSaveItem_Click
(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles bindingNavigatorSaveItem.Click
If Me.Validate Then
Me.TitlesBindingSource.EndEdit()
Me.TitlesTableAdapter.Update
(Me.LibraryDataSet.Titles)
Else
MessageBox.Show(Me, "驗證錯誤.", "儲存",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning)
End If
End Sub
Private Sub Form_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TitlesTableAdapter.Fill(Me.LibraryDataSet.Titles)
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
==========程式=========
==========程式=========
程式2
文件.htm
修改為:
文件.htm
==========程式=========
==========程式=========
程式3
Book Starter Kit.zip
Book Application
Book Starter Kit
VSTemplate
1.0
==========程式=========
==========程式=========
程式4
Multi-project
包含多專案的入門套件
CSharp
1000
true
Enabled
true
__TemplateIcon.ico
Project1\MyTemplate.vstemplate
Project2\MyTemplate.vstemplate
==========程式=========
==========程式=========
程式5
public string OutputPath = string.Empty;
private void button1_Click(object sender, EventArgs e) {
OutputPath = textBox1.Text;
this.Close();
}
==========程式=========
==========程式=========
程式6
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TemplateWizard;
namespace MyWizard {
class Class1:IWizard {
private string _outputPath = string.Empty;
#region IWizard Members
public void BeforeOpeningFile(
EnvDTE.ProjectItem projectItem) {
}
public void ProjectFinishedGenerating(
EnvDTE.Project project) {
EnvDTE.Property pt =
project.ConfigurationManager.ActiveConfiguration.
Properties.Item(
"OutputPath");
if (pt != null) { pt.Value = _outputPath; }
}
public void ProjectItemFinishedGenerating(
EnvDTE.ProjectItem projectItem){}
public void RunFinished() {}
public void RunStarted(object automationObject,
Dictionary replacementsDictionary,
WizardRunKind runKind,
object[] customParams) {
Form1 userPrompt = new Form1();
userPrompt.ShowDialog();
_outputPath = userPrompt.OutputPath;
}
public bool ShouldAddProjectItem(string filePath) {
return true;
}
#endregion
}
}
==========程式=========
==========程式=========
程式7
...
...
MyWizard, Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=2f1ca71262185337
MyWizard.Class1
==========程式=========