Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            foreach (var listBoxItem in listBox_groupPath.Items)
            {
                String namepath = listBoxItem.ToString();
                MessageBox.Show("" + namepath);
                LineParams templineparams = findLineParam(namepath);
                if (templineparams != null)
                {
                    MessageBox.Show("line");
                    pathObjectList.Add(new PathObject()
                    {
                        flag_lineparam = true, lineParams = templineparams, curveParams = null
                    });
                }
                CurveParams tempcurveparams = findCurveParam(namepath);
                if (tempcurveparams != null)
                {
                    MessageBox.Show("curve");
                    pathObjectList.Add(new PathObject()
                    {
                        flag_lineparam = false, curveParams = tempcurveparams, lineParams = null
                    });
                }
            }


            if (pathObjectList.Count > 0)
            {
                System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
                if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (StreamWriter sw = File.CreateText(System.IO.Path.GetFullPath(saveFileDialog.FileName)))
                    {
                        sw.WriteLine("// X, Y, Z, W");
                        for (int i = 0; i < pathObjectList.Count; i++)
                        {
                            String path = "";
                            CreateRobotPathPlan createpath = new CreateRobotPathPlan();
                            if (pathObjectList[i].flag_lineparam)
                            {
                                createpath.linePathPlan(pathObjectList[i].lineParams);
                                path += createpath.TextLine();
                            }
                            else
                            {
                                createpath.CurvePathPlan(pathObjectList[i].curveParams);
                                path += createpath.TextCurveLine();
                            }
                            sw.Write(path);
                        }
                    }
                }
            }
        }
Example #2
0
        private CurveParams findCurveParam(String Name)
        {
            CurveParams curveparam = null;

            for (int i = 0; i < curveList.Count; i++)
            {
                if (curveList[i].Nameobj.Equals(Name))
                {
                    curveparam = curveList[i];
                    break;
                }
            }
            return(curveparam);
        }
Example #3
0
        private void btn_openlistpath_Click(object sender, EventArgs e)
        {
            if (openpath())
            {
                JObject results = JObject.Parse(contents);
                foreach (var result in results["Line"])
                {
                    string _Name = (string)result["name"];
                    listBox_singlepath.Items.Add(_Name);
                    dynamic startPoint = result["startPoint"];

                    System.Windows.Point sp = new System.Windows.Point((double)startPoint.X, (double)startPoint.Y);
                    dynamic endPoint        = result["endPoint"];
                    System.Windows.Point ep = new System.Windows.Point((double)endPoint.X, (double)endPoint.Y);
                    double     _startdir    = (double)result["startdir"];
                    double     _enddir      = (double)result["enddir"];
                    double     _unitstep    = (double)result["unitStep"];
                    LineParams lineparam    = new LineParams()
                    {
                        Nameobj = _Name, startpoint = sp, endpoint = ep, startdir = _startdir, enddir = _enddir, unitstep = _unitstep
                    };
                    lineList.Add(lineparam);
                }
                foreach (var result in results["Curve"])
                {
                    string Name = (string)result["name"];
                    listBox_singlepath.Items.Add(Name);
                    dynamic startPoint      = result["startPoint"];
                    System.Windows.Point sp = new System.Windows.Point((double)startPoint.X, (double)startPoint.Y);
                    dynamic middlePoint     = result["middlePoint"];
                    System.Windows.Point mp = new System.Windows.Point((double)middlePoint.X, (double)middlePoint.Y);
                    dynamic endPoint        = result["endPoint"];
                    System.Windows.Point ep = new System.Windows.Point((double)endPoint.X, (double)endPoint.Y);
                    double      _startdir   = (double)result["startdir"];
                    double      _enddir     = (double)result["enddir"];
                    double      R           = (double)result["radius"];
                    double      dv          = (double)result["dv"];
                    double      dw          = (double)result["dw"];
                    CurveParams curveparam  = new CurveParams()
                    {
                        Nameobj = Name, startpoint = sp, middlepoint = mp, endpoint = ep, startdir = _startdir, enddir = _enddir, R = R, dw = dw, dv = dv
                    };
                    curveList.Add(curveparam);
                }
            }
        }
 public void Write(EndianBinaryWriter writer)
 {
     CurveParams.Write(writer);
     writer.Write(Q);
 }