Beispiel #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var parameter = (NewItem)e.Parameter;

            Item = new NewItem(parameter.Id, parameter.Category, parameter.Headline, parameter.Subhead, parameter.Dataline, parameter.Image);
        }
Beispiel #2
0
        public async Task <Player> Add([FromRoute] Guid playerId, [FromBody] NewItem itm)
        {
            if (ModelState.IsValid == false)
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                //throw new Exception("New item is not valid");

                //HOW TO RETURN ERROR???????
                //return await Task.FromResult(errors);
            }
            else
            {
                // get player and check level
                var p = await _FileRepository.Get(playerId);

                if (p != null)
                {
                    if (p.Level < 3 && itm.Type == ItemType.SWORD)
                    {
                        // return error
                        throw new LevelException("Sword is not allowed for a Player below level 3.");
                    }
                }
            }


            //var p = await _FileRepository.AddPlayerItems(itm);
            //return p;

            return(null);
        }
Beispiel #3
0
    void showGetItemEffect(Vector2 originPosInGlobal, NewItem itemCopy)
    {
        GRoot.inst.AddChild(itemCopy);
        itemCopy.position     = GRoot.inst.GlobalToLocal(new Vector2(originPosInGlobal.x - itemCopy.width / 2, originPosInGlobal.y - itemCopy.height / 2));
        itemCopy.sortingOrder = 100;
        itemCopy.touchable    = false;
        itemCopy.alpha        = 0.4f;
        //GRoot.inst.AddChild (copyView);


        itemCopy.TweenFade(1, 0.8f).OnComplete(delegate() {
            itemCopy.TweenMove(new Vector2(0, GRoot.inst.height - itemCopy.height * 0.4f), 0.3f).OnUpdate(delegate(GTweener tweener) {
                itemCopy.InvalidateBatchingState();
                float r = (tweener.deltaValue.vec2 - tweener.startValue.vec2).magnitude / (tweener.endValue.vec2 - tweener.startValue.vec2).magnitude;
                r       = 1 - r * 0.6f;
                //r = r*0.6;
                itemCopy.scale = new Vector2(r, r);
            }).OnComplete(delegate() {
                itemCopy.TweenFade(0, 0.2f).OnComplete(delegate() {
                    GRoot.inst.RemoveChild(itemCopy);
                    itemCopy.Dispose();
                });
            });
        });
    }
Beispiel #4
0
 public override void insertPhone(string name, string phone)
 {
     if (PhoneList != null && UserIsExited(name))
     {
         foreach (NewItem newItem in PhoneList)
         {
             if (newItem.Name == name)
             {
                 if (newItem.PhoneNumber != phone)
                 {
                     newItem.PhoneNumber += ":" + phone;
                 }
             }
         }
     }
     else
     {
         var newItem = new NewItem();
         newItem.Name        = name;
         newItem.PhoneNumber = phone;
         PhoneList.Add(newItem);
         //var pI = new NewItem()
         //{
         //    Name = name,
         //    PhoneNumber = phone
         //};
     }
 }
    ///<summary>
    ///Newer version of LoadContent(). Loads content by finding it in the items folder.
    ///Different logic is done depending on what kind of content it is
    ///</summary>
    public void newLoadContent(GameObject btn)
    {
        NewItem selectedItem = btn.GetComponent <NewItem>();

        switch (selectedItem.itemType)
        {
        //If the content is a text, reads the file contents and displays it in
        //inventory box
        case ItemType.Text:
            // Debug.Log(Application.dataPath + "/items/" +  selectedItem.fileName); //DEBUGGING PURPOSES
            StreamReader sr = new StreamReader(Application.dataPath + "/Scenes/items/" + selectedItem.fileName);
            contentContainer.text = sr.ReadToEnd();
            sr.Close();
            break;

        //If the content is a video, gets the path to the file and uses that path to play the video
        case ItemType.Video:
            string pathToFile = Application.dataPath + "/Scenes/items/" + selectedItem.fileName;
            inventoryScreen.SetActive(false);
            videoPlayer.GetComponentInChildren <VideoPlayer>().url = pathToFile;
            videoPlayer.SetActive(true);
            audioManager.stopAllAudio();
            videoPlayer.GetComponentInChildren <VideoPlayer>().Play();
            break;
        }
    }
Beispiel #6
0
        /// <summary>
        /// Starts creating new item.
        /// </summary>
        /// <param name="proxy">The new item proxy.</param>
        /// <param name="argument">The argument passed to the proxy for the item creation. In most cases it is null.</param>
        /// <param name="created">The event called when the item is crated by the user. The argument is the new item.</param>
        public void NewItem(ContentProxy proxy, object argument = null, Action <ContentItem> created = null)
        {
            Assert.IsNull(_newElement);
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }

            string        proxyName        = proxy.Name;
            ContentFolder parentFolder     = CurrentViewFolder;
            string        parentFolderPath = parentFolder.Path;

            // Create asset name
            string path;
            string extension = '.' + proxy.FileExtension;
            int    i         = 0;

            do
            {
                path = StringUtils.CombinePaths(parentFolderPath, string.Format("{0} {1}", proxyName, i++) + extension);
            } while (parentFolder.FindChild(path) != null);

            // Create new asset proxy, add to view and rename it
            _newElement = new NewItem(path, proxy, argument);
            _newElement.ParentFolder = parentFolder;
            _newElement.Tag          = created;
            RefreshView();
            Rename(_newElement);
        }
Beispiel #7
0
        private void AddItem_Click(object sender, EventArgs e)
        {
            NewItem A = new NewItem();

            A.StartPosition = FormStartPosition.CenterScreen;
            A.ShowDialog();
        }
Beispiel #8
0
        // GET: News/Create
        public IActionResult Create()
        {
            NewItem item = new NewItem();

            item.TimeStamp = System.DateTime.Now;
            return(View(item));
        }
Beispiel #9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TimeStamp,Text,RowVersion")] NewItem newItem)
        {
            if (id != newItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(newItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewItemExists(newItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        ModelState.AddModelError("", "Error! Data has been modified by other user.");
                        return(View(newItem));
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(newItem));
        }
        public async Task <Item> UpdateItem(Guid id, NewItem newItem)
        {
            int index = -1;

            for (int i = 0; i < items.Count; ++i)
            {
                if (items[i].Id == id)
                {
                    index = i;
                }
            }
            if (index >= 0)
            {
                items[index].Name = newItem.Name;
                //if(newItem.Name) items[i].Name = newItem.Name;
                items[index].ItemLevel    = newItem.ItemLevel;
                items[index].Price        = newItem.Price;
                items[index].OwnerId      = newItem.OwnerId;
                items[index].CreationDate = newItem.CreationDate;
                return(items[index]);
            }
            else
            {
                return(null);
            }
        }
Beispiel #11
0
    public void UpdateSelectButton()
    {
        NewItem currItem = mgr.features[mgr.currFeature].ReturnItem();

        if (currItem.GetOwned())
        {
            cost.text = "Already Owned";
            if (mgr.features[mgr.currFeature].currIndex == PlayerPrefs.GetInt("FEATURE_" + mgr.features.IndexOf(mgr.features[mgr.currFeature])))
            {
                SetSelectButtons(selectButtons[0]);
            }
            else
            {
                SetSelectButtons(selectButtons[1]);
            }
        }
        else
        {
            if (PlayerPrefs.GetInt("ORBS") < currItem.GetCost())
            {
                SetSelectButtons(selectButtons[2]);
            }
            else
            {
                SetSelectButtons(selectButtons[3]);
            }
        }
    }
Beispiel #12
0
    public void SpawnGold(int i)
    {
        GameObject NewItem;
        Vector2    Positie = new Vector2(Positions2[Random.Range(0, Positions2.Count)], Random.Range(250, -100));

        Positions2.Remove(Positie.x);
        NewItem = Instantiate(GoldBlock, Positie, GoldBlock.transform.rotation);



        NewItem.GetComponent <Image>().sprite = VisualBlock[Random.Range(0, VisualBlock.Length)];
        if ((trueWords == null) || (!trueWords.Any()))
        {
            if (Starting == true)
            {
                NewItem.GetComponentInChildren <Text>().text = SentenceMissingParts.Sentence.falseWords[Random.Range(0, SentenceMissingParts.Sentence.falseWords.Length)];
            }
            else if (Starting == false)
            {
                NewItem.GetComponentInChildren <Text>().text = SentenceMissingParts.Sentence.Words[Random.Range(0, SentenceMissingParts.Sentence.Words.Length)].Justwords[0];
            }
        }
        else
        {
            NewItem.GetComponentInChildren <Text>().text = trueWords[0];
            trueWords.Remove(NewItem.GetComponentInChildren <Text>().text);
        }
        NewItem.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform, false);
    }
Beispiel #13
0
        public ActionResult <Task <Item> > CreateItem(Guid id, int type, int level)
        {
            NewItem newItem = new NewItem();

            int enumLength = Enum.GetNames(typeof(ItemType)).Length;

            if (type < enumLength)
            {
                newItem._type = (ItemType)type;
            }
            else
            {
                return(null);
            }
            newItem._level        = level;
            newItem._creationDate = DateTime.UtcNow;
            newItem._itemId       = Guid.NewGuid();
            TryValidateModel(newItem);
            if (ModelState.IsValid)
            {
                return(itProcessor.CreateItem(id, newItem));
            }
            else
            {
                return(Task.FromResult <Item>(null));
            }
        }
Beispiel #14
0
    public void initGetItemEffect(Vector2 originPosInGlobal, string itemId)
    {
        NewItem copyView = (NewItem)UIPackage.CreateObject("UIMain", "NewItem").asCom;

        copyView.init(itemId);
        showGetItemEffect(originPosInGlobal, copyView);
    }
Beispiel #15
0
 protected void RaiseNewItem(ColumnItem item)
 {
     if (!IsLoading)
     {
         NewItem?.Invoke(this, new ColumnItemEventArgs(item));
     }
 }
Beispiel #16
0
        static void AddItems(StoreManager neto)
        {
            NewItem[] item = new NewItem[] {
                new NewItem {
                    Name         = "Price test",
                    SKU          = "1111",
                    DefaultPrice = 1.00m,
                    IsActive     = false,
                    Approved     = false
                }
            };

            var result = neto.Products.AddItem(item);

            switch (result.Ack)
            {
            case Ack.Success:
                foreach (var i in result.Item)
                {
                    Console.WriteLine($"Created ID:{i.InventoryID} SKU: {i.SKU} at {result.CurrentTime}");
                }
                break;

            case Ack.Warning:
                foreach (var warn in result.Messages.Warning)
                {
                    Console.WriteLine($"Warning: {warn.Message}");
                }
                break;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Shows popup dialog with UI to rename content item.
        /// </summary>
        /// <param name="item">The item to rename.</param>
        public void Rename(ContentItem item)
        {
            // Show element in view
            Select(item);

            // Show rename popup
            var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true);

            popup.Tag      = item;
            popup.Renamed += renamePopup => Rename((ContentItem)renamePopup.Tag, renamePopup.Text);
            popup.Closed  += renamePopup =>
            {
                // Check if was creating new element
                if (_newElement != null)
                {
                    // Destroy mock control
                    _newElement.ParentFolder = null;
                    _newElement.Dispose();
                    _newElement = null;
                }
            };

            // For new asset we want to mock the initial value so user can press just Enter to use default name
            if (_newElement != null)
            {
                popup.InitialValue = "?";
            }
        }
Beispiel #18
0
 public SyncSingleFile(AppSettings appSettings, IQuery query, IStorage subPathStorage, IWebLogger logger)
 {
     _appSettings    = appSettings;
     _subPathStorage = subPathStorage;
     _query          = query;
     _newItem        = new NewItem(_subPathStorage, new ReadMeta(_subPathStorage, appSettings));
     _logger         = logger;
 }
    public async Task <Item> CreateItem(Guid playerId, NewItem item)
    {
        Item i = new Item()
        {
        };

        return(await _mongoDBRepository.CreateItem(playerId, i));
    }
        public Task <Item> CreateItem(Guid playerId, NewItem newItem)
        {
            logger.LogInformation("Creating item with name " + newItem.Name);
            Item item = new Item( );

            item.Name = newItem.Name;
            return(repo.CreateItem(playerId, item));
        }
 void OnAddNewItem(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(NewItem.Text))
     {
         ItemsSource.Add(NewItem.Text);
         NewItem.Clear();
     }
 }
Beispiel #22
0
        public IHttpActionResult PostAddItem(NewItem item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            GeocachesEntities db = new GeocachesEntities();

            // We want to check that there is an existing geocache matching either the name or id given
            // Both the geocache name and id cannot be null, otherwise we cannot add it to any geocache
            if (item.geocacheID == null && item.geocacheName == null)
            {
                return(BadRequest("Both geocache name and geocache id cannot be null."));
            }

            // Get a guid that either matches to geocache ID or geocache name
            var guidQuery = db.Geocaches.Where(g => (g.id == item.geocacheID || g.name.Equals(item.geocacheName))).Select(g => g.id);

            if (guidQuery.Count() > 1)
            {
                return(BadRequest("Entered a geocache id and geocache name that do not match to same geoecache."));
            }

            Guid guid = guidQuery.FirstOrDefault();

            if (guid == Guid.Empty)
            {
                return(BadRequest("Both geocache name and geocache id are not valid."));
            }

            // Check if the name matches the requirements
            Regex matcher = new Regex("^([A-Za-z0-9 ]){1,50}$");

            if (item.name == null || !matcher.IsMatch(item.name))
            {
                return(BadRequest("Name must be composed of alphanumeric or space characters. Maximum length of 50."));
            }

            // Check if name previously exists
            if (db.Items.Where(i => i.name.Equals(item.name)).Any())
            {
                return(BadRequest("Item name already exists."));
            }

            db.Items.Add(new Items()
            {
                id          = Guid.NewGuid(),
                name        = item.name,
                geocache_id = guid,
                start_time  = item.startTime,
                end_time    = item.endTime
            });
            db.SaveChanges();
            db.Dispose();

            return(Ok());
        }
Beispiel #23
0
        public void RefinementFramework()
        {
            FileInfo            model     = new FileInfo(@"..\..\..\TorXakisDotNetAdapter.Models\Models\Reference.txs");
            RefinementFramework framework = new RefinementFramework(model);

            Assert.AreEqual(model, framework.Connector.Model.File);

            TransitionSystem system1 = CreateTransitionSystem1();

            framework.AddSystem(system1);
            Assert.AreEqual(system1, framework.Systems.ElementAt(0));

            TransitionSystem system2 = CreateTransitionSystem2();

            framework.AddSystem(system2);
            Assert.AreEqual(system2, framework.Systems.ElementAt(1));

            Console.WriteLine(framework);

            // Trigger a reactive transition, which should activate a proactive one next.
            if (true)
            {
                NewItem modelInput = new NewItem()
                {
                    Id = 1,
                };
                Console.WriteLine("Using model input: " + modelInput);
                HashSet <Tuple <TransitionSystem, ReactiveTransition> > reactives = framework.PossibleReactiveTransitions(modelInput);
                Console.WriteLine("Possible reactives transitions: " + string.Join(", ", reactives.Select(x => x.Item1.ModelAction.Name + ": " + x.Item2).ToArray()));
                Assert.AreEqual(1, reactives.Count);

                framework.HandleModelInput(modelInput);
                Console.WriteLine(framework);
                Assert.AreEqual(system1.States.ElementAt(0), system1.CurrentState);
            }

            // Trigger a reactive transition, which should activate a proactive one next.
            if (true)
            {
                ItemEventArgsNew systemEvent = new ItemEventArgsNew()
                {
                    GUID       = guids[0],
                    SystemName = systemNames[0],
                    Position   = positions[0],
                    Rotation   = rotations[0],
                    ModelGroup = modelGroups[0],
                    Model      = models[0],
                };
                Console.WriteLine("Using system event: " + systemEvent);
                HashSet <Tuple <TransitionSystem, ReactiveTransition> > reactives = framework.PossibleReactiveTransitions(systemEvent);
                Console.WriteLine("Possible reactives transitions: " + string.Join(", ", reactives.Select(x => x.Item1.ModelAction.Name + ": " + x.Item2).ToArray()));
                Assert.AreEqual(1, reactives.Count);

                framework.HandleSystemEvent(systemEvent);
                Console.WriteLine(framework);
                Assert.AreEqual(system2.States.ElementAt(0), system2.CurrentState);
            }
        }
Beispiel #24
0
        //public Task<NewItem> AddAdditionalItems(int id)
        //{
        //    var ar = Connection.db.Table<NewItem>().Where(i => i.ID == id).FirstOrDefault();
        //    var add=  Connection.db.Insert(ar);
        //    return Task.FromResult(add);

        //}

        public Task <NewItem> UpdateSelectedName(NewItem item)
        {
            //var list = loadList; loadList.Where(p => p.EmpNo == obj.EmpNo).Update();
            var ar = Connection.db.Table <NewItem>().Where(i => i.ItemName == item.ItemName).FirstOrDefault();

            var update = Connection.db.Update(ar);

            return(Task.FromResult(ar));
        }
Beispiel #25
0
        public int InsertNews(NewItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("News");
            }

            return(_newRepository.InsertAndGetId(item));
        }
        public ActionResult <ItemDto> CreateItem([FromBody] NewItem item)
        {
            Item ret = _stock.Create(new Item()
            {
                Name = item.Name, Types = item.Types
            });

            return(Ok(ret));
        }
Beispiel #27
0
        public void UpdateNews(NewItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("News");
            }

            _newRepository.Update(item);
        }
        public void Verify_object_can_be_created_by_repository()
        {
            Repository.Insert(NewItem);
            Context.SaveChanges();

            NewItem.VerifyIdIsFilledIn();
            NewItem.VerifyAuditCreatedPropertiesAreFilledIn(TestStartedDatTime);
            NewItem.VerifyAuditModifiedPropertiesAreFilledIn(TestStartedDatTime);
        }
Beispiel #29
0
        public IActionResult AddNewItem()
        {
            GetData();
            NewItem newItem = new NewItem();

            newItem.WineCategoryList = db.WineCategories.ToList();
            newItem.WineTypeList     = db.WineTypes.ToList();
            return(View("~/Views/Home/AddNewItem.cshtml", newItem));
        }
        public async Task <Item> Create(NewItem nItem)
        {
            Item i = new Item(Guid.NewGuid(), nItem.Name)
            {
                Lvl = nItem.Lvl
            };

            return(await repo.Create(i));
        }
Beispiel #31
0
        public void saveItem(NewItem item)
        {
            try
            {
                XmlNode root = xmlDoc.SelectSingleNode("items");

                XmlElement xe = xmlDoc.CreateElement("item");
                xe.SetAttribute("id", Convert.ToString(item.hash));

                XmlElement xesub1 = xmlDoc.CreateElement("hash");
                xesub1.InnerText = Convert.ToString(item.hash);
                xe.AppendChild(xesub1);

                XmlElement xesub2 = xmlDoc.CreateElement("name");
                xesub2.InnerText = item.itemName;
                xe.AppendChild(xesub2);

                XmlElement xesub3 = xmlDoc.CreateElement("exe");
                xesub3.InnerText = item.exePath;
                xe.AppendChild(xesub3);

                XmlElement xesub4 = xmlDoc.CreateElement("url");
                xesub4.InnerText = item.url;
                xe.AppendChild(xesub4);

                XmlElement xesub5 = xmlDoc.CreateElement("image");
                xesub5.InnerText = item.image;
                xe.AppendChild(xesub5);

                root.AppendChild(xe);
                xmlDoc.Save(this.configPath);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Beispiel #32
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string type = dataGridView1.Columns[0].Name;

            if(type == "ItemId")
            {
                NewItem itemfrm = new NewItem();
                itemfrm.Text = "Edit Item";

                itemfrm.ShowDialog();
                PrepareGridForStock();
            }
            if(type == "UserId")
            {
                EditUser editfrm = new EditUser();
                editfrm.User = UserMapper.GetInstance().GetUserById(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                editfrm.ShowDialog();
                PrepareGridForUsers();
            }
        }
Beispiel #33
0
 private void btnNewItems_Click_1(object sender, EventArgs e)
 {
     NewItem itempage = new NewItem();
     itempage.ShowDialog();
     PrepareGridForStock();
 }
Beispiel #34
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            try
            {
                ToolStripMenuItem s = new ToolStripMenuItem();
                int hash;
                s.Text = this.ItemNameTextBox.Text.Trim();
                if (s.Text.Length <= 0)
                {
                    return;
                }
                hash = s.Text.GetHashCode();
                NewItem item = new NewItem();
                item.image = "";
                if (this.IconTextBox.Text.Trim().Length > 0) {
                    Image img = Image.FromFile(this.IconTextBox.Text);
                    s.Image = img;
                    item.image = this.IconTextBox.Text;
                }
                s.Click += new System.EventHandler(this.DynamicToolStripMenuItem_Click);
                this.contextMenuStrip.Items.Insert(1,s);

                item.hash = hash;
                item.itemName = s.Text;
                item.url = "";
                item.exePath = "";
                if (this.UrlTextBox.Text.Trim().Length > 0)
                {
                    item.url = this.UrlTextBox.Text.Trim();
                }
                if (this.ExeTextBox.Text.Trim().Length > 0)
                {
                    item.exePath = this.ExeTextBox.Text.Trim();
                }
                saveItem(item);
                this.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }