Ejemplo n.º 1
0
        public static Dictionary <string, string> execute(CulculateFormulaJsonModel formula)
        {
            if (!S.firstFormula)
            {
                U.specialStackDic();
            }
            else
            {
                S.firstFormula = false;
            }

            S.LastCulculateResult = SpecialUtil.execute(formula);

            var dic = new Dictionary <string, string>();

            /*if(formula.last){
             *      S.LastCulculateResult = decimal.Parse(
             *              S.stackDictionary[
             *                      formula.execute.Where(
             *                              m => S.calculateType.Count < (int.Parse(Regex.Match(m.steps, @"[\d]+").Captures[0].Value))
             *                      )
             *                      .Last(m => m.execute.Count() > 0).steps
             *              ]
             *              [V.MainDicKeyName_LastCulculateResult]);
             * }*/

            dic.Add(V.MainDicKeyName_ResultText, formula.last ? S.LastCulculateResult.ToString() : "0");
            dic.Add(V.MainDicKeyName_ExplainText, formula.explain);
            dic.Add(V.MainDicKeyName_XText, formula.last ? S.LastCulculateResult.ToString() : "0");
            dic.Add(V.MainDicKeyName_Final, formula.last.ToString());

            return(dic);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 説明のコンテントを作成
        /// </summary>
        /// <returns>The explain content.</returns>
        /// <param name="targetMpdel">Target mpdel.</param>
        public ContentView createExplainContent(CulculateFormulaJsonModel targetMpdel)
        {
            var layout = new StackLayout {
                Style = EditorStyles.explainContentLayoutStyle
            };

            layout.Children.Add(new Label {
                Text  = "説明 ",
                Style = EditorStyles.culcLabelStyle
            });

            var explain = new Entry {
                Style = EditorStyles.explainEntryStyle
            };

            if (targetMpdel != null)
            {
                explain.Text = targetMpdel.explain;
            }

            layout.Children.Add(explain);

            editList.Last().explain = explain;

            return(new ContentView {
                Content = layout
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 最終ステップのフラグのコンテントを作成
        /// </summary>
        /// <returns>The last content.</returns>
        /// <param name="targetModel">Target model.</param>
        public ContentView createLastContent(CulculateFormulaJsonModel targetModel)
        {
            var layout = new StackLayout {
                Style = EditorStyles.lastContentLayoutStyle
            };

            layout.Children.Add(new Label {
                Text  = "最終ステップ",
                Style = EditorStyles.lastLableStyle
            });

            var final = new Switch {
                Style = EditorStyles.finalSwitchStyle
            };

            if (targetModel != null)
            {
                final.IsToggled = targetModel.last;
            }

            layout.Children.Add(final);

            editList.Last().final = final;

            return(new ContentView {
                Content = layout
            });
        }
Ejemplo n.º 4
0
        public static decimal execute(CulculateFormulaJsonModel sm)
        {
            List <ExecuteJsonModel> ejList = sm.execute;

            decimal previousResult = 0;

            foreach (ExecuteJsonModel ej in ejList)
            {
                decimal xtarget = 0;
                decimal ytarget = 0;

                switch (ej.xtype)
                {
                case JAN.Type_Constant_Value:
                    xtarget = decimal.Parse(ej.xtarget);
                    break;

                case JAN.Type_Input_Value:
                    xtarget = decimal.Parse(S.stackDictionary[int.Parse(ej.xtarget)][V.MainDicKeyName_XText]);
                    break;

                case JAN.Type_Previous_Culculate_Result_Value:
                    xtarget = previousResult;
                    break;

                case JAN.Type_Last_Culculate_Result_Value:
                    xtarget = decimal.Parse(S.stackDictionary[int.Parse(ej.xtarget)][V.MainDicKeyName_LastCulculateResult]);
                    break;
                }

                switch (ej.ytype)
                {
                case JAN.Type_Constant_Value:
                    ytarget = decimal.Parse(ej.ytarget);
                    break;

                case JAN.Type_Input_Value:
                    ytarget = decimal.Parse(S.stackDictionary[int.Parse(ej.ytarget)][V.MainDicKeyName_XText]);
                    break;

                case JAN.Type_Previous_Culculate_Result_Value:
                    ytarget = previousResult;
                    break;

                case JAN.Type_Last_Culculate_Result_Value:
                    ytarget = decimal.Parse(S.stackDictionary[int.Parse(ej.ytarget)][V.MainDicKeyName_LastCulculateResult]);
                    break;
                }

                previousResult = decimal.Parse(D.getDelegate(typeof(BC), ej.culculateMethod).DynamicInvoke(new object[] { xtarget, ytarget }).ToString());
            }

            return(previousResult);
        }
Ejemplo n.º 5
0
        public void onSave(object sender, EventArgs e)
        {
            if (!common.validate())
            {
                return;
            }

            var newstepList = new List <CulculateFormulaJsonModel>();

            foreach (var target in editList)
            {
                var newstep        = new CulculateFormulaJsonModel();
                var newstepexelist = new List <ExecuteJsonModel>();
                newstep.explain = target.explain.Text;


                if (target.final == null)
                {
                    newstep.last    = false;
                    newstep.execute = newstepexelist;
                    newstepList.Add(newstep);
                    continue;
                }

                newstep.last = target.final.IsToggled;


                foreach (CulcModel cul in target.culculates)
                {
                    var newexe = new ExecuteJsonModel();

                    string xtypeselect = SpecialUtil.typeConvertList[cul.xtypePick.Items[cul.xtypePick.SelectedIndex]];
                    string ytypeselect = SpecialUtil.typeConvertList[cul.ytypePick.Items[cul.ytypePick.SelectedIndex]];

                    newexe.culculateMethod = U.getMethodNameFromMark(cul.culcPick.Items[cul.culcPick.SelectedIndex]);
                    newexe.xtype           = xtypeselect;
                    newexe.ytype           = ytypeselect;

                    switch (xtypeselect)
                    {
                    case JAN.Type_Constant_Value:
                        newexe.xtarget = cul.xConstantEntry.Text;
                        break;

                    case JAN.Type_Input_Value:
                    case JAN.Type_Last_Culculate_Result_Value:
                        newexe.xtarget = cul.xstepPick.SelectedIndex.ToString();
                        break;
                    }

                    switch (ytypeselect)
                    {
                    case JAN.Type_Constant_Value:
                        newexe.ytarget = cul.yConstantEntry.Text;
                        break;

                    case JAN.Type_Input_Value:
                    case JAN.Type_Last_Culculate_Result_Value:
                        newexe.ytarget = cul.ystepPick.SelectedIndex.ToString();
                        break;

                    default: break;
                    }


                    newstepexelist.Add(newexe);
                }
                newstep.execute = newstepexelist;

                newstepList.Add(newstep);
            }

            var cj = new CulculateJsonModel();

            cj.formula = newstepList;

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(cj);

            UserCulculateModel um = new UserCulculateModel();

            um.Culculate   = json;
            um.Name        = "Special";
            um.DisplayName = common.nameEntry.Text;
            um.Index       = 0;
            UserCulculateUtil.insertUserCulculate(um);

            mypair.refreshEditList();

            mypair.DisplayAlert("確認", "新しい計算を作成しました。", "OK");
        }
Ejemplo n.º 6
0
        public async void onSave(object sender, EventArgs e)
        {
            var result = await mypair.DisplayAlert("確認", "計算を更新しますか?", "OK", "キャンセル");

            if (!result)
            {
                return;
            }
            if (!common.validate())
            {
                return;
            }

            var newstepList = new List <CulculateFormulaJsonModel>();

            foreach (var target in editList)
            {
                var newstep        = new CulculateFormulaJsonModel();
                var newstepexelist = new List <ExecuteJsonModel>();
                newstep.explain = target.explain.Text;


                if (target.final == null)
                {
                    newstep.last    = false;
                    newstep.execute = newstepexelist;
                    newstepList.Add(newstep);
                    continue;
                }

                newstep.last = target.final.IsToggled;

                foreach (CulcModel cul in target.culculates)
                {
                    var newexe = new ExecuteJsonModel();

                    string xtypeselect = SpecialUtil.typeConvertList[cul.xtypePick.Items[cul.xtypePick.SelectedIndex]];
                    string ytypeselect = SpecialUtil.typeConvertList[cul.ytypePick.Items[cul.ytypePick.SelectedIndex]];

                    newexe.culculateMethod = U.getMethodNameFromMark(cul.culcPick.Items[cul.culcPick.SelectedIndex]);
                    newexe.xtype           = xtypeselect;
                    newexe.ytype           = ytypeselect;

                    switch (xtypeselect)
                    {
                    case JAN.Type_Constant_Value:
                        newexe.xtarget = cul.xConstantEntry.Text;
                        break;

                    case JAN.Type_Input_Value:
                    case JAN.Type_Last_Culculate_Result_Value:
                        newexe.xtarget = cul.xstepPick.SelectedIndex.ToString();
                        break;
                    }

                    switch (ytypeselect)
                    {
                    case JAN.Type_Constant_Value:
                        newexe.ytarget = cul.yConstantEntry.Text;
                        break;

                    case JAN.Type_Input_Value:
                    case JAN.Type_Last_Culculate_Result_Value:
                        newexe.ytarget = cul.ystepPick.SelectedIndex.ToString();
                        break;
                    }

                    newstepexelist.Add(newexe);
                }
                newstep.execute = newstepexelist;

                newstepList.Add(newstep);
            }

            var cj = new CulculateJsonModel();

            cj.formula = newstepList;

            string json = JsonConvert.SerializeObject(cj);

            UserCulculateUtil.updateCulculateById(myUserCulculateModelTarget.Id, "Special", json, common.nameEntry.Text);

            mypair.refreshEditList();

            await mypair.DisplayAlert("確認", "更新が完了しました", "OK");
        }