Beispiel #1
0
    static void Main(string[] args)
    {
        Console.WriteLine(Maths.VALUE);

        Maths maths = new Maths(902);
        Console.WriteLine(maths.MAX);
          //  maths.MAX = 29;
    }
    public void Initialize()
    {
      // Create a visitable Class
      Maths mathVisitable = new Maths();
      visitThese[Strings.maths] = mathVisitable;

      // Populate the Environment
      Environment[Strings.var1] = 5;
      Environment[Strings.var2] = 3;
    }
        public QuestionsPage()
        {
            this.InitializeComponent();
            subject = new SubjectViewModel();
            correct_answer = new English();
            maths = new Maths();
            business = new Business();
            accounting = new Accounting();
            geography = new Geography();
            history = new History();
            life = new Life();
            physics = new Physics();
            time.Start();

        }
Beispiel #4
0
        public String Output(string jparameters, List<CategoryViewModel> jCategory, int GroupID, int ItemID, string MathString, bool PowOpen)
        {
            CalculationCSharp.Areas.Configuration.Models.ConfigFunctions Config = new CalculationCSharp.Areas.Configuration.Models.ConfigFunctions();
            string formula = null;
            Maths Maths = new Maths();
            Maths parameters = (Maths)javaScriptSerializ­er.Deserialize(jparameters, typeof(Maths));
            dynamic InputA = Config.VariableReplace(jCategory, parameters.Input1, GroupID, ItemID);
            dynamic InputB = Config.VariableReplace(jCategory, parameters.Input2, GroupID, ItemID);
            string Bracket1 = Convert.ToString(parameters.Bracket1);
            string Input1 = Convert.ToString(InputA);
            string Logic = Convert.ToString(parameters.Logic);
            string Input2 = Convert.ToString(InputB);
            string Bracket2 = Convert.ToString(parameters.Bracket2);
            string Logic2 = Convert.ToString(parameters.Logic2);

            if (Logic == "Pow")
            {
                formula = Logic + '(' + Input1 + ',' + Input2 + ')';
            }
            else
            {
                formula = Input1 + Logic + Input2;
            }
            string MathString1;
            if (Logic2 == "Pow")
            {
                MathString1 = string.Concat(Logic2, "(", MathString, Bracket1, formula, Bracket2, ",");
            }
            else
            {
                MathString1 = string.Concat(MathString, Bracket1, formula, Bracket2, Logic2);
            }
            if (Logic2 != "Pow" && PowOpen == true)
            {
                MathString1 = string.Concat(MathString1, ")");
            }
            return MathString1;
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new rounded rectangle shaped sub-path with varying radii for each corner.
        /// </summary>
        public static void RoundedRectVarying(this Nvg nvg, Rectangle <float> rect, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft)
        {
            if (radTopLeft < 0.1f && radTopRight < 0.1f && radBottomRight < 0.1f && radBottomLeft < 0.1f)
            {
                Rect(nvg, rect);
            }
            else
            {
                InstructionQueue queue = nvg.instructionQueue;

                float            factor = 1 - KAPPA90;
                Vector2D <float> half   = Vector2D.Abs(rect.Size) * 0.5f;
                Vector2D <float> rBL    = new(MathF.Min(radBottomLeft, half.X) * Maths.Sign(rect.Size.X), MathF.Min(radBottomLeft, half.Y) * Maths.Sign(rect.Size.Y));
                Vector2D <float> rBR    = new(MathF.Min(radBottomRight, half.X) * Maths.Sign(rect.Size.X), MathF.Min(radBottomRight, half.Y) * Maths.Sign(rect.Size.Y));
                Vector2D <float> rTR    = new(MathF.Min(radTopRight, half.X) * Maths.Sign(rect.Size.X), MathF.Min(radTopRight, half.Y) * Maths.Sign(rect.Size.Y));
                Vector2D <float> rTL    = new(MathF.Min(radTopLeft, half.X) * Maths.Sign(rect.Size.X), MathF.Min(radTopLeft, half.Y) * Maths.Sign(rect.Size.Y));
                queue.AddMoveTo(new(rect.Origin.X, rect.Origin.Y + rTL.Y));
                queue.AddLineTo(new(rect.Origin.X, rect.Origin.Y + rect.Size.Y - rBL.Y));
                queue.AddBezierTo(
                    new(rect.Origin.X, rect.Origin.Y + rect.Size.Y - rBL.Y * factor),
                    new(rect.Origin.X + rBL.X * factor, rect.Origin.Y + rect.Size.Y),
                    new(rect.Origin.X + rBL.X, rect.Origin.Y + rect.Size.Y)
                    );
                queue.AddLineTo(new(rect.Origin.X + rect.Size.X - rBR.X, rect.Origin.Y + rect.Size.Y));
                queue.AddBezierTo(
                    new(rect.Origin.X + rect.Size.X - rBR.X * factor, rect.Origin.Y + rect.Size.Y),
                    new(rect.Origin.X + rect.Size.X, rect.Origin.Y + rect.Size.Y - rBR.Y * factor),
                    new(rect.Origin.X + rect.Size.X, rect.Origin.Y + rect.Size.Y - rBR.Y)
                    );
                queue.AddLineTo(new(rect.Origin.X + rect.Size.X, rect.Origin.Y + rTR.Y));
                queue.AddBezierTo(
                    new(rect.Origin.X + rect.Size.X, rect.Origin.Y + rTR.Y * factor),
                    new(rect.Origin.X + rect.Size.X - rTR.X * factor, rect.Origin.Y),
                    new(rect.Origin.X + rect.Size.X - rTR.X, rect.Origin.Y)
                    );
                queue.AddLineTo(new(rect.Origin.X + rTL.X, rect.Origin.Y));
                queue.AddBezierTo(
                    new(rect.Origin.X + rTL.X * factor, rect.Origin.Y),
                    new(rect.Origin.X, rect.Origin.Y + rTL.Y * factor),
                    new(rect.Origin.X, rect.Origin.Y + rTL.Y)
                    );
                queue.AddClose();
            }
        }
Beispiel #6
0
 /// <summary>
 /// Implements the logarithmic stretch algorithm.
 /// </summary>
 /// <param name="x">Brightness</param>
 /// <param name="mu">Filter brightness</param>
 /// <param name="s">Shadows</param>
 /// <param name="l">Highlights</param>
 /// <returns>float precision floating point number</returns>
 public static float LogStretch(float x, float mu, float s, float l)
 {
     return(Intensity.LogPow(x, Maths.Range(Intensity.log05 / (float)Math.Log(mu), s, l)));
 }
Beispiel #7
0
 /// <summary>
 /// Returns the value of the wavelet function.
 /// </summary>
 /// <param name="x">Argument</param>
 /// <returns>Function</returns>
 public Complex32 Wavelet(float x)
 {
     return(Math.Pow(Maths.Pi * fb, -0.5) * Maths.Exp(2 * Maths.Pi * Maths.I * fc * x) * Math.Exp(-(x * x) / fb));
 }
Beispiel #8
0
        void RenderEntityList(Shader shader, RenderPass pass, List <BatchedEntity> list, VoxelObject commonVO = null)
        {
            // Pre-load mesh
            Mesh mesh = null;

            if (commonVO != null)
            {
                mesh = PrepareVO(commonVO, pass);
                if (mesh == null)
                {
                    return;
                }
            }

            // Go through batch
            foreach (BatchedEntity ent in list)
            {
                if (ent.OnlyRenderFor.HasValue && !ent.OnlyRenderFor.Value.HasFlag(pass))
                {
                    continue;
                }

                // Load mesh if were not using a common vo
                if (commonVO == null)
                {
                    mesh = PrepareVO(ent.VoxelObject, pass);
                    if (mesh == null)
                    {
                        continue;
                    }
                }

                // Determine the world matrix
                Matrix4 worldMatrix = ent.CustomMatrix
                                      ?? Maths.CreateTransformationMatrix(ent.Position, ent.MeshRotation, ent.VoxelObject.MeshScale);
                shader.LoadMatrix4("transformationMatrix", worldMatrix);

                // Prepare the entity
                //if (ent.RenderFront && pass != RenderPass.Shadow) StateManager.DepthFunc(DepthFunction.Always);
                //else StateManager.DepthFunc(DepthFunction.Less);

                StateManager.ToggleWireframe(ent.RenderAsWireframe);

                if (!pass.HasFlag(RenderPass.Shadow))
                {
                    shader.LoadBool("skipLight", ent.ApplyNoLighting);
                    shader.LoadColor4("colorOverlay", ent.ColorOverlay);
                    shader.LoadFloat("entityLighting", 1f);
                }

                // Render the entity
                GL.DrawElements(mesh.BeginMode, mesh.VertexCount, DrawElementsType.UnsignedInt, IntPtr.Zero);

                // If we're not using a common vo, end it's mesh
                if (commonVO == null)
                {
                    Master.EndMesh();
                }
            }

            // If we are using a common vo, end it's mesh last
            if (commonVO != null)
            {
                Master.EndMesh();
            }
        }
Beispiel #9
0
        public override bool Draw(out IModelPoint mp, out IModel fmodel, out IModel smodel)
        {
            List <ushort> list2 = new List <ushort>();

            base.Draw(out mp, out fmodel, out smodel);
            try
            {
                double[] vtxs;
                int      num3;
                if ((this._route != null) && (this._route.Count != 0))
                {
                    vtxs = this._pipeSection.GetVtxs();
                    int[] index = new int[1];
                    if (base.NewEmptyModel(index, RenderType.Texture, new string[] { this._tcName }, out fmodel))
                    {
                        int[] numArray4 = new int[1];
                        if (base.NewEmptyModel(numArray4, RenderType.Color, new uint[] { this._color }, out smodel))
                        {
                            goto Label_0093;
                        }
                    }
                }
                return(false);

Label_0093:
                num3 = 0;
                int num4 = 0;
                foreach (List <Vector> list3 in this._route)
                {
                    int           num2;
                    List <Vector> list     = list3;
                    double[]      numArray = new double[list.Count];
                    int           num      = 0;
                    while (num < list.Count)
                    {
                        if (num == 0)
                        {
                            numArray[num] = 0.0;
                        }
                        else
                        {
                            numArray[num] = (list[num] - list[num - 1]).Length + numArray[num - 1];
                        }
                        num++;
                    }
                    IDrawPrimitive primitive = fmodel.GetGroup(0).GetPrimitive(0);
                    num = 0;
                    while (num < list.Count)
                    {
                        Vector vector;
                        Vector vector2;
                        Vector vector3;
                        if (num == 0)
                        {
                            vector = list[num + 1] - list[num];
                        }
                        else if (num == (list.Count - 1))
                        {
                            vector = list[num] - list[num - 1];
                        }
                        else
                        {
                            vector = ((list[num] - list[num - 1])).UnitVector() + ((list[num + 1] - list[num])).UnitVector();
                        }
                        Maths.GenerateComplementBasis(vector, out vector2, out vector3);
                        num2 = 0;
                        while (num2 <= this._pipeSection.SegCount)
                        {
                            Vector vector5 = (((vtxs[num2 * 4] - this._pipeSection.OffsetX) * vector2) + ((vtxs[(num2 * 4) + 1] - this._pipeSection.OffsetY) * vector3)).UnitVector();
                            Vector vector4 = list[num] + ((Vector)((vtxs[num2 * 4] * vector2) + (vtxs[(num2 * 4) + 1] * vector3)));
                            primitive.VertexArray.Append((float)vector4.X);
                            primitive.VertexArray.Append((float)vector4.Y);
                            primitive.VertexArray.Append((float)vector4.Z);
                            list2.Add((ushort)((primitive.VertexArray.Length / 3) - 1));
                            primitive.TexcoordArray.Append((float)(numArray[num] / (3.1415926535897931 * this._pipeSection.Diameter)));
                            primitive.TexcoordArray.Append((num2 * 1f) / ((float)this._pipeSection.SegCount));
                            primitive.NormalArray.Append((float)vector5.X);
                            primitive.NormalArray.Append((float)vector5.Y);
                            primitive.NormalArray.Append((float)vector5.Z);
                            num2++;
                        }
                        num++;
                    }
                    for (num = 0; num < (list.Count - 1); num++)
                    {
                        for (num2 = 0; num2 < this._pipeSection.SegCount; num2++)
                        {
                            primitive.IndexArray.Append((ushort)(num3 + list2[(num * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[((num + 1) * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(num * (this._pipeSection.SegCount + 1)) + num2]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[((num * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                            primitive.IndexArray.Append((ushort)(num3 + list2[(((num + 1) * (this._pipeSection.SegCount + 1)) + num2) + 1]));
                        }
                    }
                    IDrawPrimitive primitive2 = smodel.GetGroup(0).GetPrimitive(0);
                    primitive2.PrimitiveMode = gviPrimitiveMode.gviPrimitiveModeLineList;
                    for (int i = 0; i < (list.Count - 1); i++)
                    {
                        Vector vector6 = list[i];
                        Vector vector7 = list[i + 1];
                        primitive2.VertexArray.Append((float)vector6.X);
                        primitive2.VertexArray.Append((float)vector6.Y);
                        primitive2.VertexArray.Append((float)vector6.Z);
                        primitive2.IndexArray.Append((ushort)(num4 + (i * 2)));
                        primitive2.VertexArray.Append((float)vector7.X);
                        primitive2.VertexArray.Append((float)vector7.Y);
                        primitive2.VertexArray.Append((float)vector7.Z);
                        primitive2.IndexArray.Append((ushort)((num4 + (i * 2)) + 1));
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(1f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(0f);
                        primitive2.NormalArray.Append(1f);
                    }
                    num3 += list.Count * (this._pipeSection.SegCount + 1);
                    num4 += list.Count;
                }
                fmodel.AddGroup(smodel.GetGroup(0));
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
        void Spawn()
        {
            if (SpawnDelayTimer.IsDone || IsFirstSpawn)
            {
                // Increase the spawn delay every 5 waves
                if (WaveNr % 5 == 0)
                {
                    SpawnDelayTimer.TimeInMS += SPAWN_DELAY_INCREASE;
                }
                // Reset the spawn delay timer
                SpawnDelayTimer.Reset();

                if (WaveNr < 60 && !IsFirstSpawn)
                {
                    WaveNr++;
                    WaveNrSB.Remove(0, WaveNrSB.Length);
                    WaveNrSB.Append(WaveNr);
                    SpawnClearBonus();
                    NBombWasUsedThisWave = false;
                }
                IsFirstSpawn = false;

                #region Clean Gun and Enemy Pools
                CleanGunPools();
                StraightEnemyPool.CleanUp();
                SuiciderEnemyPool.CleanUp();
                ZigZagEnemyPool.CleanUp();
                ItemEnemyPool.CleanUp();
                DualMissile45Pool.CleanUp();
                BombardEnemyPool.CleanUp();
                #endregion

                #region Interest
                bool InterestWasReturned = false;
                foreach (Player p in Players)
                {
                    for (int i = 0; i < p.Interests.Count; i++)
                    {
                        p.Interests[i]--;
                        if (p.Interests[i] == 0)
                        {
                            p.Score += (int)(10000 * Maths.RandomNr(115, 130) / (float)100);
                            p.Interests.RemoveAt(i);
                            i--;
                            InterestWasReturned = true;
                        }
                    }
                }
                if (InterestWasReturned)
                {
                    Engine.Instance.Audio.PlaySound(AudioConstants.CoinDrop);
                }
                #endregion

                int spawnNr = Maths.RandomNr(1, 7 + WaveNr / 2);
                // Regular
                if (WaveNr <= 5 && spawnNr < 5)
                {
                    spawnNr = 5;
                }
                for (int i = 0; i < spawnNr; i++)
                {
                    StraightEnemy se = StraightEnemyPool.New();
                    se.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 64), Maths.RandomNr(-512, -57)));
                    Entities.Add(se);
                }

                // Scrapstation
                if (ActiveScrapStation == null && WaveNr >= 12 && (Maths.Chance(10) || (ItemEnemy.LastWaveSpawn <= (WaveNr - 10))))
                {
                    SpawnScrapStation();
                }

                // Side
                if (WaveNr >= 10)
                {
                    spawnNr = Maths.RandomNr(0, (WaveNr / 10) + 1);
                    for (int i = 0; i < spawnNr; i++)
                    {
                        SideEnemy se = SideEnemyPool.New();
                        se.Initialize();
                        Entities.Add(se);
                    }
                }

                // Suicide
                if (WaveNr >= 20)
                {
                    spawnNr = Maths.RandomNr(0, (WaveNr / 3) - 5);
                    if (spawnNr > 7)
                    {
                        spawnNr = 7;
                    }
                    for (int i = 0; i < spawnNr; i++)
                    {
                        SuiciderEnemy se = SuiciderEnemyPool.New();
                        se.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 35), Maths.RandomNr(-512, -64)));
                        Entities.Add(se);
                    }
                }

                // Bombard
                if (WaveNr / 3 > 5)
                {
                    spawnNr = Maths.RandomNr(0, (WaveNr / 3) - 5);
                    for (int i = 0; i < spawnNr; i++)
                    {
                        BombardEnemy be = BombardEnemyPool.New();
                        be.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 60), Maths.RandomNr(-512, -64)));
                        Entities.Add(be);
                    }
                }

                // 45/M45 Missile
                if (WaveNr / 2 > 3)
                {
                    spawnNr = Maths.RandomNr(0, -3 + WaveNr / 2);
                    for (int i = 0; i < spawnNr; i++)
                    {
                        Dual45Enemy de45 = Dual45EnemyPool.New();
                        de45.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 43), Maths.RandomNr(-512, -64)));
                        Entities.Add(de45);
                    }
                }

                // Item enemy
                for (int i = 0; i < 3; i++)
                {
                    if (Maths.Chance(5))
                    {
                        ItemEnemy.LastWaveSpawn = WaveNr;
                        ItemEnemy ie = ItemEnemyPool.New();
                        ie.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 48), Maths.RandomNr(-512, -112)));
                        Entities.Add(ie);
                    }
                }

                // Zigzag
                if (WaveNr / 2 > 3)
                {
                    spawnNr = Maths.RandomNr(0, -3 + WaveNr / 2);
                    for (int i = 0; i < spawnNr; i++)
                    {
                        ZigZagEnemy zze = ZigZagEnemyPool.New();
                        zze.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 57), Maths.RandomNr(-256, -64)));
                        Entities.Add(zze);
                    }
                }
            }
        }
 public void RootSquaredIsOriginalNumber(double number)
 {
     Assert.AreEqual(Maths.Sqrroot(number) * Maths.Sqrroot(number), number, 1e-15);
 }
Beispiel #12
0
 public int Mul(Maths obj)
 {
     return obj.Number1 * obj.Number2;
 }
Beispiel #13
0
        public override void OnPressAction()
        {
            if (ammo > 0 && duck != null)
            {
                duck.immobilized   = true;
                duck.remoteControl = true;
                sprite._frame      = 1;


                float cx = base.x;
                float cy = base.y;
                Graphics.flashAdd = 1.3f;
                Layer.Game.darken = 1.3f;
                if (base.isServerForObject)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        float      dir   = (float)i * 18f - 5f + Rando.Float(10f);
                        ATShrapnel shrap = new ATShrapnel();
                        shrap.range = 60f + Rando.Float(18f);
                        Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                        bullet.firedFrom = this;
                        this.firedBullets.Add(bullet);
                        Level.Add(bullet);
                    }
                    System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f);
                    foreach (Window w in windows)
                    {
                        if (Level.CheckLine <Block>(this.position, w.position, w) == null)
                        {
                            w.Destroy(new DTImpact(this));
                        }
                    }
                    this.bulletFireIndex += 20;
                    if (Network.isActive)
                    {
                        NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false);
                        Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null);
                        this.firedBullets.Clear();
                    }
                }
            }
            else
            {
                SFX.Play("click");
            }
        }
        /// <summary>
        /// 查询到货单查询信息
        /// </summary>
        /// <param name="programJobNo">作业编号</param>
        /// <param name="siteNo">工厂编号</param>
        /// <param name="docNo">单据编号</param>
        /// <param name="status"></param>
        /// <returns></returns>
        private QueryNode GetTransactionDocQueryNode(string programJobNo, string siteNo, string[] docNo, string status)    //20161216 modi by shenbao for P001-161215001 修改docNo类型为数组
        {
            string    docType   = programJobNo + status;
            QueryNode queryNode =
                OOQL.Select(OOQL.CreateProperty("TRANSACTION_DOC.DOC_NO", "source_no"),
                            OOQL.CreateProperty("TRANSACTION_DOC.DOC_DATE", "create_date"),
                            OOQL.CreateProperty("TRANSACTION_DOC_D.BUSINESS_QTY", "doc_qty"),
                            OOQL.CreateConstants(0m, GeneralDBType.Decimal, "in_out_qty"),
                            Formulas.Cast(OOQL.CreateProperty("TRANSACTION_DOC_D.SequenceNumber"), GeneralDBType.Decimal, "seq"),
                            OOQL.CreateProperty("PLANT.PLANT_CODE", "site_no"),
                            OOQL.CreateProperty("PLANT.PLANT_CODE", "main_organization"),
                            Formulas.IsNull(OOQL.CreateProperty("ITEM.ITEM_CODE"), OOQL.CreateConstants(string.Empty), "item_no"),
                            Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_CODE"), OOQL.CreateConstants(string.Empty), "item_feature_no"),
                            Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_SPECIFICATION"), OOQL.CreateConstants(string.Empty), "item_feature_name"),
                            Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"), OOQL.CreateConstants(string.Empty), "warehouse_no"),
                            Formulas.IsNull(OOQL.CreateProperty("BIN.BIN_CODE"), OOQL.CreateConstants(string.Empty), "storage_spaces_no"),
                            Formulas.IsNull(OOQL.CreateProperty("ITEM_LOT.LOT_CODE"), OOQL.CreateConstants(string.Empty), "lot_no"),
                            Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_CODE"), OOQL.CreateConstants(string.Empty), "unit_no"),
                            OOQL.CreateConstants("99", "enterprise_no"),
                            OOQL.CreateConstants(programJobNo, "source_operation"),
                            OOQL.CreateConstants(docType, "doc_type"),
                            OOQL.CreateConstants(0m, GeneralDBType.Decimal, "doc_line_seq"),
                            OOQL.CreateConstants(0m, GeneralDBType.Decimal, "doc_batch_seq"),
                            OOQL.CreateConstants(string.Empty, "object_no"),
                                                                                                                                              //20161216 add by shenbao FOR P001-161215001 ===begin===
                            Formulas.IsNull(OOQL.CreateProperty("ITEM.ITEM_NAME"), OOQL.CreateConstants(string.Empty), "item_name"),          //品名
                            Formulas.IsNull(OOQL.CreateProperty("ITEM.ITEM_SPECIFICATION"), OOQL.CreateConstants(string.Empty), "item_spec"), //规格
                            Formulas.IsNull(Formulas.Case(null, OOQL.CreateConstants("1"), new CaseItem[] {
                new CaseItem(OOQL.CreateProperty("ITEM_PLANT.LOT_CONTROL") == OOQL.CreateConstants("N")
                             , OOQL.CreateConstants("2"))
            }), OOQL.CreateConstants(string.Empty), "lot_control_type"),  //批号管控方式
                            OOQL.CreateConstants(0, "allow_error_rate"),  //允许误差率
                            Formulas.Ext("UNIT_CONVERT_02", "conversion_rate_denominator", new object[] { OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_ID")
                                                                                                          , OOQL.CreateProperty("ITEM.STOCK_UNIT_ID")
                                                                                                          , OOQL.CreateProperty("TRANSACTION_DOC_D.BUSINESS_UNIT_ID")
                                                                                                          , OOQL.CreateConstants(1) }), //单位转换率分母
                            Formulas.Ext("UNIT_CONVERT_02", "conversion_rate_molecular", new object[] { OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_ID")
                                                                                                        , OOQL.CreateProperty("ITEM.STOCK_UNIT_ID")
                                                                                                        , OOQL.CreateProperty("TRANSACTION_DOC_D.BUSINESS_UNIT_ID")
                                                                                                        , OOQL.CreateConstants(0) }),           //单位转换率分子
                            Formulas.IsNull(OOQL.CreateProperty("STOCK_UNIT.UNIT_CODE"), OOQL.CreateConstants(string.Empty), "inventory_unit"), //库存单位
                                                                                                                                                //20161216 add by shenbao FOR P001-161215001 ===end===
                            OOQL.CreateProperty("UNIT.DICIMAL_DIGIT", "decimal_places"),                                                        //20170424 add by wangyq for P001-170420001
                            OOQL.CreateConstants("1", GeneralDBType.String, "decimal_places_type"),                                             //20170424 add by wangyq for P001-170420001
                                                                                                                                                // add by 08628 for P001-171023001 b
                            Formulas.Case(null,
                                          Formulas.Case(null, Formulas.Case(null, OOQL.CreateConstants("", GeneralDBType.String),
                                                                            OOQL.CreateCaseArray(
                                                                                OOQL.CreateCaseItem(
                                                                                    OOQL.CreateProperty("REG_G.FIFO_TYPE").IsNotNull(),
                                                                                    OOQL.CreateProperty("REG_G.FIFO_TYPE")))),
                                                        OOQL.CreateCaseArray(
                                                            OOQL.CreateCaseItem(
                                                                OOQL.CreateProperty("REG_I.FIFO_TYPE").IsNotNull(),
                                                                OOQL.CreateProperty("REG_I.FIFO_TYPE")))),
                                          OOQL.CreateCaseArray(
                                              OOQL.CreateCaseItem(
                                                  OOQL.CreateProperty("REG_I_F.FIFO_TYPE").IsNotNull(),
                                                  OOQL.CreateProperty("REG_I_F.FIFO_TYPE"))), "first_in_first_out_control"),
                            OOQL.CreateProperty("MAIN_WAREHOUSE.WAREHOUSE_CODE", "main_warehouse_no"),
                            OOQL.CreateProperty("MAIN_BIN.BIN_CODE", "main_storage_no")
                            // add by 08628 for P001-171023001 e
                            )
                .From("TRANSACTION_DOC", "TRANSACTION_DOC")
                .InnerJoin("TRANSACTION_DOC.TRANSACTION_DOC_D", "TRANSACTION_DOC_D")
                .On(OOQL.CreateProperty("TRANSACTION_DOC_D.TRANSACTION_DOC_ID") == OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_ID"))
                .InnerJoin("PLANT", "PLANT")
                .On(OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("TRANSACTION_DOC.Owner_Org.ROid"))
                .InnerJoin("ITEM", "ITEM")
                .On(OOQL.CreateProperty("ITEM.ITEM_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_ID"))
                .LeftJoin("ITEM.ITEM_FEATURE", "ITEM_FEATURE")
                .On(OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_FEATURE_ID"))
                .LeftJoin("WAREHOUSE", "WAREHOUSE")
                .On(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.WAREHOUSE_ID"))
                .LeftJoin("WAREHOUSE.BIN", "BIN")
                .On(OOQL.CreateProperty("BIN.BIN_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.BIN_ID"))
                .LeftJoin("ITEM_LOT", "ITEM_LOT")
                .On(OOQL.CreateProperty("ITEM_LOT.ITEM_LOT_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.ITEM_LOT_ID"))
                .LeftJoin("UNIT", "UNIT")
                .On(OOQL.CreateProperty("UNIT.UNIT_ID") == OOQL.CreateProperty("TRANSACTION_DOC_D.BUSINESS_UNIT_ID"))
                //20161216 add by shenbao FOR P001-161215001 ===begin===
                .LeftJoin("ITEM_PLANT")
                .On(OOQL.CreateProperty("ITEM.ITEM_ID") == OOQL.CreateProperty("ITEM_PLANT.ITEM_ID")
                    & OOQL.CreateProperty("TRANSACTION_DOC.Owner_Org.ROid") == OOQL.CreateProperty("ITEM_PLANT.Owner_Org.ROid"))
                .LeftJoin("UNIT", "STOCK_UNIT")
                .On(OOQL.CreateProperty("ITEM.STOCK_UNIT_ID") == OOQL.CreateProperty("STOCK_UNIT.UNIT_ID"))
                //20161216 add by shenbao FOR P001-161215001 ===end===
                // add by 08628 for P001-171023001 b
                .LeftJoin(OOQL.Select(OOQL.CreateProperty("ITEM_ID"),
                                      OOQL.CreateProperty("ITEM_FEATURE_ID"),
                                      OOQL.CreateProperty("FIFO_TYPE"),
                                      Formulas.RowNumber("SEQ", new OverClause(new[]
            {
                OOQL.CreateProperty("ITEM_ID"),
                OOQL.CreateProperty("ITEM_FEATURE_ID")
            }, new[]
            {
                OOQL.CreateOrderByItem(Formulas.Case(null, OOQL.CreateProperty("CreateDate"),
                                                     OOQL.CreateCaseArray(
                                                         OOQL.CreateCaseItem(
                                                             (OOQL.CreateProperty("MAIN") == OOQL.CreateConstants(1)),
                                                             Formulas.Cast(OOQL.CreateConstants("9998-12-31", GeneralDBType.String),
                                                                           GeneralDBType.Date)))), SortType.Desc)
            })))
                          .From("ITEM_BC_REG")
                          .Where(OOQL.CreateProperty("ITEM_FEATURE_ID").IsNotNull()
                                 &
                                 (OOQL.CreateProperty("ITEM_FEATURE_ID") !=
                                  OOQL.CreateConstants(Maths.GuidDefaultValue()))),
                          "REG_I_F")
                .On((OOQL.CreateProperty("REG_I_F.ITEM_ID") ==
                     OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_D.ITEM_ID"))
                    &
                    (OOQL.CreateProperty("REG_I_F.ITEM_FEATURE_ID") ==
                     OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_D.ITEM_FEATURE_ID"))
                    & (OOQL.CreateProperty("REG_I_F.SEQ") == OOQL.CreateConstants(1, GeneralDBType.Int32)))
                .LeftJoin(OOQL.Select(OOQL.CreateProperty("ITEM_ID"),
                                      OOQL.CreateProperty("FIFO_TYPE"),
                                      Formulas.RowNumber("SEQ", new OverClause(new[]
            {
                OOQL.CreateProperty("ITEM_ID")
            }
                                                                               , new[]
            {
                OOQL.CreateOrderByItem(Formulas.Case(null, OOQL.CreateProperty("CreateDate"),
                                                     OOQL.CreateCaseArray(
                                                         OOQL.CreateCaseItem(
                                                             (OOQL.CreateProperty("MAIN") == OOQL.CreateConstants(1, GeneralDBType.Int32)),
                                                             Formulas.Cast(OOQL.CreateConstants("9998-12-31", GeneralDBType.String),
                                                                           GeneralDBType.Date)))), SortType.Desc)
            })))
                          .From("ITEM_BC_REG"), "REG_I")
                .On((OOQL.CreateProperty("REG_I.ITEM_ID") ==
                     OOQL.CreateProperty("TRANSACTION_DOC.TRANSACTION_DOC_D.ITEM_ID"))
                    & (OOQL.CreateProperty("REG_I.SEQ") == OOQL.CreateConstants(1, GeneralDBType.Int32)))
                .LeftJoin(OOQL.Select(OOQL.CreateProperty("FEATURE_GROUP_ID"),
                                      OOQL.CreateProperty("FIFO_TYPE"),
                                      Formulas.RowNumber("SEQ", new OverClause(new[]
            {
                OOQL.CreateProperty("FEATURE_GROUP_ID"),
            }, new[]
            {
                OOQL.CreateOrderByItem(Formulas.Case(null, OOQL.CreateProperty("CreateDate"),
                                                     OOQL.CreateCaseArray(
                                                         OOQL.CreateCaseItem(
                                                             (OOQL.CreateProperty("MAIN") == OOQL.CreateConstants(1, GeneralDBType.Int32)),
                                                             Formulas.Cast(OOQL.CreateConstants("9998-12-31", GeneralDBType.String),
                                                                           GeneralDBType.Date)))), SortType.Desc)
            })))
                          .From("ITEM_BC_REG"), "REG_G")
                .On((OOQL.CreateProperty("REG_G.FEATURE_GROUP_ID") == OOQL.CreateProperty("ITEM.FEATURE_GROUP_ID"))
                    & (OOQL.CreateProperty("REG_G.SEQ") == OOQL.CreateConstants(1, GeneralDBType.Int32)))
                .LeftJoin("WAREHOUSE", "MAIN_WAREHOUSE")
                .On(OOQL.CreateProperty("MAIN_WAREHOUSE.WAREHOUSE_ID") ==
                    OOQL.CreateProperty("ITEM_PLANT.INBOUND_WAREHOUSE_ID"))
                .LeftJoin("WAREHOUSE.BIN", "MAIN_BIN")
                .On(OOQL.CreateProperty("MAIN_BIN.WAREHOUSE_ID") ==
                    OOQL.CreateProperty("ITEM_PLANT.INBOUND_WAREHOUSE_ID")
                    & OOQL.CreateProperty("MAIN_BIN.MAIN") == OOQL.CreateConstants(1))
                // add by 08628 for P001-171023001 e
                .Where((OOQL.AuthFilter("TRANSACTION_DOC", "TRANSACTION_DOC")) &
                       ((OOQL.CreateProperty("TRANSACTION_DOC.ApproveStatus") == OOQL.CreateConstants("N")) &
                        (OOQL.CreateProperty("TRANSACTION_DOC.DOC_NO").In(OOQL.CreateDyncParameter("docNos", docNo))) &      //20161216 add by shenbao FOR P001-161215001 OOQL.CreateConstants(docNo)==>.In(OOQL.CreateDyncParameter("docnos", docNo)
                        (OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo))));

            return(queryNode);
        }
Beispiel #15
0
        /// <summary>
        /// Gets world-point of specified mouse point projected onto the selected bone's local space if rotating or in world space if translating or scaling.
        /// Intersects the projected ray with the appropriate plane using the snap flags.
        /// </summary>
        public bool GetTransformPoint(
            Vector2 mousePoint,
            out Vector3 point,
            ModelPanelViewport panel,
            Matrix localTransform,
            SelectionParams selection)
        {
            Vector3 lineStart = panel.UnProject(mousePoint._x, mousePoint._y, 0.0f);
            Vector3 lineEnd   = panel.UnProject(mousePoint._x, mousePoint._y, 1.0f);
            Vector3 center    = localTransform.GetPoint();
            Vector3 camera    = panel.Camera.GetPoint();
            Vector3 normal    = new Vector3();

            bool           axisSnap = selection._snapX || selection._snapY || selection._snapZ;
            CoordinateType coord    = _coordinateTypes[(int)ControlType];

            switch (ControlType)
            {
            case TransformType.Rotation:

                float radius = CamDistance(center, ModelPanel.CurrentViewport);
                if (axisSnap)
                {
                    switch (coord)
                    {
                    case CoordinateType.Screen:
                        if (selection._snapX || selection._snapY || selection._snapZ)
                        {
                            normal = camera.Normalize(center);
                        }
                        break;

                    case CoordinateType.Local:
                        normal = (localTransform * new Vector3(
                                      selection._snapX ? 1.0f : 0.0f,
                                      selection._snapY ? 1.0f : 0.0f,
                                      selection._snapZ ? 1.0f : 0.0f)).Normalize(center);
                        break;

                    case CoordinateType.World:
                        normal = new Vector3(
                            selection._snapX ? 1.0f : 0.0f,
                            selection._snapY ? 1.0f : 0.0f,
                            selection._snapZ ? 1.0f : 0.0f);
                        break;
                    }
                }
                else if (selection._snapCirc)
                {
                    radius *= _circOrbScale;
                    normal  = camera.Normalize(center);
                }
                else if (Maths.LineSphereIntersect(lineStart, lineEnd, center, radius, out point))
                {
                    return(true);
                }
                else
                {
                    normal = camera.Normalize(center);
                }

                if (Maths.LinePlaneIntersect(lineStart, lineEnd, center, normal, out point))
                {
                    point = Maths.PointAtLineDistance(center, point, radius);
                    return(true);
                }

                break;

            case TransformType.Translation:
            case TransformType.Scale:

                if (axisSnap)
                {
                    if (selection._snapX && selection._snapY && selection._snapZ)
                    {
                        normal = Vector3.UnitZ * Matrix.RotationMatrix(panel.Camera._rotation);
                    }
                    else
                    {
                        switch (coord)
                        {
                        case CoordinateType.Screen:
                            normal = Vector3.UnitZ * Matrix.RotationMatrix(panel.Camera._rotation);
                            break;

                        case CoordinateType.Local:
                        case CoordinateType.World:

                            //Remove local rotation
                            if (coord == CoordinateType.World)
                            {
                                localTransform = Matrix.TranslationMatrix(center) * Matrix.ScaleMatrix(localTransform.GetScale());
                            }

                            if (selection._snapX && selection._snapY)
                            {
                                normal = (localTransform * Vector3.UnitZ).Normalize(center);
                            }
                            else if (selection._snapX && selection._snapZ)
                            {
                                normal = (localTransform * Vector3.UnitY).Normalize(center);
                            }
                            else if (selection._snapY && selection._snapZ)
                            {
                                normal = (localTransform * Vector3.UnitX).Normalize(center);
                            }
                            else         //One of the snaps
                            {
                                Vector3 unitSnapAxis = new Vector3(
                                    selection._snapX ? 1.0f : 0.0f,
                                    selection._snapY ? 1.0f : 0.0f,
                                    selection._snapZ ? 1.0f : 0.0f);

                                float   camDist  = camera.TrueDistance(center);
                                Vector3 camVec   = camera.Normalize(center);
                                float   ratio    = camVec.Dot(unitSnapAxis) / (camVec.TrueDistance() * unitSnapAxis.TrueDistance());
                                float   lineDist = camDist * ratio;
                                Vector3 endPoint = localTransform * (unitSnapAxis * lineDist);
                                normal = camera.Normalize(endPoint);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    normal = Vector3.UnitZ * Matrix.RotationMatrix(panel.Camera._rotation);
                }

                break;
            }

            return(Maths.LinePlaneIntersect(lineStart, lineEnd, center, normal, out point));
        }
Beispiel #16
0
        public int generatePathTable()
        {
            // We firs test this with just one moove from point x to y
            // To calc this we need to know the time the object needs to reach this point,
            // the new point and the rotation to calc pretty to sync client and server position is right
            // to get a smooth walking :)
            Maths math = new Maths();

            // First choose a new pos in the range
            LtVector3f newPos = math.RandomPointOnCircle((float)xBase,(float)yBase, (float)zBase, 5.0f * 100);
            Output.WriteDebugLog("Mob Goes from X: " + this.getXPos() + " , Z: " + this.getZPos() + " to X: " + newPos.a + ", Z: " + newPos.c);

            double xNew = (double)newPos.a;
            double zNew = (double)newPos.c;

            this.destination = newPos;
            // Try to calculate rotation

            // Oh this seems to match ...needs more testing later when we fixed random pos

            double yaw = Math.Atan((double)(xNew - getXPos()) / (zNew - getZPos()))*128/Math.PI;

            double calcRotation = Math.Atan2(Math.Cos(xNew), Math.Sin(zNew) * Math.Sin(zNew)) * 128/Math.PI;

            double testRot = Math.Atan2(xNew, zNew) * 180 / Math.PI;
            double testRot2 = Math.Atan2(xNew, zNew) * 128 / Math.PI;

            Output.WriteDebugLog("Test Rot with 360 : " + testRot.ToString() + "| 255 : " + testRot2.ToString() + " AND THE YAW: " + yaw.ToString() + " (Cast to uint16 : " + Convert.ToInt16(yaw).ToString() + " )");

            int yawVal = (int)Convert.ToInt16(yaw);

            if (zNew < this.getZPos() || xNew < this.getXPos())
            {
                Output.WriteDebugLog("Need to adjust YAW + 128 from :" + yawVal.ToString() + " to: " + (yawVal + 128).ToString());
                yawVal = yawVal + 128;
            }
            else
            {
                Output.WriteDebugLog("Need to adjust YAW - 128 from :" + yawVal.ToString() + " to: " + (yawVal - 128).ToString());
                yawVal = yawVal - 128;
            }

            Output.WriteDebugLog("YAW VAL :" + yawVal.ToString() );

            this.rotation = (ushort)yawVal;
            Output.WriteDebugLog("Calc Rotation : " + calcRotation.ToString() + " and to UINT : " + (uint)calcRotation);

            // Calculate the distance for seconds to move
            int requiredSeconds = (int)(((math.distance2Coords((float)xPos, (float)xNew, (float)zPos, (float)zNew) / 0.176) / 500) * 0.9586);
            return requiredSeconds;
        }
Beispiel #17
0
 public int Sub(Maths obj)
 {
     return obj.Number1 - obj.Number2;
 }
Beispiel #18
0
 public int Add(Maths obj)
 {
     return obj.Number1 + obj.Number2;
 }
Beispiel #19
0
        /// <summary>
        /// 获取库存信息
        /// </summary>
        /// <param name="logonName"></param>
        /// <returns></returns>
        private QueryNode GetStockInfomation(string logonName, string reportTime)
        {
            //20160309 add by shenbao for B001-170309014 ===begin===
            QueryCondition condition = null;

            if (Maths.IsNotEmpty(reportTime))
            {
                condition = OOQL.CreateProperty("WAREHOUSE.LastModifiedDate") > OOQL.CreateConstants(reportTime);
            }
            else
            {
                condition = OOQL.CreateConstants(1) == OOQL.CreateConstants(1);
            }
            //20160309 add by shenbao for B001-170309014 ===end===
            return(OOQL.Select(true,
                               OOQL.CreateConstants("Y", GeneralDBType.String, "status"),
                               OOQL.CreateConstants("99", GeneralDBType.String, "enterprise_no"),
                               OOQL.CreateProperty("PLANT.PLANT_CODE", "site_no"),
                               Formulas.IsNull(
                                   OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"),
                                   OOQL.CreateConstants(string.Empty, GeneralDBType.String), "warehouse_no"),
                               Formulas.IsNull(
                                   OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_NAME"),
                                   OOQL.CreateConstants(string.Empty, GeneralDBType.String), "warehouse_name"),
                               Formulas.IsNull(
                                   OOQL.CreateProperty("WAREHOUSE.BIN_CODE"),
                                   OOQL.CreateConstants(string.Empty, GeneralDBType.String), "storage_spaces_no"),
                               Formulas.IsNull(
                                   OOQL.CreateProperty("WAREHOUSE.BIN_NAME"),
                                   OOQL.CreateConstants(string.Empty, GeneralDBType.String), "storage_spaces_name")
                               //20170303 add by liwei1 for B001-170303008  ===begin===
                               , Formulas.IsNull(
                                   OOQL.CreateProperty("WAREHOUSE.BIN_CONTROL"),
                                   OOQL.CreateConstants(string.Empty, GeneralDBType.String), "storage_spaces"))
                   //20170303 add by liwei1 for B001-170303008  ===end===
                   .From("USER", "USER")
                   .InnerJoin("USER.USER_ORG", "USER_ORG")
                   .On((OOQL.CreateProperty("USER_ORG.USER_ID") == OOQL.CreateProperty("USER.USER_ID")))
                   .InnerJoin("PLANT", "PLANT")
                   .On((OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("USER_ORG.ORG.ROid")))
                   .InnerJoin(               //20160309 MODI by shenbao for B001-170309014 改成innerjoin
                       OOQL.Select(
                           OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid", "Owner_Org_ROid"),
                           OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"),
                           OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_NAME"),
                           OOQL.CreateProperty("BIN.BIN_CODE"),
                           OOQL.CreateProperty("BIN.BIN_NAME")
                           //20170303 add by liwei1 for B001-170303008  ===begin===
                           , Formulas.Case(null,
                                           OOQL.CreateConstants("N", GeneralDBType.String),
                                           OOQL.CreateCaseArray(
                                               OOQL.CreateCaseItem((OOQL.CreateProperty("WAREHOUSE.BIN_CONTROL") == OOQL.CreateConstants("1")),
                                                                   OOQL.CreateConstants("Y", GeneralDBType.String))), "BIN_CONTROL")
                           //20170303 add by liwei1 for B001-170303008  ===end===
                           )
                       .From("WAREHOUSE", "WAREHOUSE")
                       .LeftJoin("WAREHOUSE.BIN", "BIN")
                       .On((OOQL.CreateProperty("BIN.WAREHOUSE_ID") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"))
                           & (OOQL.CreateProperty("WAREHOUSE.BIN_CONTROL") == OOQL.CreateConstants("1")))
                       .Where(condition), "WAREHOUSE")                   //20160309 add by shenbao for B001-170309014 添加条件condition
                   .On((OOQL.CreateProperty("WAREHOUSE.Owner_Org_ROid") == OOQL.CreateProperty("USER_ORG.ORG.ROid")))
                   .Where((OOQL.AuthFilter("USER", "USER"))
                          & ((OOQL.CreateProperty("USER.LOGONNAME") == OOQL.CreateConstants(logonName))
                             & (OOQL.CreateProperty("USER_ORG.ORG.RTK") == OOQL.CreateConstants("PLANT")))));
        }
        public DependencyObjectCollection QueryItemInvQty(object itemId, object itemFeatureId, string itemLotCode, string siteNo, string scanWarehouseNo,//20170331 modi by wangyq for P001-170327001 old:public DependencyObjectCollection QueryItemInvQty(DependencyObject itemInfo, string siteNo, string scan_warehouse_no,
                                                          string scanStorageSpacesNo, string showZeroInventory)
        {
            QueryNode node = OOQL.Select(OOQL.CreateProperty("ITEM.ITEM_CODE", "item_no"),
                                         OOQL.CreateProperty("ITEM.ITEM_NAME", "item_name"),
                                         OOQL.CreateProperty("ITEM.ITEM_SPECIFICATION", "item_spec"),
                                         OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_CODE", "item_feature_no"),    //wangrm
                                         OOQL.CreateProperty("ITEM_FEATURE.ITEM_SPECIFICATION", "item_feature_name"), //wangrm
                                         Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"), OOQL.CreateConstants(""), "warehouse_no"),
                                         Formulas.IsNull(OOQL.CreateProperty("BIN.BIN_CODE"), OOQL.CreateConstants(""), "storage_spaces_no"),
                                         Formulas.IsNull(OOQL.CreateProperty("ITEM_LOT.LOT_CODE"), OOQL.CreateConstants(""), "lot_no"),
                                         Formulas.IsNull(OOQL.CreateProperty("UNIT.UNIT_CODE"), OOQL.CreateConstants(""), "inventory_unit"),
                                         Formulas.IsNull(Formulas.Sum(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY")), OOQL.CreateConstants(0), "inventory_qty")
                                         )
                             .From("ITEM_WAREHOUSE_BIN", "ITEM_WAREHOUSE_BIN")
                             .InnerJoin("ITEM")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_ID") == OOQL.CreateProperty("ITEM.ITEM_ID"))
                             .LeftJoin("ITEM.ITEM_FEATURE", "ITEM_FEATURE")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_FEATURE_ID") == OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID"))
                             .LeftJoin("WAREHOUSE")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.WAREHOUSE_ID") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"))
                             .LeftJoin("WAREHOUSE.BIN", "BIN")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.BIN_ID") == OOQL.CreateProperty("BIN.BIN_ID"))
                             .LeftJoin("ITEM_LOT")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_LOT_ID") == OOQL.CreateProperty("ITEM_LOT.ITEM_LOT_ID"))
                             .LeftJoin("PLANT")
                             .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID"))
                             .LeftJoin("UNIT")
                             .On(OOQL.CreateProperty("ITEM.STOCK_UNIT_ID") == OOQL.CreateProperty("UNIT.UNIT_ID"))
                             .Where(OOQL.AuthFilter("ITEM_WAREHOUSE_BIN", "ITEM_WAREHOUSE_BIN")
                                    & (OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo)
                                       & (OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_ID") == OOQL.CreateConstants(itemId)                //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_ID"]
                                          | (OOQL.CreateConstants(itemId) == OOQL.CreateConstants(Maths.GuidDefaultValue())))              //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_ID"]
                                       & (OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_FEATURE_ID") == OOQL.CreateConstants(itemFeatureId) //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_FEATURE_ID"]
                                          | (OOQL.CreateConstants(itemFeatureId) == OOQL.CreateConstants(Maths.GuidDefaultValue())))       //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_FEATURE_ID"]
                                       & (OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") == OOQL.CreateConstants(scanWarehouseNo)
                                          | (OOQL.CreateConstants(scanWarehouseNo) == OOQL.CreateConstants("")))
                                       & (OOQL.CreateProperty("BIN.BIN_CODE") == OOQL.CreateConstants(scanStorageSpacesNo)
                                          | (OOQL.CreateConstants(scanStorageSpacesNo) == OOQL.CreateConstants("")))
                                       & (OOQL.CreateProperty("ITEM_LOT.LOT_CODE") == OOQL.CreateConstants(itemLotCode) //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_LOT_CODE"]
                                          | (OOQL.CreateConstants(itemLotCode) == OOQL.CreateConstants("")))            //20170331 modi by wangyq for P001-170327001 old:itemInfo["ITEM_LOT_CODE"]
                                       ))
                             .GroupBy(OOQL.CreateProperty("ITEM.ITEM_CODE"), OOQL.CreateProperty("ITEM.ITEM_NAME"),
                                      OOQL.CreateProperty("ITEM.ITEM_SPECIFICATION"),
                                      OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_CODE"), OOQL.CreateProperty("ITEM_FEATURE.ITEM_SPECIFICATION"),//wangrm
                                      OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"),
                                      OOQL.CreateProperty("BIN.BIN_CODE"), OOQL.CreateProperty("ITEM_LOT.LOT_CODE"),
                                      OOQL.CreateProperty("UNIT.UNIT_CODE")
                                      )
                             .Having((OOQL.CreateConstants(showZeroInventory) == OOQL.CreateConstants("N")
                                      & Formulas.IsNull(Formulas.Sum(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY")), OOQL.CreateConstants(0)) != OOQL.CreateConstants(0))
                                     | (OOQL.CreateConstants(showZeroInventory) == OOQL.CreateConstants("Y"))
                                     );

            return(GetService <IQueryService>().ExecuteDependencyObject(node));
        }
Beispiel #21
0
 public int Div(Maths obj)
 {
     return obj.Number2 == 0 ? 0 : obj.Number1 / obj.Number2;
 }
Beispiel #22
0
        public void loadViewMatrix(Camera camera)
        {
            Matrix4f viewMatrix = Maths.createViewMatrix(camera);

            base.loadMatrix(location_viewMatrix, viewMatrix);
        }
        public Hashtable GetInvQty(string site_no, string show_zero_inventory, string scan_barcode, string scan_warehouse_no,
                                   string scan_storage_spaces_no, string program_job_no)
        {
            //20170329 add by wangrm for P001-170316001======end=======
            Hashtable result = new Hashtable();  //返回值

            #region 参数检查
            //if (Maths.IsEmpty(scan_barcode)) {//20170331 mark by wangyq for P001-170327001
            //    throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "scan_barcode" }));
            //}
            if (Maths.IsEmpty(site_no))
            {
                throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "site_no" }));
            }
            //20170329 add by wangrm for P001-170316001======start=======
            if (program_job_no != null && Maths.IsEmpty(program_job_no))
            {
                throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "program_job_no" }));
            }
            //20170329 add by wangrm for P001-170316001======end=======
            #endregion
            if (program_job_no == null || program_job_no == "15")
            {
                //属性值
                object propertyId = QueryItemLot();
                if (propertyId == null)
                {
                    throw new BusinessRuleException("QueryItemLot");
                }

                //品号批号相关信息
                //20170331 modi by wangyq for P001-170327001  ==================begin==================
                object itemId        = Maths.GuidDefaultValue();
                object itemFeatureId = Maths.GuidDefaultValue();
                string itemLotCode   = string.Empty;
                if (!string.IsNullOrEmpty(scan_barcode))
                {
                    DependencyObject itemInfo = QueryBcBarCode(propertyId, scan_barcode);
                    if (itemInfo != null)
                    {
                        itemId        = itemInfo["ITEM_ID"];
                        itemFeatureId = itemInfo["ITEM_FEATURE_ID"];
                        itemLotCode   = itemInfo["ITEM_LOT_CODE"].ToStringExtension();
                    }
                }
                //DependencyObject itemInfo = QueryBcBarCode(propertyID, scan_barcode);
                //if (itemInfo == null)
                //    throw new BusinessRuleException("Query_BC_RECORD");
                //20170331 modi by wangyq for P001-170327001  ==================end==================
                //查品号库存
                DependencyObjectCollection itemInvQty = QueryItemInvQty(itemId, itemFeatureId, itemLotCode, site_no, scan_warehouse_no, scan_storage_spaces_no, show_zero_inventory);
                //20170331 modi by wangyq for P001-170327001 old:
                //DependencyObjectCollection itemInvQTY = QueryItemInvQty(itemInfo, site_no, scan_warehouse_no, scan_storage_spaces_no, show_zero_inventory);
                result.Add("item_detail", itemInvQty);

                //查条码库存
                bool bcLintFlag = IsBcLineManagement();
                if (!bcLintFlag)
                {
                    DependencyObjectCollection emptyColl = CreateReturnCollection();
                    result.Add("barcode_detail", emptyColl);
                }
                else
                {
                    DependencyObjectCollection barCodeInvQty = QueryBarCodeInvQty(scan_barcode, site_no, scan_warehouse_no, scan_storage_spaces_no, show_zero_inventory);
                    result.Add("barcode_detail", barCodeInvQty);
                }
                //20170329 add by wangrm for P001-170316001======start=======
            }
            else if (program_job_no == "18")
            {
                DependencyObjectCollection emptyItemColl = CreateReturnCollectionForItemDetail();
                result.Add("item_detail", emptyItemColl);

                bool bcLintFlag = IsBcLineManagement();
                if (!bcLintFlag)
                {
                    DependencyObjectCollection emptyColl = CreateReturnCollection();
                    result.Add("barcode_detail", emptyColl);
                }
                else
                {
                    DependencyObjectCollection barCodeInvQty = QueryBcFrozen(scan_barcode);
                    result.Add("barcode_detail", barCodeInvQty);
                }
            }
            //20170329 add by wangrm for P001-170316001======end=======
            return(result);
        }
Beispiel #24
0
 public override Sample <float3> Get(float3 xyz)
 {
     return(Maths.Min(operands.Select(i => i.Get(xyz)).ToArray()));
 }
Beispiel #25
0
 private void UpdateSprite()
 {
     sprite.frame = Maths.Clamp(MaxAmmo - ammo, 0, MaxAmmo) + (CoolingDown ? 8 : 0);
 }
        private QueryNode QueryData(string program_job_no, string status,
                                    DependencyObjectCollection doc_no, string site_no, string warehouse_no, string warseHouseControl)
        {
            OrderByItem[] orderByItem  = null;
            QueryProperty property     = null;
            bool          bcInvControl = UtilsClass.IsBCInventoryManagement(this.GetService <IQueryService>());

            if (bcInvControl)
            {
                property = OOQL.CreateProperty("BC_INVENTORY.QTY");
            }
            else
            {
                property = OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY");
            }

            //策略
            if (warseHouseControl == "1")  //1.生效日期先进先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem("ITEM_LOT.EFFECTIVE_DATE", SortType.Asc) }
            }
            ;
            else if (warseHouseControl == "2")  //2.生效日期后进先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem("ITEM_LOT.EFFECTIVE_DATE", SortType.Desc) }
            }
            ;
            else if (warseHouseControl == "3")  //3.不限定
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem("ITEM_LOT.LOT_CODE", SortType.Asc) }
            }
            ;
            else if (warseHouseControl == "4")  //4.先到期先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem("ITEM_LOT.INEFFECTIVE_DATE", SortType.Asc) }
            }
            ;
            else if (warseHouseControl == "5")  //5.允许出库日早者先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem("ITEM_LOT.ALLOW_ISSUE_DATE", SortType.Asc) }
            }
            ;
            else if (warseHouseControl == "6")    //6.可用量少的先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem(property, SortType.Asc) };
            }
            else if (warseHouseControl == "7")      //6.可用量少的先出
            {
                orderByItem = new OrderByItem[] { OOQL.CreateOrderByItem(property, SortType.Desc) };
            }

            //组织单号
            List <ConstantsQueryProperty> docNos = new List <ConstantsQueryProperty>();

            foreach (DependencyObject item in doc_no)
            {
                docNos.Add(OOQL.CreateConstants(item["doc_no"].ToStringExtension()));
            }

            QueryNode node = null;

            if (program_job_no == "5")//20170328 modi by wangyq for P001-170327001去掉&& status == "A"
            {
                node = GetSalesDeliveryNode(site_no, docNos, warseHouseControl);
            }
            else if (program_job_no.StartsWith("7") && status == "A")
            {
                node = GetMONode(site_no, program_job_no, docNos, warseHouseControl);
            }
            else if (program_job_no.StartsWith("7") && status == "S")
            {
                node = GetIssueReceiptNode(site_no, docNos, warseHouseControl);
            }
            else if (program_job_no.StartsWith("11") && status == "S")
            {
                node = GeTransferDocNode(site_no, docNos, warseHouseControl);
            }
            else if (program_job_no.StartsWith("4"))                             //20170629 add by zhangcn for P001-170606002  //20170719 modi by shenbao for 拿掉status == "A"
            {
                node = GePurchaseReturnNode(site_no, docNos, warseHouseControl); //20170629 add by zhangcn for P001-170606002
            }
            else if (program_job_no.StartsWith("5-1"))                           //20170829 add by shenbao for P001-170717001
            {
                node = GetSalesOrderDocNode(site_no, docNos, warseHouseControl);
            }

            List <QueryProperty> pubProperties = new List <QueryProperty>()
            {
                OOQL.CreateConstants("99", "enterprise_no"),
                OOQL.CreateProperty("QuerySource.PLANT_CODE", "site_no"),
                OOQL.CreateProperty("QuerySource.ITEM_CODE", "item_no"),
                OOQL.CreateProperty("QuerySource.ITEM_NAME", "item_name"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.ITEM_SPECIFICATION"), OOQL.CreateConstants(string.Empty), "item_spec"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.ITEM_FEATURE_CODE"), OOQL.CreateConstants(string.Empty), "item_feature_no"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.ITEM_FEATURE_SPECIFICATION"), OOQL.CreateConstants(string.Empty), "item_feature_name"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.UNIT_CODE"), OOQL.CreateConstants(string.Empty), "unit_no"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.STOCK_UNIT_CODE"), OOQL.CreateConstants(string.Empty), "inventory_unit"),
                Formulas.IsNull(OOQL.CreateProperty("QuerySource.SOURCE_QTY"), OOQL.CreateConstants(0), "SOURCE_QTY")
            };

            //查询
            if (bcInvControl)
            {
                pubProperties.AddRange(new QueryProperty[] {
                    OOQL.CreateProperty("BC_INVENTORY.BARCODE_NO", "barcode_no"),
                    Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"), OOQL.CreateConstants(string.Empty), "warehouse_no"),
                    Formulas.IsNull(OOQL.CreateProperty("BIN.BIN_CODE"), OOQL.CreateConstants(string.Empty), "storage_spaces_no"),
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_LOT.LOT_CODE"), OOQL.CreateConstants(string.Empty), "lot_no"),
                    OOQL.CreateConstants(UtilsClass.SpaceValue, "inventory_management_features"),//20170328 modi by wangyq for P001-170327001 old:string.Empty
                    Formulas.IsNull(OOQL.CreateProperty("BC_INVENTORY.CreateDate"), OOQL.CreateConstants(OrmDataOption.EmptyDateTime.Date), "first_storage_date"),
                    Formulas.IsNull(OOQL.CreateProperty("BC_INVENTORY.QTY"), OOQL.CreateConstants(0), "inventory_qty"),
                    Formulas.IsNull(Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("QuerySource.ITEM_ID")
                                                                                , OOQL.CreateProperty("QuerySource.STOCK_UNIT_ID")
                                                                                , OOQL.CreateProperty("BC_INVENTORY.QTY")
                                                                                , OOQL.CreateProperty("QuerySource.UNIT_ID")
                                                                                , OOQL.CreateConstants(0) }), OOQL.CreateConstants(0), "conversion_qty"),
                    Formulas.RowNumber("sort_no", OOQL.Over(new QueryProperty[] { OOQL.CreateProperty("QuerySource.ITEM_CODE") },
                                                            orderByItem
                                                            ))
                });
                node = OOQL.Select(
                    pubProperties
                    )
                       .From(node, "QuerySource")
                       .LeftJoin("BC_INVENTORY")
                       .On(OOQL.CreateProperty("QuerySource.ITEM_ID") == OOQL.CreateProperty("BC_INVENTORY.ITEM_ID")
                           & Formulas.IsNull(OOQL.CreateProperty("QuerySource.ITEM_FEATURE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())) == OOQL.CreateProperty("BC_INVENTORY.ITEM_FEATURE_ID"))
                       .LeftJoin("WAREHOUSE")
                       .On(OOQL.CreateProperty("BC_INVENTORY.WAREHOUSE_ID") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"))
                       .LeftJoin("WAREHOUSE.BIN", "BIN")
                       .On(OOQL.CreateProperty("BC_INVENTORY.BIN_ID") == OOQL.CreateProperty("BIN.BIN_ID"))
                       .LeftJoin("ITEM_LOT")
                       .On(OOQL.CreateProperty("BC_INVENTORY.ITEM_LOT_ID") == OOQL.CreateProperty("ITEM_LOT.ITEM_LOT_ID"))
                       .LeftJoin("PLANT") //20170719 add by shenbao for P001-170717001
                       .On(OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID"))
                       .Where(((OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") == OOQL.CreateConstants(warehouse_no))
                               | OOQL.CreateConstants(warehouse_no) == OOQL.CreateConstants(""))
                              & OOQL.CreateProperty("BC_INVENTORY.QTY") > OOQL.CreateConstants(0)
                              & OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_PROPERTY") == OOQL.CreateConstants("1")      //20170717 add by shenbao for P001-170717001
                              & OOQL.CreateProperty("WAREHOUSE.INCLUDED_AVAILABLE_QTY") == OOQL.CreateConstants(true) //20170717 add by shenbao for P001-170717001
                              & OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(site_no));            //20170719 add by shenbao for P001-170717001
            }
            else
            {
                pubProperties.AddRange(new QueryProperty[] {
                    OOQL.CreateConstants("", "barcode_no"),
                    Formulas.IsNull(OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE"), OOQL.CreateConstants(string.Empty), "warehouse_no"),
                    Formulas.IsNull(OOQL.CreateProperty("BIN.BIN_CODE"), OOQL.CreateConstants(string.Empty), "storage_spaces_no"),
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_LOT.LOT_CODE"), OOQL.CreateConstants(string.Empty), "lot_no"),
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.LAST_RECEIPT_DATE"), OOQL.CreateConstants(OrmDataOption.EmptyDateTime.Date), "first_storage_date"),
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY"), OOQL.CreateConstants(0), "inventory_qty"),
                    Formulas.IsNull(Formulas.Ext("UNIT_CONVERT", new object[] { OOQL.CreateProperty("QuerySource.ITEM_ID")
                                                                                , OOQL.CreateProperty("QuerySource.STOCK_UNIT_ID")
                                                                                , OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY")
                                                                                , OOQL.CreateProperty("QuerySource.UNIT_ID")
                                                                                , OOQL.CreateConstants(0) }), OOQL.CreateConstants(0), "conversion_qty"),
                    Formulas.RowNumber("sort_no", OOQL.Over(new QueryProperty[] { OOQL.CreateProperty("QuerySource.ITEM_CODE") },
                                                            orderByItem
                                                            ))
                });
                node = OOQL.Select(
                    pubProperties
                    )
                       .From(node, "QuerySource")
                       .LeftJoin("ITEM_WAREHOUSE_BIN")
                       .On(OOQL.CreateProperty("QuerySource.ITEM_ID") == OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_ID")
                           & Formulas.IsNull(OOQL.CreateProperty("QuerySource.ITEM_FEATURE_ID"), OOQL.CreateConstants(Maths.GuidDefaultValue())) == OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_FEATURE_ID"))
                       .LeftJoin("WAREHOUSE")
                       .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.WAREHOUSE_ID") == OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_ID"))
                       .LeftJoin("WAREHOUSE.BIN", "BIN")
                       .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.BIN_ID") == OOQL.CreateProperty("BIN.BIN_ID"))
                       .LeftJoin("ITEM_LOT")
                       .On(OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.ITEM_LOT_ID") == OOQL.CreateProperty("ITEM_LOT.ITEM_LOT_ID"))
                       .LeftJoin("PLANT") //20170719 add by shenbao for P001-170717001
                       .On(OOQL.CreateProperty("WAREHOUSE.Owner_Org.ROid") == OOQL.CreateProperty("PLANT.PLANT_ID"))
                       .Where(((OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_CODE") == OOQL.CreateConstants(warehouse_no))
                               | OOQL.CreateConstants(warehouse_no) == OOQL.CreateConstants(""))
                              & OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.INVENTORY_QTY") > OOQL.CreateConstants(0)
                              & OOQL.CreateProperty("ITEM_WAREHOUSE_BIN.BO_ID.RTK") == OOQL.CreateConstants("OTHER")
                              & OOQL.CreateProperty("WAREHOUSE.WAREHOUSE_PROPERTY") == OOQL.CreateConstants("1")      //20170717 add by shenbao for P001-170717001
                              & OOQL.CreateProperty("WAREHOUSE.INCLUDED_AVAILABLE_QTY") == OOQL.CreateConstants(true) //20170717 add by shenbao for P001-170717001
                              & OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(site_no));            //20170719 add by shenbao for P001-170717001
            }

            return(node);
        }
Beispiel #27
0
        public static void ProcessCarForCarmageddonMaxDamage()
        {
            if (SceneManager.Current.Models.Count == 0)
            {
                return;
            }

            Model model = SceneManager.Current.Models[0];
            ModelBoneCollection bones = SceneManager.Current.Models[0].Bones[0].AllChildren();

            SceneManager.Current.UpdateProgress("Applying Carmageddon Reincarnation scale");

            ModelManipulator.Scale(bones, Matrix4D.CreateScale(6.9f, 6.9f, -6.9f), true);
            ModelManipulator.FlipFaces(bones, true);

            SceneManager.Current.UpdateProgress("Fixing material names");

            foreach (Material material in SceneManager.Current.Materials)
            {
                if (material.Name.Contains("."))
                {
                    material.Name = material.Name.Substring(0, material.Name.IndexOf("."));
                }
                material.Name = material.Name.Replace("\\", "");
            }

            SceneManager.Current.UpdateProgress("Munging parts and fixing wheels");

            float scale;

            for (int i = 0; i < bones.Count; i++)
            {
                ModelBone bone = bones[i];

                if (i == 0)
                {
                    bone.Name      = "c_Body";
                    bone.Mesh.Name = "c_Body";
                }
                else
                {
                    bone.Name = Path.GetFileNameWithoutExtension(bone.Name);
                }

                switch (bone.Name.ToUpper())
                {
                case "C_BODY":
                    break;

                case "FLPIVOT":
                case "FRPIVOT":
                    bone.Name = "Hub_" + bone.Name.ToUpper().Substring(0, 2);

                    if (bone.Transform.ExtractTranslation() == Vector3.Zero)
                    {
                        ModelManipulator.MungeMeshWithBone(bone.Children[0].Mesh, false);

                        Matrix4D m = bone.Transform;
                        m.M31          = bone.Children[0].Transform.M31;
                        m.M32          = bone.Children[0].Transform.M32;
                        m.M33          = bone.Children[0].Transform.M33;
                        bone.Transform = m;

                        model.SetTransform(Matrix4D.Identity, bone.Children[0].Index);
                    }
                    break;

                case "FLWHEEL":
                    scale = bone.CombinedTransform.ExtractTranslation().Y / 0.35f;

                    bone.Name = "Wheel_FL";
                    model.ClearMesh(bone.Index);
                    model.SetTransform(Matrix4D.CreateScale(scale) * Matrix4D.CreateRotationY(Maths.DegreesToRadians(180)), bone.Index);
                    break;

                case "FRWHEEL":
                    scale = bone.CombinedTransform.ExtractTranslation().Y / 0.35f;

                    bone.Name = "Wheel_FR";
                    model.ClearMesh(bone.Index);
                    model.SetTransform(Matrix4D.CreateScale(scale), bone.Index);
                    break;

                case "RLWHEEL":
                case "RRWHEEL":
                    string suffix = bone.Name.ToUpper().Substring(0, 2);

                    bone.Name = "Hub_" + suffix;

                    if (bone.Transform.ExtractTranslation() == Vector3.Zero)
                    {
                        ModelManipulator.MungeMeshWithBone(bone.Mesh, false);
                    }
                    model.ClearMesh(bone.Index);

                    scale = bone.CombinedTransform.ExtractTranslation().Y / 0.35f;

                    int newBone = model.AddMesh(null, bone.Index);
                    model.SetName("Wheel_" + suffix, newBone);
                    model.SetTransform(Matrix4D.CreateScale(scale) * (suffix == "RL" ? Matrix4D.CreateRotationY(Maths.DegreesToRadians(180)) : Matrix4D.Identity), newBone);
                    break;

                case "DRIVER":
                    bone.Name = "Dryver";
                    goto default;

                default:
                    if (bone.Type == BoneType.Mesh)
                    {
                        ModelManipulator.MungeMeshWithBone(bone.Mesh, false);
                    }
                    break;
                }
            }

            SceneManager.Current.UpdateProgress("Processing complete!");

            SceneManager.Current.SetCoordinateSystem(CoordinateSystem.LeftHanded);

            SceneManager.Current.Change(ChangeType.Munge, ChangeContext.Model, -1);

            SceneManager.Current.SetContext("Carmageddon Max Damage", ContextMode.Car);
        }
        void SpawnScrapStation()
        {
            ScrapStation ss = ScrapStationPool.New();

            ss.Initialize(new Vector2(Maths.RandomNr(0, Engine.Instance.Width - 128), Maths.RandomNr(-256, -174)));
            ActiveScrapStation = ss;
        }
Beispiel #29
0
        public static DigiwinSelectControl CreateSelectControl(DependencyObject dataSource, string name, string propertyName, ParaEntity para
                                                               , bool isReadOnly, bool visible, bool allowMultiSelect, int tabeIndex)
        {
            DigiwinSelectControl dsc1 = new DigiwinSelectControl();

            ((System.ComponentModel.ISupportInitialize)(dsc1)).BeginInit();
            dsc1.Name        = name;
            dsc1.SelectStyle = SelectStyle.TwoInOneOpen;
            dsc1.ReadOnly    = isReadOnly;
            dsc1.Visible     = visible;
            dsc1.AllowInput  = false;
            dsc1.AllowOpenWindowInOpenState = false;
            BindingSource bs          = new BindingSource();
            string        hiddenText  = propertyName.Replace("_ID", "_CODE");
            string        displayText = propertyName.Replace("_ID", "_NAME");

            if (dataSource != null)
            {
                bs.DataSource = dataSource.DefaultView;

                dsc1.DataBindings.Add(new Binding("Value", bs, propertyName, true, DataSourceUpdateMode.OnPropertyChanged, Maths.GuidDefaultValue()));
                dsc1.DataBindings.Add(new Binding("HiddenText", bs, hiddenText, true, DataSourceUpdateMode.OnPropertyChanged));
                dsc1.DataBindings.Add(new Binding("DisplayText", bs, displayText, true, DataSourceUpdateMode.OnPropertyChanged));
            }

            GeneralWindowOpener generalWindowOpener = new GeneralWindowOpener();

            generalWindowOpener.Description = null;
            generalWindowOpener.InexactQuery.QueryProjectId = null;
            generalWindowOpener.InexactQuery.QueryTypeKey   = null;
            generalWindowOpener.InexactQuery.ReturnField    = null;
            generalWindowOpener.Name            = null;
            generalWindowOpener.OpenCondition   = null;
            generalWindowOpener.OpenFailMessage = null;
            generalWindowOpener.RelatedType     = RelatedType.BindingField;
            generalWindowOpener.MultiSelect     = allowMultiSelect;
            //if (propertyVM.OpeningPatameters.Count > 0) {
            //    foreach (OpeningParameter parameter in propertyVM.OpeningPatameters) {
            //        generalWindowOpener.OpeningParameters.Add(parameter);
            //    }
            //}

            ReturnExpression returnExpression1 = new ReturnExpression();
            ReturnExpression returnExpression2 = new ReturnExpression();
            ReturnExpression returnExpression3 = new ReturnExpression();
            ReturnExpression returnExpression4 = new ReturnExpression();

            generalWindowOpener.QueryProjectId = para.QueryProjectId;
            generalWindowOpener.QueryTypeKey   = para.QueryTypeKey;

            returnExpression1.Left  = "ActiveObject." + propertyName;
            returnExpression1.Name  = "ActiveObject." + para.PropertyName;
            returnExpression1.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID;

            returnExpression2.Left  = "ActiveObject." + hiddenText;
            returnExpression2.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");
            returnExpression2.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");

            returnExpression3.Left  = "ActiveObject." + displayText;
            returnExpression3.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");
            returnExpression3.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");

            returnExpression4.Left  = "ActiveObject." + propertyName + "_RETURN_VALUE";
            returnExpression4.Name  = "ActiveObject." + para.PropertyName + "_RETURN_VALUE";
            returnExpression4.Right = "SelectedObjects[0].RETURN_VALUE";

            generalWindowOpener.ReturnExpressions.Add(returnExpression1);
            generalWindowOpener.ReturnExpressions.Add(returnExpression2);
            generalWindowOpener.ReturnExpressions.Add(returnExpression3);
            generalWindowOpener.ReturnExpressions.Add(returnExpression4);

            generalWindowOpener.ReturnField = para.TargetEntityPirmaryKeyID;
            generalWindowOpener.Shortcut    = System.Windows.Forms.Keys.F2;
            generalWindowOpener.Tip         = para.Tip;
            dsc1.WindowOpeners.Add(generalWindowOpener);
            ((System.ComponentModel.ISupportInitialize)(dsc1)).EndInit();

            return(dsc1);
        }
Beispiel #30
0
        private void DoSwing(Vector3 hitPoint, Entity webHitHelper, Control webControl, bool checkMinAngle = true)
        {
            // Create a helper prop for rotations.
            var rotationHelper = World.CreateVehicle("bmx", Profile.LocalUser.Position);

            rotationHelper.Alpha = 0;

            // Store the initial velocity.
            var initialVelocity = Profile.LocalUser.Velocity;

            // Clear the player tasks.
            Profile.LocalUser.Task.ClearAll();

            // Attach the player to the helper prop.
            Profile.LocalUser.AttachToEntity(rotationHelper, 0, new Vector3(0, -0.25f, -1.15f),
                                             Vector3.Zero, false, false, true, 0, true);

            var t = 0.5f;

            while (!Profile.LocalUser.IsAttached() && t > 0)
            {
                t -= Time.UnscaledDeltaTime;
                Script.Yield();
            }

            // We should play the base animation initially for good blending
            Profile.LocalUser.Task.PlayAnimation("move_fall", "fall_high",
                                                 8.0f, -4.0f, -1, AnimationFlags.StayInEndFrame, 0.0f);

            // The rappel anim!
            Profile.LocalUser.Task.PlayAnimation("missrappel", "rappel_idle", 4.0f, -4.0f, -1,
                                                 AnimationFlags.Loop | AnimationFlags.AllowRotation | AnimationFlags.UpperBodyOnly,
                                                 0.0f);

            // Create our rope.
            var initialLength = Vector3.Distance(rotationHelper.Position, hitPoint);

            if (initialLength <= 0)
            {
                initialLength = 1;
            }
            var rope = Rope.AddRope(rotationHelper.Position, initialLength,
                                    GTARopeType.ThickRope, initialLength, 0.1f, true, false);

            // Attach the two helpers.
            rope.AttachEntities(rotationHelper, Vector3.Zero, webHitHelper, Vector3.Zero, initialLength);
            rope.ActivatePhysics();

            // Init a rotation.
            var initalDirection = Vector3.ProjectOnPlane(Profile.GetCameraDirection(),
                                                         (webHitHelper.Position - rotationHelper.Position).Normalized);

            // Apply an initial force to the rotation helper.
            rotationHelper.Velocity = initalDirection * initialVelocity.Length() * 1.5f;

            // A bool to help us determine if we've played our forward swing
            // animation or not.
            var forwardSwing = false;

            // The amount of momentum we build.
            var momentumBuild = 1f;

            // Here's our loop.
            while (true)
            {
                // Disable the parachute deploy control.
                Game.DisableControlThisFrame(2, Control.ParachuteDeploy);

                // Disable the jump control.
                Game.DisableControlThisFrame(2, webControl);

                if (rotationHelper.HasCollidedWithAnything)
                {
                    var normal = rotationHelper.GetLastCollisionNormal();
                    var dir    = Vector3.Reflect(rotationHelper.Velocity, normal);
                    dir.Normalize();
                    Profile.LocalUser.Detach();
                    Profile.LocalUser.Heading  = dir.ToHeading();
                    Profile.LocalUser.Velocity = dir * rotationHelper.Velocity.Length() / 2;
                    Profile.LocalUser.Task.Skydive();
                    Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_flip_back_to_front",
                                                         4.0f, -2.0f, 1150, (AnimationFlags)40, 0.0f);
                    Profile.LocalUser.Quaternion.Normalize();
                    Audio.ReleaseSound(Audio.PlaySoundFromEntity(Profile.LocalUser,
                                                                 "DLC_Exec_Office_Non_Player_Footstep_Mute_group_MAP"));
                    GTAGraphics.StartParticle("core", "ent_dst_dust", Profile.LocalUser.Position,
                                              Profile.LocalUser.Rotation, 1f);
                    break;
                }

                // If we're near the ground then stop.
                if (Profile.LocalUser.HeightAboveGround <= 2f)
                {
                    // The swing was canceled.
                    break;
                }

                // If we release the attach control then
                // we should start the skydive.
                if (Game.IsDisabledControlJustReleased(2, webControl))
                {
                    ReleaseWebToAir(-1, rotationHelper);
                    break;
                }

                // Set the hand ik positions.
                var ropeCoord  = rope[0];
                var boneOffset = Profile.LocalUser.RightVector * 0.05f;
                Profile.LocalUser.SetIKTarget(IKIndex.LeftArm, ropeCoord - boneOffset, -1f, 0f);
                Profile.LocalUser.SetIKTarget(IKIndex.RightArm, ropeCoord + boneOffset, -1f, 0f);

                // Swing the player's legs based on his forward direction.
                var dot = Vector3.Dot(Vector3.WorldUp, Profile.LocalUser.ForwardVector);

                // Swinging down.
                if (dot < 0)
                {
                    // Check our flag.
                    if (!forwardSwing)
                    {
                        // Play the down swinging anim.
                        Profile.LocalUser.Task.PlayAnimation("skydive@parachute@", "chute_idle_alt",
                                                             1.0f, -4.0f, -1, AnimationFlags.Loop, 0.0f);

                        // Set our flag.
                        forwardSwing = true;
                    }
                }
                // Swinging up.
                else if (dot > 0)
                {
                    // Check our flag.
                    if (forwardSwing)
                    {
                        // Play the up swinging anim.
                        Profile.LocalUser.Task.PlayAnimation("skydive@parachute@", "chute_forward",
                                                             1.0f, -4.0f, -1, AnimationFlags.Loop, 0.0f);

                        // Set our flag.
                        forwardSwing = false;
                    }
                }

                // Get the desired rotation for our
                // rotation helper.
                var directionToWebHit = webHitHelper.Position - rotationHelper.Position;
                directionToWebHit.Normalize();
                var dirVel   = Vector3.ProjectOnPlane(rotationHelper.Velocity, directionToWebHit);
                var rotation = Maths.LookRotation(dirVel, directionToWebHit);
                rotationHelper.Quaternion = rotation;

                // Get the direction of input.
                var moveDir     = Profile.GetInputDirection();
                var relativeDir = Quaternion.Euler(Profile.GetCameraRotation()) * moveDir;
                relativeDir = Vector3.ProjectOnPlane(relativeDir, directionToWebHit);

                // Apply force of input.
                if (momentumBuild < 2.5f)
                {
                    momentumBuild += Time.DeltaTime;
                }
                rotationHelper.ApplyForce(relativeDir * momentumBuild * 50f * Time.UnscaledDeltaTime);
                rotationHelper.ApplyForce(Vector3.WorldDown * 15f * Time.UnscaledDeltaTime);

                if (checkMinAngle)
                {
                    var angle = Vector3.Angle(directionToWebHit, Vector3.WorldUp);
                    if (angle > 70)
                    {
                        ReleaseWebToAir(0, rotationHelper);
                        break;
                    }
                }

                // Yield the script.
                Script.Yield();
            }

            // Reset the cooldown!
            _webSwingCooldown = 0.7f;

            Profile.LocalUser.Task.ClearAnimation("skydive@parachute@", "chute_idle_alt");
            Profile.LocalUser.Task.ClearAnimation("skydive@parachute@", "chute_forward");
            Profile.LocalUser.Task.ClearAnimation("missrappel", "rappel_idle");

            // Delete the helper props.
            rotationHelper.Delete();

            // Delete the rope.
            rope.Delete();
        }
        internal void Parse(MDL0Node model)
        {
            Influence   inf;
            ModelLinker linker = model._linker;

            int typeIndex = (int)_type;

            fixed(ResourceGroup **gList = &linker.Defs)
            {
                if (gList[typeIndex] != null)
                {
                    ExtractGroup(gList[typeIndex], ModelLinker.TypeBank[typeIndex]);
                }
                else
                {
                    return; //Nothing to read
                }
            }

            //Special handling for bones and objects
            if (_type == MDLResourceType.Bones)
            {
                //Bones have been parsed from raw data as a flat list.
                //Bones re-assign parents in their Initialize block, so parents are true.
                //Parents must be assigned now as bones will be moved in memory when assigned as children.

                //Cache flat list
                linker.BoneCache = _children.Select(x => x as MDL0BoneNode).ToArray();

                //Reset children so we can rebuild
                _children.Clear();

                //Assign children using each bones' parent offset in case NodeTree is corrupted.
                //Bone parents are assigned when they are initialized in a flat array.
                foreach (MDL0BoneNode b in linker.BoneCache)
                {
                    MDL0Bone *header = b.Header;

                    //Assign true parent using parent header offset
                    int offset = header->_parentOffset;
                    if (offset != 0)
                    {
                        //Get address of parent header
                        MDL0Bone *pHeader = (MDL0Bone *)((byte *)header + offset);
                        //Search bone list for matching header
                        foreach (MDL0BoneNode b2 in linker.BoneCache)
                        {
                            if (pHeader == b2.Header)
                            {
                                b._parent = b2;
                                break;
                            }
                        }
                    }

                    if (b._boneFlags.HasFlag(BoneFlags.HasBillboardParent))
                    {
                        b._bbRefNode = model._linker.BoneCache[header->_bbIndex];
                    }
                }

                //Make sure the node cache is the correct size
                int highest = 0;

                //Add bones to their parent's child lists and find highest node id
                foreach (MDL0BoneNode b in linker.BoneCache)
                {
                    b._parent._children.Add(b);

                    if (b._nodeIndex >= linker.NodeCache.Length && b._nodeIndex > highest)
                    {
                        highest = b._nodeIndex;
                    }
                }

                if (highest >= linker.NodeCache.Length)
                {
                    linker.NodeCache = new IMatrixNode[highest + 1];
                }

                //Populate node cache
                MDL0BoneNode bone = null;
                int          index;
                int          count = linker.BoneCache.Length;
                for (int i = 0; i < count; i++)
                {
                    linker.NodeCache[(bone = linker.BoneCache[i])._nodeIndex] = bone;
                }

                int nullCount = 0;

                bool nodeTreeError = false;

                //Now that bones and primary influences have been cached, we can create weighted influences.
                foreach (ResourcePair p in *linker.Defs)
                {
                    if (p.Name == "NodeTree")
                    {
                        //Double check bone tree using the NodeTree definition.
                        //If the NodeTree is corrupt, the user will be informed that it needs to be rebuilt.
                        byte *pData     = (byte *)p.Data;
                        bool  fixCS0159 = false;

                        List <MDL0BoneNode> bones = linker.BoneCache.ToList();

STop:
                        if (*pData == 2)
                        {
                            bone  = linker.BoneCache[*(bushort *)(pData + 1)];
                            index = *(bushort *)(pData + 3); //Parent bone node index

                            if (bone.Header->_parentOffset == 0)
                            {
                                if (!_children.Contains(bone))
                                {
                                    nodeTreeError = true;
                                    continue;
                                }

                                bones.Remove(bone);
                            }
                            else
                            {
                                MDL0BoneNode parent = linker.NodeCache[index] as MDL0BoneNode;
                                if (parent == null || bone._parent != parent || !parent._children.Contains(bone))
                                {
                                    nodeTreeError = true;
                                    continue;
                                }

                                bones.Remove(bone);
                            }

                            pData    += 5;
                            fixCS0159 = true;
                        }

                        if (fixCS0159)
                        {
                            fixCS0159 = false;
                            goto STop;
                        }

                        if (bones.Count > 0)
                        {
                            nodeTreeError = true;
                        }
                    }
                    else if (p.Name == "NodeMix")
                    {
                        //Use node mix to create weight groups
                        byte *pData     = (byte *)p.Data;
                        bool  fixCS0159 = false;
TTop:
                        switch (*pData)
                        {
                        //Type 3 is for weighted influences
                        case 3:
                            //Get index/count fields
                            index = *(bushort *)(pData + 1);
                            count = pData[3];
                            //Get data pointer (offset of 4)
                            MDL0NodeType3Entry *nEntry = (MDL0NodeType3Entry *)(pData + 4);
                            //Create influence with specified count
                            inf = new Influence();
                            //Iterate through weights, adding each to the influence
                            //Here, we are referring back to the NodeCache to grab the bone.
                            //Note that the weights do not reference other influences, only bones. There is a good reason for this.
                            MDL0BoneNode b           = null;
                            List <int>   nullIndices = new List <int>();
                            for (int i = 0; i < count; i++, nEntry++)
                            {
                                if (nEntry->_id < linker.NodeCache.Length &&
                                    (b = linker.NodeCache[nEntry->_id] as MDL0BoneNode) != null)
                                {
                                    inf.AddWeight(new BoneWeight(b, nEntry->_value));
                                }
                                else
                                {
                                    nullIndices.Add(i);
                                }
                            }

                            bool noWeights = false;
                            if ((nullCount = nullIndices.Count) > 0)
                            {
                                List <BoneWeight> newWeights = new List <BoneWeight>();
                                for (int i = 0; i < inf.Weights.Count; i++)
                                {
                                    if (!nullIndices.Contains(i))
                                    {
                                        newWeights.Add(inf.Weights[i]);
                                    }
                                }

                                if (newWeights.Count == 0)
                                {
                                    noWeights = true;
                                }
                                else
                                {
                                    inf.SetWeights(newWeights);
                                }
                            }

                            //Add influence to model object, while adding it to the cache.
                            //Don't add user references here, they will be added during each object's initialization
                            if (!noWeights)
                            {
                                ((Influence)(linker.NodeCache[index] = model._influences.FindOrCreate(inf)))
                                ._index = index;
                            }

                            //Move data pointer to next entry
                            pData     = (byte *)nEntry;
                            fixCS0159 = true;
                            break;

                        //Type 5 is for primary influences
                        case 5:
                            pData    += 5;
                            fixCS0159 = true;
                            break;
                        }

                        if (fixCS0159)
                        {
                            fixCS0159 = false;
                            goto TTop;
                        }
                    }
                }

                if (nullCount > 0)
                {
                    model._errors.Add("There were " + nullCount + " null weights in NodeMix.");
                }

                if (nodeTreeError)
                {
                    model._errors.Add("The NodeTree definition did not match the bone tree.");
                }
            }
            else if (_type == MDLResourceType.Objects)
            {
                //Attach materials to polygons.
                //This assumes that materials have already been parsed.

                List <ResourceNode> matList = ((MDL0Node)_parent)._matList;
                MDL0ObjectNode      obj;
                MDL0MaterialNode    mat;

                //Find DrawOpa or DrawXlu entry in Definition list
                foreach (ResourcePair p in *linker.Defs)
                {
                    if (p.Name == "DrawOpa" || p.Name == "DrawXlu")
                    {
                        bool isXLU = p.Name == "DrawXlu";

                        ushort objectIndex = 0;
                        byte * pData       = (byte *)p.Data;
                        while (*pData++ == 4)
                        {
                            //Get object with index
                            objectIndex = *(bushort *)(pData + 2);
                            if (objectIndex >= _children.Count || objectIndex < 0)
                            {
                                model._errors.Add("Object index was greater than the actual object count.");
                                objectIndex = 0;
                            }

                            obj = _children[objectIndex] as MDL0ObjectNode;

                            //Get material with index
                            mat = matList[*(bushort *)pData] as MDL0MaterialNode;

                            //Get bone with index
                            int          boneIndex = *(bushort *)(pData + 4);
                            MDL0BoneNode visBone   = null;
                            if (linker.BoneCache != null && boneIndex >= 0 && boneIndex < linker.BoneCache.Length)
                            {
                                visBone = linker.BoneCache[boneIndex];
                            }

                            obj._drawCalls.Add(new DrawCall(obj)
                            {
                                _drawOrder         = pData[6],
                                _isXLU             = isXLU,
                                MaterialNode       = mat,
                                VisibilityBoneNode = visBone
                            });

                            //Increment pointer
                            pData += 7;
                        }
                    }
                }

                foreach (MDL0ObjectNode m in _children)
                {
                    int max = 0;
                    foreach (DrawCall c in m._drawCalls)
                    {
                        max = Maths.Max(max, c.MaterialNode.Children.Count);
                        if (c.MaterialNode.MetalMaterial != null)
                        {
                            max = Maths.Max(max, c.MaterialNode.MetalMaterial.Children.Count);
                        }
                    }

                    bool hasUnused = false;
                    if (m._manager != null)
                    {
                        for (int i = max; i < 8; i++)
                        {
                            if (m._manager.HasTextureMatrix[i])
                            {
                                m._manager.HasTextureMatrix[i] = false;
                                m._forceRebuild = true;
                                hasUnused       = true;
                            }
                        }
                    }

                    if (hasUnused)
                    {
                        ((MDL0Node)Parent)._errors.Add("Object " + m.Index + " has unused texture matrices.");
                    }

                    //This error doesn't seem to always be true for factory models...
                    //if (m.HasTexMtx && m.HasNonFloatVertices)
                    //{
                    //    ((MDL0Node)Parent)._errors.Add("Object " + m.Index + " has texture matrices and non-float vertices, meaning it will explode in-game.");
                    //    m.SignalPropertyChange();
                    //}
                }
            }
        }
Beispiel #32
0
        public void ModNegative()
        {
            var actual = Maths.Mod(-8, 7);

            Assert.Equal(6, actual);
        }
        // ***** ALGORITHME 16 *****
        /// <summary>
        /// Calcule les corrections dues au mouvement propre d’un corps céleste à apporter sur les coordonnées équatoriales géocentriques géométriques à l’époque J2000 d’un corps céleste
        /// à partir du Jour Julien des Ephémérides correspondant à la date et l’heure considérées, des mouvements propres annuels du corps céleste en ascension droite et déclinaison et
        /// de la déclinaison géocentrique géométrique du corps céleste à l’époque J2000.
        /// </summary>
        /// <param name="a_lieuEtDateCalcul">Lieu d'observation et date pour le calcul.</param>
        private void CalculerMouvementPropre(PositionTemps a_lieuEtDateCalcul)
        {
            // Déclaration des variables de la méthode
            double T; // variable de calcul

            // Calcul du nombre d'années écoulées depuis le 1,5 janvier 2000
            T = (a_lieuEtDateCalcul.JourJulienEphemerides - 2451545.0) / 365.25;

            // Calcul de la correction à apporter sur l'ascension droite géocentrique géométrique à l'époque J2000
            deltaAlpha1 = T * (objetCielProfond.MouvementPropreAlpha / (1000.0 * Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale)))); // correction en s
            deltaAlpha1 = deltaAlpha1 / 3600.0;                                                                                                    // correction en h

            // Calcul de la correction à apporter sur la déclinaison géocentrique géométrique à l'époque J2000
            deltaDelta1 = T * (objetCielProfond.MouvementPropreDelta / 1000.0); // correction en s
            deltaDelta1 = deltaDelta1 / 3600.0;                                 // correction en degrés
        }
Beispiel #34
0
        public void Batch(VoxelObject vo, Vector3 position)
        {
            Matrix4 mat4 = Maths.CreateTransformationMatrix(position, vo.MeshRotation, vo.MeshScale);

            Batch(vo, mat4);
        }
        // ***** ALGORITHME 18P *****
        /// <summary>
        /// Calcule les corrections dues à la précession à apporter sur les coordonnées équatoriales géocentriques géométriques d’un corps céleste rapportées à l’équinoxe J2000
        /// à partir du Jour Julien des Ephémérides correspondant à la date et l’heure considérées, des coordonnées équatoriales géocentriques géométriques du corps céleste à
        /// l’époque J2000 et des corrections dues au mouvement propre.
        /// </summary>
        /// <param name="a_lieuEtDateCalcul">Lieu d'observation et date pour le calcul.</param>
        private void CalculerCorrectionCoordonneesEquatorialesPrecession(PositionTemps a_lieuEtDateCalcul)
        {
            // Déclaration des variables de la méthodes
            double T, dzeta, z, teta, A, B, C; // variables de calcul

            // Calcul du nombre de siècles depuis le 1,5 janvier 2000
            T = (a_lieuEtDateCalcul.JourJulienEphemerides - 2451545.0) / 36525.0;

            // Calcul de l'angle eta
            dzeta = 2306.2181 * T + 0.30188 * T * T + 0.017998 * T * T * T; // angle en secondes d'arc
            dzeta = dzeta / 3600.0;                                         // angle en degrés

            // Calcul de l'angle pi
            z = 2306.2181 * T + 1.09468 * T * T + 0.018203 * T * T * T; // angle en secondes d'arc
            z = z / 3600.0;                                             // angle en degrés

            // Calcul de l'angle p
            teta = 2004.3109 * T - 0.42665 * T * T - 0.041833 * T * T * T; // angle en secondes d'arc
            teta = teta / 3600.0;                                          // angle en degrés

            // Calcul de l'angle A
            A = Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1)) * Math.Sin(Maths.DegToRad(15.0 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1) + dzeta));

            // Calcul de l'angle B
            B = Math.Cos(Maths.DegToRad(teta)) * Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1)) * Math.Cos(Maths.DegToRad(15.0 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1) + dzeta)) - Math.Sin(Maths.DegToRad(teta)) * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1));

            // Calcul de l'angle C
            C = Math.Sin(Maths.DegToRad(teta)) * Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1)) * Math.Cos(Maths.DegToRad(15.0 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1) + dzeta)) + Math.Cos(Maths.DegToRad(teta)) * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1));

            // Calcul de la correction à apporter sur l'ascension droite géocentrique géométrique rapportée à l'équinoxe J2000
            deltaAlpha2 = (Maths.Modulo(Maths.RadToDeg(Math.Atan2(A, B)) + z, TypeAngle.ANGLE_DEGRES_360) / 15.0) - deltaAlpha1 - objetCielProfond.AlphaJ2000.Decimale;

            // Calcul de la correction à apporter sur la déclinaison géocentrique géométrique rapportée à l'équinoxe J2000
            deltaDelta2 = Maths.RadToDeg(Math.Asin(C)) - deltaDelta1 - objetCielProfond.DeltaJ2000.Decimale;
        }
        private QueryNode GetPurchaseDetail(string supplierNo, string dateS, string dateE, string dueDateS, string dueDateE,
                                            string itemNo, string itemName, string itemSpec, string siteNo
                                            , string purchase_no//20170919 add by liwei1 for B001-170918003
                                            )
        {
            QueryNode  subNodeFilArrival = GetFilArrivalQueryNode();
            JoinOnNode joinOnNode        =
                OOQL.Select(
                    OOQL.CreateProperty("PURCHASE_ORDER.DOC_NO", "purchase_no"),
                    OOQL.CreateProperty("PURCHASE_ORDER.PURCHASE_DATE", "purchase_date"),
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.PLAN_ARRIVAL_DATE", "so_due_date"),
                    OOQL.CreateProperty("PURCHASE_ORDER_D.SequenceNumber", "seq"),
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.SequenceNumber", "line_seq"),
                    OOQL.CreateConstants(0, GeneralDBType.Int32, "batch_seq"),
                    OOQL.CreateProperty("ITEM.ITEM_CODE", "item_no"),
                    OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_DESCRIPTION", "item_name"),
                    OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_SPECIFICATION", "item_spec"),
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_CODE"), OOQL.CreateConstants(string.Empty, GeneralDBType.String), "item_feature_no"),        //20170504 add by wangyq for P001-161209002
                    Formulas.IsNull(OOQL.CreateProperty("ITEM_FEATURE.ITEM_SPECIFICATION"), OOQL.CreateConstants(string.Empty, GeneralDBType.String), "item_feature_name"),     //20171010 modi by zhangcn for B001-171010004
                    Formulas.IsNull(
                        OOQL.CreateProperty("UNIT.UNIT_CODE"),
                        OOQL.CreateConstants(string.Empty, GeneralDBType.String), "unit_no"),
                    OOQL.CreateConstants("N", GeneralDBType.String, "qc_type"),       //20170619 modi by zhangcn for B001-170629006 【OLD:null】
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.BUSINESS_QTY", "purchase_qty"),
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.ARRIVED_BUSINESS_QTY", "receipt_qty"),
                    //OOQL.CreateArithmetic(
                    //        OOQL.CreateProperty("PURCHASE_ORDER_SD.BUSINESS_QTY"),
                    //        OOQL.CreateProperty("PURCHASE_ORDER_SD.ARRIVED_BUSINESS_QTY"), ArithmeticOperators.Sub,"unpaid_qty"),

                    OOQL.CreateArithmetic(OOQL.CreateArithmetic(OOQL.CreateProperty("PURCHASE_ORDER_SD.BUSINESS_QTY"), OOQL.CreateProperty("PURCHASE_ORDER_SD.ARRIVED_BUSINESS_QTY"), ArithmeticOperators.Sub),
                                          Formulas.IsNull(OOQL.CreateProperty("FILARR.AQTY"), OOQL.CreateConstants(0)),
                                          ArithmeticOperators.Sub,
                                          "unpaid_qty"),
                    Formulas.IsNull(OOQL.CreateProperty("FILARR.AQTY"), OOQL.CreateConstants(0), "on_the_way_qty"),       //20170619 modi by zhangcn for B001-170629006 【OLD:0】
                    Formulas.IsNull(
                        OOQL.CreateProperty("ITEM_PURCHASE.RECEIPT_OVER_RATE") * OOQL.CreateConstants(100, GeneralDBType.Decimal),
                        OOQL.CreateConstants(0, GeneralDBType.Decimal), "over_deliver_rate"),
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.REMARK", "remark"),
                    Formulas.IsNull(
                        OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_NAME"),
                        OOQL.CreateConstants(string.Empty, GeneralDBType.String), "employee_name"),
                    Formulas.IsNull(
                        OOQL.CreateProperty("PRICE_UNIT.UNIT_CODE"),
                        OOQL.CreateConstants(string.Empty, GeneralDBType.String), "valuation_unit_no"),
                    OOQL.CreateProperty("PURCHASE_ORDER_SD.PRICE_QTY", "valuation_qty"),
                    OOQL.CreateConstants(0, GeneralDBType.Decimal, "returned_qty"),   //20170619 add by zhangcn for B001-170629006
                    OOQL.CreateConstants(1, GeneralDBType.Decimal, "box_qty"))        //20170619 add by zhangcn for B001-170629006
                .From("PURCHASE_ORDER", "PURCHASE_ORDER")
                .InnerJoin("PURCHASE_ORDER.PURCHASE_ORDER_D", "PURCHASE_ORDER_D")
                .On((OOQL.CreateProperty("PURCHASE_ORDER_D.PURCHASE_ORDER_ID") == OOQL.CreateProperty("PURCHASE_ORDER.PURCHASE_ORDER_ID")))
                .InnerJoin("PURCHASE_ORDER.PURCHASE_ORDER_D.PURCHASE_ORDER_SD", "PURCHASE_ORDER_SD")
                .On((OOQL.CreateProperty("PURCHASE_ORDER_SD.PURCHASE_ORDER_D_ID") == OOQL.CreateProperty("PURCHASE_ORDER_D.PURCHASE_ORDER_D_ID")))
                .InnerJoin("PLANT", "PLANT")
                .On((OOQL.CreateProperty("PLANT.PLANT_ID") == OOQL.CreateProperty("PURCHASE_ORDER_SD.RECEIVE_Owner_Org.ROid")))
                .InnerJoin("ITEM", "ITEM")
                .On((OOQL.CreateProperty("ITEM.ITEM_ID") == OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_ID")))
                //20170504 add by wangyq for P001-161209002  ========================begin=========================
                .LeftJoin("ITEM.ITEM_FEATURE", "ITEM_FEATURE")
                .On(OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_FEATURE_ID") == OOQL.CreateProperty("ITEM_FEATURE.ITEM_FEATURE_ID"))
                //20170504 add by wangyq for P001-161209002  ========================end=========================
                .LeftJoin("UNIT", "UNIT")
                .On((OOQL.CreateProperty("UNIT.UNIT_ID") == OOQL.CreateProperty("PURCHASE_ORDER_D.BUSINESS_UNIT_ID")))
                .InnerJoin("SUPPLIER", "SUPPLIER")
                .On((OOQL.CreateProperty("SUPPLIER.SUPPLIER_ID") == OOQL.CreateProperty("PURCHASE_ORDER.SUPPLIER_ID")))
                .LeftJoin("ITEM_PURCHASE", "ITEM_PURCHASE")
                .On((OOQL.CreateProperty("ITEM_PURCHASE.ITEM_ID") == OOQL.CreateProperty("ITEM.ITEM_ID"))
                    & (OOQL.CreateProperty("ITEM_PURCHASE.Owner_Org.ROid") == OOQL.CreateProperty("PURCHASE_ORDER.Owner_Org.ROid")))
                .LeftJoin("EMPLOYEE", "EMPLOYEE")
                .On((OOQL.CreateProperty("EMPLOYEE.EMPLOYEE_ID") == OOQL.CreateProperty("PURCHASE_ORDER.Owner_Emp")))
                .LeftJoin("UNIT", "PRICE_UNIT")
                .On((OOQL.CreateProperty("PRICE_UNIT.UNIT_ID") == OOQL.CreateProperty("PURCHASE_ORDER_D.PRICE_UNIT_ID")))
                //20170619 add by zhangcn for B001-170629006 ===begin===
                .LeftJoin(subNodeFilArrival, "FILARR")
                .On(OOQL.CreateProperty("FILARR.ORDER_NO") == OOQL.CreateProperty("PURCHASE_ORDER.DOC_NO") &
                    OOQL.CreateProperty("FILARR.ORDER_SE") == OOQL.CreateProperty("PURCHASE_ORDER_D.SequenceNumber") &
                    OOQL.CreateProperty("FILARR.ORDER_SE_SE") == OOQL.CreateProperty("PURCHASE_ORDER_SD.SequenceNumber"));

            //20170619 add by zhangcn for B001-170629006 ===begin===

            //如果起始日期为空格,空值,null时默认最小日期
            if (Maths.IsEmpty(dateS.ToDate()))
            {
                dateS = OrmDataOption.EmptyDateTime.ToStringExtension();
            }
            if (Maths.IsEmpty(dueDateS.ToDate()))
            {
                dueDateS = OrmDataOption.EmptyDateTime.ToStringExtension();
            }
            //如果结束日期为空格,空值,null时默认最大日期
            if (Maths.IsEmpty(dateE.ToDate()))
            {
                dateE = OrmDataOption.EmptyDateTime1.ToStringExtension();
            }
            if (Maths.IsEmpty(dueDateE.ToDate()))
            {
                dueDateE = OrmDataOption.EmptyDateTime1.ToStringExtension();
            }

            QueryConditionGroup conditionGroup = (OOQL.AuthFilter("TRANSACTION_DOC", "TRANSACTION_DOC"))
                                                 & ((OOQL.CreateProperty("PURCHASE_ORDER.ApproveStatus") == OOQL.CreateConstants("Y"))
                                                                                                                                                                              //& (OOQL.CreateProperty("PURCHASE_ORDER_SD.BUSINESS_QTY") > OOQL.CreateProperty("PURCHASE_ORDER_SD.RECEIPTED_BUSINESS_QTY"))//20170903 mark by liwei1 for B001-170901012
                                                    & (OOQL.CreateProperty("PURCHASE_ORDER_SD.BUSINESS_QTY") > OOQL.CreateProperty("PURCHASE_ORDER_SD.ARRIVED_BUSINESS_QTY")) //20170903 add by liwei1 for B001-170901012
                                                    & (OOQL.CreateProperty("SUPPLIER.SUPPLIER_CODE") == OOQL.CreateConstants(supplierNo))
                                                    & ((OOQL.CreateProperty("PURCHASE_ORDER.DOC_DATE") >= OOQL.CreateConstants(dateS.ToDate()))
                                                       & (OOQL.CreateProperty("PURCHASE_ORDER.DOC_DATE") <= OOQL.CreateConstants(dateE.ToDate())))
                                                    & ((OOQL.CreateProperty("PURCHASE_ORDER_SD.PLAN_ARRIVAL_DATE") >= OOQL.CreateConstants(dueDateS.ToDate()))
                                                       & (OOQL.CreateProperty("PURCHASE_ORDER_SD.PLAN_ARRIVAL_DATE") <= OOQL.CreateConstants(dueDateE.ToDate()))));

            //如果【品号】不为空增加条件
            if (!Maths.IsEmpty(itemNo))
            {
                conditionGroup &= (OOQL.CreateProperty("ITEM.ITEM_CODE").Like(OOQL.CreateConstants("%" + itemNo + "%")));
            }
            //如果【品名】不为空增加条件
            if (!Maths.IsEmpty(itemName))
            {
                conditionGroup &= (OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_DESCRIPTION").Like(OOQL.CreateConstants("%" + itemName + "%")));
            }
            //如果【规格】不为空增加条件
            if (!Maths.IsEmpty(itemSpec))
            {
                conditionGroup &= (OOQL.CreateProperty("PURCHASE_ORDER_D.ITEM_SPECIFICATION").Like(OOQL.CreateConstants("%" + itemSpec + "%")));
            }
            //如果营运中心不为空增加条件
            if (!Maths.IsEmpty(siteNo))
            {
                conditionGroup &= (OOQL.CreateProperty("PLANT.PLANT_CODE") == OOQL.CreateConstants(siteNo));
            }

            //20170919 add by liwei1 for B001-170918003 ===begin===
            //如果采购单号不为空增加条件
            if (!Maths.IsEmpty(purchase_no))
            {
                conditionGroup &= (OOQL.CreateProperty("PURCHASE_ORDER.DOC_NO") == OOQL.CreateConstants(purchase_no));
            }
            //20170919 add by liwei1 for B001-170918003 ===end===

            return(joinOnNode.Where(conditionGroup)
                   //20170919 add by liwei1 for B001-170918003 ===begin===
                   .OrderBy(
                       OOQL.CreateOrderByItem(
                           OOQL.CreateProperty("PURCHASE_ORDER.DOC_NO"), SortType.Asc),
                       OOQL.CreateOrderByItem(
                           OOQL.CreateProperty("PURCHASE_ORDER_D.SequenceNumber"), SortType.Asc))
                   //20170919 add by liwei1 for B001-170918003 ===end===
                   );
        }
        // ***** ALGORITHME 19 *****
        /// <summary>
        /// Calcule les corrections dues à la nutation à apporter sur les coordonnées équatoriales géocentriques géométriques d’un corps céleste à partir de l’obliquité moyenne,
        /// de la nutation en longitude écliptique, de la nutation en obliquité, des coordonnées équatoriales géocentriques géométriques du corps céleste à l’époque J2000,
        /// des corrections dues au mouvement propre et des corrections dues à la précession.
        /// </summary>
        /// <param name="a_lieuEtDateCalcul">Lieu d'observation et date pour le calcul.</param>
        private void CalculerCorrectionCoordonneesEquatorialesNutation(PositionTemps a_lieuEtDateCalcul)
        {
            // Calcul de la correction à apporter sur l'ascension droite géométrique
            deltaAlpha3 = (Math.Cos(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne)) + Math.Sin(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne)) * Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                           * Math.Tan(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2))) * (a_lieuEtDateCalcul.NutationLongitude * 3600.0)
                          - (Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2))) * Math.Tan(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2))) * (a_lieuEtDateCalcul.NutationObliquite * 3600.0); // correction en seconde d'arc de degrés

            deltaAlpha3 = deltaAlpha3 / 54000.0;                                                                                                                                                                                                                                // correction en heure

            // Calcul de la correction à apporter sur la déclinaison géométrique
            deltaDelta3 = (Math.Sin(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne)) * Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))) * (a_lieuEtDateCalcul.NutationLongitude * 3600.0)
                          + Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2))) * (a_lieuEtDateCalcul.NutationObliquite * 3600.0); // correction en secondes d'arc

            deltaDelta3 = deltaDelta3 / 3600.0;                                                                                                                                  // correction en degrés
        }
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            lblPopup.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            lblNumberOfQuestions.Text = selItem + " questions will be generated randomly";
            btnFinish.IsEnabled = true;
            btnStartAgain.IsEnabled = true;
            //lblTotalMarks.Visibility = Windows.UI.Xaml.Visibility.Visible;
            if (countTimer < 5 || countTimer < 15 || countTimer20 < 61 || countTimer30 < 75 || countTimer50 < 120)
            {
                lblTimeRunning.Text = "Dear learner, you are running out of time";
            }
            btnStartAgain.Visibility = Windows.UI.Xaml.Visibility.Visible;
            if (countTimer == 0)
            {
                messageBox("You have ran out of time ,your total mark = " + marks + "/" + 10);
                lblTimeElapsed.Text = "You have ran out of time ,your total mark = " + marks + "/" + 10;
                radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblQuestion.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                btnStartAgain.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else if (countTimer20 == 0)
            {
                messageBox("You have ran out of time ,your total mark = " + marks + "/" + 20);
                lblTimeElapsed.Text = "You have ran out of time ,your total mark = " + marks + "/" + 20;
                radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblQuestion.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else if (countTimer30 == 0)
            {
                messageBox("You have ran out of time ,your total mark = " + marks + "/" + 30);
                lblTimeElapsed.Text = "You have ran out of time ,your total mark = " + marks + "/" + 30;
                radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblQuestion.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
                btnNext.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else if (countTimer50 == 0)
            {
                messageBox("You have ran out of time ,your total mark = " + marks + "/" + 50);
                lblTimeElapsed.Text = "You have ran out of time ,your total mark = " + marks + "/" + 50;
                radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblQuestion.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
                btnNext.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Visible;
            radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Visible;
            radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Visible;
            lblDisplayMark.Visibility = Windows.UI.Xaml.Visibility.Visible;
            lblTop.Visibility = Windows.UI.Xaml.Visibility.Visible;
            lblTop2.Visibility = Windows.UI.Xaml.Visibility.Visible;
            btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
            btnNext.Visibility = Windows.UI.Xaml.Visibility.Visible;

            module = new InsertModule();
            int number = 0;
            myList = new List<SubjectViewModel>();
            subjects = new ObservableCollection<SubjectViewModel>();
            subjectsList = new List<SubjectViewModel>();

            subjectModel = new SubjectsViewModel();

            string grade = item.Substring(0, item.IndexOf(":"));
            table = item.Substring(item.IndexOf(":") + 1);

            btnNext.Content = "Question " + countButton + ".";
            try
            {
                if (table.Equals("English"))
                {

                    subjects = subjectModel.getEnglishQuestions1(grade);
                    subjectsList = subjectModel.getEnglishQuestion(grade);
                    myList = subjectModel.getEnglishQuestion(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;

                    it = names[number];

                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));

                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    correct_answer = subject.getEnglishCorrectAnswer(pass_question);

                    if (subject.verifyExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];

                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }
                }
                else if (table.Equals("Maths"))
                {
                    subjects = subjectModel.getMathsQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    maths = subject.getMathsCorrectAnswer(pass_question);
                    if (subject.verifyMathsExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("Business"))
                {
                    subjects = subjectModel.getBusinessQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    business = subject.getBusinessCorrectAnswer(pass_question);
                    if (subject.verifyBusinessExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("Accounting"))
                {
                    subjects = subjectModel.getAccountingQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    accounting = subject.getAccountingCorrectAnswer(pass_question);
                    if (subject.verifyAccountingExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("Geography"))
                {
                    subjects = subjectModel.getGeographyQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    geography = subject.getGeographyCorrectAnswer(pass_question);
                    if (subject.verifyGeographyExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("History"))
                {
                    subjects = subjectModel.getHistoryQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    history = subject.getHistoryCorrectAnswer(pass_question);
                    if (subject.verifyHistoryExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("Life"))
                {
                    subjects = subjectModel.getLifeOrientationQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + "." + it.Substring(0, it.IndexOf("#"));
                    life = subject.getLifeCorrectAnswer(pass_question);
                    if (subject.verifyLifeOriontationExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
                else if (table.Equals("Physics"))
                {
                    subjects = subjectModel.getPhysicsQuestions1(grade);
                    int totalItems = subjects.Count();
                    int count = 0;
                    names = new string[subjects.Count()];
                    foreach (var i in subjects)
                    {
                        names[count] = i.QUESTION + "#" + i.ANSWER + "#" + i.ANSWER1 + "#" + i.ANSWER2;
                        count++;
                    }
                    combo.SelectedIndex.ToString();
                    string answer1 = string.Empty, answer2 = string.Empty, answer3 = string.Empty;
                    if (readQuestion.Equals(number)) { }
                    number = random.Next(0, totalItems);
                    readQuestion = number;
                    it = names[number];
                    names = it.Split('#');
                    answer1 = names[1];
                    answer2 = names[2];
                    answer3 = names[3];
                    pass_question = it.Substring(0, it.IndexOf("#"));
                    myQuestion = pass_question;
                    lblQuestion.Text = countButton + ".  " + it.Substring(0, it.IndexOf("#"));
                    physics = subject.getPhysicsCorrectAnswer(pass_question);
                    if (subject.verifyPhysicsExist(pass_question, answer1))
                    {
                        string[] answers_array = { answer1, answer2, answer3 };
                        Random ran = new Random();
                        int num = 0;
                        num = ran.Next(0, 2);
                        int num1 = ran.Next(0, 2);
                        int num2 = ran.Next(0, 2);
                        if (num == num1)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[0];
                        }
                        else if (num == num2)
                        {
                            radAnswer1.Content = answers_array[0];
                            radAnswer2.Content = answers_array[1];
                            radAnswer3.Content = answers_array[2];
                        }
                        else if (num1 == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else if (num == num1 && num == num2)
                        {
                            radAnswer1.Content = answers_array[2];
                            radAnswer2.Content = answers_array[0];
                            radAnswer3.Content = answers_array[1];
                        }
                        else
                        {
                            radAnswer1.Content = answers_array[num];
                            radAnswer2.Content = answers_array[num1];
                            radAnswer3.Content = answers_array[num2];
                        }
                    }

                }
            }
            catch
            {

            }

            radAnswer1.IsChecked = false;
            radAnswer2.IsChecked = false;
            radAnswer3.IsChecked = false;

            radAnswer1.IsEnabled = true;
            radAnswer2.IsEnabled = true;
            radAnswer3.IsEnabled = true;
            // time.Interval = new TimeSpan(0, 0, 0, 1);
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (combo.SelectedItem != null)
            {
                selItem = int.Parse(combo.SelectedItem.ToString());
                //messageBox("Selected is " + selItem);
                if (countButton > selItem)
                {
                    btnNext.Content = "Finish";
                    if (marks > 0)
                    {
                        if (selItem == 10)
                        {

                            marks = (marks / 10) * 100;
                        }
                        if (selItem == 20)
                        {
                            marks = (marks / 20) * 100;
                        }
                        if (selItem == 30)
                        {
                            marks = (marks / 30) * 100;
                        }
                        if (selItem == 50)
                        {
                            marks = (marks / 50) * 100;
                        }
                    }
                    time.Stop();
                    ////////////////////////////////////////////////////////////////////////////////////////

                    string message = "";
                    if (marks < 50)
                    {
                        // message = "Sorry You failed the test";
                        lblTotalMarks.Text = "Complete!!!";
                        //lblTotalMarks.Text = message;
                    }
                    else if (marks >= 50 && marks < 75)
                    {
                        message = "You passed the test with an avarage score";
                        lblTotalMarks.Text = "Complete!!!";
                    }
                    else if (marks >= 75)
                    {
                        message = "Passed with Distinction";
                        lblTotalMarks.Text = "Complete!!!";

                    }
                    lblNumberOfQuestions.Visibility = Windows.UI.Xaml.Visibility.Collapsed;//lblTotalMarks.Text = message;
                    //messageBox("Complete!!! :Total marks " + marks + "% " + message);
                    //lblTotalMarks.Text = "Complete!!! :Total marks " + marks + "% " + message;
                    if (table.Equals("Accounting"))
                    {
                        subject.removeAllAccountingQuestions(); module.pupulateAccountingTable();
                    }
                    else if (table.Equals("Business"))
                    {
                        subject.removeAllBusinessQuestions(); module.pupulateBusinessTable();
                    }
                    else if (table.Equals("English"))
                    {
                        subject.removeAll(); module.populateEnglishTables();
                    }
                    else if (table.Equals("Geography"))
                    {
                        subject.removeAllGeographyQuestions(); module.pupulateGeographyTable();
                    }
                    else if (table.Equals("History"))
                    {
                        subject.removeAllHistoryQuestions(); module.pupulateHistoryTable();
                    }
                    else if (table.Equals("Life"))
                    {
                        subject.removeAllLifeQuestions(); module.pupulateLifeOrientationTable();
                    }
                    else if (table.Equals("Maths"))
                    {
                        subject.removeAllMathsQuestions(); module.pupulateMathsTable();
                    }
                    else if (table.Equals("Physics"))
                    {
                        subject.removeAllPhysicsQuestions(); module.pupulatePhysicsTable();
                    }
                    btnNext.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    lblQuestion.Text = "";
                    btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }

            }
            else
            {
                lblNumberOfQuestions.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                if (countButton > 10)
                {
                    time.Stop();
                    btnNext.Content = "Finish";
                    if (marks > 0)
                    {
                        if (selItem == 10)
                        {
                            marks = (marks / 10) * 100;

                        }
                    }
                    string message = "";
                    if (marks < 50)
                    {
                        message = "Sorry You failed the test";
                        lblTotalMarks.Text = "Complete!!!";

                    }
                    else if (marks >= 50 && marks < 75)
                    {
                        message = "You passed the test with an avarage mark";
                        lblTotalMarks.Text = "Complete!!!";
                    }
                    else if (marks >= 75)
                    {
                        message = "Passed with Distinction";
                        lblTotalMarks.Text = "Complete!!!";
                    }
                    double store = marks = (marks / 10) * 100;
                    //messageBox("Complete!!! :Total marks " + store + "% ");
                    //lblTotalMarks.Text = "Complete!!! :Total marks " + store + "% "+message;
                    lblNumberOfQuestions.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    btnNext.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    lblQuestion.Text = "";
                    btnFinish.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    if (table.Equals("Accounting"))
                    {
                        subject.removeAllAccountingQuestions(); module.pupulateAccountingTable();
                    }
                    else if (table.Equals("Business"))
                    {
                        subject.removeAllBusinessQuestions(); module.pupulateBusinessTable();
                    }
                    else if (table.Equals("English"))
                    {
                        subject.removeAll(); module.populateEnglishTables();
                    }
                    else if (table.Equals("Geography"))
                    {
                        subject.removeAllGeographyQuestions(); module.pupulateGeographyTable();
                    }
                    else if (table.Equals("History"))
                    {
                        subject.removeAllHistoryQuestions(); module.pupulateHistoryTable();
                    }
                    else if (table.Equals("Life"))
                    {
                        subject.removeAllLifeQuestions(); module.pupulateLifeOrientationTable();
                    }
                    else if (table.Equals("Maths"))
                    {
                        subject.removeAllMathsQuestions(); module.pupulateMathsTable();
                    }
                    else if (table.Equals("Physics"))
                    {
                        subject.removeAllPhysicsQuestions(); module.pupulatePhysicsTable();
                    }
                }
            }
            /*if (!(radAnswer1.IsChecked == true) || !(radAnswer2.IsChecked == true) || !(radAnswer3.IsChecked == true))
            {
                messageBox("You have to select at least one of the answers");
            }*/
            if (countTimer == 0 || countTimer20 == 0 || countTimer30 == 0 || countTimer50 == 0)
            {
                lblQuestion.Text = "";
                lblTop.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTop2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                radAnswer3.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                lblTimeRunning.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                btnNext.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                time.Stop();
            }
            countButton++;
            subject.remove(pass_question);
            subject.removeMaths(pass_question);
            subject.removeBusiness(pass_question);
            subject.removeAccounting(pass_question);
            subject.removeGeography(pass_question);
            subject.removeHistory(pass_question);
            subject.removeLifeOrientation(pass_question);
            subject.removePhysics(pass_question);
            lblWrong.Text = "";



        }
        // ***** ALGORITHME 21 *****
        /// <summary>
        /// Calcule les corrections dues à l’aberration de la lumière à apporter sur les coordonnées équatoriales géocentriques géométriques d’un corps céleste à partir du Jour Julien des Ephémérides correspondant
        /// à la date et l’heure considérées, de la longitude écliptique géocentrique géométrique du Soleil, de l’obliquité moyenne, de la nutation en obliquité, des coordonnées équatoriales géocentriques
        /// géométriques du corps céleste à l’époque J2000, des corrections dues au mouvement propre et des corrections dues à la précession.
        /// </summary>
        /// <param name="a_lieuEtDateCalcul">Lieu d'observation et date pour le calcul.</param>
        /// <param name="a_terreSoleil">Objet Soleil calculé pour le lieu d'observation et la date du calcul.</param>
        private void CalculerCorrectionCoordonneesEquatorialesAberration(PositionTemps a_lieuEtDateCalcul, CorpsSystemeSolaire a_terreSoleil)
        {
            // Déclaration des variables de la méthode
            double T, et, pit; // variables de calcul

            // Calcul du nombre de siècles depuis le 1,5 janvier 2000
            T = (a_lieuEtDateCalcul.JourJulienEphemerides - 2451545.0) / 36525.0;

            // Calcul de l'excentricité de l'orbite de la Terre
            et = 0.016708617 - 0.000042037 * T - 0.0000001236 * T * T + 0.00000000004 * T * T * T;

            // Calcul de la longitude du perihélie de la Terre
            pit = 102.937348 + 1.7195269 * T + 0.00045962 * T * T + 0.000000499 * T * T * T;

            // Calcul de la correction à apporter sur la longitude écliptique géocentrique géométrique
            deltaAlpha4 = -20.49552 * ((Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2))) * Math.Cos(Maths.DegToRad(a_terreSoleil.LambdaGeometrique))
                                        * Math.Cos(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite)) + Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                                        * Math.Sin(Maths.DegToRad(a_terreSoleil.LambdaGeometrique))) / Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)))
                          + 20.49552 * et * ((Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2))) * Math.Cos(Maths.DegToRad(pit))
                                              * Math.Cos(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite)) + Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2))) * Math.Sin(Maths.DegToRad(pit)))
                                             / Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)));

            deltaAlpha4 = deltaAlpha4 / 54000.0; // corrections en heure

            // Calcul de la correction à apporter sur la déclinaison géocentrique géométrique
            deltaDelta4 = -20.49552 * (Math.Cos(Maths.DegToRad(a_terreSoleil.LambdaGeometrique)) * Math.Cos(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite)) * (Math.Tan(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite))
                                                                                                                                                                                                           * Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)) - Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                                                                                                                                                                                                           * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2))) + Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                                       * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)) * Math.Sin(Maths.DegToRad(a_terreSoleil.LambdaGeometrique)))
                          + 20.49552 * et * (Math.Cos(Maths.DegToRad(pit)) * Math.Cos(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite)) * (Math.Tan(Maths.DegToRad(a_lieuEtDateCalcul.ObliquiteMoyenne + a_lieuEtDateCalcul.NutationObliquite))
                                                                                                                                                                                     * Math.Cos(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)) - Math.Sin(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                                                                                                                                                                                     * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2))) + Math.Cos(Maths.DegToRad(15 * (objetCielProfond.AlphaJ2000.Decimale + deltaAlpha1 + deltaAlpha2)))
                                             * Math.Sin(Maths.DegToRad(objetCielProfond.DeltaJ2000.Decimale + deltaDelta1 + deltaDelta2)) * Math.Sin(Maths.DegToRad(pit))); // correction en secondes d'arc

            deltaDelta4 = deltaDelta4 / 3600.0;                                                                                                                             // corrections en degrés
        }
        public HttpResponseMessage SpecBuild(int id,  JObject moveTaskParams)
        {
            dynamic json = moveTaskParams;
            string jsonString = Convert.ToString(json.data);
            var response = Request.CreateResponse();
            List<CategoryViewModel> jCategory = (List<CategoryViewModel>)javaScriptSerializ­er.Deserialize(jsonString, typeof(List<CategoryViewModel>));

            //Iterate through data list collection
            List <List <string>> propNames = new List<List<string>>();
            List<List<string>> propParamsVal = new List<List<string>>();
            List<string> propLabel = new List<string>();
            List<string> propValues = new List<string>();
            List<string> propParams = new List<string>();
            List<string> propMathsParams = new List<string>();
            List<string> propInputParams = new List<string>();
            int LoopCounter = 0;
            LoopCounter = 0;

            foreach (var item in jCategory)
            {
                //
                LoopCounter = 0;
                propValues.Add(item.Name);
                propValues.Add(item.Description);
                propNames.Add(propValues);
                propValues = new List<string>();

                foreach (var list in item.Functions)
                {
                    //Propoerties for the row
                    LoopCounter = LoopCounter + 1;
                    propValues.Add(Convert.ToString(list.ID));
                    propValues.Add(Convert.ToString(list.Name));
                    propValues.Add(Convert.ToString(list.Function));
                    propValues.Add(Convert.ToString(list.Type));

                    //Logic string
                    List<string> logicString = new List<string>();
                    foreach (var logicvar in list.Logic)
                    {
                        logicString.Add(Convert.ToString(logicvar.Bracket1 + " " + logicvar.Input1 + " "
                            + " " + logicvar.LogicInd + " " + logicvar.Input2 + " " + logicvar.Bracket2 + " " + logicvar.Operator));
                    }

                    StringBuilder builderLogic = new StringBuilder();
                    foreach (var logiclevel in logicString)
                    {
                        // Append each int to the StringBuilder overload.
                        builderLogic.Append(logiclevel).Append(" ");
                    }
                    //Add row
                    propValues.Add(Convert.ToString(builderLogic));

                    //Functions
                    if (list.Function != "Input")
                    {
                        if(list.Function == "Maths")
                        {
                            //Maths string builder
                            List<string> mathString = new List<string>();
                            foreach (var Mathvar in list.Parameter)
                            {
                                Maths MathsObject = new Maths();
                                foreach (var MathvarLevel in Mathvar)
                                {
                                    if(MathvarLevel.Key == "Bracket1")
                                    {
                                        MathsObject.Bracket1 = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Input1")
                                    {
                                        MathsObject.Input1 = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Logic")
                                    {
                                        MathsObject.Logic = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Input2")
                                    {
                                        MathsObject.Input2 = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Bracket2")
                                    {
                                        MathsObject.Bracket2 = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Rounding")
                                    {
                                        if(MathvarLevel.Value != null)
                                        {
                                            MathsObject.Rounding = Convert.ToInt16(MathvarLevel.Value);
                                        }
                                        else
                                        {
                                            MathsObject.Rounding = null;
                                        }
                                    }
                                    else if (MathvarLevel.Key == "RoundingType")
                                    {
                                        MathsObject.RoundingType = MathvarLevel.Value;
                                    }
                                    else if (MathvarLevel.Key == "Logic2")
                                    {
                                        MathsObject.Logic2 = MathvarLevel.Value;
                                    }
                                }
                                //Show maths formula with rounding
                                if(MathsObject.Rounding > 0)
                                {
                                    mathString.Add(Convert.ToString(MathsObject.Bracket1 + "" + MathsObject.Input1 + " "
                                   + MathsObject.Logic + " " + MathsObject.Input2 + "" + MathsObject.Bracket2 + " "
                                   + MathsObject.Rounding + "dp " + MathsObject.RoundingType + " " + MathsObject.Logic2));
                                }
                                else
                                {
                                    mathString.Add(Convert.ToString(MathsObject.Bracket1 + "" + MathsObject.Input1 + " "
                                   + MathsObject.Logic + " " + MathsObject.Input2 + "" + MathsObject.Bracket2 + " "
                                   + MathsObject.Rounding + "" + MathsObject.RoundingType + "" + MathsObject.Logic2));
                                }
                            }
                            StringBuilder MathStringbuilder = new StringBuilder();
                            foreach (var bitmathlevel in mathString)
                            {
                                // Append each int to the StringBuilder overload.
                                MathStringbuilder.Append(bitmathlevel).Append(" ");
                            }
                            //Add to List
                            propValues.Add(Convert.ToString(MathStringbuilder));
                            propMathsParams = new List<string>();
                        }
                        else
                        {
                            foreach (var bit in list.Parameter)
                            {
                                foreach (var bitlevel in bit)
                                {
                                    propParams.Add(Convert.ToString(bitlevel.Key));
                                    propParams.Add(":");
                                    propParams.Add(Convert.ToString(bitlevel.Value));
                                    propParams.Add("~");
                                }
                                propParams.RemoveAt(propParams.LastIndexOf("~"));
                                StringBuilder builder = new StringBuilder();
                                foreach (var bitlevel in propParams)
                                {
                                    // Append each int to the StringBuilder overload.
                                    builder.Append(bitlevel).Append(" ");
                                }
                                propValues.Add(Convert.ToString(builder));
                                propParams = new List<string>();
                            }
                        }
                    }
                    else
                    {
                        foreach(var InputVal in list.Parameter)
                        {
                            foreach(var InputVal1 in InputVal)
                            {
                                if(InputVal1.Key == "templateOptions")
                                {
                                    foreach(var InputVal2 in InputVal1.Value)
                                    {
                                        if(InputVal2.Key != "options")
                                        {
                                            propInputParams.Add(InputVal2.Key);
                                            propInputParams.Add(":");
                                            propInputParams.Add(Convert.ToString(InputVal2.Value));
                                            propInputParams.Add("~");
                                        }
                                    }
                                }
                            }
                        }
                        propInputParams.RemoveAt(propInputParams.LastIndexOf("~"));
                        StringBuilder inputbuilder = new StringBuilder();
                        foreach (var bitlevel2 in propInputParams)
                        {
                            // Append each int to the StringBuilder overload.
                            inputbuilder.Append(bitlevel2).Append(" ");
                        }
                        propValues.Add(Convert.ToString(inputbuilder));
                        propInputParams = new List<string>();
                    }
                    propNames.Add(propValues);
                    propValues = new List<string>();
                }
            }
            response.Content = new StringContent(JsonConvert.SerializeObject(propNames));
            response.StatusCode = HttpStatusCode.OK;
            return response;
        }
Beispiel #41
0
        protected override void UpdateGfxCore()
        {
            // Generate the EMA line for the visible area of the chart
            var ema_colour = Settings.ColourEMA.ToArgbU();
            var bol_colour = Settings.ColourBollingerBands.ToArgbU();

            // Get the visible X axis range, and convert it to positive indices
            var first_idx = Instrument.FirstIdx;
            var rng       = Instrument.IndexRange((int)(Chart.XAxis.Min - 1), (int)(Chart.XAxis.Max + 1));

            rng.Beg = Maths.Clamp(rng.Beg - first_idx, 0, m_ema.Count);
            rng.End = Maths.Clamp(rng.End - first_idx, 0, m_ema.Count);
            if (rng.Counti == 0)
            {
                Gfx = null;
                return;
            }

            var count = rng.Counti;

            m_vbuf.Resize(count);
            m_ibuf.Resize((count - 1) * 2);
            m_nbuf.Resize(1);

            // EMA model
            var v = 0; var i = 0;

            foreach (var candle_index in rng)
            {
                var ema = m_ema[(int)candle_index];
                m_vbuf[v++] = new View3d.Vertex(new v4(candle_index + first_idx, (float)ema.Mean, ChartUI.Z.Indicators, 1f), ema_colour);
            }
            for (var vi = 0; i != m_ibuf.Count; ++vi)
            {
                m_ibuf[i++] = (ushort)(vi);
                m_ibuf[i++] = (ushort)(vi + 1);
            }
            var mat = new View3d.Material(shader: View3d.EShader.ThickLineListGS, shader_data: new[] { Settings.Width, 0, 0, 0 });

            m_nbuf[0] = new View3d.Nugget(View3d.EPrim.LineList, View3d.EGeom.Vert | View3d.EGeom.Colr, 0, (uint)v, 0, (uint)i, false, mat);

            // Add geometry for Bollinger bands
            if (Settings.BollingerBands != 0)
            {
                m_vbuf.Resize(m_vbuf.Count + 2 * count);
                m_ibuf.Resize(m_ibuf.Count + 2 * count);
                m_nbuf.Resize(m_nbuf.Count + 2);

                // Lower/Upper band
                foreach (var candle_index in rng)
                {
                    var ema = m_ema[(int)candle_index];
                    m_vbuf[v++] = new View3d.Vertex(new v4(candle_index + first_idx, (float)(ema.Mean - Settings.BollingerBands * ema.PopStdDev), ChartUI.Z.Indicators, 1f), bol_colour);
                    m_ibuf[i++] = (ushort)(v - 1);
                }
                m_nbuf[1] = new View3d.Nugget(View3d.EPrim.LineStrip, View3d.EGeom.Vert | View3d.EGeom.Colr, (uint)(v - count), (uint)v, (uint)(i - count), (uint)i);
                foreach (var candle_index in rng)
                {
                    var ema = m_ema[(int)candle_index];
                    m_vbuf[v++] = new View3d.Vertex(new v4(candle_index + first_idx, (float)(ema.Mean + Settings.BollingerBands * ema.PopStdDev), ChartUI.Z.Indicators, 1f), bol_colour);
                    m_ibuf[i++] = (ushort)(v - 1);
                }
                m_nbuf[2] = new View3d.Nugget(View3d.EPrim.LineStrip, View3d.EGeom.Vert | View3d.EGeom.Colr, (uint)(v - count), (uint)v, (uint)(i - count), (uint)i);
            }

            // Create the graphics
            Gfx = new View3d.Object(Name, 0xFFFFFFFF, m_vbuf.Count, m_ibuf.Count, m_nbuf.Count, m_vbuf.ToArray(), m_ibuf.ToArray(), m_nbuf.ToArray());

            base.UpdateGfxCore();
        }