public static void UpdateFiles(PackageClass packageClass, FolderGroup folderGroup) { if (string.IsNullOrEmpty(folderGroup.Folder)) { return; } folderGroup.Folder = Path.GetFullPath(folderGroup.Folder); GroupItem _groupItem = packageClass.Groups[folderGroup.Group]; DirectoryInfo di = new DirectoryInfo(Path.GetFullPath(folderGroup.Folder)); FileInfo[] fileList; fileList = folderGroup.Recursive ? di.GetFiles("*.*", SearchOption.AllDirectories) : di.GetFiles("*.*", SearchOption.TopDirectoryOnly); string dir = Path.GetFullPath(folderGroup.Folder); string templ = folderGroup.DestinationFilename; if (!dir.EndsWith("\\")) { dir += "\\"; } if (!templ.EndsWith("\\")) { templ += "\\"; } foreach (FileInfo f in fileList) { if (!f.DirectoryName.Contains(".svn")) { FileItem fileItem = new FileItem(f.FullName, false); fileItem.UpdateOption = folderGroup.UpdateOption; fileItem.Param1 = folderGroup.Param1; fileItem.InstallType = folderGroup.InstallType; fileItem.Modified = false; fileItem.DestinationFilename = f.FullName.Replace(dir, templ); if (_groupItem.Files.Get(f.FullName, fileItem.DestinationFilename) != null) { continue; } _groupItem.Files.Add(fileItem); } } List <FileItem> misingFiles = new List <FileItem>(); foreach (FileItem item in _groupItem.Files.Items) { if (!File.Exists(item.LocalFileName) && !item.Modified) { misingFiles.Add(item); } } foreach (FileItem item in misingFiles) { _groupItem.Files.Items.Remove(item); } }
public static void UpdateFiles(PackageClass packageClass, FolderGroup folderGroup) { if (string.IsNullOrEmpty(folderGroup.Folder)) return; folderGroup.Folder = Path.GetFullPath(folderGroup.Folder); GroupItem _groupItem = packageClass.Groups[folderGroup.Group]; DirectoryInfo di = new DirectoryInfo(Path.GetFullPath(folderGroup.Folder)); FileInfo[] fileList = new FileInfo[0]; // only if the directory does not exists check files, otherwise exception would occur if (di.Exists) { fileList = folderGroup.Recursive ? di.GetFiles("*.*", SearchOption.AllDirectories) : di.GetFiles("*.*", SearchOption.TopDirectoryOnly); } string dir = Path.GetFullPath(folderGroup.Folder); string templ = folderGroup.DestinationFilename; if (!dir.EndsWith("\\")) { dir += "\\"; } if (!templ.EndsWith("\\")) { templ += "\\"; } foreach (FileInfo f in fileList) { if (!f.DirectoryName.Contains(".svn")) { FileItem fileItem = new FileItem(f.FullName, false); fileItem.UpdateOption = folderGroup.UpdateOption; fileItem.Param1 = folderGroup.Param1; fileItem.InstallType = folderGroup.InstallType; fileItem.Modified = false; fileItem.DestinationFilename = f.FullName.Replace(dir, templ); if (_groupItem.Files.Get(f.FullName, fileItem.DestinationFilename) != null) continue; _groupItem.Files.Add(fileItem); } } List<FileItem> misingFiles = new List<FileItem>(); foreach (FileItem item in _groupItem.Files.Items) { if (!File.Exists(item.LocalFileName) && !item.Modified) misingFiles.Add(item); } foreach (FileItem item in misingFiles) { _groupItem.Files.Items.Remove(item); } }
public void Add(FolderGroup folderGroup) { foreach (FolderGroup list in FolderGroups) { if (list.Group == folderGroup.Group && list.Folder == folderGroup.Folder) { list.DestinationFilename = folderGroup.DestinationFilename; list.InstallType = folderGroup.InstallType; list.UpdateOption = folderGroup.UpdateOption; return; } } FolderGroups.Add(folderGroup); }
private void btn_done_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_skinpath.Text)) { MessageBox.Show("No skin folder specified !"); return; } Package.GeneralInfo.Name = txt_name.Text; Package.GeneralInfo.Author = txt_author.Text; Package.GeneralInfo.Version = new VersionInfo() { Major = txt_version1.Text, Minor = txt_version2.Text, Build = txt_version3.Text, Revision = txt_version4.Text }; string fontName = Path.GetFileName(txt_skinpath.Text); #region Skin GroupItem skinGroup = new GroupItem("Skin files"); FolderGroup skinfoldergroup = new FolderGroup() { DestinationFilename = "%Skin%\\" + fontName, Folder = txt_skinpath.Text, InstallType = "CopyFile", UpdateOption = UpdateOptionEnum.OverwriteIfOlder, Param1 = "", Recursive = true, Group = skinGroup.Name }; Package.Groups.Add(skinGroup); Package.ProjectSettings.Add(skinfoldergroup); ProjectSettings.UpdateFiles(Package, skinfoldergroup); #endregion #region fonts if (!string.IsNullOrEmpty(txt_font1.Text + txt_font2.Text + txt_font3.Text)) { GroupItem fontGroup = new GroupItem("Font files"); if (!string.IsNullOrEmpty(txt_font1.Text) && File.Exists(txt_font1.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font1.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font1.Text) }; fontGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_font2.Text) && File.Exists(txt_font2.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font2.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font2.Text) }; fontGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_font3.Text) && File.Exists(txt_font3.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font3.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font3.Text) }; fontGroup.Files.Add(fileitem); } Package.Groups.Add(fontGroup); } #endregion #region dlls %Plugins% if (!string.IsNullOrEmpty(txt_plugin_procces.Text + txt_plugin_window.Text + txt_plugin_exe.Text)) { GroupItem dllGroup = new GroupItem("Plugin files"); if (!string.IsNullOrEmpty(txt_plugin_procces.Text) && File.Exists(txt_plugin_procces.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Plugins%\\process\\" + Path.GetFileName(txt_plugin_procces.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_procces.Text) }; dllGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_plugin_window.Text) && File.Exists(txt_plugin_window.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Plugins%\\Windows\\" + Path.GetFileName(txt_plugin_window.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_window.Text) }; dllGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_plugin_exe.Text) && File.Exists(txt_plugin_exe.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Base%\\" + Path.GetFileName(txt_plugin_exe.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_exe.Text) }; dllGroup.Files.Add(fileitem); } Package.Groups.Add(dllGroup); } #endregion #region install sections Package.Sections.Add("Welcome Screen").WizardButtonsEnum = WizardButtonsEnum.NextCancel; Package.Sections.Add("Install Section").WizardButtonsEnum = WizardButtonsEnum.Next; var item = new ActionItem("InstallFiles") { Params = new SectionParamCollection( MpeInstaller.ActionProviders["InstallFiles"].GetDefaultParams()) }; Package.Sections.Items[1].Actions.Add(item); Package.Sections.Add("Setup Complete").WizardButtonsEnum = WizardButtonsEnum.Finish; #endregion #region config if (radioButton1.Checked && File.Exists(txt_plugin_procces.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Plugins%\\process\\" + Path.GetFileName(txt_plugin_procces.Text); if (radioButton1.Checked && File.Exists(txt_plugin_window.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Plugins%\\Windows\\" + Path.GetFileName(txt_plugin_window.Text); if (radioButton1.Checked && File.Exists(txt_plugin_exe.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Base%\\" + Path.GetFileName(txt_plugin_exe.Text); if (File.Exists(txt_ico.Text)) { string icofile = Path.GetFullPath(txt_ico.Text); Package.GeneralInfo.Params[ParamNamesConst.ICON].Value = icofile; Package.Sections.Items[0].Params[ParamNamesConst.SECTION_ICON].Value = icofile; Package.Sections.Items[1].Params[ParamNamesConst.SECTION_ICON].Value = icofile; Package.Sections.Items[2].Params[ParamNamesConst.SECTION_ICON].Value = icofile; } Package.GeneralInfo.Location = txt_mpe_folder.Text + "\\" + Package.GeneralInfo.Name + ".mpe1"; #endregion Close(); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_folder.Text)) { MessageBox.Show("Source folder not specified !"); return; } if (string.IsNullOrEmpty(txt_template.Text)) { MessageBox.Show("Template not specified !"); return; } if (!Directory.Exists(txt_folder.Text)) { MessageBox.Show("Folder not found !"); return; } FolderGroup group = new FolderGroup { DestinationFilename = txt_template.Text, Folder = txt_folder.Text, InstallType = cmb_installtype.Text, UpdateOption = (UpdateOptionEnum)cmb_overwrite.SelectedIndex, Param1 = txt_param1.Text, Recursive = chk_recurs.Checked, Group = _groupItem.Name }; Package.ProjectSettings.Add(group); ProjectSettings.UpdateFiles(Package, group); DialogResult = DialogResult.OK; Close(); }