private void CmdSave_Click(object sender, EventArgs e) { if (BrowseOutput.ShowDialog() != DialogResult.OK) { return; } using (new AutoWaitCursor()) { var factories = Utils.GetFactories().ToList(); var depends = new HashSet <string>(); // work out dependencies from each type in spec var specFileName = (string)Macros.SelectedItem; using (var fs = new FileStream(specFileName, FileMode.Open)) { var reader = XmlReader.Create(fs); reader.ReadToDescendant("ParameterManager"); if (reader.ReadToNextSibling("Steps")) { while (reader.ReadToFollowing("Step")) { var stepType = reader.GetAttribute("Type"); var stepFactory = factories.First(x => x.CreatedType.ToString() == stepType); var stepFactDep = Utils.GetReferencesAssembliesPaths(stepFactory.GetType()); foreach (var thisDep in stepFactDep) { depends.SafeAdd(thisDep); } } } } // copy spec file CopyFile(specFileName); // add support files and their dependencies var depFile = Utils.GetPathForLocal("Depends.txt"); var deps = from thisLine in File.ReadAllLines(depFile) where !string.IsNullOrWhiteSpace(thisLine) select thisLine; foreach (var thisDep in deps) { Utils.GetDependenciesForLocal(thisDep, depends); } CopyDependencies(depends); } var msg = string.Format("Files saved to {0}", BrowseOutput.SelectedPath); MessageBox.Show(msg, ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void CmdCreate_Click(object sender, EventArgs e) { if (BrowseOutput.ShowDialog() != DialogResult.OK) { return; } using (new AutoWaitCursor()) { // generate Ribbon.xml GenerateCustomUIFile(); var factories = Utils.GetFactories().ToList(); var depends = new HashSet <string>(); // make a copy of the command configs as we want to adjust various file paths var copyCfgs = new List <CommandConfig>(mConfigs.Count); for (var i = 0; i < mConfigs.Count; i++) { var thisCfg = mConfigs[i]; var cfg = new CommandConfig { Hint = thisCfg.Hint, Image = Path.GetFileName(thisCfg.Image), Name = GetCommandId(i), SpecFileName = Path.GetFileNameWithoutExtension(thisCfg.SpecFileName), Text = thisCfg.Text }; // work out dependencies from each type in spec using (var fs = new FileStream(thisCfg.SpecFileName, FileMode.Open)) { var reader = XmlReader.Create(fs); reader.ReadToDescendant("ParameterManager"); if (reader.ReadToNextSibling("Steps")) { while (reader.ReadToFollowing("Step")) { var stepType = reader.GetAttribute("Type"); var stepFactory = factories.First(x => x.CreatedType.ToString() == stepType); var stepFactDep = GetReferencesAssembliesPaths(stepFactory.GetType()); foreach (var thisDep in stepFactDep) { depends.SafeAdd(thisDep); } } } } // copy spec file CopyFile(thisCfg.SpecFileName); // copy command icon CopyFile(thisCfg.Image); copyCfgs.Add(cfg); } // add support files and their dependencies var depFile = Utils.GetPathForLocal("Depends.txt"); var deps = from thisLine in File.ReadAllLines(depFile) where !string.IsNullOrWhiteSpace(thisLine) select thisLine; foreach (var thisDep in deps) { Utils.GetDependenciesForLocal(thisDep, depends); } CopyDependencies(depends); // copy panel icon CopyFile(BrowseIcon.FileName); // copy Manifest.xml var manifestFilePath = Utils.GetPathForLocal("Manifest.xml"); CopyFile(manifestFilePath); var rtCfg = new RuntimeConfig { PanelIcon = Path.GetFileName(BrowseIcon.FileName), PanelText = PanelText.Text, RibbonText = RibbonText.Text, TabText = TabText.Text, CommandConfigs = copyCfgs }; var filePath = Path.Combine(BrowseOutput.SelectedPath, RuntimeAddin.RuntimeConfigFileName); rtCfg.SaveToFile(filePath); } }