Skip to content

Commit

Permalink
Minor changes for Export view
Browse files Browse the repository at this point in the history
  • Loading branch information
PetLahev committed May 25, 2015
1 parent 732df22 commit 3808c5c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
Binary file modified Installers/Output/VBE Components Setup.exe
Binary file not shown.
Binary file modified Installers/Sources/VbeComponents.dll
Binary file not shown.
20 changes: 20 additions & 0 deletions VBEModules/Business/Export/View/ExportComponentsView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions VBEModules/Business/Export/View/ExportComponentsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,33 @@ private void tw_AfterCheck(object sender, TreeViewEventArgs e)
}
lblItems.Text = string.Format(strings.NumberOfComponentsPlusSelected, _counter, SelectedItems.Count());
}

private void txtExportPath_MouseHover(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtExportPath.Text))
toolTip1.SetToolTip(txtExportPath, null);
else
toolTip1.SetToolTip(txtExportPath, txtExportPath.Text);
}

private void tw_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e == null || e.Node.Tag == null)
{
txtContent.Text = null;
return;
}

Component component = (Component)e.Node.Tag;
if (string.IsNullOrWhiteSpace(component.Content))
{
txtContent.Text = null;
}
else
{
txtContent.Text = component.Content;
}
}

}
}
6 changes: 6 additions & 0 deletions VBEModules/Business/Export/View/ExportComponentsView.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>127, 17</value>
</metadata>
<metadata name="txtContent.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
32 changes: 29 additions & 3 deletions VBEModules/Extensions/VbeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public static IEnumerable<CodeModule> FindCodeModules(this VBE vbe, string compo
return matches;
}

/// <summary>
/// Checks if active project contains a component with given name
/// </summary>
/// <param name="vbe"></param>
/// <param name="componentName">a name of component to check</param>
/// <returns></returns>
public static bool HasCodeModule(this VBE vbe, string componentName)
{
var hasAny =
Expand All @@ -50,11 +56,31 @@ public static IEnumerable<VBComponent> GetComponents(this VBE vbe)
/// <returns>collection of all components from the given project</returns>
public static IEnumerable<Business.Component> GetAsComponents(this VBE vbe)
{

var vbComps = vbe.ActiveVBProject.VBComponents.Cast<VBComponent>();
return vbComps.ToList().ConvertAll(x => new Business.Component(x));
var tmp = vbComps.ToList().ConvertAll(x => new Business.Component(x));
tmp.ForEach(x => x.Content = GetComponentText(vbe, x.Name));
return tmp;
}

/// <summary>
/// Gets the whole code of given component
/// </summary>
/// <param name="vbe"></param>
/// <param name="componentName">a name of component to get text from</param>
/// <returns>code of the component</returns>
public static string GetComponentText(this VBE vbe, string componentName)
{
var module = vbe.ActiveVBProject.VBComponents.Cast<VBComponent>()
.FirstOrDefault(component => component.Name == componentName);
string retVal = null;
if (module.CodeModule.CountOfLines > 0)
{
retVal = module.CodeModule.get_Lines(1, module.CodeModule.CountOfLines);
}
return retVal;
}


/// <summary>
/// Checks if given component exists, if so, will remove it from the project
/// If the component is document type, will just clear all lines
Expand All @@ -79,7 +105,7 @@ public static void RemoveComponent(this VBE vbe, string componentName)
{
if (component.CodeModule.CountOfLines > 0)
{
component.CodeModule.DeleteLines(1, component.CodeModule.CountOfLines);
component.CodeModule.DeleteLines(1, component.CodeModule.CountOfLines);
}
}
}
Expand Down

0 comments on commit 3808c5c

Please sign in to comment.