public async Task <IActionResult> Edit(int id, [Bind("Id,Name,TotalKilo")] PackSize packSize)
        {
            if (id != packSize.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(packSize);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PackSizeExists(packSize.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(packSize));
        }
Exemplo n.º 2
0
        private bool CalculateBestFitSquare(SizeInt area, float atlasRes, ref Vector2 Scale, UMAData.GeneratedMaterial generatedMaterial)
        {
            while (true)
            {
                PackSize lastRect =


                    CalculateRects(generatedMaterial, area);
                if (lastRect.success)
                {
                    if (area.Width != umaGenerator.atlasResolution || area.Height != umaGenerator.atlasResolution)
                    {
                        float neww = lastRect.xMax;                         // was area.Width;
                        float newh = lastRect.yMax;                         // was area.Height;

                        Scale.x = atlasRes / neww;
                        Scale.y = atlasRes / newh;
                        return(true);
                    }
                    return(false); // Everything fit, let's leave.
                }

                int projectedWidth  = lastRect.xMax + lastRect.Width;
                int projectedHeight = lastRect.yMax + lastRect.Height;


                if (area.Width < area.Height)
                {
                    // increase width.
                    if (projectedWidth <= area.Width)
                    {
                        // If projectedWidth < the area width, then it's not
                        // increasing each loop, and it MUST.
                        area.Width += lastRect.Width;
                    }
                    else
                    {
                        area.Width = projectedWidth;
                    }
                }
                else
                {
                    // increase height
                    if (projectedHeight <= area.Height)
                    {
                        area.Height += lastRect.Height;
                    }
                    else
                    {
                        area.Height = projectedHeight;
                    }
                }
            }
            // no exit here! :)
        }
        public async Task <IActionResult> Create([Bind("Id,Name,TotalKilo")] PackSize packSize)
        {
            if (ModelState.IsValid)
            {
                _context.Add(packSize);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(packSize));
        }
        private PackSize CalculateRects(UMAData.GeneratedMaterial material, PackSize area)
        {
            Rect     nullRect     = new Rect(0, 0, 0, 0);
            PackSize lastPackSize = new PackSize();

            packTexture.Init(area.Width, area.Height, false);

            for (int atlasElementIndex = 0; atlasElementIndex < material.materialFragments.Count; atlasElementIndex++)
            {
                var tempMaterialDef = material.materialFragments[atlasElementIndex];
                if (tempMaterialDef.isRectShared)
                {
                    continue;
                }

                int width  = Mathf.FloorToInt(tempMaterialDef.baseOverlay.textureList[0].width * material.resolutionScale.x * tempMaterialDef.slotData.overlayScale);
                int height = Mathf.FloorToInt(tempMaterialDef.baseOverlay.textureList[0].height * material.resolutionScale.y * tempMaterialDef.slotData.overlayScale);

                // If either width or height are 0 we will end up with nullRect and potentially loop forever
                if (width == 0 || height == 0)
                {
                    tempMaterialDef.atlasRegion = nullRect;
                    continue;
                }

                tempMaterialDef.atlasRegion = packTexture.Insert(width, height, MaxRectsBinPack.FreeRectChoiceHeuristic.RectBestLongSideFit);
                lastPackSize.Width          = width;
                lastPackSize.Height         = height;

                if (tempMaterialDef.atlasRegion == nullRect)
                {
                    if (umaGenerator.fitAtlas)
                    {
                        //if (Debug.isDebugBuild) // JRRM : re-enable this
                        //	Debug.LogWarning("Atlas resolution is too small, Textures will be reduced.", umaData.gameObject);
                        lastPackSize.success = false;
                        return(lastPackSize);
                    }
                    else
                    {
                        if (Debug.isDebugBuild)
                        {
                            Debug.LogError("Atlas resolution is too small, not all textures will fit.", umaData.gameObject);
                        }
                    }
                }
            }
            lastPackSize.success = true;
            return(lastPackSize);
        }
Exemplo n.º 5
0
        internal void AddNewProduct()
        {
            ExcelLib.PopulateInCollection(InventoryTest.ExcelPath, "ProductPage");

            Thread.Sleep(2000);
            //Select Invenotory menu
            Invetory.Click();
            Thread.Sleep(2000);
            //Select Product menu
            Product.Click();
            Thread.Sleep(2000);
            //Select Add New Product from menu
            AddProduct.Click();
            Thread.Sleep(2000);

            //sending product code
            ProductCode.SendKeys(ExcelLib.ReadData(2, "ProductCode"));
            Thread.Sleep(1000);
            //sending product desc
            ProductDesc.SendKeys(ExcelLib.ReadData(2, "ProductDesc"));
            Thread.Sleep(1000);
            //sending barcode
            Barcode.SendKeys(ExcelLib.ReadData(2, "Barcode"));
            Thread.Sleep(1000);
            //sending Unitof measure
            //UnitOfMesureClick.Click();
            //Thread.Sleep(2000);
            //UnitOfMesure.SendKeys(ExcelLib.ReadData(2, "UnitOfMesure"));

            var UnitOfMesure       = CommonMethods.driver.FindElement(By.Id("Product_UnitOfMeasureId"));
            var selectUnitOfMesure = new SelectElement(UnitOfMesure);

            Thread.Sleep(1000);
            selectUnitOfMesure.SelectByText(ExcelLib.ReadData(2, "UnitOfMesure"));


            //sending Product group
            //ProductGrp.SendKeys(ExcelLib.ReadData(2, "ProductGroup"));

            var ProductGrpList  = CommonMethods.driver.FindElement(By.Id("Product_ProductGroupId"));
            var selectProGrpVal = new SelectElement(ProductGrpList);

            Thread.Sleep(1000);
            selectProGrpVal.SelectByText(ExcelLib.ReadData(2, "ProductGroup"));
            Thread.Sleep(1000);
            //sending Pack size
            PackSize.SendKeys(ExcelLib.ReadData(2, "PackSize"));
            Thread.Sleep(1000);
            //Sending Weight
            ProductWeight.SendKeys(ExcelLib.ReadData(2, "ProductWeight"));
            Thread.Sleep(1000);
            //Sending Product width
            ProductWidth.SendKeys(ExcelLib.ReadData(2, "ProductWidth"));
            Thread.Sleep(1000);
            //sending Product Height
            ProductHeight.SendKeys(ExcelLib.ReadData(2, "ProductHeight"));
            Thread.Sleep(1000);
            //sending ProductDepth
            ProductDepth.SendKeys(ExcelLib.ReadData(2, "ProductDepth"));
            Thread.Sleep(1000);

            ////select Types
            //NeverDimishing.Click();
            //Thread.Sleep(1000);
            ////CommonMethods.driver.SwitchTo().Alert().Dismiss();
            //Obsolete.Click();
            //Thread.Sleep(1000);
            ////CommonMethods.driver.SwitchTo().Alert().Dismiss();

            //Sending Notes
            Notes.SendKeys(ExcelLib.ReadData(2, "Notes"));
            //savedata
            SaveBtn.Click();
            Thread.Sleep(2000);
            ProductView.Click();
            Thread.Sleep(1000);
            ProductCodeFilter.SendKeys(ExcelLib.ReadData(2, "ProductCode"));
            Thread.Sleep(1000);
            //press enter
            ProductCodeFilter.SendKeys(Keys.Enter);
            Thread.Sleep(4000);


            try
            {
                //verify record is added
                if (ExcelLib.ReadData(2, "ProductCode") == CommonMethods.driver.FindElement(By.XPath(".//*[@id='ProductList_tccell0_2']/div/a")).Text)
                {
                    if (ExcelLib.ReadData(2, "ProductDesc") == CommonMethods.driver.FindElement(By.XPath(".//*[@id='ProductList_tccell0_3']/div/a")).Text)
                    {
                        if (ExcelLib.ReadData(2, "ProductGrp") == CommonMethods.driver.FindElement(By.XPath(".//*[@id='ProductList_tccell0_3']/div/a")).Text)
                        {
                            SaveScreenShotClass.SaveScreenshot(CommonMethods.driver, "Found Added Product ");
                        }
                    }
                }
                else
                {
                    SaveScreenShotClass.SaveScreenshot(CommonMethods.driver, "No record found ");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Can not find added Product,Test failed" + e.Message);
            }
        }
        /// <summary>
        /// JRRM - this is where we calculate the atlas rectangles.
        /// </summary>
        private void GenerateAtlasData()
        {
            PackSize area       = new PackSize();
            float    atlasRes   = umaGenerator.atlasResolution;
            Vector2  StartScale = Vector2.one / (float)scaleFactor;
            Vector2  Scale      = Vector2.one;
            bool     scaled     = false;

            for (int i = 0; i < atlassedMaterials.Count; i++)
            {
                area.Width  = umaGenerator.atlasResolution;
                area.Height = umaGenerator.atlasResolution;

                var generatedMaterial = atlassedMaterials[i];
                generatedMaterial.materialFragments.Sort(comparer);
                generatedMaterial.resolutionScale = StartScale;
                generatedMaterial.cropResolution  = new Vector2(atlasRes, atlasRes);

                // We need a better method than this.
                // if "BestFitSquare"

                /*switch (umaGenerator.AtlasOverflowFitMethod)
                 * {
                 *      case UMAGeneratorBase.FitMethod.BestFitSquare:
                 *              while (true)
                 *              {
                 *                      PackSize lastRect = CalculateRects(generatedMaterial, area);
                 *                      if (lastRect.success)
                 *                      {
                 *                              if (area.Width != umaGenerator.atlasResolution || area.Height != umaGenerator.atlasResolution)
                 *                              {
                 *                                      float neww = area.Width;
                 *                                      float newh = area.Height;
                 *
                 *                                      Scale.x = atlasRes / neww;
                 *                                      Scale.y = atlasRes / newh;
                 *                                      scaled = true;
                 *                              }
                 *                              break; // Everything fit, let's leave.
                 *                      }
                 *
                 *                      // do the smallest increase possible and try again.
                 *                      if ((area.Width+lastRect.Width) <  (area.Height+lastRect.Height))
                 *                      {
                 *                              area.Width += lastRect.Width;
                 *                      }
                 *                      else
                 * {
                 *                              area.Height += lastRect.Height;
                 * }
                 *              }
                 *              break;
                 *      default: // Shrink Textures */
                while (!CalculateRects(generatedMaterial, area).success)
                {
                    generatedMaterial.resolutionScale = generatedMaterial.resolutionScale * umaGenerator.FitPercentageDecrease;
                }                                /*
                                                  * break;
                                                  * }*/

                UpdateSharedRect(generatedMaterial);
                if (scaled)
                {
                    UpdateAtlasRects(generatedMaterial, Scale);
                }
            }
        }
Exemplo n.º 7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Priority != 0)
            {
                hash ^= Priority.GetHashCode();
            }
            if (SubcategoryId.Length != 0)
            {
                hash ^= SubcategoryId.GetHashCode();
            }
            if (IconPath.Length != 0)
            {
                hash ^= IconPath.GetHashCode();
            }
            if (ShowQuantityBanner != false)
            {
                hash ^= ShowQuantityBanner.GetHashCode();
            }
            if (QuantityOverride.Length != 0)
            {
                hash ^= QuantityOverride.GetHashCode();
            }
            if (PrefabPath.Length != 0)
            {
                hash ^= PrefabPath.GetHashCode();
            }
            if (MarketingText.Length != 0)
            {
                hash ^= MarketingText.GetHashCode();
            }
            if (DescriptionText.Length != 0)
            {
                hash ^= DescriptionText.GetHashCode();
            }
            if (ShowBadge != false)
            {
                hash ^= ShowBadge.GetHashCode();
            }
            if (BonusValue != 0)
            {
                hash ^= BonusValue.GetHashCode();
            }
            if (RarityId.Length != 0)
            {
                hash ^= RarityId.GetHashCode();
            }
            if (PackSize != 0)
            {
                hash ^= PackSize.GetHashCode();
            }
            if (ShowInHud != false)
            {
                hash ^= ShowInHud.GetHashCode();
            }
            if (HudPriority != 0)
            {
                hash ^= HudPriority.GetHashCode();
            }
            if (HudIconPath.Length != 0)
            {
                hash ^= HudIconPath.GetHashCode();
            }
            if (Icon2Path.Length != 0)
            {
                hash ^= Icon2Path.GetHashCode();
            }
            if (PopupImageOverride.Length != 0)
            {
                hash ^= PopupImageOverride.GetHashCode();
            }
            if (HidePackOnSoldOut != false)
            {
                hash ^= HidePackOnSoldOut.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 8
0
 public override string Stats()
 {
     return(base.Stats() + $"\nPack Size: " +
            $" {PackSize.ToString()} \nHunting Area: {HuntingArea.ToString()}km.");
 }