void delete()
        {
            List <UserCulculateModel> usrs = UserCulculateUtil.getAllUserCulculate();

            foreach (UserCulculateModel usr in usrs)
            {
                UserCulculateUtil.deleteCulculateById(usr.Id);
            }
        }
        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);
            }
        }
 /// <summary>
 /// 作成画面を更新モードで開きます
 /// </summary>
 /// <param name="target">Target.</param>
 public void updateCulculate(int target)
 {
     CreateCul.Content = new UpdateMode().updateTable(this, UserCulculateUtil.getUserCulculateById(target));
     CurrentPage       = Children.First(page => page == CreateCul);
 }
Exemple #4
0
        public TableView createTable(MyCalculatorPage pair)
        {
            myPair = pair;

            var table = new TableView()
            {
                RowHeight = 70
            };

            table.BackgroundColor = Color.FromHex("#F8F8F8");
            table.Intent          = TableIntent.Settings;

            var lists = new List <ViewCell>();

            List <UserCulculateModel> ul = UserCulculateUtil.getAllUserCulculate();

            foreach (UserCulculateModel u in ul)
            {
                var layout = new StackLayout {
                    Style = CreateListStyles.cellLayoutStyle
                };

                layout.Children.Add(new Label
                {
                    Text  = u.DisplayName,
                    Style = CreateListStyles.cellLabelStyle
                });

                var deleteBtn = new Button {
                    Style        = CreateListStyles.deleteButtonStyle,
                    AutomationId = u.Id.ToString()
                };

                deleteBtn.Clicked += async(sender, args) =>
                {
                    var result = await myPair.DisplayAlert("確認", "選択した計算を削除しますか?", "OK", "キャンセル");

                    if (result)
                    {
                        UserCulculateUtil.deleteCulculateById(u.Id);
                        myPair.refreshEditList();
                    }
                };

                var updateBtn = new Button
                {
                    Style        = CreateListStyles.editButtonStyle,
                    AutomationId = u.Id.ToString()
                };

                updateBtn.Clicked += (sender, args) => { myPair.updateCulculate(u.Id); };

                layout.Children.Add(updateBtn);
                layout.Children.Add(deleteBtn);

                var cell = new ViewCell {
                    View = layout, AutomationId = u.Id.ToString()
                };


                cell.Tapped += (sender, args) =>
                {
                    S.InitParameter();
                    S.selectUserModel = UserCulculateUtil.getUserCulculateById(u.Id);
                    myPair.OnSpecial(new Button {
                        Text = u.Name
                    }, args);
                };


                lists.Add(cell);
            }

            table.Root.Add(new TableRoot {
                new TableSection("マイ計算リスト")
                {
                    lists
                }
            });

            return(table);
        }
Exemple #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");
        }
Exemple #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");
        }