Bläddra i källkod

Fixed examples so that they work after Debug directory gets deleted (missing logo's). Images moved to proper location.

master
MadBoy_cp 12 år sedan
förälder
incheckning
305015e639

+ 1
- 0
Examples/Examples.csproj Visa fil

@@ -51,6 +51,7 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelativeDirectory.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DocX\DocX.csproj">

+ 10
- 4
Examples/Program.cs Visa fil

@@ -20,7 +20,7 @@ namespace Examples
HelloWorld();
RightToLeft();
Indentation();
HeadersAndFooters();
HyperlinksImagesTables();
AddList();
@@ -287,7 +287,9 @@ namespace Examples
newRow.ReplaceText("4", "5");
// Add an image into the document.
Novacode.Image image = document.AddImage(@"images\logo_template.png");
RelativeDirectory rd = new RelativeDirectory(); // prepares the files for testing
rd.Up(2);
Novacode.Image image = document.AddImage(rd.Path + @"\images\logo_template.png");
// Create a picture (A custom view of an Image).
Picture picture = image.CreatePicture();
@@ -488,7 +490,9 @@ namespace Examples
logo_paragraph.Pictures[0].Remove();
// Add the Happy Builders logo to this document.
Novacode.Image logo = template.AddImage(@"images\logo_the_happy_builder.png");
RelativeDirectory rd = new RelativeDirectory(); // prepares the files for testing
rd.Up(2);
Novacode.Image logo = template.AddImage(rd.Path + @"\images\logo_the_happy_builder.png");
// Insert the Happy Builders logo into this Paragraph.
logo_paragraph.InsertPicture(logo.CreatePicture());
@@ -580,7 +584,9 @@ namespace Examples
Paragraph upper_right_paragraph = layout_table.Rows[0].Cells[1].Paragraphs[0];
// Add a template logo image to this document.
Novacode.Image logo = document.AddImage(@"images\logo_template.png");
RelativeDirectory rd = new RelativeDirectory(); // prepares the files for testing
rd.Up(2);
Novacode.Image logo = document.AddImage(rd.Path + @"\images\logo_template.png");
// Insert this template logo into the upper right Paragraph.
upper_right_paragraph.InsertPicture(logo.CreatePicture());

+ 72
- 0
Examples/RelativeDirectory.cs Visa fil

@@ -0,0 +1,72 @@
using System;
using System.IO;
namespace Examples
{
class RelativeDirectory
{
// Author D. Bolton see http://cplus.about.com (c) 2010
private DirectoryInfo _dirInfo;
public string Dir
{
get
{
return _dirInfo.Name;
}
}
public string Path
{
get { return _dirInfo.FullName; }
set
{
try
{
DirectoryInfo newDir = new DirectoryInfo(value);
_dirInfo = newDir;
}
catch
{
// silent
}
}
}
public RelativeDirectory()
{
_dirInfo = new DirectoryInfo(Environment.CurrentDirectory);
}
public RelativeDirectory(string absoluteDir)
{
_dirInfo = new DirectoryInfo(absoluteDir);
}
public Boolean Up(int numLevels)
{
for (int i = 0; i < numLevels; i++)
{
DirectoryInfo tempDir = _dirInfo.Parent;
if (tempDir != null)
_dirInfo = tempDir;
else
return false;
}
return true;
}
public Boolean Up()
{
return Up(1);
}
public Boolean Down(string match)
{
DirectoryInfo[] dirs = _dirInfo.GetDirectories(match + '*');
_dirInfo = dirs[0];
return true;
}
}
}

Binär
Examples/images/logo_template.png Visa fil


Binär
Examples/images/logo_the_happy_builder.png Visa fil


Laddar…
Avbryt
Spara