请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2893|回复: 2

[资源分享] vb.net调用Grapher10.1.640

[复制链接]

新浪微博达人勋

发表于 2017-6-18 19:03:15 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 xyangtian 于 2017-6-18 19:07 编辑
  1. Imports Microsoft.Win32
  2. Class MainWindow
  3.     Dim ArrFile() As String
  4.     Dim ListFile As New List(Of String)
  5.     Dim ListName As New List(Of String)
  6.     Dim BaseFolder As String
  7.     Private Sub button_Click(sender As Object, e As RoutedEventArgs)
  8.         Dim dlg As New Microsoft.Win32.OpenFileDialog()
  9.         dlg.FileName = "Document"
  10.         dlg.DefaultExt = ".dat"
  11.         dlg.Filter = "Text documents (.dat)|*.dat"
  12.         dlg.Multiselect = True
  13.         Dim result? As Boolean = dlg.ShowDialog()
  14.         If result = True Then
  15.             ArrFile = dlg.FileNames
  16.             FileTb.Text = dlg.FileName
  17.             For i = 0 To ArrFile.Length - 1
  18.                 BaseFolder = ArrFile(i).Remove(ArrFile(i).LastIndexOf("")) '获取文件路径
  19.                 ListFile.Add(ArrFile(i).Remove(ArrFile(i).LastIndexOf("."))) '移除文件名后缀
  20.                 ListName.Add(ArrFile(i).Substring(ArrFile(i).LastIndexOf("") + 1, (ArrFile(i).LastIndexOf(".") - ArrFile(i).LastIndexOf("") - 1))) '截取文件名
  21.             Next
  22.         End If
  23.     End Sub

  24.     Private Sub Scatter_Click(sender As Object, e As RoutedEventArgs)
  25.         For i = 0 To ArrFile.Count() - 1
  26.             Dim GrapherApp As Object
  27.             GrapherApp = CreateObject("Grapher.Application") '创建Grapher实例
  28.             GrapherApp.Visible = False
  29.             Dim Docs As Object
  30.             Docs = GrapherApp.Documents
  31.             Dim Plot As Object
  32.             Plot = Docs.Add()
  33.             Dim Shapes As Object
  34.             Shapes = Plot.Shapes
  35.             Dim Graph As Object
  36.             Graph = Shapes.AddLinePlotGraph(ArrFile(i), 2, 3)
  37.             Dim Axes As Object
  38.             Axes = Graph.Axes
  39.             Dim XAxis As Object
  40.             XAxis = Axes(1)
  41.             XAxis.Scale = 2 '设置X轴为对数
  42.             Dim XAxisTitle As Object
  43.             XAxisTitle = XAxis.title
  44.             XAxisTitle.Text = "1111" '设置X轴标题内容
  45.             Dim YAxis As Object
  46.             YAxis = Axes(2)
  47.             YAxis.Scale = 2 '设置Y轴为对数
  48.             Dim YAxisTitle As Object
  49.             YAxisTitle = YAxis.title
  50.             YAxisTitle.Text = "2222" '设置Y轴标题内容
  51.             Dim GraphPlots As Object
  52.             GraphPlots = Graph.Plots(1)
  53.             Dim GraphTitle As Object
  54.             GraphTitle = Graph.Title
  55.             GraphTitle.Text = "nihao" '设置标题内容
  56.             Dim GraphLine As Object
  57.             GraphLine = GraphTitle.line '选取标题的线属性
  58.             GraphLine.Style = "Invisible" '设置线属性
  59.             Dim GraphSymbol As Object
  60.             GraphSymbol = Graph.Plots.Item(1)
  61.             GraphSymbol.symbolFreq = 1 '设置标记个数
  62.             Dim GraphColor As Object
  63.             GraphColor = GraphSymbol.Symbol
  64.             GraphColor.Fill.ForeColor = 100 '设置标记填充颜色
  65.             Plot.SaveAs(BaseFolder + "" + ListName(i) + "grf")
  66.             GrapherApp.Quit()
  67.             System.GC.Collect(System.GC.GetGeneration(GrapherApp))
  68.         Next
  69.         MsgBox("OK")
  70.     End Sub
  71. End Class
复制代码
vb.net,你可以把它转成vb。grapher一定要是英文版,汉化版会有各种错误。

Wpfvb1.zip

477.04 KB, 下载次数: 6, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-6-22 19:00:14 | 显示全部楼层
这个是拿来做什么用的?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-24 09:39:59 | 显示全部楼层
张爱气象 发表于 2017-6-22 19:00
这个是拿来做什么用的?

仅供参考,做什么要自己编
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表