Example #1
0
 public override void setDimensions(Formulas formula, Dictionary<string, decimal> dimensions)
 {
     switch (formula)
     {
         case Formulas.Area:
             dimensions.TryGetValue("r", out r);
             break;
         case Formulas.Perimeter:
             dimensions.TryGetValue("d", out d);
             break;
         case Formulas.AreaPerimeter:
             dimensions.TryGetValue("r", out r);
             dimensions.TryGetValue("d", out d);
             break;
     }
 }
Example #2
0
    public static PuzzleControllerInterface[] puzzleControllers; // this holds the puzzle controllers

/*    // HAAAAAX. As in hacks :3
 *  public bool hack_Ulti_On;
 *  public bool hack_init_tutorials;
 *  public bool hack_init_everything;
 */
    // Use this for initialization
    void Awake()
    {
        if (instance == null) // check if instance already exists
        {
            instance = this;  // if not, set instance to this
        }

        else if (instance != this) // if instance already exists and is not this
        {
            Destroy(gameObject);   // then destroy it. enforcing singleton
        }

        playerAtkPuzSolved  = 0;
        playerDefPuzSolved  = 0;
        playerUltiPuzSolved = false;
        enemyAtkPuzSolved   = 0;
        enemyDefPuzSolved   = 0;
        currentActivePuzzle = 1;

        //    checkHacks(); // check if any hacks on, and update accordingly

        // go to player prefs to get skills equipped information,
        // and pass into function to turn the string into array of int to find puzzles equipped
        puzzles = new int[3];
        Formulas.StringToIntArray(PlayerPrefs.GetString("skillsEquipped"), puzzles);
        // get number of puzzles
        if (puzzles[2] == 0)
        {
            noOfPuzzles = 2;
        }
        else
        {
            noOfPuzzles = 3;
        }

        // Instantiate the puzzles we need
        InstantiatePuzzles();

        // get the stats UI manager script and set up the UI
        statsUIManagerScript = GetComponent <StatsUIManager>();
        statsUIManagerScript.Setup();

        gameManager = FindObjectOfType <GameManager>();

        // get the controllers of each puzzle
        GetControllers();
    }
Example #3
0
        public static double CalculateOGDto(RecipeDto recipe)
        {
            var og = 0.0;

            try
            {
                foreach (var fermentable in recipe.MashSteps.SelectMany(mashStep => mashStep.Fermentables.Where(f => f != null)))
                {
                    var efficency = recipe.Efficiency;
                    //if (fermentable.PPG <= 0)
                    //{
                    var esFermentable = _fermentableElasticsearch.GetSingle(fermentable.FermentableId);
                    if (esFermentable != null && esFermentable.PPG > 0)
                    {
                        fermentable.PPG = esFermentable.PPG;
                        if (esFermentable.Type.Contains("Extract") || esFermentable.Type.Contains("Sugar"))
                        {
                            efficency = 100;
                        }
                        //og += Formulas.MaltOG(fermentable.Amount, esFermentable.PPG, recipe.Efficiency, recipe.Volume);
                    }
                    else
                    {
                        var efFermentable = _fermentableRepository.GetSingle(fermentable.FermentableId);
                        if (efFermentable?.PPG != null)
                        {
                            fermentable.PPG = (int)efFermentable.PPG;
                            if (efFermentable.Type.Contains("Extract") || efFermentable.Type.Contains("Sugar"))
                            {
                                efficency = 100;
                            }
                        }
                        //og += Formulas.MaltOG(fermentable.Amount, (int)efFermentable.PPG, recipe.Efficiency, recipe.Volume);
                    }

                    //}
                    og += Formulas.MaltOG(fermentable.Amount, (int)fermentable.PPG, efficency, recipe.Volume);
                }
            }
            catch (Exception exception)
            {
                throw;
            }

            return(Math.Round(1 + og / 1000, 4));
        }
Example #4
0
        /// <summary>
        /// QuerySum+新增实体的查询逻辑
        /// </summary>
        /// <param name="countingNo"></param>
        /// <returns></returns>
        private QueryNode QuerySumForInsert(string countingNo, QueryNode queryScan)
        {
            List <QueryProperty> groupList      = new List <QueryProperty>();
            List <string>        paraStringList = GetSumAboutString();

            foreach (string paraStr in paraStringList)
            {
                groupList.Add(OOQL.CreateProperty("queryScan." + paraStr));
            }
            List <QueryProperty> selectList = new List <QueryProperty>();

            selectList.AddRange(groupList);
            selectList.Add(Formulas.Sum("queryScan.qty", "QTY"));
            QueryNode querySum = OOQL.Select(selectList.ToArray())
                                 .From(queryScan, "queryScan")
                                 .GroupBy(groupList.ToArray());

            #region  为新增COUNTING的字段进行查询
            List <QueryProperty> returnSelectList = new List <QueryProperty>();
            foreach (string paraStr in paraStringList)
            {
                returnSelectList.Add(OOQL.CreateProperty("querySum." + paraStr));
            }
            returnSelectList.Add(OOQL.CreateProperty("querySum.QTY"));
            returnSelectList.Add(OOQL.CreateProperty("ITEM.ITEM_NAME", "ITEM_DESCRIPTION"));
            returnSelectList.Add(OOQL.CreateProperty("ITEM.ITEM_SPECIFICATION"));
            returnSelectList.Add(Formulas.Cast(Formulas.Ext("UNIT_CONVERT", string.Empty, new object[] { OOQL.CreateProperty("querySum.ITEM_ID"),
                                                                                                         OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"),
                                                                                                         OOQL.CreateProperty("querySum.QTY"),
                                                                                                         OOQL.CreateProperty("ITEM.SECOND_UNIT_ID"),
                                                                                                         OOQL.CreateConstants(0) }), GeneralDBType.Decimal, 16, 6, "SECOND_QTY"));
            returnSelectList.Add(Formulas.IsNull(OOQL.CreateProperty("COUNTING_PLAN.PLAN_DATE"), OOQL.CreateConstants(DateTime.Now), "PLAN_DATE"));
            returnSelectList.Add(OOQL.CreateProperty("PLANT.COMPANY_ID"));
            returnSelectList.Add(Formulas.IsNull(OOQL.CreateProperty("COUNTING_PLAN.COUNTING_PLAN_ID"), OOQL.CreateConstants(Guid.NewGuid()), "COUNTING_PLAN_ID"));
            returnSelectList.Add(OOQL.CreateProperty("ITEM.STOCK_UNIT_ID"));
            returnSelectList.Add(OOQL.CreateProperty("COUNTING_PLAN.SequenceNumber"));
            #endregion
            return(OOQL.Select(returnSelectList.ToArray())
                   .From(querySum, "querySum")
                   .LeftJoin("COUNTING_PLAN", "COUNTING_PLAN")
                   .On(OOQL.CreateProperty("querySum.COUNTING_PLAN_ID") == OOQL.CreateProperty("COUNTING_PLAN.COUNTING_PLAN_ID"))
                   .InnerJoin("ITEM", "ITEM")
                   .On(OOQL.CreateProperty("querySum.ITEM_ID") == OOQL.CreateProperty("ITEM.ITEM_ID"))
                   .InnerJoin("PLANT", "PLANT")
                   .On(OOQL.CreateProperty("querySum.PLANT_ID") == OOQL.CreateProperty("PLANT.PLANT_ID")));
        }
Example #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            int n = 0;

            if (textBox2.Text.ToString() == textBox3.Text.ToString())
            {
                Formulas f = new Formulas();
                n           = f.PassDecode(textBox2.Text.ToString());
                Users[n, 0] = textBox1.Text.ToString();
                Users[n, 1] = textBox2.Text.ToString();
                MessageBox.Show("Account successfully created!", "success");
            }
            else
            {
                MessageBox.Show("Password does not match", "Unsuccesful");
            }
        }
Example #6
0
        /// <summary>
        /// 获取寄售订单数据
        /// </summary>
        /// <param name="siteNo">工厂</param>
        /// <param name="programJobNo">作业编号</param>
        /// <returns></returns>
        private DependencyObjectCollection GetSalesOrder(string siteNo, string programJobNo, DependencyObjectCollection condition)
        {
            QueryNode queryNode =
                OOQL.Select(true,
                            OOQL.CreateProperty("SALES_ORDER_DOC.DOC_NO", "doc_no"),
                            OOQL.CreateProperty("SALES_ORDER_DOC.DOC_DATE", "create_date"),
                            Formulas.IsNull(
                                OOQL.CreateProperty("CUSTOMER.CUSTOMER_NAME"),
                                OOQL.CreateConstants(string.Empty), "customer_name"),
                            OOQL.CreateConstants(programJobNo, "program_job_no"),
                            Formulas.IsNull(
                                OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"),
                                OOQL.CreateConstants(string.Empty), "employee_name"),
                            Formulas.IsNull(
                                OOQL.CreateProperty("SALES_CENTER.SALES_CENTER_CODE"),
                                OOQL.CreateConstants(string.Empty), "main_organization"))
                .From("SALES_ORDER_DOC", "SALES_ORDER_DOC")
                .InnerJoin("SALES_ORDER_DOC.SALES_ORDER_DOC_D", "SALES_ORDER_DOC_D")
                .On((OOQL.CreateProperty("SALES_ORDER_DOC_D.SALES_ORDER_DOC_ID") == OOQL.CreateProperty("SALES_ORDER_DOC.SALES_ORDER_DOC_ID")))
                .InnerJoin("SALES_ORDER_DOC.SALES_ORDER_DOC_D.SALES_ORDER_DOC_SD", "SALES_ORDER_DOC_SD")
                .On((OOQL.CreateProperty("SALES_ORDER_DOC_SD.SALES_ORDER_DOC_D_ID") == OOQL.CreateProperty("SALES_ORDER_DOC_D.SALES_ORDER_DOC_D_ID")))
                .InnerJoin("PLANT", "PLANT")
                .On((OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("SALES_ORDER_DOC_SD.DELIVERY_PARTNER_ID.ROid")))
                .InnerJoin("SALES_CENTER", "SALES_CENTER")
                .On((OOQL.CreateProperty("SALES_CENTER.SALES_CENTER_ID") == OOQL.CreateProperty("SALES_ORDER_DOC.Owner_Org.ROid")))
                .LeftJoin("CUSTOMER", "CUSTOMER")
                .On((OOQL.CreateProperty("CUSTOMER.CUSTOMER_ID") == OOQL.CreateProperty("SALES_ORDER_DOC.CUSTOMER_ID")))
                .LeftJoin("EMPLOYEE", "EMPLOYEE")
                .On((OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID") == OOQL.CreateProperty("SALES_ORDER_DOC.Owner_Emp")))
                .LeftJoin("ADMIN_UNIT", "ADMIN_UNIT")
                .On((OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_ID") == OOQL.CreateProperty("SALES_ORDER_DOC.Owner_Dept")));

            QueryConditionGroup group =
                ((OOQL.CreateProperty("SALES_ORDER_DOC.ApproveStatus") == OOQL.CreateConstants("Y"))
                 & (OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo))
                 & (OOQL.CreateProperty("SALES_ORDER_DOC.CATEGORY") == OOQL.CreateConstants("2B"))
                 & (OOQL.CreateProperty("SALES_ORDER_DOC.CLOSE") == OOQL.CreateConstants("0")));

            if (condition != null)
            {
                ConditionPropertyNameEntity conPropertyEntity = new ConditionPropertyNameEntity("SALES_ORDER_DOC.DOC_NO", "SALES_ORDER_DOC.DOC_DATE", new string[] { "1", "2", "3", "4", "6" });
                group = UtilsClass.CreateNewConditionByParameter(group, condition, conPropertyEntity);
            }
            queryNode = ((JoinOnNode)queryNode).Where(OOQL.AuthFilter("SALES_ORDER_DOC", "SALES_ORDER_DOC") & (group));
            return(GetService <IQueryService>().ExecuteDependencyObject(queryNode));
        }
Example #7
0
        public override string Solve()
        {
            var count = 0;

            for (int n = 1; n <= 100; n++)
            {
                for (int r = 1; r < n; r++)
                {
                    var result = Formulas.nCr(n, r);
                    if (result > 1000000)
                    {
                        count++;
                    }
                }
            }
            return(count.ToString());
        }
        /// <summary>
        /// 获取库存交易单查询信息
        /// </summary>
        /// <param name="siteNo">工厂编号</param>
        /// <param name="programJobNo">作业编号</param>
        /// <returns></returns>
        private QueryNode GetTransactionDocQueryNode(string siteNo, string programJobNo
                                                     , DependencyObjectCollection condition//20170328 add by wangyq for P001-170327001
                                                     )
        {
            QueryConditionGroup conditionGroup = (OOQL.AuthFilter("TRANSACTION_DOC", "TRANSACTION_DOC")) &
                                                 (((OOQL.CreateProperty("TRANSACTION_DOC.CATEGORY") == OOQL.CreateConstants("11")) &
                                                   (OOQL.CreateProperty("TRANSACTION_DOC.ApproveStatus") == OOQL.CreateConstants("N")) &
                                                   (OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo))));

            if (programJobNo == "11")
            {
                //箱条码
                conditionGroup &= (OOQL.CreateProperty("TRANSACTION_DOC.STOCK_ACTION") == OOQL.CreateConstants(-1));
            }
            else if (programJobNo == "12")
            {
                //单据条码
                conditionGroup &= (OOQL.CreateProperty("TRANSACTION_DOC.STOCK_ACTION") == OOQL.CreateConstants(1));
            }
            QueryNode queryNode =
                OOQL.Select(true,
                            OOQL.CreateProperty("TRANSACTION_DOC.DOC_NO", "doc_no"),
                            OOQL.CreateProperty("TRANSACTION_DOC.DOC_DATE", "create_date"),
                            Formulas.IsNull(OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_NAME"), OOQL.CreateConstants(string.Empty), "customer_name"),
                            OOQL.CreateProperty("PLANT.PLANT_CODE", "main_organization"),
                            OOQL.CreateConstants(programJobNo, "program_job_no"),
                            Formulas.IsNull(OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"), OOQL.CreateConstants(string.Empty), "employee_name"))
                .From("TRANSACTION_DOC", "TRANSACTION_DOC")
                .InnerJoin("PLANT", "PLANT")
                .On(OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("TRANSACTION_DOC.Owner_Org.ROid"))
                .LeftJoin("ADMIN_UNIT", "ADMIN_UNIT")
                .On(OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_ID") == OOQL.CreateProperty("TRANSACTION_DOC.Owner_Dept"))
                .LeftJoin("EMPLOYEE", "EMPLOYEE")
                .On(OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID") == OOQL.CreateProperty("TRANSACTION_DOC.Owner_Emp"));

            //.Where(conditionGroup);//20170328 mark by wangyq for P001-170327001
            //20170328 add by wangyq for P001-170327001  ================begin==============
            if (condition != null)
            {
                ConditionPropertyNameEntity conPropertyEntity = new ConditionPropertyNameEntity("TRANSACTION_DOC.DOC_NO", "TRANSACTION_DOC.DOC_DATE", new string[] { "1", "2", "3", "4" });
                conditionGroup = UtilsClass.CreateNewConditionByParameter(conditionGroup, condition, conPropertyEntity);
            }
            queryNode = ((JoinOnNode)queryNode).Where(conditionGroup);
            //20170328 add by wangyq for P001-170327001  ================end==============
            return(queryNode);
        }
Example #9
0
        public Molecule GetFormula(String peptide)
        {
            var formula = new StringBuilder();

            foreach (var ch in peptide)
            {
                String aaFormula;
                if (!Formulas.TryGetValue(ch, out aaFormula))
                {
                    // TODO: error
                    continue;
                }
                formula.Append(aaFormula);
            }
            formula.Append("H2O");
            return(Molecule.Parse(formula.ToString()));
        }
Example #10
0
        private void FillAllData(List <double> dataItems)
        {
            variationRow = new VariationRow(dataItems);

            FillVariationTable(variationRow);
            DrawEmpericalChart(variationRow.Variants);

            lblStegesClassesCount.Text = Formulas.GetNumberOfClasses(dataItems.Count).ToString();
            nudIntervalsCount.Value    = Formulas.GetNumberOfClasses(variationRow.DataCount);

            iVariationRow = new IntervalVariationRow(variationRow, (int)nudIntervalsCount.Value);

            FillIntervalVariationTable(iVariationRow);
            DrawHistogram(iVariationRow, dataItems);

            FillCharacteristicsGrid(dataItems, dgvCharacteristics);
        }
Example #11
0
    // Almacenamos en el archivo ejercicio json un ejercicio de una determinada familia
    public void CrearEjercicio(Formulas formula, string familia)
    {
        Formulas ejercicio = new Formulas();


        foreach (Formula form in formula.listaFormulas)
        {
            if (form.grupoFormula == familia)
            {
                ejercicio.listaFormulas.Add(form);
            }
        }

        //Escribimos de nuevo en el fichero los elementos del inventario
        jsonString = JsonUtility.ToJson(ejercicio);
        File.WriteAllText(filePathEjercicio, jsonString);
    }
Example #12
0
        static void Main(string[] args)
        {
            var attacker = CharacterFactory.GetCharacter <AngryMagebird>();
            var defender = CharacterFactory.GetCharacter <AngryMagebird>();

            attacker.Name = "Angry MageBird";
            defender.Name = "Angry OracleBird";

            if (Formulas.Chance(25))
            {
                attacker.AddBuff(new RingOfFlames());
            }
            if (Formulas.Chance(25))
            {
                attacker.AddBuff(new LuckyPants());
            }
            if (Formulas.Chance(25))
            {
                defender.AddBuff(new RingOfFlames());
            }
            if (Formulas.Chance(25))
            {
                defender.AddBuff(new LuckyPants());
            }

            var ui = new ConsoleInterface();

            ui.ShowMessage("Now for the main event of the night, here comes our first combatant");
            ui.ShowFullStats(attacker);
            ui.ShowMessage("Now, his opponent, the magnificent, the greatest");
            ui.ShowFullStats(defender);

            var battle = new Battle(ui, attacker, defender);
            var result = battle.RunBattle();

            ui.ShowMessage("");
            ui.ShowMessage("----- BATTLE IS OVER ----");
            ui.ShowMessage("WINNER: " + result.Winner.Name);
            ui.ShowHealth(result.Winner);
            ui.ShowMessage("");
            ui.ShowMessage("LOOSER: " + result.Looser.Name);
            ui.ShowHealth(result.Looser);

            Console.ReadKey();
        }
        /// <summary>
        /// Инициализация по базовой формуле
        /// </summary>
        /// <param name="baseFormula">Базовая формула</param>
        public void Init(string baseFormula)
        {
            if (string.IsNullOrEmpty(baseFormula))
            {
                return;
            }

            BaseFormula = baseFormula;
            Formulas.Clear();

            //разделение сложной формулы на простые
            SplitFormula();

            //составление комбинаций
            MakeAllPermutation();

            isInit = true;
        }
Example #14
0
        public static IList <FormulaParameter> getAllowedParameter(Formulas p_formula)
        {
            IList <FormulaParameter> formulaParameter;

            switch (p_formula)
            {
            case Formulas.DATE:
                formulaParameter = new List <FormulaParameter>();
                formulaParameter.Add(FormulaParameter.YEAR);
                formulaParameter.Add(FormulaParameter.MONTH);
                formulaParameter.Add(FormulaParameter.DAY);
                break;

            default:
                throw new ArgumentOutOfRangeException("p_formula");
            }
            return(formulaParameter);
        }
    private void SetRoute()
    {
        if (_goingToPosition != null && _movingToDirection == Direction.NONE)
        {
            _movingToDirection = MapPosition.GetDirection(_goingToPosition);
            var timeToMove = (float)Formulas.GetTimeToMoveBetweenTwoTiles(Speed);

            SetDestination(new Vector3(_goingToPosition.X * 16, _goingToPosition.Y * 16, 0), timeToMove / 1000);
            Debug.Log("Moving Player To " + _goingToPosition.X + " - " + _goingToPosition.Y);

            SpriteSheets.ForEach(e => e.Direction = _movingToDirection);
            SpriteSheets.ForEach(e => e.Moving    = true);

            MapPosition.X    = _goingToPosition.X;
            MapPosition.Y    = _goingToPosition.Y;
            _goingToPosition = null;
        }
    }
Example #16
0
        public override bool TranslateFunction()
        {
            var  exp     = (SpreadsheetParser.NFuncContext)Fexp;
            bool success = true;
            var  args    = exp.oneArg();

            var arg1     = args.exp();
            var formula1 = Formulas.TranslateFormula(arg1, CellIndex, out bool successFormula);

            success &= successFormula;

            if (success)
            {
                var node1 = formula1.Node;
                Node = new AbstractNFuncNode(this, node1);
            }
            return(success);
        }
Example #17
0
        private async void SearchHandler(object param)
        {
            Formulas.Clear();

            var textBox     = param as TextBox;
            var searchQuery = textBox.Text;

            var formulas = await _context.Formulas
                           .Where(p => p.Name.Contains(searchQuery))
                           .ToListAsync();

            foreach (var formula in formulas)
            {
                Formulas.Add(formula.ToDomain());
            }

            RaisePropertyChanged("Formulas");
        }
Example #18
0
        public double Run(string path1 = null, string path2 = null)
        {
            var wirePath1 = path1 == null ? Wire1Paths : ParsePaths(path1);
            var wirePath2 = path2 == null ? Wire2Paths : ParsePaths(path2);

            var(path1Lines, path2Lines) = GetLines(wirePath1, wirePath2);

            var resquery =
                from linea in path1Lines
                from lineb in path2Lines
                let intersection = linea.Intersects(lineb)
                                   where intersection.intersects && intersection.point != new Point()
                                   select Formulas.Manhattan(new Point(), intersection.point);

            var res = resquery.Min();

            return(res);
        }
        /// <summary>
        /// 利用临时表关联实体表进行批量新增条码交易明细
        /// </summary>
        /// <param name="qrySrv"></param>
        /// <param name="tmpBCLine"></param>
        private void InsertBCLine(IQueryService qrySrv, IDataEntityType tmpIssueReceiptD)
        {
            #region properties
            List <QueryProperty> selectListPro = new List <QueryProperty>();

            selectListPro.Add(Formulas.NewId("BC_LINE_ID"));                                            //主键
            selectListPro.Add(OOQL.CreateProperty("TmpTable.barcode_no", "BARCODE_NO"));                //条码CODE
            selectListPro.Add(OOQL.CreateConstants("SALES_ISSUE.SALES_ISSUE_D", "SOURCE_ID.RTK"));      //来源单据类型
            selectListPro.Add(OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_D_ID", "SOURCE_ID.ROid")); //来源单据
            selectListPro.Add(Formulas.Ext("UNIT_CONVERT", "QTY", new object[] { OOQL.CreateProperty("ITEM.ITEM_ID")
                                                                                 , OOQL.CreateProperty("UNIT.UNIT_ID")
                                                                                 , OOQL.CreateProperty("TmpTable.sum_picking_qty")
                                                                                 , OOQL.CreateProperty("ITEM.STOCK_UNIT_ID")
                                                                                 , OOQL.CreateConstants(0) }));                                                //数量
            selectListPro.Add(Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue()), "WAREHOUSE_ID")); //仓库
            selectListPro.Add(Formulas.IsNull(Formulas.Case(null, OOQL.CreateProperty("BIN.BIN_ID"), new CaseItem[] {
                new CaseItem(OOQL.CreateProperty("TmpTable.storage_spaces_no") == OOQL.CreateConstants(string.Empty)
                             , OOQL.CreateConstants(Maths.GuidDefaultValue()))
            }), OOQL.CreateConstants(Maths.GuidDefaultValue()), "BIN_ID"));      //库位

            #endregion

            QueryNode groupNode  = GetGroupForInsert(tmpIssueReceiptD);
            QueryNode insertNode = OOQL.Select(selectListPro.ToArray())
                                   .From(groupNode, "TmpTable")
                                   .InnerJoin("SALES_ISSUE", "SALES_ISSUE")
                                   .On(OOQL.CreateProperty("TmpTable.doc_no") == OOQL.CreateProperty("SALES_ISSUE.DOC_NO"))
                                   .InnerJoin("SALES_ISSUE.SALES_ISSUE_D", "SALES_ISSUE_D")
                                   .On(OOQL.CreateProperty("TmpTable.seq") == OOQL.CreateProperty("SALES_ISSUE_D.SequenceNumber")
                                       & OOQL.CreateProperty("SALES_ISSUE.SALES_ISSUE_ID") == OOQL.CreateProperty("SALES_ISSUE_D.SALES_ISSUE_ID"))
                                   .InnerJoin("ITEM", "ITEM")
                                   .On(OOQL.CreateProperty("TmpTable.item_no") == OOQL.CreateProperty("ITEM.ITEM_CODE"))
                                   .InnerJoin("UNIT", "UNIT")
                                   .On(OOQL.CreateProperty("TmpTable.picking_unit_no") == OOQL.CreateProperty("UNIT.UNIT_CODE"))
                                   .LeftJoin("WAREHOUSE", "WAREHOUSE")
                                   .On(OOQL.CreateProperty("TmpTable.warehouse_no") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE")
                                       & OOQL.CreateProperty("SALES_ISSUE.Owner_Org.ROid") == OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid"))
                                   .LeftJoin("WAREHOUSE.BIN", "BIN")
                                   .On(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID") == OOQL.CreateProperty("BIN.WAREHOUSE_ID")
                                       & OOQL.CreateProperty("TmpTable.storage_spaces_no") == OOQL.CreateProperty("BIN.BIN_CODE"))
                                   .Where(OOQL.CreateProperty("TmpTable.barcode_no") != OOQL.CreateConstants(String.Empty));

            InsertBcLineDB(insertNode, qrySrv);
        }
        public QueryNode GetMOListNode(string siteNo, string programJobNo
                                       , DependencyObjectCollection condition)
        {
            QueryNode node = OOQL.Select(OOQL.CreateProperty("MO.DOC_NO", "doc_no"),
                                         OOQL.CreateProperty("MO.DOC_DATE", "create_date"),
                                         OOQL.CreateProperty("WORK_CENTER.WORK_CENTER_NAME", "customer_name"),
                                         OOQL.CreateConstants(programJobNo, GeneralDBType.String, "program_job_no"),
                                         Formulas.IsNull(OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"), OOQL.CreateConstants(string.Empty), "employee_name"),
                                         OOQL.CreateProperty("PLANT.PLANT_CODE", "main_organization")
                                         )
                             .From("MO", "MO")
                             .InnerJoin("PLANT")
                             .On(OOQL.CreateProperty("MO.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID"))
                             .InnerJoin("ITEM")
                             .On(OOQL.CreateProperty("MO.ITEM_ID") == OOQL.CreateProperty("ITEM.ITEM_ID"))
                             .LeftJoin("ITEM.ITEM_FEATURE", "ITEM_FEATURE")
                             .On(OOQL.CreateProperty("MO.ITEM_FEATURE_ID") == OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID"))
                             .LeftJoin("UNIT")
                             .On(OOQL.CreateProperty("MO.BUSINESS_UNIT_ID") == OOQL.CreateProperty("UNIT.UNIT_ID"))
                             .LeftJoin("WORK_CENTER")
                             .On(OOQL.CreateProperty("MO.SOURCE_ID.RTK") == OOQL.CreateConstants("WORK_CENTER")
                                 & OOQL.CreateProperty("MO.SOURCE_ID.ROid") == OOQL.CreateProperty("WORK_CENTER.WORK_CENTER_ID"))
                             .LeftJoin("ADMIN_UNIT")
                             .On(OOQL.CreateProperty("MO.Owner_Dept") == OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_ID"))
                             .LeftJoin("EMPLOYEE")
                             .On(OOQL.CreateProperty("MO.Owner_Emp") == OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID"));

            QueryConditionGroup group =
                (OOQL.CreateProperty("MO.ApproveStatus") == OOQL.CreateConstants("Y")
                 & OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo)
                 & OOQL.CreateProperty("MO.STATUS").NotIn(OOQL.CreateConstants("Y", GeneralDBType.String), OOQL.CreateConstants("y", GeneralDBType.String))
                 & OOQL.CreateProperty("MO.RECEIPT_REQ_CONTROL") == OOQL.CreateConstants(false)
                );

            if (condition != null && condition.Count > 0)
            {
                ConditionPropertyNameEntity conPropertyEntity = new ConditionPropertyNameEntity("MO.DOC_NO", "MO.DOC_DATE", new string[] { "1", "2", "3", "4" });
                group = UtilsClass.CreateNewConditionByParameter(group, condition, conPropertyEntity);
            }

            node = ((JoinOnNode)node).Where(OOQL.AuthFilter("MO", "MO") & (group));

            return(node);
        }
Example #21
0
        /// <summary>
        /// 获取销退单通知
        /// </summary>
        /// <param name="siteNo">工厂编号</param>
        /// <param name="programJobNo">作业编号</param>
        /// <returns></returns>
        private QueryNode GetSalesReturnListQueryNode(string siteNo, string programJobNo
                                                      , DependencyObjectCollection condition//20170328 add by wangyq for P001-170327001
                                                      )
        {
            QueryNode queryNode =
                OOQL.Select(true,
                            OOQL.CreateProperty("SALES_CENTER.SALES_CENTER_CODE", "main_organization"),
                            OOQL.CreateProperty("SALES_RETURN.DOC_NO", "doc_no"),
                            OOQL.CreateProperty("SALES_RETURN.DOC_DATE", "create_date"),
                            OOQL.CreateProperty("CUSTOMER.CUSTOMER_NAME", "customer_name"),
                            OOQL.CreateConstants(programJobNo, "program_job_no"),
                            Formulas.IsNull(OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"), OOQL.CreateConstants(string.Empty), "employee_name"))
                .From("SALES_RETURN", "SALES_RETURN")
                .InnerJoin("PLANT", "PLANT")
                .On(OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("SALES_RETURN.PLANT_ID"))
                .InnerJoin("SALES_CENTER", "SALES_CENTER")
                .On(OOQL.CreateProperty("SALES_CENTER.SALES_CENTER_ID") == OOQL.CreateProperty("SALES_RETURN.Owner_Org.ROid"))
                .InnerJoin("CUSTOMER", "CUSTOMER")
                .On(OOQL.CreateProperty("CUSTOMER.CUSTOMER_ID") == OOQL.CreateProperty("SALES_RETURN.CUSTOMER_ID"))
                .LeftJoin("EMPLOYEE", "EMPLOYEE")
                .On(OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID") == OOQL.CreateProperty("SALES_RETURN.Owner_Emp"))
                //20170328 add by wangyq for P001-170327001  ================begin==============
                .LeftJoin("ADMIN_UNIT", "ADMIN_UNIT")
                .On(OOQL.CreateProperty("SALES_RETURN.Owner_Dept") == OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_ID"));
            //20170328 add by wangyq for P001-170327001  ================end==============
            //.Where(//20170328 mark by wangyq for P001-170327001
            QueryConditionGroup group =   //20170328 add by wangyq for P001-170327001
                                        OOQL.CreateProperty("SALES_RETURN.CATEGORY") == OOQL.CreateConstants("26") &
                                        OOQL.CreateProperty("SALES_RETURN.ApproveStatus") == OOQL.CreateConstants("Y") &
                                        OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo) &
                                        OOQL.CreateProperty("SALES_RETURN.RECEIPTED_STATUS").In(OOQL.CreateConstants("1"), OOQL.CreateConstants("2"));

            //);//20170328 mark by wangyq for P001-170327001

            //20170328 add by wangyq for P001-170327001  ================begin==============
            if (condition != null)
            {
                ConditionPropertyNameEntity conPropertyEntity = new ConditionPropertyNameEntity("SALES_RETURN.DOC_NO", "SALES_RETURN.DOC_DATE", new string[] { "1", "2", "3", "4", "6" });
                group = UtilsClass.CreateNewConditionByParameter(group, condition, conPropertyEntity);
            }
            queryNode = ((JoinOnNode)queryNode).Where(OOQL.AuthFilter("SALES_RETURN", "SALES_RETURN") & (group));
            //20170328 add by wangyq for P001-170327001  ================end==============
            return(queryNode);
        }
Example #22
0
    public void PerformAttackAnimation(LivingEntityBehaviour target, int damage)
    {
        var atkSpeedDelay = Formulas.GetTimeBetweenAttacks(Entity.AtkSpeed);

        SpriteSheets.ForEach(e => e.SetDirection(Entity.Position.GetDirection(target.Entity.Position)));

        SpriteSheets.ForEach(e =>
        {
            e.SetAnimation(SpriteAnimations.ATTACKING, atkSpeedDelay);
        });

        // Make a animation callback to display the hit in a cool moment
        SpriteSheets[0].SetAnimationFrameCallback(AttackAnimation.HIT_FRAME, () =>
        {
            Debug.Log("TARGET: " + target.name);
            Debug.Log("ATKER:" + this.name);

            AnimationFactory.BuildAndInstantiate(new AnimationOpts()
            {
                AnimationImageName = DefaultAssets.ANM_BLOOD,
                MapPosition        = target.Entity.Position
            });

            var unityPosition = target.Entity.Position.ToUnityPosition();
            TextFactory.BuildAndInstantiate <DamageText>(new TextOptions()
            {
                UnityX    = unityPosition.x + 8,
                UnityY    = unityPosition.y + 18,
                Text      = damage.ToString(),
                TextColor = Color.red,
                Size      = 7
            });

            target.Entity.HP -= damage;
            if (target.Entity.HP <= 0 || WilLDie)
            {
                target.Die();
            }
            else
            {
                target.HealthBar?.SetLife(target.Entity.HP, target.Entity.MAXHP);
            }
        });
    }
Example #23
0
    private void ManageTime()
    {
        time += timeTicks;

        if (vel > 0)
        {
            ownTime += timeTicks * Formulas.GetGamma(vel);
        }
        else if (vel < 0)
        {
            ownTime += timeTicks / Formulas.GetGamma(vel);
        }
        else
        {
            ownTime += timeTicks;
        }

        //rv.timeText.text = "t = " + (time).ToString("F1") + " / " + "t' = " + (ownTime).ToString("F1");
    }
 public override string[] getDimensionLabels(Formulas formula)
 {
     string[] dimensions;
     switch (formula)
     {
         case Formulas.Area:
             dimensions = new string[] { "b", "h" };
             break;
         case Formulas.Perimeter:
             dimensions = new string[] { "a", "b", "c" };
             break;
         case Formulas.AreaPerimeter:
             dimensions = new string[] { "a", "b", "c", "h" };
             break;
         default:
             throw new ArgumentException("Tried to get the dimension labels for a formula that does not exist.");
     }
     return dimensions;
 }
Example #25
0
        public IntervalVariationRow(VariationRow variationRow, int intervalsCount)
        {
            vr = variationRow;
            h  = Formulas.GetStep(variationRow, intervalsCount);

            var beginInterval = variationRow.Variants.First().Value - h / 2;

            while (beginInterval < variationRow.Variants.Last().Value)
            {
                double endInterval       = beginInterval + h;
                double frequency         = 0;
                double relativeFrequency = 0;
                double empericalFunction = 0;

                for (int i = 0; i < variationRow.Variants.Count; i++)
                {
                    if (variationRow.Variants[i].Value >= beginInterval && variationRow.Variants[i].Value < endInterval)
                    {
                        frequency         += variationRow.Variants[i].Frequency;
                        relativeFrequency += variationRow.Variants[i].RelativeFrequency;
                    }
                }

                double cumFreq = relativeFrequency;
                if (IntervalVariants.Count > 0)
                {
                    cumFreq += IntervalVariants.Last().CummulatedFrequenct;
                }

                empericalFunction = cumFreq;

                IntervalVariants.Add(new IntervalVariant
                {
                    Interval            = new Tuple <double, double>(beginInterval, beginInterval + h),
                    Frequency           = frequency,
                    RelativeFrequency   = relativeFrequency,
                    CummulatedFrequenct = cumFreq,
                    EmpericalFunction   = empericalFunction
                });

                beginInterval += h;
            }
        }
        //20170619 add by zhangcn for B001-170629006 ===begin===
        private QueryNode GetFilArrivalQueryNode()
        {
            QueryNode node = OOQL.Select(Formulas.Sum("FIL_ARRIVAL_D.ACTUAL_QTY", "AQTY"),
                                         OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_NO", "ORDER_NO"),
                                         OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_SE", "ORDER_SE"),
                                         OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_SE_SE", "ORDER_SE_SE")
                                         )
                             .From("FIL_ARRIVAL.FIL_ARRIVAL_D", "FIL_ARRIVAL_D")
                             .InnerJoin("FIL_ARRIVAL", "FIL_ARRIVAL")
                             .On(OOQL.CreateProperty("FIL_ARRIVAL_D.FIL_ARRIVAL_ID") ==
                                 OOQL.CreateProperty("FIL_ARRIVAL.FIL_ARRIVAL_ID"))
                             .Where(OOQL.CreateProperty("FIL_ARRIVAL.STATUS") == OOQL.CreateConstants("2") &
                                    OOQL.CreateProperty("FIL_ARRIVAL_D.STATUS") == OOQL.CreateConstants("N"))
                             .GroupBy(OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_NO"),
                                      OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_SE"),
                                      OOQL.CreateProperty("FIL_ARRIVAL_D.ORDER_SE_SE"));

            return(node);
        }
Example #27
0
        public static void TryAttacking(this LivingEntity attacker, LivingEntity defender, bool singleHit = false)
        {
            if (attacker.Position.GetDistance(defender.Position) > 1)
            {
                Log.Info("Entity tryed to attack other entity being too far away");
                return;
            }
            if (defender.HP <= 0 || attacker.HP < 0)
            {
                return;
            }
            var now = GameThread.TIME_MS_NOW;

            if (now < attacker.NextAttackAt)
            {
                var timeToFinishCd = attacker.NextAttackAt - now;
                if (!singleHit)
                {
                    RescheduleAttack(attacker, defender, timeToFinishCd);
                }
                return;
            }
            if (attacker.AttackTaskId != null)
            {
                GameScheduler.CancelTask(attacker.AttackTaskId);
            }
            var attackDelay = Formulas.GetTimeBetweenAttacks(attacker.AtkSpeed);

            attacker.NextAttackAt = now + attackDelay;

            Log.Debug(attacker.Name + " Attacking " + defender.Name);
            Server.Events.Call(new EntityAttackEvent()
            {
                Attacker = attacker,
                Defender = defender
            });

            if (!singleHit)
            {
                RescheduleAttack(attacker, defender, attackDelay);
            }
        }
        private QueryNode GetTransferReqListNode(string siteNo, string programJobNo
                                                 , DependencyObjectCollection condition//20170328 add by wangyq for P001-170327001
                                                 )
        {
            QueryNode node = OOQL.Select(true,//20170104 add by wangyq for P001-161215001
                                         OOQL.CreateProperty("TRANSFER_REQUISITION.DOC_NO", "doc_no"),
                                         OOQL.CreateProperty("TRANSFER_REQUISITION.DOC_DATE", "create_date"),
                                         Formulas.IsNull(OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_NAME"), OOQL.CreateConstants(string.Empty), "customer_name"),
                                         OOQL.CreateConstants(programJobNo, "program_job_no"),
                                         Formulas.IsNull(
                                             OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"),
                                             OOQL.CreateConstants(string.Empty), "employee_name"),
                                         OOQL.CreateProperty("PLANT.PLANT_CODE", "main_organization"))
                             .From("TRANSFER_REQUISITION", "TRANSFER_REQUISITION")
                             .InnerJoin("PLANT", "PLANT")
                             .On((OOQL.CreateProperty("TRANSFER_REQUISITION.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID")))
                             .LeftJoin("ADMIN_UNIT")
                             .On((OOQL.CreateProperty("TRANSFER_REQUISITION.Owner_Dept") == OOQL.CreateProperty("ADMIN_UNIT.ADMIN_UNIT_ID")))
                             .LeftJoin("EMPLOYEE", "EMPLOYEE")
                             .On((OOQL.CreateProperty("TRANSFER_REQUISITION.Owner_Emp") == OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID")))
                             //20170104 add by wangyq for P001-161215001  ================begin=====================
                             .LeftJoin("TRANSFER_REQUISITION.TRANSFER_REQUISITION_D", "TRANSFER_REQUISITION_D")
                             .On(OOQL.CreateProperty("TRANSFER_REQUISITION.TRANSFER_REQUISITION_ID") == OOQL.CreateProperty("TRANSFER_REQUISITION_D.TRANSFER_REQUISITION_ID"));
            //20170104 add by wangyq for P001-161215001  ================end=====================
            //.Where((OOQL.AuthFilter("TRANSFER_REQUISITION", "TRANSFER_REQUISITION")) & //20170328 mark by wangyq for P001-170327001
            QueryConditionGroup group =//20170328 add by wangyq for P001-170327001
                                        (OOQL.CreateProperty("TRANSFER_REQUISITION.ApproveStatus") == OOQL.CreateConstants("Y")
                                         & OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo)
                                         & OOQL.CreateProperty("TRANSFER_REQUISITION_D.CLOSE") == OOQL.CreateConstants("0", GeneralDBType.String)//20170104 add by wangyq for P001-161215001
                                        );

            //);//20170328 mark by wangyq for P001-170327001
            //20170328 add by wangyq for P001-170327001  ================begin==============
            if (condition != null)
            {
                ConditionPropertyNameEntity conPropertyEntity = new ConditionPropertyNameEntity("TRANSFER_REQUISITION.DOC_NO", "TRANSFER_REQUISITION.DOC_DATE", new string[] { "1", "2", "3", "4" });
                group = UtilsClass.CreateNewConditionByParameter(group, condition, conPropertyEntity);
            }
            node = ((JoinOnNode)node).Where(OOQL.AuthFilter("TRANSFER_REQUISITION", "TRANSFER_REQUISITION") & (group));
            //20170328 add by wangyq for P001-170327001  ================end==============
            return(node);
        }
Example #29
0
    public void setPositionGrid(Vector3[] positions, byte[] obstacleGrid)
    {
        _obstacleGrid = obstacleGrid;
        _positions    = new Vector3[positions.Length];

        for (int i = 0; i < positions.Length; i++)
        {
            _positions [i] = Formulas.getPositionInMap(positions [i]);
            if (_obstacleGrid [i] == Pathfinder.WALKABLE_CELL)
            {
                _maxPossiblePositions++;
            }
        }

        updateObstacleGridWithTowers();

        SpawnPoint target = SpawnTable.getInstance().getTargetSpawns() [0];

        _maxPossiblePositions += target.getBounds().Count;
    }
 public ActionResult AddNewFormula(Formulas formulas)
 {
     if (formulas != null)
     {
         try
         {
             testsService.InsertFormula(formulas);
         }
         catch (Exception e)
         {
             Program.Logger.Error(e);
             return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while creating new formula"))));
         }
         return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS)));
     }
     else
     {
         return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper formula details"))));
     }
 }
Example #31
0
        public void CalculateGainModerate()
        {
            ClientInformation clientInfo = new ClientInformation();

            clientInfo.ActivityRate      = 1.375;
            clientInfo.AverageWeightInKg = Formulas.LbtoKg(198);
            clientInfo.BodyFatPercentage = 0.15;
            clientInfo.Goal = new Goal
            {
                Intensity = GoalIntensityType.Moderate,
                Type      = GoalType.Gain
            };

            Assert.AreEqual(Math.Round(clientInfo.AverageWeightInKg), 90);

            var leanBodyMass                        = Formulas.LeanBodyMass(clientInfo.AverageWeightInKg, clientInfo.BodyFatPercentage);
            var basalMetabolicRate                  = Formulas.KatchMcArdle(leanBodyMass);
            var totalDailyEnergyExpenditure         = Formulas.CalculateTDEE(clientInfo.ActivityRate, basalMetabolicRate);
            var adjustedTotalDailyEnergyExpenditure = totalDailyEnergyExpenditure + clientInfo.Goal.AdjustBasedOnGoal(clientInfo.AverageWeightInKg);
        }
Example #32
0
        public override EffectResult OnStart(L2Character caster, L2Character target)
        {
            if (!_tempSuccess)
            {
                return(Nothing);
            }

            //double shieldDef = Formulas.checkShieldDef(caster, target);
            double damage = Formulas.GetPhysSkillHitDamage(caster, target, _power);

            caster.SendPacket(new SystemMessage(SystemMessage.SystemMessageId.C1HasGivenC2DamageOfS3).AddPlayerName(caster.Name).AddString(target.Name).AddNumber(damage));
            if (target is L2Player)
            {
                target.SendPacket(new SystemMessage(SystemMessage.SystemMessageId.C1HasReceivedS3DamageFromC2).AddPlayerName(target.Name).AddPlayerName(caster.Name).AddNumber(damage));
            }

            target.ReduceHp(caster, damage);

            return(Nothing);
        }
 public override void setDimensions(Formulas formula, Dictionary<string, decimal> dimensions)
 {
     switch (formula)
     {
         case Formulas.Area:
             dimensions.TryGetValue("b", out b);
             dimensions.TryGetValue("h", out h);
             break;
         case Formulas.Perimeter:
             dimensions.TryGetValue("a", out a);
             dimensions.TryGetValue("b", out b);
             dimensions.TryGetValue("c", out c);
             break;
         case Formulas.AreaPerimeter:
             dimensions.TryGetValue("a", out a);
             dimensions.TryGetValue("b", out b);
             dimensions.TryGetValue("c", out c);
             dimensions.TryGetValue("h", out h);
             break;
     }
 }
Example #34
0
 public override string[] getDimensionLabels(Formulas formula)
 {
     // To make it easier on myself, we will only accept r for the area and
     // d for the permimeter, even though it technically doesn't matter.
     string[] dimensions;
     switch (formula)
     {
         case Formulas.Area:
             dimensions = new string[] { "r" };
             break;
         case Formulas.Perimeter:
             dimensions = new string[] { "d" };
             break;
         case Formulas.AreaPerimeter:
             dimensions = new string[] { "r", "d" };
             break;
         default:
             throw new ArgumentException("Tried to get the dimension labels for a formula that does not exist.");
     }
     return dimensions;
 }
Example #35
0
 public abstract void setDimensions(Formulas formula, Dictionary<string, decimal> dimensions);
Example #36
0
 public abstract string[] getDimensionLabels(Formulas formula);
 public override void setDimensions(Formulas formula, Dictionary<string, decimal> dimensions)
 {
     dimensions.TryGetValue("l", out l);
     dimensions.TryGetValue("w", out w);
 }
 public override string[] getDimensionLabels(Formulas formula)
 {
     string[] dimensions = new string[] { "l", "w" };
     return dimensions;
 }
Example #39
0
 public override void setDimensions(Formulas formula, Dictionary<string, decimal> dimensions)
 {
     dimensions.TryGetValue("b", out b);
     dimensions.TryGetValue("h", out h);
 }
Example #40
0
 public override string[] getDimensionLabels(Formulas formula)
 {
     // we always need b and h
     string[] dimensions = new string[] { "b", "h" };
     return dimensions;
 }
Example #41
0
 /// <summary>
 /// Initialisation with formula is needed for sharp rendering and computing original coordinates.
 /// </summary>
 public virtual void Init(Formulas formula)
 {
     this.formula = formula;
 }
        /// <summary>
        /// Initialisation with formula is needed for computing original coordinates.
        /// </summary>
        public override void Init(Formulas formula)
        {
            base.Init(formula);
            // Original data has to scale such that values fits into float range.
            Vec3 minPoint = new Vec3(0, 0, 0);
            Vec3 maxPoint = new Vec3(0, 0, 0);
            minPoint.X = Double.MaxValue;
            minPoint.Y = Double.MaxValue;
            minPoint.Z = Double.MaxValue;
            maxPoint.X = Double.MinValue;
            maxPoint.Y = Double.MinValue;
            maxPoint.Z = Double.MinValue;
            for (int i = 0; i < pData.Width; i++)
            {
                for (int j = 0; j < pData.Height; j++)
                {
                    PixelInfo pInfo = pData.Points[i, j];
                    if (pInfo != null)
                    {
                        Vec3 coord = formula.GetTransform(pInfo.Coord.X, pInfo.Coord.Y, pInfo.Coord.Z);
                        if (coord.X < minPoint.X)
                            minPoint.X = coord.X;
                        if (coord.Y < minPoint.Y)
                            minPoint.Y = coord.Y;
                        if (coord.Z < minPoint.Z)
                            minPoint.Z = coord.Z;
                        if (coord.X > maxPoint.X)
                            maxPoint.X = coord.X;
                        if (coord.Y > maxPoint.Y)
                            maxPoint.Y = coord.Y;
                        if (coord.Z > maxPoint.Z)
                            maxPoint.Z = coord.Z;
                    }
                }
            }
            Vec3 center = new Vec3(0, 0, 0);
            center.X = (maxPoint.X + minPoint.X) / 2.0;
            center.Y = (maxPoint.Y + minPoint.Y) / 2.0;
            center.Z = (maxPoint.Z + minPoint.Z) / 2.0;
            double radius = maxPoint.X - minPoint.X + maxPoint.Y - minPoint.Y + maxPoint.Z - minPoint.Z;

            for (int i = 0; i < pData.Width; i++)
            {
                for (int j = 0; j < pData.Height; j++)
                {
                    PixelInfo pInfo = pData.Points[i, j];
                    if (pInfo != null)
                    {
                        FloatPixelInfo floatPixelInfo = new FloatPixelInfo();
                        floatPixelInfo.Coord.X = (float)((pInfo.Coord.X - center.X) / radius);
                        floatPixelInfo.Coord.Y = (float)((pInfo.Coord.Y - center.Y) / radius);
                        floatPixelInfo.Coord.Z = (float)((pInfo.Coord.Z - center.Z) / radius);
                        floatPixelInfo.AdditionalInfo = pInfo.AdditionalInfo;
                        floatPixelInfo.IsInside = pInfo.IsInside;

                        pInfo.Normal.Normalize();

                        floatPixelInfo.Normal.X = (float)pInfo.Normal.X;
                        floatPixelInfo.Normal.Y = (float)pInfo.Normal.Y;
                        floatPixelInfo.Normal.Z = (float)pInfo.Normal.Z;
                        _pictureData.Points[i, j] = floatPixelInfo;
                    }
                }
            }
        }
        private void UpdateUi()
        {
            /***********************************************
             * This method updates the UI to match the user's
             * Shape and Formula selection.
             ***********************************************/

            // TODO: This seems like an awkward place to update the current Shape/Formula...
            currentShape = GetSelectedShape();
            currentFormula = GetSelectedFormula();

            picShape.Image = currentShape.getImage();

            // Update input Labels/TextBoxes
            string[] requiredDimensions = currentShape.getDimensionLabels(currentFormula);
            int numberOfRequiredInputs = requiredDimensions.Length;

            for (int inputNumber = 0; inputNumber < NumberOfInputs; inputNumber++)
            {
                if (inputNumber < numberOfRequiredInputs)
                {
                    // Prepare the Labels/TextBoxes we will need for the selected formula(s).
                    inputLabels[inputNumber].Text = requiredDimensions[inputNumber];
                    inputLabels[inputNumber].Visible = true;
                    inputTextBoxes[inputNumber].Clear();
                    inputTextBoxes[inputNumber].Visible = true;
                }
                else
                {
                    // Hide the Labels/TextBoxes that we don't need.
                    inputLabels[inputNumber].Text = "";
                    // We don't need to make the Label invisible, but I will do it anyways.
                    inputLabels[inputNumber].Visible = false;
                    inputTextBoxes[inputNumber].Clear();
                    inputTextBoxes[inputNumber].Visible = false;
                }
            }

            // Update formula outputs
            switch (currentFormula)
            {
                case Formulas.Area:
                    lblArea.Visible = true;
                    txtArea.Clear();
                    txtArea.Visible = true;
                    lblAreaFormula.Text = currentShape.getAreaFormulaString();
                    lblAreaFormula.Visible = true;
                    lblPerimeter.Visible = false;
                    txtPerimeter.Clear();
                    txtPerimeter.Visible = false;
                    lblPerimeterFormula.Visible = false;
                    break;
                case Formulas.Perimeter:
                    lblArea.Visible = false;
                    txtArea.Clear();
                    txtArea.Visible = false;
                    lblAreaFormula.Visible = false;
                    lblPerimeter.Visible = true;
                    txtPerimeter.Clear();
                    txtPerimeter.Visible = true;
                    lblPerimeterFormula.Text = currentShape.getPerimeterForumulaString();
                    lblPerimeterFormula.Visible = true;
                    break;
                case Formulas.AreaPerimeter:
                    lblArea.Visible = true;
                    txtArea.Clear();
                    txtArea.Visible = true;
                    lblAreaFormula.Text = currentShape.getAreaFormulaString();
                    lblAreaFormula.Visible = true;
                    lblPerimeter.Visible = true;
                    txtPerimeter.Clear();
                    txtPerimeter.Visible = true;
                    lblPerimeterFormula.Text = currentShape.getPerimeterForumulaString();
                    lblPerimeterFormula.Visible = true;
                    break;
            }
        }