private void bnAsCenter_Click(object sender, EventArgs e)
 {
     Framework.Data.Location ll = null;
     if (tbSolutions.SelectionLength > 0)
     {
         ll = Utils.Conversion.StringToLocation(tbSolutions.SelectedText);
     }
     if (ll != null)
     {
         Core.CenterLocation.SetLocation(ll.Lat, ll.Lon);
         Core.Geocaches.BeginUpdate();
         foreach (Framework.Data.Geocache gc in Core.Geocaches)
         {
             Utils.Calculus.SetDistanceAndAngleGeocacheFromLocation(gc, Core.CenterLocation);
         }
         Core.Geocaches.EndUpdate();
     }
     else
     {
         MessageBox.Show(
             StrRes.GetString(StrRes.NO_PROPER_COORDINATES_SELECTED),
             "Formula Solver",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information
             );
     }
 }
 private void SetLanguageSpecificControlText()
 {
     this.Text        = StrRes.GetString(StrRes.STR_WPSEL_TITLE);
     lblWaypoint.Text = StrRes.GetString(StrRes.STR_WPSEL_WAYPOINTS);
     bnInsert.Text    = StrRes.GetString(StrRes.STR_WPSEL_INSERT);
     bnCancel.Text    = StrRes.GetString(StrRes.STR_WPSEL_CANCEL);
 }
 private void UpdateControlsLanguage()
 {
     bnInsertFormula.Text  = StrRes.GetString(StrRes.STR_INSERT_FORMULA);
     bnInsertWaypoint.Text = StrRes.GetString(StrRes.STR_INSERT_WAYPOINT);
     bnSolve.Text          = StrRes.GetString(StrRes.STR_SOLVE);
     bnAsWaypoint.Text     = StrRes.GetString(StrRes.STR_AS_WAYPOINT);
     bnAsCenter.Text       = StrRes.GetString(StrRes.STR_AS_CENTER);
     OnPropertyChanged("activeTitle");
 }
Exemple #4
0
 private void SetLanguageSpecificControlText()
 {
     this.Text          = StrRes.GetString(StrRes.STR_INSFORM_TITLE);
     lblGroup.Text      = StrRes.GetString(StrRes.STR_INSFORM_GROUP);
     lblFunctions.Text  = StrRes.GetString(StrRes.STR_INSFORM_FUNCTIONS);
     lblOtherNames.Text = StrRes.GetString(StrRes.STR_INSFORM_OTHER);
     bnInsert.Text      = StrRes.GetString(StrRes.STR_INSFORM_INSERT);
     bnCancel.Text      = StrRes.GetString(StrRes.STR_INSFORM_CANCEL);
 }
Exemple #5
0
        public async override Task <bool> InitializeAsync(Framework.Interfaces.ICore core)
        {
            var p = new PluginSettings(core);

            AddAction(ACTION_SHOW);

            FormulaSolverForm.InitDatabase(core);
            StrRes.InitializeCoreLanguageItems(core);
            return(await base.InitializeAsync(core));
        }
        private void bnSolve_Click(object sender, EventArgs e)
        {
            StoreFormula();
            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(Core);

                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();
            }
        }
        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);
            }
        }