Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            saveData();

            String formula = tbFormula.Text;

            tbSolutions.Text = "";
            if (formula.Length > 0)
            {
                string[]         lines = formula.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
                StringBuilder    sb    = new StringBuilder();
                ExecutionContext ctx   = new ExecutionContext();

                foreach (string line in lines)
                {
                    if (line.Length == 0)
                    {
                        sb.AppendLine("");
                    }
                    else
                    {
                        string res = Convert.ToString(_interpreter.Exec(line, ctx), new System.Globalization.CultureInfo(""));
                        sb.AppendLine(res);
                    }
                }

                if (ctx.HasMissingVariables())
                {
                    string text = string.Format(StrRes.GetString(StrRes.STR_MISSING_VARIABLES), String.Join(", ", ctx.GetMissingVariableNames()));
                    //if (MessageBox.Show(text, "Formula Solver", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        StringBuilder sbInput = new StringBuilder();
                        foreach (string name in ctx.GetMissingVariableNames())
                        {
                            sbInput.AppendLine(name + "=");
                        }
                        foreach (string line in lines)
                        {
                            sbInput.AppendLine(line);
                        }

                        tbFormula.Text = sbInput.ToString();
                    }
                    sb.Clear();
                }
                tbSolutions.Text = sb.ToString();
            }
        }
Beispiel #2
0
        public static string GroupName(FunctionGroup group)
        {
            switch (group)
            {
            case FunctionGroup.NumberGroup:
                return(StrRes.GetString(StrRes.STR_NUMBER_GROUP));

            case FunctionGroup.CoordinateGroup:
                return(StrRes.GetString(StrRes.STR_COORDINATE_GROUP));

            case FunctionGroup.TextGroup:
                return(StrRes.GetString(StrRes.STR_TEXT_GROUP));

            case FunctionGroup.ContextGroup:
                return(StrRes.GetString(StrRes.STR_CONTEXT_GROUP));

            case FunctionGroup.TrigonometricGroup:
                return(StrRes.GetString(StrRes.STR_TRIGONOMETRIC_GROUP));

            default:
                return(null);
            }
        }
Beispiel #3
0
 private void Button_Click_4(object sender, RoutedEventArgs e)
 {
     Core.Data.Location ll = null;
     if (tbSolutions.SelectionLength > 0)
     {
         ll = Utils.Conversion.StringToLocation(tbSolutions.SelectedText);
     }
     if (ll != null)
     {
         Utils.DataAccess.SetCenterLocation(ll.Lat, ll.Lon);
     }
     else
     {
         Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, StrRes.GetString(StrRes.NO_PROPER_COORDINATES_SELECTED));
     }
 }