Beispiel #1
0
        getUserInput(string nameCmd)
        {
            bool          escape    = false;
            List <double> userInput = new List <double>();

            try
            {
                TypedValue[] TVs    = null;
                ResultBuffer RB     = null;
                bool         exists = false;
                if (nameCmd == "cmdABG")
                {
                    nameCmd = "cmdBG";
                }

                if (nameCmd == "cmdABC")
                {
                    nameCmd = "cmdBC";
                }

                ObjectId idDict = Dict.getNamedDictionary(nameCmd, out exists);
                if (!exists)
                {
                    userInput.Add(0.5);
                    userInput.Add(1.5);
                    userInput.Add(0.02);

                    userInput.Add(1.5);
                    userInput.Add(0.1875);

                    TVs = new TypedValue[userInput.Count];
                    for (int i = 0; i < userInput.Count; i++)
                    {
                        TVs.SetValue(new TypedValue(1040, userInput[i]), i);
                    }
                    RB = new ResultBuffer(TVs);
                    Dict.addXRec(idDict, "cmdDefault", RB);
                }
                else
                {
                    RB  = Dict.getXRec(idDict, "cmdDefault");
                    TVs = RB.AsArray();
                    for (int i = 0; i < TVs.Length; i++)
                    {
                        if (TVs[i].Value.ToString() != "")
                        {
                            userInput.Add(Convert.ToDouble(TVs[i].Value));
                        }
                        else
                        {
                            switch (i)
                            {
                            case 0:
                            case 1:
                            case 2:
                                break;

                            case 3:
                                userInput.Add(1.5);
                                break;

                            case 4:
                                userInput.Add(0.1875);
                                break;
                            }
                        }
                    }
                }

                if (RB != null)
                {
                    string message1 = "Curb Height: ";
                    string message2 = "\nBench Width: ";
                    string message3 = "\nBench Slope: ";

                    string message = string.Format("{0}{1}{2}{3}{4}{5}", message1.PadRight(50), userInput[0].ToString(), message2.PadRight(49), userInput[1].ToString(), message3.PadRight(50), userInput[2].ToString());
                    if (nameCmd == "cmdBG")
                    {
                        string message4 = "\nGutter Width: ";
                        string message5 = "\nGutter Vertical Difference: ";

                        message = string.Format("{0}{1}{2}{3}{4}", message, message4.PadRight(50), userInput[3].ToString(), message5.PadRight(42), userInput[4].ToString());
                    }

                    var response = MessageBox.Show(message, "Accept Current Settings?", MessageBoxButtons.YesNoCancel);
                    if (response == DialogResult.Yes)
                    {
                        return(userInput);
                    }
                    if (response == DialogResult.Cancel)
                    {
                        return(null);
                    }
                }
                double value = 0;
                escape = UserInput.getUserInput("\nEnter Curb Height in Feet: ", out value, Convert.ToDouble(userInput[0]));
                if (escape)
                {
                    return(null);
                }
                userInput[0] = value;
                escape       = UserInput.getUserInput("\nEnter Bench Width in feet (from Back of Curb to Grade Break): ", out value, Convert.ToDouble(userInput[1]));
                if (escape)
                {
                    return(null);
                }
                userInput[1] = value;
                escape       = UserInput.getUserInput("\nEnter Bench Slope: ", out value, Convert.ToDouble(userInput[2]));
                if (escape)
                {
                    return(null);
                }
                userInput[2] = value;

                if (nameCmd == "cmdBG")
                {
                    escape = UserInput.getUserInput("\nEnter Gutter Width in feet (distance from Curb Line to Edge of Pavement: ", out value, Convert.ToDouble(userInput[3]));
                    if (escape)
                    {
                        return(null);
                    }
                    userInput[3] = value;
                    escape       = UserInput.getUserInput("\nEnter Vert. Diff (FL to Lip of Gutter/Edge of Pavement: ", out value, Convert.ToDouble(userInput[4]));
                    if (escape)
                    {
                        return(null);
                    }
                    userInput[4] = value;
                }

                Dict.deleteXRec(idDict, "cmdDefault");

                TVs = new TypedValue[userInput.Count];

                for (int i = 0; i < userInput.Count; i++)
                {
                    TVs.SetValue(new TypedValue(1040, userInput[i]), i);
                }
                RB = new ResultBuffer(TVs);
                Dict.addXRec(idDict, "cmdDefault", RB);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBC.cs: line: 310");
            }

            return(userInput);
        }