Exemple #1
0
        private void buttonImportAddCurPos_Click(object sender, EventArgs e)
        {
            var platform = Platforms.FirstOrDefault(p => p.Name == comboBoxCurPlatform.Text);

            if (platform == null)
            {
                return;
            }

            var data = platform.GetPos(comboBoxCurPosType.Text);

            if (data == null)
            {
                MessageBox.Show($"Get Cur Pos Convert Error: Platform GetPos Fail {comboBoxCurPosType.Text}");
                return;
            }

            if (platform is PlatformXyz)
            {
                var pos = new PosXYZ(data);
                richTextBoxTestPos.Text += $"{pos.X:F2} {pos.Y:F2} {pos.Z:F2}\r\n";
            }
            else if (platform is PlatformXyzu)
            {
                var pos = new PosXYZU(data);
                richTextBoxTestPos.Text += $"{pos.X:F2} {pos.Y:F2} {pos.Z:F2} {pos.U:F2}\r\n";
            }
            else
            {
                MessageBox.Show($"Get Cur Pos Convert Error : {platform.GetType()} Error");
                return;
            }
        }
Exemple #2
0
        private void buttonUpdatePosData_Click(object sender, EventArgs e)
        {
            var newPos = new List <IPlatformPos>();
            var data   = richTextBoxPosData.Lines;
            var line   = string.Empty;

            if (TestPos.Count > 0 && TestPos.First().GetType() == typeof(PosXYZ))
            {
                try
                {
                    foreach (var l in data)
                    {
                        if (string.IsNullOrEmpty(l))
                        {
                            continue;
                        }
                        line = l;
                        newPos.Add(PosXYZ.Create(l));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"PosXYZ点位数据异常: {line} {ex.Message}");
                    return;
                }
            }
            else if (TestPos.Count > 0 && TestPos.First().GetType() == typeof(PosXYZU))
            {
                try
                {
                    foreach (var l in data)
                    {
                        if (string.IsNullOrEmpty(l))
                        {
                            continue;
                        }
                        line = l;
                        newPos.Add(PosXYZU.Create(l));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"PosXYZU点位数据异常: {line} {ex.Message}");
                    return;
                }
            }
            else if (TestPos.Count > 0 && TestPos.First().GetType() == typeof(PosXYZUVW))
            {
                try
                {
                    foreach (var l in data)
                    {
                        if (string.IsNullOrEmpty(l))
                        {
                            continue;
                        }
                        line = l;
                        newPos.Add(PosXYZUVW.Create(l));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"PosXYZUVW点位数据异常: {line} {ex.Message}");
                    return;
                }
            }
            else
            {
                return;
            }


            if (MessageBox.Show($"是否更新点位为:\r\n{string.Join("\r\n", newPos.Select(p => p.ToString()))} ", "更新点位数据", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }


            try
            {
                TestPos.Clear();
                TestPos.AddRange(newPos);

                LoadTestPos();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"更新点位数据异常:{ex.Message}");
            }
        }