/// <summary> /// Exports components to specified path and updates configuration file /// </summary> /// <param name="args">info about specified path, selected components etc. </param> /// <param name="config">a reference to a configuration file</param> /// <returns></returns> public virtual bool ExportComponents(Events.ExportEventArgs args, Configurations.ConfigurationBase config) { try { List <_VBComponent> comps = args.SelectedComponents.Select(x => x.VbComponent).ToList(); foreach (var component in comps) { string fullPath = Path.Combine(args.Path, component.Name + VbeExtensions.GetExtension(component.Type)); if (component.Type == vbext_ComponentType.vbext_ct_Document) { string text = ""; if (component.CodeModule.CountOfLines > 0) { text = component.CodeModule.get_Lines(1, component.CodeModule.CountOfLines); } File.WriteAllText(fullPath, text); } else { component.Export(fullPath); } } config.SaveProject(_projectName, args.Path); return(true); } catch (COMException comEx) { throw new COMException(string.Format(strings.ExportComExceptionText, comEx.ErrorCode), comEx.ErrorCode); } }
private void _view_ExportRequestedRaised(object sender, Events.ExportEventArgs e) { if (e == null) { return; } _model.ExportComponents(e, _config); }
/// <summary>Raise when user has request a path change </summary> void _view_PathSelecting(object sender, Events.ExportEventArgs e) { _model.PathRequestHandler(); }
/// <summary> /// Raised when user is about to use a selected path. /// Will perform a validation if the path is still valid /// </summary> void _view_PathValidating(object sender, Events.ExportEventArgs e) { e.Cancel = _config.Exists(e.Path); }