Ejemplo n.º 1
0
 private void PreviewEquation(EqnCalc eqnCalc, Action finishAction)
 {
     CurrentEquationCalc = eqnCalc;
     _vmEquations.EquationsUiService.PreviewEquation(_vmEquations.ContentManager, CurrentEquationCalc,
                                                     okAction: () => { AcceptCurrentEquationCalc(); finishAction(); },
                                                     cancelAction: () => { SelectEquation(finishAction); });
 }
Ejemplo n.º 2
0
        private void DefineCommands()
        {
            // -------------------
            ChooseEquation = new Command(
                execute: () => { _equationsUiService.ShowChooseEquation(this); });

            // -------------------
            ShowSettings = new Command(
                execute: () => { _equationsUiService.ShowSettings(); });

            // -------------------
            ShowCalculationTree = new Command(
                execute: () => { _equationsUiService.ShowCalculationTree(CurrentEquationCalc, NumberFormat); });

            // -------------------
            AddEqn = new Command(
                execute: async() =>
            {
                EqnCalc equationCalc = await _equationsUiService.ShowCreateEquation(ContentManager);
                if (equationCalc != null)
                {
                    CurrentEquationCalc = equationCalc;
                }
            });

            // -------------------
            ChooseDefaultUnits = new Command(
                execute: () => _equationsUiService.ShowChooseDefaultUnits(ContentManager));
        }
        // -----------------------------
        public void PreviewEquation(ContentManager contentManager, EqnCalc equationCalc, Action okAction, Action cancelAction)
        {
            VmPreviewEquation vm = new VmPreviewEquation(contentManager, equationCalc, okAction, cancelAction);
            VwPreviewEquation vw = new VwPreviewEquation(vm);

            Navigation.PushModalAsync(vw);
            //await vw.PageClosedTask; // Wait here until the Page is dismissed
            //Navigation.PushAsync(vw);

            return;
        }
        private void SetCurrentEquationCalc(EqnCalc eqnCalc)
        {
            if (_currentEquationCalc != eqnCalc)
            {
                _currentEquationCalc = eqnCalc;

                SetEqPreviewVariables();
                Recalculate();

                OnPropertyChanged("CurrentEqCalcDescription");
            }
        }
 // -----------------------------
 public void ShowCalculationTree(EqnCalc equationCalc, string numberFormat)
 {
     try
     {
         Navigation.PushAsync(new VwCalculationTree(new VmCalculationTree(this, equationCalc, numberFormat), this));
     }
     catch (Exception ex)
     {
         Logging.LogException(ex);
         throw;
     }
 }
Ejemplo n.º 6
0
        private void ChangeDependantVariable(string varRequired, Func <string /**/, bool /*result: Not used*/> displayAlertFunc)
        {
            Result <EqnCalc> r_result = EqnCalc.RearrangeEquation(_originalEquationCalc, varRequired, ContentManager);

            if (r_result.IsNotGood())
            {
                displayAlertFunc(r_result.Message);
            }
            else
            {
                SetCurrentEquationCalc(r_result.Value);
            }
        }
        public async Task <EqnCalc> ShowCreateEquation(ContentManager cm)
        {
            Tuple <bool, string, string, string, IList <VarInfo> > tpl;

            tpl = await ShowAddEquation(cm);

            try
            {
                bool            bCancelled         = tpl.Item1;
                string          equationString     = null;
                string          userEquationString = null;
                string          eqDescription      = null;
                IList <VarInfo> varInfos           = null;

                if (!bCancelled)
                {
                    equationString     = tpl.Item2;
                    userEquationString = tpl.Item3;
                    eqDescription      = tpl.Item4;
                    varInfos           = tpl.Item5;

                    Debug.WriteLine("equationString={0}, userEquationString={1},eqDescription={2}");
                    Debug.WriteLine(varInfos);

                    JongErrWarn  errW    = null;
                    FunctionCalc funCalc = cm.CreateFunctionCalcFromExpression(equationString, eqDescription, varInfos, out errW);

                    EqnCalc equationCalc = funCalc as EqnCalc;

                    if (equationCalc == null)
                    {
                        // TODO
                    }
                    else
                    {
                        // TODO
                        //EquationLibraries.Add(equationCalc);
                        return(equationCalc);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }

            return(null);
        }
        public VmPreviewEquation(ContentManager contentManager, EqnCalc currentEquationCalc, Action okAction, Action cancelAction)
        {
            try
            {
                _contentManager = contentManager;
                _uOMSet = ContentManager.UOMSet_SI;

                SetCurrentEquationCalc(EqnCalc.IsolateFirstVariableIfRequired(currentEquationCalc, contentManager));

                _okAction = okAction;
                _cancelAction = cancelAction;
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
        }
Ejemplo n.º 9
0
 public VmCalculationTree(IEquationsUiService equationsUiService, EqnCalc equationCalc, string numberFormat)
 {
     EquationsUiService  = equationsUiService;
     NumberFormat        = numberFormat;
     CurrentEquationCalc = equationCalc;
 }