예제 #1
0
        public static Product ToProduct(this InventoryRow inventoryRow)
        {
            DevelopmentStatus status;
            bool succeeded = Enum.TryParse <DevelopmentStatus>(inventoryRow.Status, true, out status);

            if (!succeeded)
            {
                status = DevelopmentStatus.Prototype;
            }

            var product = new Product
            {
                Id                     = inventoryRow.Id,
                Engineer               = inventoryRow.Engineer,
                Name                   = inventoryRow.Name,
                RawMaterial            = inventoryRow.RawMaterial,
                Status                 = status,
                DevelopmentStartDate   = inventoryRow.DevelopmentStartDate,
                ExpectedCompletionDate = inventoryRow.ExpectedCompletionDate,
                Notes                  = inventoryRow.Notes,
                ImageSource            = inventoryRow.ImageSource
            };

            return(product);
        }
        private void InventoryDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            InventoryRow ir = (InventoryRow)InventoryDataGrid.SelectedItem;

            DescriptionTextBox.Document.Blocks.Clear();
            DescriptionTextBox.Document.Blocks.AddRange(ir.RowItem.Description);
        }
예제 #3
0
            public InventoryRow AddInventoryRow(int CarID, string Make, string Color, string PetName)
            {
                InventoryRow rowInventoryRow = ((InventoryRow)(this.NewRow()));

                rowInventoryRow.ItemArray = new object[] {
                    CarID,
                    Make,
                    Color,
                    PetName
                };
                this.Rows.Add(rowInventoryRow);
                return(rowInventoryRow);
            }
예제 #4
0
    public void Populate()
    {
        RealmInventory = DarkestDungeonManager.Campaign.RealmInventory;
        InventoryRows  = new List <InventoryRow>();

        int trinketCount   = RealmInventory.Trinkets.Count;
        int rowCount       = Mathf.Max(3, trinketCount / 7 + 1);
        int trinketsLoaded = 0;

        CurrentCapacity = trinketCount;
        MaxCapacity     = rowCount * 7;

        for (int i = 0; i < rowCount; i++)
        {
            InventoryRow newRow = Instantiate(rowTemplate);
            newRow.Initialize(this);
            newRow.onRowEmptied += RealmInventoryWindow_onRowEmptied;
            newRow.RectTransform.SetParent(trinketBox, false);
            InventoryRows.Add(newRow);
            InventorySlots.AddRange(newRow.InventorySlots);

            for (int j = 0; j < 7; j++)
            {
                if (trinketsLoaded != trinketCount)
                {
                    Trinket trinket = RealmInventory.Trinkets[trinketsLoaded];
                    newRow.InventorySlots[j].CreateItem(trinket);
                    newRow.ItemAdded();
                    trinketsLoaded++;
                }
                else
                {
                    break;
                }
            }
        }

        for (int i = 0; i < InventoryRows.Count; i++)
        {
            InventoryRows[i].RowNumber     = i + 1;
            InventoryRows[i].onRowEmptied += RealmInventoryWindow_onRowEmptied;
            for (int j = 0; j < InventoryRows[i].SlotCount; j++)
            {
                InventoryRows[i].InventorySlots[j].onDropIn  += RealmInventoryWindow_onDropIn;
                InventoryRows[i].InventorySlots[j].onDropOut += RealmInventoryWindow_onDropOut;
            }
        }
        UpdateWindow();
    }
예제 #5
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var parameters = e.Parameter.ToString().Split("id=");

            if (parameters.Length <= 1)
            {
                return;
            }

            bool isNewItem = false;

            InventoryRow inventoryRow = null;

            if (!isNewItem)
            {
                inventoryRow = InventoryBLL.Current.GetInventory().FindById(parameters[1]);
            }

            isNewItem = (inventoryRow == null);

            _editItemViewModel = new EditItemViewModel();

            if (!isNewItem && inventoryRow != null)
            {
                _editItemViewModel.Id                     = inventoryRow.Id;
                _editItemViewModel.Engineer               = inventoryRow.Engineer;
                _editItemViewModel.Name                   = inventoryRow.Name;
                _editItemViewModel.RawMaterial            = inventoryRow.RawMaterial;
                _editItemViewModel.DevelopmentStartDate   = inventoryRow.DevelopmentStartDate;
                _editItemViewModel.ExpectedCompletionDate = inventoryRow.ExpectedCompletionDate;
                _editItemViewModel.Notes                  = inventoryRow.Notes;
                _editItemViewModel.ImageSource            = inventoryRow.ImageSource;
            }

            var editItemView = new EditItemView
            {
                EditItemViewModel = _editItemViewModel,
            };

            await editItemView.ShowAsync();
        }
    private InventoryRow AddRow()
    {
        InventoryRow newRow = Instantiate(rowTemplate);

        newRow.Initialize(this);
        newRow.RectTransform.SetParent(trinketBox, false);
        InventoryRows.Add(newRow);
        InventorySlots.AddRange(newRow.InventorySlots);

        newRow.RowNumber        = InventoryRows.Count;
        MaxCapacity            += newRow.SlotCount;
        newRow.EventRowEmptied += RealmInventoryRowEmptied;

        for (int j = 0; j < newRow.SlotCount; j++)
        {
            newRow.InventorySlots[j].EventDropIn  += RealmInventorySlotDropIn;
            newRow.InventorySlots[j].EventDropOut += RealmInventorySlotDropOut;
        }
        return(newRow);
    }
        private void AddInventoryItem(Inventory inventory)
        {
            InventoryRow newInventoryRow = dtInventory.NewInventoryRow();

            newInventoryRow.Entered_Date = inventory.Entered_Date;
            newInventoryRow.Scout_Name   = inventory.Scout_Name;
            newInventoryRow.Item_Name    = inventory.Item_Name;
            newInventoryRow.Price        = inventory.Price;
            newInventoryRow.Quantity     = inventory.Quantity;
            newInventoryRow.Total_Price  = inventory.Total_Price;
            newInventoryRow.Notes        = inventory.Notes;
            newInventoryRow.Delete_Row   = inventory.Delete_Row;
            try
            {
                dtInventory.AddInventoryRow(newInventoryRow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
    // Use this for initialization
    void Start()
    {
        //This creates a mapping of the inventory system.
        //This specifically looks for "RowX" then "SlotY"

        for ( int i = 0; i < this.transform.childCount; i++)
        {
            var rowObj = this.transform.GetChild(i);
            if ( rowObj.name.StartsWith("Row") )
            {
                int rowIndex = int.Parse(rowObj.name.Substring("Row".Length));
                var row = new InventoryRow();
                row.Slots = new List<global::InventorySlot>();
                row.Index = rowIndex;
                slots.Add(row);

                for ( int c = 0; c < rowObj.childCount; c++)
                {
                    var cellObj = rowObj.GetChild(c);
                    if ( cellObj.name.StartsWith("Slot") )
                    {
                        int cellIndex = int.Parse(cellObj.name.Substring("Slot".Length));

                        //Create the slot here, attach it to the marker.
                        var slotObj = GameObject.Instantiate(InventorySlot, cellObj.transform.position, Quaternion.identity) as GameObject;
                        slotObj.transform.parent = cellObj.transform;

                        //Create an Invetory slot on the new object:
                        var slot = slotObj.GetComponent<InventorySlot>();
                        slot.IndexRow = rowIndex;
                        slot.IndexCol = cellIndex;

                        //Name it accordingly:
                        slotObj.name = "Inventory_" + rowIndex + "_" + cellIndex;
                        row.Slots.Add(slot);

                        //The "Equipment" bar is special, it gets shortcut keys!
                        if ( this.gameObject.tag == "Equipment" ) {
                            if ( c < 9 ) {
                                slot.ShortCutKey = KeyCode.Alpha1 + c;
                            } else if ( c == 9 ) {
                                slot.ShortCutKey = KeyCode.Alpha0;
                            } else if ( c == 10 ) {
                                slot.ShortCutKey = KeyCode.Minus;
                            } else if ( c == 11 ) {
                                slot.ShortCutKey = KeyCode.Equals;
                            }
                        }

                        //When the slot is selected, trigger it:
                        slot.OnSelected += (global::InventorySlot obj) => {
                            this.SelectedItem = obj;
                            TriggerSelectionChanged();
                        };

                    }
                }

                //Sort it and store it:
                row.Slots.Sort( (obj1, obj2) => {
                    return obj1.IndexCol - obj2.IndexCol;
                });

            }
        }

        //Sort it and store it:
        slots.Sort( (rowA, rowB) => {
            return rowA.Index - rowB.Index;
        });

        this.Rows = slots.Count;
        this.Columns = slots[0].Slots.Count;
    }
 public InventoryRowChangeEvent(InventoryRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
예제 #10
0
 public void RemoveInventoryRow(InventoryRow row)
 {
     this.Rows.Remove(row);
 }
예제 #11
0
 public void AddInventoryRow(InventoryRow row)
 {
     this.Rows.Add(row);
 }