zoukankan      html  css  js  c++  java
  • Halcon_Gocator_VisualStudio

    代码中启动另一个exe程序:

    ProcessStartInfo info = new ProcessStartInfo();
                info.FileName = @"D:KitaSOFT_WAREqqBinQQ.exe";
                info.Arguments = "";
                info.WindowStyle = ProcessWindowStyle.Minimized;
                Process pro = Process.Start(info);
                //pro.WaitForExit();
    

      Gocator Sdk获取数据:

     dataSet = system.ReceiveData(30000000);
                for (int i = 0; i < dataSet.Count; i++)
                {
                    GoDataMsg dataFrame = (GoDataMsg)dataSet.Get(i);
                    if (dataFrame.MessageType==GoDataMessageType.UniformSurface)
                    {
                        GoSurfaceMsg dataSurface = (GoSurfaceMsg)dataFrame;
                        long width = dataSurface.Width;
                        long length = dataSurface.Length;
                        long bufferSize = width * length;
    
                        IntPtr bufferPointer = dataSurface.Data;
    
                        //Console.WriteLine("Whole Part Height Map received:");
                        //Console.WriteLine(" Buffer  {0}", width);
                        //Console.WriteLine(" Buffer length: {0}", length);
    
                        
                        short[] ranges = new short[bufferSize];
                        Marshal.Copy(bufferPointer, ranges, 0, ranges.Length);
                        RecSurfData.Add(ranges);
    

      其中用到Marshal类的copy函数,需要using System.Runtime.InteropServices;

    打开选择文件窗口,并返回选中文件绝对路径

    using Microsoft.Win32;
    
      OpenFileDialog dialog = new OpenFileDialog();
      dialog.ShowDiag(); //返回一个可空的布尔值
        
        Console.Write(dialog.Filename);  //路径保存在这里
    

      

    切换空间字体颜色;

      StateConnect.Foreground = Brushes.Green;
    

      

     TextBox作为InfoLog使用

    VerticalScrollBarVisibility="Auto" Foreground="Green"
    
    
     public void StateBox(string txt)
            {
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff");
                string str = time + "->"+"
    "+txt+"
    ";
                WindowStateLog.AppendText(str);
                WindowStateLog.ScrollToEnd();
            }
    

      

    打开文件选择对话框,选择文件获取路径

    using Microsoft.Win32;
    
    private void BtnOpenFile_Click(object sender, RoutedEventArgs e)
            {
                OpenFileDialog op = new OpenFileDialog();
                //op.InitialDirectory = "D:/3D";
                op.Title = "请选择导入csv文件";
                op.Filter = "csv文件|*.csv";
               
                if (op.ShowDialog() ==true)
                {
                    SingleDataPath = op.FileName;
                    TextBoxPath.Text = op.FileName;
                }
                else {
                    MessageBox.Show("未选中任何文件");
                }
            }
    OpenFileDialog 也可直接返回Stream对象,直接进行读写操作;


     OutPutFile = new StreamWriter("D:/3D/output.csv",true);
    //查看构造函数重载,采用覆盖,末尾添加等模式
    

      

    textbox作为状态log输出框
    VerticalScrollBarVisibility="Auto"
    
    WPF里面 自动显示滚动条
    
                WindowStateLog.AppendText(str);
                WindowStateLog.ScrollToEnd();
    末尾添加新log并把焦点聚焦在最后一排
    

      



  • 相关阅读:
    学了这么多年技术,为什么水平还是一般般?
    你能不用计算机来计算S=a+(a+1)+(a+2) + ...... + b的解的数目吗?
    迟来的2013年总结
    如何快速查找IP归属地
    Shiro 权限标签
    Shiro 权限注解
    Shiro 授权
    shiro 身份验证
    Kaptcha
    FastJson
  • 原文地址:https://www.cnblogs.com/kita/p/11374628.html
Copyright © 2011-2022 走看看