/// <summary>
        /// 特殊ボタンが押された時に実行される
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public void OnSpecial(object sender, EventArgs e)
        {
            CurrentPage = Children.First(page => page == Cul);

            onButtonBorderClear();
            enterButton.Text = V.NEXT_MARK;

            S.selectSpecialClass = Type.GetType("MyCalculator." + ((Button)sender).Text);

            CulculateJsonModel cj = JsonConvert.DeserializeObject <CulculateJsonModel>(S.selectUserModel.Culculate);

            cj.formula.ForEach(fl => S.formulaQueue.Enqueue(fl));

            setResultDic((Dictionary <string, string>)
                         D.getDelegate(S.selectSpecialClass, "execute")
                         .DynamicInvoke(new object[] { S.formulaQueue.Dequeue() }));
        }
示例#2
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");
        }
示例#3
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");
        }