Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (tabControl1.SelectedIndex)
            {
            case 0:
                Screw s = screwSizes[screwDiams.SelectedIndex];
                s.Length = screwLen[screwLength.SelectedIndex];
                s.Draw(UFSession.GetUFSession(), path + "screw"
                       + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("screw")).ToList().Count);
                break;

            case 1:
                PushScrew ps = pScrewSizes[pScrewDiams.SelectedIndex];
                ps.Length = pScrewLen[pScrewLength.SelectedIndex];
                ps.Draw(UFSession.GetUFSession(), path + "p_screw"
                        + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("p_screw")).ToList().Count);
                break;

            case 2:
                Nut n = nutSizes[nutDiams.SelectedIndex];
                n.Draw(UFSession.GetUFSession(), path + "nut"
                       + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("nut")).ToList().Count);
                break;

            default:
                break;
            }
        }
Example #2
0
        public ActionResult AllSettings(DataSourceRequest command,
            Nut.Web.Framework.Kendoui.Filter filter = null, IEnumerable<Sort> sort = null) {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            var settings = _settingService
                .GetAllSettings()
                .Select(x => {
                    string storeName;
                    if (x.StoreId == 0) {
                        storeName = _localizationService.GetResource("Admin.Configuration.Settings.AllSettings.Fields.StoreName.AllStores");
                    } else {
                        var store = _storeService.GetStoreById(x.StoreId);
                        storeName = store != null ? store.Name : "Unknown";
                    }
                    var settingModel = new SettingModel {
                        Id = x.Id,
                        Name = x.Name,
                        Value = x.Value,
                        Store = storeName,
                        StoreId = x.StoreId
                    };
                    return settingModel;
                })
                .AsQueryable()
                .Filter(filter)
                .Sort(sort);

            var gridModel = new DataSourceResult {
                Data = settings.PagedForCommand(command).ToList(),
                Total = settings.Count()
            };

            return Json(gridModel);
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            nut = new Nut(POLL_PERIOD);

            nut.update += Nut_update;
            nut.Init(true, "nas2", 3493, "upsmon", "secret", "ups");
        }
Example #4
0
 void IShootable.Shoot()
 {
     if (MyInputManager.instance.GetAxis("Shoot") > 0 && PlayerBrain.instance.HasBullet("Nut") && canShoot)
     {
         canShoot = false;
         //   Vector3 sp = Camera.main.WorldToScreenPoint(transform.position + offsetShoot);
         // Vector3 dir = (Input.mousePosition - sp).normalized;
         //  dir.z = transform.position.z;
         print(PlayerBrain.instance.shootZone.position);
         if (prefabNut == null)
         {
             print("Che es null");
         }
         Nut nut = Instantiate(prefabNut, PlayerBrain.instance.shootZone.position, PlayerBrain.instance.shootZone.rotation);
         if (nut == null)
         {
             print("Che es null nut");
         }
         nut.addImpulse(nutShootVelocity);
         PlayerBrain.instance.RemoveBullet("Nut");
         //listLinearNut.RemoveAt(0);
     }
     if (MyInputManager.instance.GetAxis("Shoot") == 0)
     {
         canShoot = true;
     }
 }
Example #5
0
        private void AddNut()
        {
            var elements = ReadElements();
            Nut nut      = new Nut(elements[0], elements[1], decimal.Parse(elements[2]), int.Parse(elements[3]));

            nutController.Add(nut);
            Console.WriteLine("The product was successfully added!");
        }
Example #6
0
        public Nut AddNut(int x, int y)
        {
            var Nut = new Nut(new Vector2(x, y));

            DrawScene.Push(Nut);
            Nuts.Add(Nut);
            return(Nut);
        }
Example #7
0
        public void CarPartGetsExpectedID()
        {
            //Arrange
            CarPart a = new Nut(125, 0);

            //Assert
            Assert.AreEqual("N-D125", a.Id);
        }
Example #8
0
 /// <summary>
 /// Adds a Nut.
 /// </summary>
 /// <param name="nut">the nut that will be added</param>
 public void Add(Nut nut)
 {
     using (context = new ShopContext())
     {
         context.Nuts.Add(nut);
         context.SaveChanges();
     }
 }
Example #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Nut nut = db.Nuts.Find(id);

            db.Nuts.Remove(nut);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "NutID,Image,Name,Protein,Carbohydrates,Fat,Energy")] Nut nut)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nut).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nut));
 }
Example #11
0
        /// <summary>
        /// Updates a Nut.
        /// </summary>
        /// <param name="nut">the nut that will be updated</param>
        public void Update(Nut nut)
        {
            var item = context.Drinks.FirstOrDefault(m => m.Id == nut.Id);

            if (item != null)
            {
                context.Entry(item).CurrentValues.SetValues(nut);
                context.SaveChanges();
            }
        }
Example #12
0
        public ActionResult Create([Bind(Include = "NutID,Image,Name,Protein,Carbohydrates,Fat,Energy")] Nut nut)
        {
            if (ModelState.IsValid)
            {
                db.Nuts.Add(nut);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nut));
        }
Example #13
0
        /// <summary>
        /// Returns the first nut in the watch area
        /// </summary>
        /// <returns>null if there is none</returns>
        public Nut GetNutInWatchArea()
        {
            foreach (var Nut in Nuts)
            {
                if (Nut.Placed && Tree.Basement.MouseHole.WatchArea.Contains(Nut.Get <Transform>().Position))
                {
                    return(Nut);
                }
            }

            return(null);
        }
Example #14
0
 /// <summary>
 /// Updates a Nut.
 /// </summary>
 /// <param name="nut">the nut that will be updated</param>
 public void Update(Nut nut)
 {
     using (context = new ShopContext())
     {
         var item = context.Drinks.Find(nut.Id);
         if (item != null)
         {
             context.Entry(item).CurrentValues.SetValues(nut);
             context.SaveChanges();
         }
     }
 }
Example #15
0
 void launchNut(float direction)
 {
     playMusicOnAttack();
     if (direction != 0)
     {
         GameObject obj = GameObject.Instantiate(this.Nut);
         obj.transform.position  = this.transform.position;
         obj.transform.position += new Vector3(0.0f, 1.0f, 0.0f);
         Nut nut = obj.GetComponent <Nut>();
         nut.launch(direction);
     }
 }
Example #16
0
    void pickupNut(Nut nut)
    {
        if (nutShieldState == 2)
        {
            return;
        }

        nutShieldState++;
        setNutShieldSprite();

        Destroy(nut.gameObject);
    }
Example #17
0
 private void ShouldShootNut()
 {
     //    if (listNut.Count > 0 && Input.GetMouseButtonDown(0))
     if (listLinearNut.Count > 0 && MyInputManager.instance.GetButtonDown("Shoot"))
     {
         //   Vector3 sp = Camera.main.WorldToScreenPoint(transform.position + offsetShoot);
         // Vector3 dir = (Input.mousePosition - sp).normalized;
         //  dir.z = transform.position.z;
         Nut h = listLinearNut[0];
         // h.addImpulse(shootZone.position, this.transform.forward, velocityLinearNut);
         listLinearNut.RemoveAt(0);
     }
 }
Example #18
0
        public Match(Nut _nut, Screw _screw)
        {
            Nut   = _nut;
            Screw = _screw;

            if (_nut.Diameter == _screw.Diameter)
            {
                Diameter = _nut.Diameter;
            }
            else
            {
                throw new Exception("Error");
            }
        }
Example #19
0
        // GET: Nut/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Nut nut = db.Nuts.Find(id);

            if (nut == null)
            {
                return(HttpNotFound());
            }
            return(View(nut));
        }
Example #20
0
        public void Initializer()
        {
            //TODO: CREATE THIS BETTER
            Nuts   = new Nut[NutsQuantity];
            Screws = new Screw[ScrewQuantity];

            for (var a = 0; a < NutsQuantity; a++)
            {
                Nuts[a] = new Nut(new Random().Next(minDiameterSize, maxDiameterSize));
            }
            for (var a = 0; a < ScrewQuantity; a++)
            {
                Screws[a] = new Screw(new Random().Next(minDiameterSize, maxDiameterSize));
            }
        }
Example #21
0
        public void AddNut_Add_A_Nut()
        {
            var mockSet     = new Mock <DbSet <Nut> >();
            var nut         = new Nut();
            var mockContext = new Mock <ShopContext>();

            mockContext.Setup(m => m.Nuts).Returns(mockSet.Object);

            var controller = new NutController(mockContext.Object);

            controller.Add(nut);

            mockSet.Verify(m => m.Add(It.IsAny <Nut>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
        public BoltProblemSolver(int size)
        {
            this.Size = size;
            this.ProblemBolts = new Bolt[Size];
            this.ProblemNuts = new Nut[Size];
            this.rand = new Random();

            for (int i=0; i<Size;i++)
            {
                ProblemBolts[i] = new Bolt(i);
                ProblemNuts[i] = new Nut(i);
            }

            // Randomize Lists
            ProblemNuts = ProblemNuts.OrderBy(x => rand.Next()).ToArray();
            ProblemBolts = ProblemBolts.OrderBy(x => rand.Next()).ToArray();
        }
Example #23
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == 13)  //NUt
        {
            Nut nut = collision.gameObject.GetComponent <Nut>();

            TakeNut(nut); // TODO: event manager y pool object
            nut.gameObject.SetActive(false);
        }

        if (collision.gameObject.layer == 14) //HazleNUt
        {
            HazelNut Hazelnut = collision.gameObject.GetComponent <HazelNut>();

            TakeHazelNut(Hazelnut); // TODO: event manager y pool object
            Hazelnut.gameObject.SetActive(false);
        }
    }
Example #24
0
        static void Main(string[] args)
        {
            Warehouse w = Warehouse.Get_Warehouse();

            Console.WriteLine("Intento agregar una lista de 3 partes al warehouse.");
            w.AddParts(new List <CarPart>()
            {
                new Nut(10, 5), new Cog(10, 5), new BallBearing(20, 2)
            });
            Console.WriteLine("Total de partes en la lista: " + w.GetParts().Count.ToString());

            Console.WriteLine("\n\nCompruebo que el warehose guarde el archivo de manera correcta.");
            w.Save(Environment.CurrentDirectory + "\\Warehouse.xml");
            Console.WriteLine("Resultado: " + File.Exists(Environment.CurrentDirectory + "\\Warehouse.xml").ToString());

            Console.WriteLine("\n\nReduzco el Stock de una de las partes en 3");
            Console.WriteLine("Stock antes de realizar el pedido: " + w.GetParts()[0].Stock.ToString());
            w.ReceiveRequest(new List <CarPart>()
            {
                new Nut(10, 3)
            });
            Console.WriteLine("Stock despues de realizar el pedido: " + w.GetParts()[0].Stock.ToString());

            Console.WriteLine("\n\nCompruebo que el warehose se cargue correctamente desde un archivo.");
            w.GetParts().Clear();
            w.Load(Environment.CurrentDirectory + "\\Warehouse.xml");
            Console.WriteLine("Total de elementos en el warehouse: " + w.GetParts().Count.ToString());

            Console.WriteLine("\n\nComparo dos parte de con las mismas caracteristicas para ver si comparan bien.");
            CarPart a = new Nut(10, 5);
            CarPart b = new Nut(10, 20);

            Console.WriteLine("Resultado de la comparacion: " + (a == b).ToString());

            Console.WriteLine("\n\nComparo dos parte de con diferentes caracteristicas para ver si comparan bien.");
            CarPart c = new Nut(5, 5);
            CarPart d = new Nut(10, 20);

            Console.WriteLine("Resultado de la comparacion: " + (c == d).ToString());



            Console.ReadKey();
        }
Example #25
0
        /// <summary>
        /// Gets the closest nut to the given position.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="withinDistance">if != -1 only the given distance is considered</param>
        /// <returns></returns>
        public Nut GetClosestNut(Vector2 position, float withinDistance = -1)
        {
            Nut Result          = null;
            var ClosestDistance = float.MaxValue;

            foreach (var Nut in Nuts)
            {
                if (Nut.Placed)
                {
                    var Distance = (Nut.Get <Transform>().Position - position).Length();

                    if (Distance < ClosestDistance && (withinDistance == -1 || Distance <= withinDistance))
                    {
                        Result          = Nut;
                        ClosestDistance = Distance;
                    }
                }
            }

            return(Result);
        }
Example #26
0
    void pickupNut(Nut nut)
    {
        if (nutShieldState == 2) return;

        nutShieldState++;
        setNutShieldSprite ();

        Destroy (nut.gameObject);
    }
Example #27
0
 public void RemoveNut(Nut nut)
 {
     DrawScene.Pop(nut);
     Nuts.Remove(nut);
 }
Example #28
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        Sprinkle sprinkle = collider.gameObject.GetComponent <Sprinkle>();

        if (sprinkle != null)
        {
            GameObject.Find("GUI").BroadcastMessage("addScore", sprinkle.getPointWorth());
            AudioSource noise = GetComponents <AudioSource>()[0];
            noise.Play();

            var sprinkleSprite = sprinkle.gameObject.GetComponent <SpriteRenderer>().sprite;
            gameObject.BroadcastMessage("addSprinklesToDonut", sprinkleSprite);

            Destroy(sprinkle.gameObject);
        }

/*
 *              Sugarpile sugarpile = collider.gameObject.GetComponent<Sugarpile>();
 *              if (sugarpile != null) {
 *                      //AudioSource noise = GetComponents<AudioSource>()[0];
 *                      //noise.Play();
 *
 *                      //var sugarpileSprite = sugarpile.gameObject.GetComponent<SpriteRenderer>().sprite;
 *                      //gameObject.BroadcastMessage("addSugarPileToDonut", sugarpileSprite);
 *
 *                      Debug.Log("Hit sugarpile");
 *                      slowedDownAmount = slowedDownAmountTotal = sugarpile.getSlowDownModifier();
 *                      slowedDownCooldown = slowedDownTimeTotal = sugarpile.getSlowDownTimeLength();
 *                      Destroy(sugarpile.gameObject);
 *              }
 */
        Nut nut = collider.gameObject.GetComponent <Nut> ();

        if (nut != null)
        {
            pickupNut(nut);
        }

        CreamFilling creamFilling = collider.gameObject.GetComponent <CreamFilling>();

        if (creamFilling)
        {
            pickupCreamFilling(creamFilling);
        }

        DonutEnemy de = collider.gameObject.GetComponent <DonutEnemy>();

        if (de != null)
        {
            getHitByDonutEnemy(de);
            //if (de.getSize() > transform.localScale.x) { // its bigger, player loses
            //GameObject.Find("GUI").GetComponentInChildren<InGameStates>().loseGame();
            //GetComponent<Controls>().setGameOver();

            /*} else { // its smaller, player gets bigger
             *      float newSize = transform.localScale.x + sizePerEat;
             *      transform.localScale = new Vector3(newSize, newSize, 1.0f);
             *      GameObject.Find("GUI").BroadcastMessage("addScore", 10);
             *      Destroy(de.gameObject);
             * }*/
        }
    }
Example #29
0
        const int POLL_PERIOD = 15000;  // 15 sec

        public Form1()
        {
            nut = null;
            InitializeComponent();
        }
Example #30
0
 public BoltNode(Bolt bolt , Nut nut)
 {
     this.bolt = bolt;
     this.nut = nut;
 }
Example #31
0
        public ActionResult Resources(int languageId, DataSourceRequest command,
            Nut.Web.Framework.Kendoui.Filter filter = null, IEnumerable<Sort> sort = null) {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages))
                return AccessDeniedView();

            var language = _languageService.GetLanguageById(languageId);

            var resources = _localizationService
                .GetAllResourceValues(languageId)
                .OrderBy(x => x.Key)
                .Select(x => new LanguageResourceModel {
                    LanguageId = languageId,
                    LanguageName = language.Name,
                    Id = x.Value.Key,
                    Name = x.Key,
                    Value = x.Value.Value,
                })
                    .AsQueryable()
                    .Filter(filter)
                    .Sort(sort);

            var gridModel = new DataSourceResult {
                Data = resources.PagedForCommand(command),
                Total = resources.Count()
            };

            return Json(gridModel);
        }
Example #32
0
 internal void TakeNut(Nut pn)
 {
     listLinearNut.Add(pn);
 }
Example #33
0
 /// <summary>
 /// Construct a tree object with an identifying noun.
 /// </summary>
 public Tree(string noun, Nut nut)
     : base(id, noun)
 {
     this.nut = nut;
 }
Example #34
0
 /// <summary>
 /// Adds a Nut.
 /// </summary>
 /// <param name="nut">the nut that will be added</param>
 public void Add(Nut nut)
 {
     context.Nuts.Add(nut);
     context.SaveChanges();
 }
Example #35
0
 public CandyBarBuilder SetNutType(Nut nutType)
 {
     Confection.NutType = nutType;
     return(this);
 }