void setup()
        {
            if (UserCulculateUtil.getAllUserCulculate().Count == 0)
            {
                UserCulculateModel u = new UserCulculateModel();

                u.DisplayName = "円の面積";
                u.Name        = "Special";
                u.Culculate   = "{\"formula\":[{\"explain\":\"半径を入力して下さい\",\"execute\":[],\"last\":false},{\"explain\":\"円の面積を計算しました\",\"execute\":[{\"xtype\":\"input_value\",\"xtarget\":\"0\",\"ytype\":\"input_value\",\"ytarget\":\"0\",\"culculateMethod\":\"multiplication\"},{\"xtype\":\"previous_culculate_result_value\",\"xtarget\":null,\"ytype\":\"constant_value\",\"ytarget\":\"3.14\",\"culculateMethod\":\"multiplication\"}],\"last\":true}]}";

                UserCulculateUtil.insertUserCulculate(u);
            }
        }
Exemple #2
0
        /// <summary>
        /// 各種共通で扱う静的変数を初期化します
        /// </summary>
        public static void InitParameter()
        {
            //最初の式フラグを戻します
            firstFormula = true;
            //式のキューをリセットします
            formulaQueue.Clear();
            //選択したクラスをリセットします
            selectSpecialClass = null;
            //計算の途中結果をスタックするディクショナリをクリアします
            stackDictionary.Clear();
            //最終式フラグを戻します
            finalFlag = false;
            //選択したユーザモデルをクリアします
            selectUserModel = null;

            inputValue.Clear();
            inputFormula.Clear();
        }
Exemple #3
0
        public static bool insertUserCulculate(UserCulculateModel um)
        {
            SQLiteConnection db = null;

            try
            {
                db = new SQLiteConnection(S.dbPath);

                db.Insert(um);

                db.Commit();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return(false);
            }
            finally
            {
                db.Close();
            }

            return(true);
        }
Exemple #4
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");
        }
Exemple #5
0
        public ScrollView updateTable(MyCalculatorPage pair, UserCulculateModel target)
        {
            var culcModel = JsonConvert.DeserializeObject <CulculateJsonModel>(target.Culculate);

            mypair = pair;
            myUserCulculateModelTarget = target;

            common = new ModeCommon(formulaList, editList, baseContentLayout, mypair);

            var baseContent    = new ScrollView();
            var formula1layout = new StackLayout {
                Style = EditorStyles.stepContentLayoutStyle
            };


            baseContentLayout.Children.Add(common.createHelpContent());
            baseContentLayout.Children.Add(common.createNameContent(target.DisplayName));

            editList.Add(new EditorBaseModel());
            formula1layout.Children.Add(common.createFormulaTitleContent());
            formula1layout.Children.Add(common.createExplainContent(culcModel.formula[0]));
            baseContentLayout.Children.Add(formula1layout);
            formulaList.Add(formula1layout);

            var layout = new StackLayout {
                Style = EditorStyles.baseContentLayoutStyle
            };

            layout.Children.Add(baseContentLayout);
            layout.Children.Add(createUpdateButton());

            baseContent = new ScrollView {
                Style = EditorStyles.baseContentStyle, Content = layout
            };


            foreach (CulculateFormulaJsonModel model in culcModel.formula)
            {
                if (culcModel.formula[0].Equals(model))
                {
                    continue;
                }


                var nextsteplayout = new StackLayout {
                    Style = EditorStyles.stepContentLayoutStyle
                };

                formulaList.Add(nextsteplayout);

                editList.Add(new EditorBaseModel());

                editList.Last().culculates = new List <CulcModel>();

                formulaList.Last().Children.Add(common.createFormulaTitleContent());
                formulaList.Last().Children.Add(common.createExplainContent(model));
                formulaList.Last().Children.Add(common.createLastContent(model));

                baseContentLayout.Children.Add(nextsteplayout);

                foreach (ExecuteJsonModel exec in model.execute)
                {
                    formulaList.Last().Children.Add(
                        common.createCulculateContent(
                            exec, formulaList.IndexOf(formulaList.Last())
                            )
                        );
                }

                formulaList.Last().Children.Add(common.createEditButtonContent(false));
            }
            formulaList.Last().Children.Remove(formulaList.Last().Children.Last());
            formulaList.Last().Children.Add(common.createEditButtonContent(true));

            return(baseContent);
        }