Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

dotNetInstaller - Setup Bootstrapper for .NET Application

, 4 Jan 2004 MIT
With this tool the developer can define the application prerequisites and install the correct version of these components in the correct order based on the user operating system type and language, allow the user to download these components from the web or install these components directly.
dotnetinstaller_source.zip
dotNetInstaller_source
dotNetInstaller
dotNetInstaller.vcproj.vspscc
dotNetInstaller.vssscc
mssccprj.scc
res
banner.bmp
dotNetInstaller.ico
dotNetInstaller.manifest
Thumbs.db
vssver.scc
Tools
vssver.scc
vssver.scc
InstallerEditor
App.ico
banner.bmp
bin
Release
InstallerEditor.exe
SourceLibrary.dll
vssver.scc
InstallerEditor.csproj.user
InstallerEditor.csproj.vspscc
InstallerEditor.suo
InstallerEditor.vssscc
mssccprj.scc
References
SourceLibrary.dll
vssver.scc
Thumbs.db
vssver.scc
Sample
banner.bmp
dotNetInstaller.exe
SupportFiles
DataAccess
Jet
Jet40Sp7
Win2000_English
Win2000_Italiano
Win9x_NT
WinME
WinXp_English
WinXp_Italiano
MDAC2.7Sp1Refresh
Win_98_ME_NT_2000
dotNet
v1.1
English
Italiano
InternetExplorer
IE60SP1_English
IE60SP1_Italiano
ServicePack
2000_SP4_English
2000_SP4_Italiano
NT4_SP6a_English
NT4_SP6a_Italiano
Win98_Y2k_Update_English
Win98_Y2k_Update_Italiano
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace InstallerEditor
{
	/// <summary>
	/// Summary description for MainForm.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem mnFile;
		private System.Windows.Forms.MenuItem mnNew;
		private System.Windows.Forms.MenuItem mnClose;
		private System.Windows.Forms.MenuItem mnSave;
		private System.Windows.Forms.MenuItem mnExit;
		private System.Windows.Forms.MenuItem mnOpen;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem mnCreateExe;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.TreeView treeView;
		private System.Windows.Forms.PropertyGrid propertyGrid;
		private System.Windows.Forms.ImageList imageList;
		private System.Windows.Forms.ContextMenu contextMenuTreeView;
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.MenuItem mnAdd;
		private System.Windows.Forms.MenuItem mnAddSetupConfiguration;
		private System.Windows.Forms.MenuItem mnAddWebConfiguration;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem mnDelete;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem mnAddDownloadFile;
		private System.Windows.Forms.MenuItem mnView;
		private System.Windows.Forms.MenuItem mnRefresh;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem mnAddMsiComponent;
		private System.Windows.Forms.MenuItem mnAddCommandComponent;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem mnAddInstalledCheckRegistry;
		private System.Windows.Forms.MenuItem mnAddInstalledCheckFile;
		private System.Windows.Forms.MenuItem mnAddDownloadDialog;
		private System.Windows.Forms.MenuItem mnSaveAs;
		private System.Windows.Forms.MenuItem mnEditWithNotepad;
		private System.Windows.Forms.MenuItem mnTools;
		private System.Windows.Forms.MenuItem mnLanguageForNewItem;
		private System.Windows.Forms.MenuItem mnLanguageEnglish;
		private System.Windows.Forms.MenuItem mnLanguageItalian;
		private System.Windows.Forms.MenuItem mnHelp;
		private System.Windows.Forms.MenuItem mnHomePage;
		private System.Windows.Forms.MenuItem mnAddOpenFileComponent;
		private System.Windows.Forms.MenuItem mnAddComponentWizard;
		private System.Windows.Forms.MenuItem mnHelpAbout;
		private System.ComponentModel.IContainer components;

		public MainForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.mnFile = new System.Windows.Forms.MenuItem();
			this.mnNew = new System.Windows.Forms.MenuItem();
			this.mnOpen = new System.Windows.Forms.MenuItem();
			this.mnClose = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.mnSave = new System.Windows.Forms.MenuItem();
			this.mnSaveAs = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.mnEditWithNotepad = new System.Windows.Forms.MenuItem();
			this.mnCreateExe = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.mnExit = new System.Windows.Forms.MenuItem();
			this.mnView = new System.Windows.Forms.MenuItem();
			this.mnRefresh = new System.Windows.Forms.MenuItem();
			this.mnTools = new System.Windows.Forms.MenuItem();
			this.mnLanguageForNewItem = new System.Windows.Forms.MenuItem();
			this.mnLanguageEnglish = new System.Windows.Forms.MenuItem();
			this.mnLanguageItalian = new System.Windows.Forms.MenuItem();
			this.mnHelp = new System.Windows.Forms.MenuItem();
			this.mnHomePage = new System.Windows.Forms.MenuItem();
			this.treeView = new System.Windows.Forms.TreeView();
			this.contextMenuTreeView = new System.Windows.Forms.ContextMenu();
			this.mnAdd = new System.Windows.Forms.MenuItem();
			this.mnAddSetupConfiguration = new System.Windows.Forms.MenuItem();
			this.mnAddWebConfiguration = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.mnAddDownloadDialog = new System.Windows.Forms.MenuItem();
			this.mnAddDownloadFile = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.mnAddComponentWizard = new System.Windows.Forms.MenuItem();
			this.mnAddMsiComponent = new System.Windows.Forms.MenuItem();
			this.mnAddCommandComponent = new System.Windows.Forms.MenuItem();
			this.mnAddOpenFileComponent = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.mnAddInstalledCheckRegistry = new System.Windows.Forms.MenuItem();
			this.mnAddInstalledCheckFile = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.mnDelete = new System.Windows.Forms.MenuItem();
			this.imageList = new System.Windows.Forms.ImageList(this.components);
			this.propertyGrid = new System.Windows.Forms.PropertyGrid();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.mnHelpAbout = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.mnFile,
																					  this.mnView,
																					  this.mnTools,
																					  this.mnHelp});
			// 
			// mnFile
			// 
			this.mnFile.Index = 0;
			this.mnFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.mnNew,
																				   this.mnOpen,
																				   this.mnClose,
																				   this.menuItem1,
																				   this.mnSave,
																				   this.mnSaveAs,
																				   this.menuItem2,
																				   this.mnEditWithNotepad,
																				   this.mnCreateExe,
																				   this.menuItem4,
																				   this.mnExit});
			this.mnFile.Text = "File";
			// 
			// mnNew
			// 
			this.mnNew.Index = 0;
			this.mnNew.Text = "New...";
			this.mnNew.Click += new System.EventHandler(this.mnNew_Click);
			// 
			// mnOpen
			// 
			this.mnOpen.Index = 1;
			this.mnOpen.Text = "Open...";
			this.mnOpen.Click += new System.EventHandler(this.mnOpen_Click);
			// 
			// mnClose
			// 
			this.mnClose.Enabled = false;
			this.mnClose.Index = 2;
			this.mnClose.Text = "Close";
			this.mnClose.Click += new System.EventHandler(this.mnClose_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 3;
			this.menuItem1.Text = "-";
			// 
			// mnSave
			// 
			this.mnSave.Enabled = false;
			this.mnSave.Index = 4;
			this.mnSave.Text = "Save";
			this.mnSave.Click += new System.EventHandler(this.mnSave_Click);
			// 
			// mnSaveAs
			// 
			this.mnSaveAs.Enabled = false;
			this.mnSaveAs.Index = 5;
			this.mnSaveAs.Text = "Save As...";
			this.mnSaveAs.Click += new System.EventHandler(this.mnSaveAs_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 6;
			this.menuItem2.Text = "-";
			// 
			// mnEditWithNotepad
			// 
			this.mnEditWithNotepad.Enabled = false;
			this.mnEditWithNotepad.Index = 7;
			this.mnEditWithNotepad.Text = "Edit With Notepad";
			this.mnEditWithNotepad.Click += new System.EventHandler(this.mnEditWithNotepad_Click);
			// 
			// mnCreateExe
			// 
			this.mnCreateExe.Index = 8;
			this.mnCreateExe.Text = "Create Exe...";
			this.mnCreateExe.Click += new System.EventHandler(this.mnCreateExe_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 9;
			this.menuItem4.Text = "-";
			// 
			// mnExit
			// 
			this.mnExit.Index = 10;
			this.mnExit.Text = "Exit";
			this.mnExit.Click += new System.EventHandler(this.mnExit_Click);
			// 
			// mnView
			// 
			this.mnView.Index = 1;
			this.mnView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.mnRefresh});
			this.mnView.Text = "View";
			// 
			// mnRefresh
			// 
			this.mnRefresh.Index = 0;
			this.mnRefresh.Text = "Refresh";
			this.mnRefresh.Click += new System.EventHandler(this.mnRefresh_Click);
			// 
			// mnTools
			// 
			this.mnTools.Index = 2;
			this.mnTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnLanguageForNewItem});
			this.mnTools.Text = "Tools";
			// 
			// mnLanguageForNewItem
			// 
			this.mnLanguageForNewItem.Index = 0;
			this.mnLanguageForNewItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																								 this.mnLanguageEnglish,
																								 this.mnLanguageItalian});
			this.mnLanguageForNewItem.Text = "Language For New Item";
			// 
			// mnLanguageEnglish
			// 
			this.mnLanguageEnglish.Checked = true;
			this.mnLanguageEnglish.Index = 0;
			this.mnLanguageEnglish.RadioCheck = true;
			this.mnLanguageEnglish.Text = "English";
			this.mnLanguageEnglish.Click += new System.EventHandler(this.mnLanguageEnglish_Click);
			// 
			// mnLanguageItalian
			// 
			this.mnLanguageItalian.Index = 1;
			this.mnLanguageItalian.RadioCheck = true;
			this.mnLanguageItalian.Text = "Italian";
			this.mnLanguageItalian.Click += new System.EventHandler(this.mnLanguageItalian_Click);
			// 
			// mnHelp
			// 
			this.mnHelp.Index = 3;
			this.mnHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.mnHomePage,
																				   this.mnHelpAbout});
			this.mnHelp.Text = "Help";
			// 
			// mnHomePage
			// 
			this.mnHomePage.Index = 0;
			this.mnHomePage.Text = "Home Page";
			this.mnHomePage.Click += new System.EventHandler(this.mnHomePage_Click);
			// 
			// treeView
			// 
			this.treeView.ContextMenu = this.contextMenuTreeView;
			this.treeView.Dock = System.Windows.Forms.DockStyle.Left;
			this.treeView.HideSelection = false;
			this.treeView.ImageList = this.imageList;
			this.treeView.Location = new System.Drawing.Point(0, 0);
			this.treeView.Name = "treeView";
			this.treeView.Size = new System.Drawing.Size(176, 346);
			this.treeView.TabIndex = 0;
			this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
			this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
			// 
			// contextMenuTreeView
			// 
			this.contextMenuTreeView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																								this.mnAdd,
																								this.menuItem7,
																								this.mnDelete});
			// 
			// mnAdd
			// 
			this.mnAdd.Index = 0;
			this.mnAdd.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				  this.mnAddSetupConfiguration,
																				  this.mnAddWebConfiguration,
																				  this.menuItem3,
																				  this.mnAddDownloadDialog,
																				  this.mnAddDownloadFile,
																				  this.menuItem5,
																				  this.mnAddComponentWizard,
																				  this.mnAddMsiComponent,
																				  this.mnAddCommandComponent,
																				  this.mnAddOpenFileComponent,
																				  this.menuItem6,
																				  this.mnAddInstalledCheckRegistry,
																				  this.mnAddInstalledCheckFile});
			this.mnAdd.Text = "Add";
			// 
			// mnAddSetupConfiguration
			// 
			this.mnAddSetupConfiguration.Index = 0;
			this.mnAddSetupConfiguration.Text = "Setup Configuration";
			this.mnAddSetupConfiguration.Click += new System.EventHandler(this.mnAddSetupConfiguration_Click);
			// 
			// mnAddWebConfiguration
			// 
			this.mnAddWebConfiguration.Index = 1;
			this.mnAddWebConfiguration.Text = "Web Configuration";
			this.mnAddWebConfiguration.Click += new System.EventHandler(this.mnAddWebConfiguration_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 2;
			this.menuItem3.Text = "-";
			// 
			// mnAddDownloadDialog
			// 
			this.mnAddDownloadDialog.Index = 3;
			this.mnAddDownloadDialog.Text = "Download Dialog";
			this.mnAddDownloadDialog.Click += new System.EventHandler(this.mnAddDownloadDialog_Click);
			// 
			// mnAddDownloadFile
			// 
			this.mnAddDownloadFile.Index = 4;
			this.mnAddDownloadFile.Text = "Download File";
			this.mnAddDownloadFile.Click += new System.EventHandler(this.mnAddDownloadFile_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 5;
			this.menuItem5.Text = "-";
			// 
			// mnAddComponentWizard
			// 
			this.mnAddComponentWizard.Index = 6;
			this.mnAddComponentWizard.Text = "Component Wizard...";
			this.mnAddComponentWizard.Click += new System.EventHandler(this.mnAddComponentWizard_Click);
			// 
			// mnAddMsiComponent
			// 
			this.mnAddMsiComponent.Index = 7;
			this.mnAddMsiComponent.Text = "Msi Component";
			this.mnAddMsiComponent.Click += new System.EventHandler(this.mnAddMsiComponent_Click);
			// 
			// mnAddCommandComponent
			// 
			this.mnAddCommandComponent.Index = 8;
			this.mnAddCommandComponent.Text = "Command Component";
			this.mnAddCommandComponent.Click += new System.EventHandler(this.mnAddCommandComponent_Click);
			// 
			// mnAddOpenFileComponent
			// 
			this.mnAddOpenFileComponent.Index = 9;
			this.mnAddOpenFileComponent.Text = "OpenFile Component";
			this.mnAddOpenFileComponent.Click += new System.EventHandler(this.mnAddOpenFileComponent_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 10;
			this.menuItem6.Text = "-";
			// 
			// mnAddInstalledCheckRegistry
			// 
			this.mnAddInstalledCheckRegistry.Index = 11;
			this.mnAddInstalledCheckRegistry.Text = "Installed Check Registry";
			this.mnAddInstalledCheckRegistry.Click += new System.EventHandler(this.mnAddInstalledCheckRegistry_Click);
			// 
			// mnAddInstalledCheckFile
			// 
			this.mnAddInstalledCheckFile.Index = 12;
			this.mnAddInstalledCheckFile.Text = "Installed Check File";
			this.mnAddInstalledCheckFile.Click += new System.EventHandler(this.mnInstalledCheckFile_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 1;
			this.menuItem7.Text = "-";
			// 
			// mnDelete
			// 
			this.mnDelete.Index = 2;
			this.mnDelete.Text = "Delete";
			this.mnDelete.Click += new System.EventHandler(this.mnDelete_Click);
			// 
			// imageList
			// 
			this.imageList.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// propertyGrid
			// 
			this.propertyGrid.CommandsVisibleIfAvailable = true;
			this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
			this.propertyGrid.LargeButtons = false;
			this.propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
			this.propertyGrid.Location = new System.Drawing.Point(176, 0);
			this.propertyGrid.Name = "propertyGrid";
			this.propertyGrid.Size = new System.Drawing.Size(444, 346);
			this.propertyGrid.TabIndex = 2;
			this.propertyGrid.Text = "propertyGrid1";
			this.propertyGrid.ViewBackColor = System.Drawing.SystemColors.Window;
			this.propertyGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
			// 
			// splitter1
			// 
			this.splitter1.Location = new System.Drawing.Point(176, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(3, 346);
			this.splitter1.TabIndex = 3;
			this.splitter1.TabStop = false;
			// 
			// mnHelpAbout
			// 
			this.mnHelpAbout.Index = 1;
			this.mnHelpAbout.Text = "About";
			this.mnHelpAbout.Click += new System.EventHandler(this.mnHelpAbout_Click);
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(620, 346);
			this.Controls.Add(this.splitter1);
			this.Controls.Add(this.propertyGrid);
			this.Controls.Add(this.treeView);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mainMenu1;
			this.Name = "MainForm";
			this.Text = "Installer Editor";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
			this.Load += new System.EventHandler(this.MainForm_Load);
			this.Closed += new System.EventHandler(this.MainForm_Closed);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}

		private void mnExit_Click(object sender, System.EventArgs e)
		{
			Close();
		}

		private TreeNodeConfigFile m_TreeNodeConfigFile = null;


		private bool NewConfiguration()
		{
			try
			{
				CloseConfiguration();

				SaveFileDialog l_dg = new SaveFileDialog();
				l_dg.Filter = "Xml Files(*.xml)|*.xml|All Files(*.*)|*.*";
				l_dg.DefaultExt = "xml";
				if (l_dg.ShowDialog(this) == DialogResult.OK)
				{
					m_TreeNodeConfigFile = new TreeNodeConfigFile(new ConfigFile());
					m_TreeNodeConfigFile.ConfigFile.Create(l_dg.FileName);
					RefreshMenu();
				}
				else
					return false;

				LoadTreeView(m_TreeNodeConfigFile);

				return true;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
				return false;
			}
		}

		private bool OpenConfiguration()
		{
			try
			{
				CloseConfiguration();

				OpenFileDialog l_dg = new OpenFileDialog();
				l_dg.Filter = "Xml Files(*.xml)|*.xml|All Files(*.*)|*.*";
				l_dg.DefaultExt = "xml";
				if (l_dg.ShowDialog(this) == DialogResult.OK)
				{
					ConfigFile l_File = new ConfigFile();
					l_File.Load(l_dg.FileName);

					m_TreeNodeConfigFile = new TreeNodeConfigFile(l_File);
				}
				else
					return false;

				RefreshMenu();
				LoadTreeView(m_TreeNodeConfigFile);

				return true;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
				return false;
			}
		}
		private bool CloseConfiguration()
		{
			try
			{
				if (m_TreeNodeConfigFile!=null)
				{
					DialogResult l_ret = MessageBox.Show(this, "Do you want to save your changes?","Setup Installer", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
					if (l_ret == DialogResult.Yes)
					{
						if (SaveConfiguration()==false)
							return false;
					}
					else if (l_ret == DialogResult.Cancel)
					{
						return false;
					}
				}

				m_TreeNodeConfigFile = null;

				CloseTreeView();

				RefreshMenu();

				return true;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);

				return false;
			}
		}
		private bool SaveConfiguration()
		{
			try
			{
				if (m_TreeNodeConfigFile != null)
				{
					if (m_TreeNodeConfigFile.ConfigFile.FileName==null)
					{
						SaveFileDialog l_dg = new SaveFileDialog();
						l_dg.Filter = "Xml Files(*.xml)|*.xml|All Files(*.*)|*.*";
						l_dg.DefaultExt = "xml";
						if (l_dg.ShowDialog(this) == DialogResult.OK)
						{
							m_TreeNodeConfigFile.ConfigFile.SaveAs(l_dg.FileName);
						}
						else
							return false;
					}
					else
						m_TreeNodeConfigFile.ConfigFile.Save();
				}

				return true;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
				return false;
			}
		}

		private void RefreshMenu()
		{
			if (m_TreeNodeConfigFile!=null)
			{
				mnClose.Enabled = true;
				//mnCreateExe.Enabled = true;
				mnNew.Enabled = false;
				mnOpen.Enabled = false;
				mnSave.Enabled = true;
				mnSaveAs.Enabled = true;
				mnEditWithNotepad.Enabled = true;
			}
			else
			{
				mnClose.Enabled = false;
				//mnCreateExe.Enabled = false;
				mnNew.Enabled = true;
				mnOpen.Enabled = true;
				mnSave.Enabled = false;
				mnSaveAs.Enabled = false;
				mnEditWithNotepad.Enabled = false;
			}

			if (m_TreeNodeConfigFile != null && 
				m_TreeNodeConfigFile.ConfigFile != null && 
				m_TreeNodeConfigFile.ConfigFile.FileName != null)
				Text = "Installer Editor - " + m_TreeNodeConfigFile.ConfigFile.FileName;
			else
				Text = "Installer Editor";
		}

		private void mnSave_Click(object sender, System.EventArgs e)
		{
			SaveConfiguration();
		}

		private void mnClose_Click(object sender, System.EventArgs e)
		{
			CloseConfiguration();
		}

		public ConfigFile ConfigFile
		{
			get{return m_TreeNodeConfigFile.ConfigFile;}
			set{m_TreeNodeConfigFile.ConfigFile = value;}
		}
		
		private void CloseTreeView()
		{
			treeView.Nodes.Clear();
		}

		private void LoadTreeView(TreeNodeConfigFile p_Configuration)
		{
			CloseTreeView();

			//configuration
			treeView.Nodes.Add(p_Configuration);
			

		}

		private void mnNew_Click(object sender, System.EventArgs e)
		{
			NewConfiguration();
		}

		private void mnOpen_Click(object sender, System.EventArgs e)
		{
			OpenConfiguration();
		}

		private void treeView_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			try
			{
				propertyGrid.SelectedObject = e.Node.Tag;

				RefreshNodeContextMenu();
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void RefreshNodeContextMenu()
		{
			if (treeView.SelectedNode != null)
			{
				mnAddDownloadFile.Enabled = false;
				mnAddSetupConfiguration.Enabled = false;
				mnAddWebConfiguration.Enabled = false;
				mnDelete.Enabled = false;
				mnAddCommandComponent.Enabled = false;
				mnAddMsiComponent.Enabled = false;
				mnAddInstalledCheckRegistry.Enabled = false;
				mnAddInstalledCheckFile.Enabled = false;
				mnAddDownloadDialog.Enabled = false;
				mnAddOpenFileComponent.Enabled = false;
				mnAddComponentWizard.Enabled = false;

				if (treeView.SelectedNode.Tag is ConfigFile)
				{
					mnAddSetupConfiguration.Enabled = true;
					mnAddWebConfiguration.Enabled = true;
				}
				else if (treeView.SelectedNode.Tag is WebConfiguration)
				{
					mnDelete.Enabled = true;
				}
				else if (treeView.SelectedNode.Tag is SetupConfiguration)
				{
					mnDelete.Enabled = true;
					mnAddCommandComponent.Enabled = true;
					mnAddMsiComponent.Enabled = true;
					mnAddOpenFileComponent.Enabled = true;
					mnAddComponentWizard.Enabled = true;
				}
				else if (treeView.SelectedNode.Tag is DownloadDialog)
				{
					mnAddDownloadFile.Enabled = true;
					mnDelete.Enabled = true; //questo delete � valido solo nel caso in cui la classe downloaddialog non si trovi sotto un component
				}
				else if (treeView.SelectedNode.Tag is Download)
				{
					mnDelete.Enabled = true;
				}
				else if (treeView.SelectedNode.Tag is Component)
				{
					mnAddInstalledCheckRegistry.Enabled = true;
					mnAddInstalledCheckFile.Enabled = true;
					mnDelete.Enabled = true;
					mnAddDownloadDialog.Enabled = true;
				}
				else if (treeView.SelectedNode.Tag is installedcheck)
				{
					mnDelete.Enabled = true;
				}
			}
		}

		private Configuration AddWebConfiguration()
		{
			WebConfiguration l_Config = new WebConfiguration();
			m_TreeNodeConfigFile.ConfigFile.Configurations.Add(l_Config);
			return l_Config;
		}
		private Configuration AddSetupConfiguration()
		{
			SetupConfiguration l_Config = new SetupConfiguration();
			m_TreeNodeConfigFile.ConfigFile.Configurations.Add(l_Config);
			return l_Config;
		}
		private Download AddDownload(DownloadDialog p_Dialog)
		{
			Download d = new Download();
			p_Dialog.Downloads.Add(d);
			return d;
		}
		private Component AddMsiComponent(SetupConfiguration p_Config)
		{
			ComponentMsi l_Component = new ComponentMsi();
			p_Config.Components.Add(l_Component);
			return l_Component;
		}
		private Component AddCmdComponent(SetupConfiguration p_Config)
		{
			ComponentCmd l_Component = new ComponentCmd();
			p_Config.Components.Add(l_Component);
			return l_Component;
		}
		private Component AddOpenFileComponent(SetupConfiguration p_Config)
		{
			ComponentOpenFile l_Component = new ComponentOpenFile();
			p_Config.Components.Add(l_Component);
			return l_Component;
		}
		private installedcheck AddInstalledCheckRegistry(Component p_Component)
		{
			installedcheck_registry l_Check = new installedcheck_registry();
			p_Component.installchecks.Add(l_Check);
			return l_Check;
		}
		private installedcheck AddInstalledCheckFile(Component p_Component)
		{
			installedcheck_file l_Check = new installedcheck_file();
			p_Component.installchecks.Add(l_Check);
			return l_Check;
		}
		private DownloadDialog AddDownloadDIalogToComponetnt(Component p_Component)
		{
			if (p_Component.DownloadDialog != null)
				throw new ApplicationException("There is already one download dialog for this component");
			DownloadDialog l_DownloadDialog = new DownloadDialog();
			p_Component.DownloadDialog = l_DownloadDialog;
			return l_DownloadDialog;
		}

		private void mnAddSetupConfiguration_Click(object sender, System.EventArgs e)
		{
			try
			{
				m_TreeNodeConfigFile.Nodes.Add(new TreeNodeConfiguration(AddSetupConfiguration()));
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnAddWebConfiguration_Click(object sender, System.EventArgs e)
		{
			try
			{
				m_TreeNodeConfigFile.Nodes.Add(new TreeNodeConfiguration(AddWebConfiguration()));
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if (CloseConfiguration()==false)
				e.Cancel = true;
		}

		private void mnAddDownloadFile_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is DownloadDialog)
				{
					DownloadDialog d = (DownloadDialog)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeDownload( AddDownload(d) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void DeleteConfiguration(Configuration p_Config, TreeNode p_CurrentNode)
		{
			if (p_CurrentNode.Parent.Tag is ConfigFile)
			{
				ConfigFile l_config = (ConfigFile)p_CurrentNode.Parent.Tag;
				l_config.Configurations.Remove(p_Config);
				p_CurrentNode.Remove();
			}
			else
				throw new ApplicationException("Invalid node");
		}

		private void DeleteDownload(Download p_Download, TreeNode p_CurrentNode)
		{
			if (p_CurrentNode.Parent.Tag is DownloadDialog)
			{
				DownloadDialog l_DownloadDialog = (DownloadDialog)p_CurrentNode.Parent.Tag;
				l_DownloadDialog.Downloads.Remove(p_Download);
				p_CurrentNode.Remove();
			}
			else
				throw new ApplicationException("Invalid node");
		}
		private void DeleteComponent(Component p_Component, TreeNode p_CurrentNode)
		{
			if (p_CurrentNode.Parent.Tag is SetupConfiguration)
			{
				SetupConfiguration l_SetupConfiguration = (SetupConfiguration)p_CurrentNode.Parent.Tag;
				l_SetupConfiguration.Components.Remove(p_Component);
				p_CurrentNode.Remove();
			}
			else
				throw new ApplicationException("Invalid node");
		}
		private void DeleteInstalledCheck(installedcheck p_Check, TreeNode p_CurrentNode)
		{
			if (p_CurrentNode.Parent.Tag is Component)
			{
				Component l_Component = (Component)p_CurrentNode.Parent.Tag;
				l_Component.installchecks.Remove(p_Check);
				p_CurrentNode.Remove();
			}
			else
				throw new ApplicationException("Invalid node");
		}
		private void DeleteDownloadDialogFromComp(DownloadDialog p_DownloadDlg, TreeNode p_CurrentNode)
		{
			if (p_CurrentNode.Parent.Tag is Component)
			{
				Component l_Component = (Component)p_CurrentNode.Parent.Tag;
				if (l_Component.DownloadDialog != p_DownloadDlg)
					throw new ApplicationException("Invalid download dialog");
				l_Component.DownloadDialog = null;
				p_CurrentNode.Remove();
			}
			else if (p_CurrentNode.Parent.Tag is WebConfiguration)
			{
				throw new ApplicationException("This element cannot be deleted");
			}
			else
				throw new ApplicationException("Invalid node");
		}

		private void mnDelete_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null)
				{
					if (treeView.SelectedNode.Tag is Configuration)
					{
						DeleteConfiguration((Configuration)(treeView.SelectedNode.Tag), treeView.SelectedNode);
					}
					else if (treeView.SelectedNode.Tag is Download)
					{
						DeleteDownload((Download)(treeView.SelectedNode.Tag), treeView.SelectedNode);
					}
					else if (treeView.SelectedNode.Tag is Component)
					{
						DeleteComponent((Component)(treeView.SelectedNode.Tag), treeView.SelectedNode);
					}		
					else if (treeView.SelectedNode.Tag is installedcheck)
					{
						DeleteInstalledCheck((installedcheck)(treeView.SelectedNode.Tag), treeView.SelectedNode);
					}
					else if  (treeView.SelectedNode.Tag is DownloadDialog)
					{
						DeleteDownloadDialogFromComp((DownloadDialog)(treeView.SelectedNode.Tag), treeView.SelectedNode);
					}
				}			
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnRefresh_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (m_TreeNodeConfigFile!=null && m_TreeNodeConfigFile.ConfigFile != null )
				{
					m_TreeNodeConfigFile = new TreeNodeConfigFile(m_TreeNodeConfigFile.ConfigFile);
					LoadTreeView(m_TreeNodeConfigFile);
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnAddMsiComponent_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is SetupConfiguration)
				{
					SetupConfiguration l_Setup = (SetupConfiguration)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeComponent( AddMsiComponent(l_Setup) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnAddCommandComponent_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is SetupConfiguration)
				{
					SetupConfiguration l_Setup = (SetupConfiguration)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeComponent( AddCmdComponent(l_Setup) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnAddInstalledCheckRegistry_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is Component)
				{
					Component l_Component = (Component)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeinstalledcheck( AddInstalledCheckRegistry(l_Component) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnInstalledCheckFile_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is Component)
				{
					Component l_Component = (Component)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeinstalledcheck( AddInstalledCheckFile(l_Component) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnAddDownloadDialog_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is Component)
				{
					Component l_Component = (Component)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeDownloadDialog( AddDownloadDIalogToComponetnt(l_Component) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			try
			{
				TreeNode l_Node = treeView.GetNodeAt(e.X, e.Y);
				if (l_Node != null)
					treeView.SelectedNode = l_Node;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnSaveAs_Click(object sender, System.EventArgs e)
		{
			if (m_TreeNodeConfigFile != null && m_TreeNodeConfigFile.ConfigFile != null)
			{
				m_TreeNodeConfigFile.ConfigFile.FileName = null;
				SaveConfiguration();
			}
		}

		private void mnEditWithNotepad_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (m_TreeNodeConfigFile.ConfigFile.FileName!=null)
				{
					System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo("NOTEPAD.EXE", "\"" + m_TreeNodeConfigFile.ConfigFile.FileName + "\"");
					p.UseShellExecute = false;
					System.Diagnostics.Process process = new System.Diagnostics.Process();
					process.StartInfo = p;
					process.Start();
					//SourceLibrary.Utility.Shell.ExecCommand("NOTEPAD.EXE \"" + m_TreeNodeConfigFile.ConfigFile.FileName + "\"");
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnHomePage_Click(object sender, System.EventArgs e)
		{
			try
			{
				SourceLibrary.Utility.Shell.ExecCommand("http://www.devage.com");
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnLanguageEnglish_Click(object sender, System.EventArgs e)
		{
			mnLanguageEnglish.Checked = true;
			mnLanguageItalian.Checked = false;
			LanguageUI.Language = SupportedLanguage.English;
		}

		private void mnLanguageItalian_Click(object sender, System.EventArgs e)
		{
			mnLanguageItalian.Checked = true;
			mnLanguageEnglish.Checked = false;
			LanguageUI.Language = SupportedLanguage.Italian;
		}

		private AppSetting m_AppSetting;
		private void MainForm_Load(object sender, System.EventArgs e)
		{
			m_AppSetting = new AppSetting();
			m_AppSetting.Load();
		}

		private void MainForm_Closed(object sender, System.EventArgs e)
		{
			m_AppSetting.Save();
		}

		private void mnCreateExe_Click(object sender, System.EventArgs e)
		{
			try
			{
				MakeExe l_frmMakeExe = new MakeExe();
				l_frmMakeExe.TemplateFile = m_AppSetting.TemplateInstallerFile;
				l_frmMakeExe.BannerBitmapFile = m_AppSetting.BannerBitmapFile;
				l_frmMakeExe.OutputFileName = m_AppSetting.OutputMakeFile;
				if (m_TreeNodeConfigFile!=null && m_TreeNodeConfigFile.ConfigFile!=null)
					l_frmMakeExe.Configuration = m_TreeNodeConfigFile.ConfigFile.FileName;

				l_frmMakeExe.ShowDialog(this);

				m_AppSetting.TemplateInstallerFile = l_frmMakeExe.TemplateFile;
				m_AppSetting.BannerBitmapFile = l_frmMakeExe.BannerBitmapFile;
				m_AppSetting.OutputMakeFile = l_frmMakeExe.OutputFileName;
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}
		}

		private void mnAddOpenFileComponent_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is SetupConfiguration)
				{
					SetupConfiguration l_Setup = (SetupConfiguration)treeView.SelectedNode.Tag;
					treeView.SelectedNode.Nodes.Add(new TreeNodeComponent( AddOpenFileComponent(l_Setup) ));
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnAddComponentWizard_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (treeView.SelectedNode != null && treeView.SelectedNode.Tag is SetupConfiguration)
				{
					SetupConfiguration l_Setup = (SetupConfiguration)treeView.SelectedNode.Tag;
					
					ComponentWizard l_frmWizard = new ComponentWizard();

					if (l_frmWizard.ShowDialog(this) == DialogResult.OK)
					{
						foreach (Component c in l_frmWizard.SelectedComponents)
						{
							treeView.SelectedNode.Nodes.Add(new TreeNodeComponent(c));
							l_Setup.Components.Add(c);
						}
					}
				}
			}
			catch(Exception err)
			{
				AppUtility.ShowError(this, err);
			}		
		}

		private void mnHelpAbout_Click(object sender, System.EventArgs e)
		{
			About a = new About();
			a.ShowDialog(this);
		}
	}
}

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 MIT License

Share

About the Author

Davide Icardi
Software Developer
Italy Italy
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.1 | Last Updated 5 Jan 2004
Article Copyright 2003 by Davide Icardi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid