Foxtable(狐表)用户栏目专家坐堂 → VB,C#代码用在fox


  共有2458人关注过本帖树形打印复制链接

主题:VB,C#代码用在fox

帅哥哟,离线,有人找我吗?
超古伯
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:98 积分:1080 威望:0 精华:0 注册:2017/4/4 14:19:00
VB,C#代码用在fox  发帖心情 Post By:2018/12/24 9:04:00 [只看该作者]

请教老师,下面一段vb代码用在fox该怎么做?先引用Corel.Interop.VGCore.dll?然后代码该怎么改呢,代码放在哪里呢?


Imports Corel.Interop.VGCore

 

Module Module1

  Sub CreateTextInCorelDRAW(text As String, fontName As String, fontSize As Single)

    Dim pia_type As Type = Type.GetTypeFromProgID("CorelDRAW.Application.17")

    Dim app As Application = Activator.CreateInstance(pia_type)

 

    app.Visible = True

 

    Dim doc As Document = app.ActiveDocument

    If doc Is Nothing Then doc = app.CreateDocument()

 

    Dim shape As Shape = doc.ActiveLayer.CreateArtisticText(

      0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed,

      cdrTextCharSet.cdrCharSetMixed, fontName, fontSize,

      cdrTriState.cdrUndefined, cdrTriState.cdrUndefined,

      cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment)

  End Sub

 

  Sub Main()

    Try

      CreateTextInCorelDRAW("Hello, world""Arial", 24.0F)

    Catch ex As Exception

      Console.WriteLine("Error occurred: {0}", ex.Message)

    End Try

  End Sub

End Module


下面是一段同样效果的C#代码,也是不清楚该怎么用在fox


using System.Text;

using System.Threading.Tasks;

using Corel.Interop.VGCore;

 

namespace TextCreatorCS

{

  class Program

  {

    static void CreateTextInCorelDRAW(string text, string fontName,

                                      float fontSize)

    {

      Type pia_type = Type.GetTypeFromProgID("CorelDRAW.Application.17");

      Application app = Activator.CreateInstance(pia_type) as Application;

 

      app.Visible = true;

 

      Document doc = app.ActiveDocument;

      if (doc == null)

        doc = app.CreateDocument();

 

      Shape shape = doc.ActiveLayer.CreateArtisticText(

        0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed,

        cdrTextCharSet.cdrCharSetMixed, fontName, fontSize,

        cdrTriState.cdrUndefined, cdrTriState.cdrUndefined,

        cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment);

    }

 

    static void Main(string[] args)

    {

      try

      {

        CreateTextInCorelDRAW("Hello, world""Arial", 24.0f);

      }

      catch (Exception ex)

      {

        Console.WriteLine("Error occurred: {0}", ex.Message);

      }

    }

  }

}


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/12/24 9:15:00 [只看该作者]

全局代码

 

Public Sub CreateTextInCorelDRAW(text As String, fontName As String, fontSize As Single)

Dim pia_type As Type = Type.GetTypeFromProgID("CorelDRAW.Application.17")

Dim app As object = Activator.CreateInstance(pia_type)

app.Visible = True

Dim doc As object = app.ActiveDocument

If doc Is Nothing Then doc = app.CreateDocument()

Dim shape As object = doc.ActiveLayer.CreateArtisticText( _
0.0, 0.0, text, Corel.Interop.VGCore.cdrTextLanguage.cdrLanguageMixed, _
Corel.Interop.VGCore.cdrTextCharSet.cdrCharSetMixed, fontName, fontSize, _
Corel.Interop.VGCore.cdrTriState.cdrUndefined, Corel.Interop.VGCore.cdrTriState.cdrUndefined, _
Corel.Interop.VGCore.cdrFontLine.cdrMixedFontLine, Corel.Interop.VGCore.cdrAlignment.cdrLeftAlignment)

End Sub

 


 回到顶部