请问,在VB.net转化为C#.net后,有一些语句没有完全转化过来,请问如何完全转化为C# ( 积分: 20 )

  • 主题发起人 主题发起人 mycwcgr_new
  • 开始时间 开始时间
M

mycwcgr_new

Unregistered / Unconfirmed
GUEST, unregistred user!
请问,在VB.net转化为C#.net后,有一些语句没有完全转化过来,请问如何完全转化为C#

下面是FotoVision示例从VB.net转化为C#.net后的代码,不过仍然残留using Microsoft.VisualBasic;
其中object vector = Interaction.CreateObject( Consts.VectorProgId, "" );
似乎是VB的语句,
请问如何完全转化为C#


using System.Diagnostics;
using Microsoft.VisualBasic;
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
// Uses the XP Photo Printing Wizard to print one or more photos.
// The implementation of the photo wizard is in photowiz.dll but the
// interface is not exposed. Instead, Microsoft provides the Windows
// Image Acquisition Library (WIA).
//
// Use late binding incase the userdo
es not have the WIA component
// installed (and easier for developers to use the source if it's
// not installed).
// use late binding for this source file
namespace FotoVision
{
public sealed class Print
{
// const values
private class Consts
{
public const string DialogProgId = "WIA.CommonDialog";
public const string VectorProgId = "WIA.Vector";
}

// static class
private Print() {
}

// public methods

// print the specified photo (full path to the photo)
public static void PrintFile (string file)
{
PrintFiles(new string[] {file});
}

// print the list of photos
public static void PrintFiles (Photo[] photos)
{
// convert to a string array
string[] files = new string[photos.Length-1 + 1];
for (int i = 0;
i <= files.Length - 1;
i++)
{
files = photos.PhotoPath;
}
PrintFiles(files);
}

// print the list of files
public static void PrintFiles (string[] files)
{
try
{
// create the vector COM object
object vector = Interaction.CreateObject(Consts.VectorProgId, "");

// add files to the vector object
foreach (string file in files)
{
System.Diagnostics.vector.Add(file);
}

// create the common dialog COM object, and
// display the photo print wizard
object dialog = Interaction.CreateObject(Consts.DialogProgId, "");
dialog.ShowPhotoPrintingWizard(vector);

vector = null;
dialog = null;
}
catch (Exception ex)
{
Global.DisplayError("The photo could not be printed.", ex);
}
}

}

}
 
请问,在VB.net转化为C#.net后,有一些语句没有完全转化过来,请问如何完全转化为C#

下面是FotoVision示例从VB.net转化为C#.net后的代码,不过仍然残留using Microsoft.VisualBasic;
其中object vector = Interaction.CreateObject( Consts.VectorProgId, "" );
似乎是VB的语句,
请问如何完全转化为C#


using System.Diagnostics;
using Microsoft.VisualBasic;
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
// Uses the XP Photo Printing Wizard to print one or more photos.
// The implementation of the photo wizard is in photowiz.dll but the
// interface is not exposed. Instead, Microsoft provides the Windows
// Image Acquisition Library (WIA).
//
// Use late binding incase the userdo
es not have the WIA component
// installed (and easier for developers to use the source if it's
// not installed).
// use late binding for this source file
namespace FotoVision
{
public sealed class Print
{
// const values
private class Consts
{
public const string DialogProgId = "WIA.CommonDialog";
public const string VectorProgId = "WIA.Vector";
}

// static class
private Print() {
}

// public methods

// print the specified photo (full path to the photo)
public static void PrintFile (string file)
{
PrintFiles(new string[] {file});
}

// print the list of photos
public static void PrintFiles (Photo[] photos)
{
// convert to a string array
string[] files = new string[photos.Length-1 + 1];
for (int i = 0;
i <= files.Length - 1;
i++)
{
files = photos.PhotoPath;
}
PrintFiles(files);
}

// print the list of files
public static void PrintFiles (string[] files)
{
try
{
// create the vector COM object
object vector = Interaction.CreateObject(Consts.VectorProgId, "");

// add files to the vector object
foreach (string file in files)
{
System.Diagnostics.vector.Add(file);
}

// create the common dialog COM object, and
// display the photo print wizard
object dialog = Interaction.CreateObject(Consts.DialogProgId, "");
dialog.ShowPhotoPrintingWizard(vector);

vector = null;
dialog = null;
}
catch (Exception ex)
{
Global.DisplayError("The photo could not be printed.", ex);
}
}

}

}
 
后退
顶部