Esempio n. 1
0
        public static void read <T>(out T x, string s = "read: ")
        {
            x = default(T);
            if (x == null)
            {
                x = (T)(object)(" ");
            }

            var rf = new ReadForm(s);

            rf.ShowDialog();
            if (rf.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                var result = rf.Result;

                if (x.IsNumericType())
                {
                    x = (T)((object)double.Parse(result, System.Globalization.CultureInfo.InvariantCulture));
                }

                if (x is string)
                {
                    x = (T)((object)(result));
                }

                if (x is System.Numerics.Complex)
                {
                    x = (T)((object)MathNet.Numerics.ComplexExtensions.ToComplex(result, System.Globalization.CultureInfo.InvariantCulture));
                }
            }
            CONSOLE_OUTPUT(System.Environment.NewLine + s + " " + objectToString(x));
        }
        public static T read <T>(string caption)
        {
            var rf = new ReadForm(caption);

            rf.ShowDialog();
            var x = convert <T>(rf.DialogResult == System.Windows.Forms.DialogResult.OK ? rf.Result : null);

            return(x);
        }