Canguro.Controller.CommandServices.onEnterData C# (CSharp) Метод

onEnterData() приватный Метод

Method that responds to the EnterData event of SmallPanel. The text input by the user on the SmallPanel's TextBox (data) is parsed here. If the input is successfull locks are released and execution continues normally, i.e.: waitingObj is assigned to the refered object and the selectionFilter is set to None. Otherwise, the input is rejected.
private onEnterData ( object sender, Canguro e ) : void
sender object Usually, the SmallPanel in MainFrm
e Canguro Event args with the user input
Результат void
        void onEnterData(object sender, Canguro.View.EnterDataEventArgs e)
        {
            char[] charSeparators = new char[] {',', ';', ' ', '\t', '@'};
            waitingObj = null;

            switch (selectionFilter)
            {
                case WaitingFor.Point:
                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        bool relativePt = false;
                        string trimmedPt = e.Data.Trim();
                        if (trimmedPt.Length > 0 && trimmedPt[0] == '@')
                            relativePt = true;

                        string[] pt = trimmedPt.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                        Microsoft.DirectX.Vector3 v;

                        try
                        {
                            if (pt.Length != 3) throw new FormatException();
                            v = new Microsoft.DirectX.Vector3(
                                float.Parse(pt[0]), float.Parse(pt[1]), float.Parse(pt[2]));
                            if (relativePt)
                                v += lastPoint;
                        }
                        catch (FormatException)
                        {
                            System.Windows.Forms.MessageBox.Show(
                                Culture.Get("enterDataError") + "'" + Culture.Get("enterDataPoint") + "'",
                                Culture.Get("enterDataErrorTitle"), System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Error);

                            return;
                        }
                        waitingObj = new Snap.PointMagnet(v);
                    }

                    selectionFilter = WaitingFor.None;
                    break;

                case WaitingFor.Joint:
                    parseItem(e.Data, Canguro.Model.Model.Instance.JointList, Culture.Get("enterDataJoint"));
                    break;

                case WaitingFor.Line:
                    parseItem(e.Data, Canguro.Model.Model.Instance.LineList, Culture.Get("enterDataLine"));
                    break;

                case WaitingFor.Area:
                    parseItem(e.Data, Canguro.Model.Model.Instance.AreaList, Culture.Get("enterDataArea"));
                    break;

                case WaitingFor.Text:
                    waitingObj = e.Data;
                    selectionFilter = WaitingFor.None;
                    break;

                case WaitingFor.SimpleValue:
                    try
                    {
                        waitingObj = float.Parse(e.Data);
                        selectionFilter = WaitingFor.None;
                    }
                    catch (FormatException)
                    {
                        System.Windows.Forms.MessageBox.Show(
                            Culture.Get("enterDataError") + "'" + Culture.Get("enterDataSimpleValue") + "'",
                            Culture.Get("enterDataErrorTitle"), System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Error);

                        return;
                    }
                    break;

                case WaitingFor.Any:
                case WaitingFor.Many:
                case WaitingFor.None:
                    break;

                default:
                    throw new NotImplementedException("CommandServices.onEnterData");
            }
        }